Rodrigo Lino
/
Menu_IHM
Menu para a IHM
Fork of TextLCD_HelloWorld2 by
main.cpp@2:c2978a6fa79a, 2014-06-28 (annotated)
- Committer:
- wim
- Date:
- Sat Jun 28 14:28:08 2014 +0000
- Revision:
- 2:c2978a6fa79a
- Parent:
- 1:ef419b21167d
- Child:
- 3:f238b4f7874f
Tested AIP31068 for I2C, Tested SPI3_9 and SPI3_10
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wim | 0:a75049de1a82 | 1 | // Hello World! for the TextLCD |
wim | 0:a75049de1a82 | 2 | |
wim | 0:a75049de1a82 | 3 | #include "mbed.h" |
wim | 0:a75049de1a82 | 4 | #include "TextLCD.h" |
wim | 0:a75049de1a82 | 5 | |
wim | 0:a75049de1a82 | 6 | // Host PC Communication channels |
wim | 0:a75049de1a82 | 7 | Serial pc(USBTX, USBRX); // tx, rx |
wim | 0:a75049de1a82 | 8 | |
wim | 0:a75049de1a82 | 9 | void show_menu() { |
wim | 0:a75049de1a82 | 10 | pc.printf("0: Exit\n\r"); |
wim | 0:a75049de1a82 | 11 | pc.printf("1: Show Menu\n\r"); |
wim | 0:a75049de1a82 | 12 | pc.printf("2: Goto 0,0\n\r"); |
wim | 0:a75049de1a82 | 13 | pc.printf("3: Goto columns(),rows()\n\r"); |
wim | 0:a75049de1a82 | 14 | pc.printf("4: cls()\n\r"); |
wim | 0:a75049de1a82 | 15 | pc.printf("5: UDCs \n\r"); |
wim | 0:a75049de1a82 | 16 | pc.printf("6: Fill\n\r"); |
wim | 0:a75049de1a82 | 17 | pc.printf("7: Cursor On\n\r"); |
wim | 0:a75049de1a82 | 18 | pc.printf("8: Cursor Off\n\r"); |
wim | 0:a75049de1a82 | 19 | pc.printf("9: Text\n\r"); |
wim | 0:a75049de1a82 | 20 | pc.printf("A: Display On\n\r"); |
wim | 0:a75049de1a82 | 21 | pc.printf("B: Display Off\n\r"); |
wim | 0:a75049de1a82 | 22 | pc.printf("C: Backlight On\n\r"); |
wim | 0:a75049de1a82 | 23 | pc.printf("D: Backlight Off\n\r"); |
wim | 1:ef419b21167d | 24 | pc.printf("P: init \n\r"); |
wim | 0:a75049de1a82 | 25 | pc.printf("\n\r"); |
wim | 0:a75049de1a82 | 26 | } |
wim | 0:a75049de1a82 | 27 | |
wim | 0:a75049de1a82 | 28 | |
wim | 0:a75049de1a82 | 29 | // I2C Communication |
wim | 0:a75049de1a82 | 30 | I2C i2c_lcd(p28,p27); // SDA, SCL |
wim | 0:a75049de1a82 | 31 | //I2C i2c_lcd(p9,p10); // SDA, SCL |
wim | 0:a75049de1a82 | 32 | |
wim | 0:a75049de1a82 | 33 | // SPI Communication |
wim | 0:a75049de1a82 | 34 | SPI spi_lcd(p5, NC, p7); // MOSI, MISO, SCLK |
wim | 0:a75049de1a82 | 35 | //DigitalOut cs(p8); |
wim | 0:a75049de1a82 | 36 | //DigitalOut cs2(p9); |
wim | 0:a75049de1a82 | 37 | |
wim | 0:a75049de1a82 | 38 | //TextLCD lcd2(p15, p16, p17, p18, p19, p20, TextLCD::LCD16x4); // rs, e, d4-d7 =ok |
wim | 0:a75049de1a82 | 39 | //TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD20x2); // rs, e, d4-d7 =ok |
wim | 0:a75049de1a82 | 40 | //TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD20x4); // rs, e, d4-d7 =ok |
wim | 0:a75049de1a82 | 41 | //TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD24x2); // rs, e, d4-d7 =ok |
wim | 2:c2978a6fa79a | 42 | //TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD24x4D, TextLCD::KS0078); // rs, e, d4-d7 =ok |
wim | 0:a75049de1a82 | 43 | //TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD40x2); // rs, e, d4-d7 =ok |
wim | 0:a75049de1a82 | 44 | |
wim | 1:ef419b21167d | 45 | //TextLCD_I2C lcd(&i2c_lcd, 0x40, TextLCD::LCD20x4); // I2C bus, PCF8574 Slaveaddress, LCD Type =ok |
wim | 0:a75049de1a82 | 46 | //TextLCD_I2C lcd(&i2c_lcd, 0x42, TextLCD::LCD20x4); // I2C bus, PCF8574 Slaveaddress, LCD Type =ok |
wim | 0:a75049de1a82 | 47 | |
wim | 1:ef419b21167d | 48 | //Test Adafruit module, change #define |
wim | 2:c2978a6fa79a | 49 | //TextLCD_I2C lcd(&i2c_lcd, MCP23008_SA0, TextLCD::LCD20x4); // I2C bus, MCP23008 Slaveaddress, LCD Type =OK |
wim | 0:a75049de1a82 | 50 | |
wim | 0:a75049de1a82 | 51 | //TextLCD_I2C lcd(&i2c_lcd, 0x42, TextLCD::LCD16x2, TextLCD::WS0010); // I2C bus, PCF8574 Slaveaddress, LCD Type, LCD Ctrl |
wim | 0:a75049de1a82 | 52 | |
wim | 2:c2978a6fa79a | 53 | //TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD24x4D, TextLCD::KS0078); // SPI bus, CS pin, LCD Type =ok |
wim | 0:a75049de1a82 | 54 | //TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD40x2); // SPI bus, CS pin, LCD Type =ok |
wim | 0:a75049de1a82 | 55 | //TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD40x4); // SPI bus, CS pin, LCD Type =ok |
wim | 0:a75049de1a82 | 56 | |
wim | 0:a75049de1a82 | 57 | //TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD40x4, TextLCD::HD44780); // SPI bus, CS pin, LCD Type, LCD Ctrl =ok |
wim | 2:c2978a6fa79a | 58 | |
wim | 0:a75049de1a82 | 59 | |
wim | 0:a75049de1a82 | 60 | //TextLCD_SPI lcd2(&spi_lcd, p9, TextLCD::LCD8x2B); // SPI bus, CS pin, LCD Type =ok |
wim | 2:c2978a6fa79a | 61 | //TextLCD_SPI lcd2(&spi_lcd, p9, TextLCD::LCD16x1C); // SPI bus, CS pin, LCD Type =ok |
wim | 0:a75049de1a82 | 62 | //TextLCD_SPI lcd2(&spi_lcd, p9, TextLCD::LCD16x2); // SPI bus, CS pin, LCD Type (VFD) =ok |
wim | 0:a75049de1a82 | 63 | |
wim | 1:ef419b21167d | 64 | //TextLCD_SPI_N lcd(&spi_lcd, p8, p9, TextLCD::LCD16x2, NC, TextLCD::ST7032_3V3); // SPI bus, CS pin, RS pin, LCDType=LCD16x2, BL=NC, LCDTCtrl=ST7032 =ok |
wim | 1:ef419b21167d | 65 | //TextLCD_I2C_N lcd(&i2c_lcd, ST7032_SA, TextLCD::LCD16x2, NC, TextLCD::ST7032_3V3); // I2C bus, slaveaddress, LCDType=LCD16x2, BL=NC, LCDTCtrl=ST7032 |
wim | 0:a75049de1a82 | 66 | |
wim | 2:c2978a6fa79a | 67 | //Test PCF2113 |
wim | 2:c2978a6fa79a | 68 | //TextLCD_I2C_N lcd(&i2c_lcd, PCF21XX_SA0, TextLCD::LCD12x2, NC, TextLCD::PCF2113_3V3); // I2C bus, slaveaddress, LCDType=LCD12x2, BL=NC, LCDTCtrl=PCF2113 |
wim | 1:ef419b21167d | 69 | |
wim | 2:c2978a6fa79a | 70 | //PCF2116 |
wim | 2:c2978a6fa79a | 71 | //TextLCD_I2C_N lcd(&i2c_lcd, PCF21XX_SA0, TextLCD::LCD12x3D1, NC, TextLCD::PCF2116_3V3); // I2C bus, slaveaddress, LCDType=LCD12x3D1, BL=NC, LCDTCtrl=PCF2116 |
wim | 2:c2978a6fa79a | 72 | //TextLCD_I2C_N lcd(&i2c_lcd, PCF21XX_SA0, TextLCD::LCD12x4D, NC, TextLCD::PCF2116_3V3); // I2C bus, slaveaddress, LCDType=LCD12x4D, BL=NC, LCDTCtrl=PCF2116 |
wim | 2:c2978a6fa79a | 73 | //TextLCD_I2C_N lcd(&i2c_lcd, PCF21XX_SA0, TextLCD::LCD24x1, NC, TextLCD::PCF2116_3V3); // I2C bus, slaveaddress, LCDType=LCD24x1, BL=NC, LCDTCtrl=PCF2116 |
wim | 2:c2978a6fa79a | 74 | //TextLCD_I2C_N lcd(&i2c_lcd, PCF21XX_SA0, TextLCD::LCD24x2, NC, TextLCD::PCF21116_3V3); // I2C bus, slaveaddress, LCDType=LCD24x2, BL=NC, LCDTCtrl=PCF2116 |
wim | 2:c2978a6fa79a | 75 | |
wim | 2:c2978a6fa79a | 76 | //AIP31068 |
wim | 2:c2978a6fa79a | 77 | TextLCD_I2C_N lcd(&i2c_lcd, AIP31068_SA, TextLCD::LCD16x2, NC, TextLCD::AIP31068); // I2C bus, slaveaddress, LCDType=LCD16x2, BL=NC, LCDTCtrl=AIP31068 |
wim | 2:c2978a6fa79a | 78 | //TextLCD_SPI_N_3_9 lcd(&spi_lcd, p8, TextLCD::LCD16x2, NC, TextLCD::AIP31068); // I2C bus, slaveaddress, LCDType=LCD16x2, BL=NC, LCDTCtrl=AIP31068 |
wim | 2:c2978a6fa79a | 79 | //TextLCD_SPI_N_3_10 lcd(&spi_lcd, p8, TextLCD::LCD16x2, NC, TextLCD::WS0010); // I2C bus, slaveaddress, LCDType=LCD16x2, BL=NC, LCDTCtrl=WS0010 |
wim | 0:a75049de1a82 | 80 | |
wim | 0:a75049de1a82 | 81 | int main() { |
wim | 0:a75049de1a82 | 82 | // int i=0; |
wim | 0:a75049de1a82 | 83 | int count=0; |
wim | 0:a75049de1a82 | 84 | bool running=true; |
wim | 0:a75049de1a82 | 85 | char command; |
wim | 0:a75049de1a82 | 86 | |
wim | 0:a75049de1a82 | 87 | pc.printf("LCD Test. Colums=%d, Rows=%d\n\r", lcd.columns(), lcd.rows()); |
wim | 0:a75049de1a82 | 88 | |
wim | 0:a75049de1a82 | 89 | //while (1) { |
wim | 0:a75049de1a82 | 90 | for (int row=0; row<lcd.rows(); row++) { |
wim | 0:a75049de1a82 | 91 | int col=0; |
wim | 0:a75049de1a82 | 92 | |
wim | 0:a75049de1a82 | 93 | pc.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row)); |
wim | 0:a75049de1a82 | 94 | // lcd.putc('-'); |
wim | 0:a75049de1a82 | 95 | lcd.putc('0' + row); |
wim | 0:a75049de1a82 | 96 | |
wim | 0:a75049de1a82 | 97 | for (col=1; col<lcd.columns()-1; col++) { |
wim | 0:a75049de1a82 | 98 | lcd.putc('*'); |
wim | 0:a75049de1a82 | 99 | } |
wim | 0:a75049de1a82 | 100 | |
wim | 0:a75049de1a82 | 101 | pc.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row)); |
wim | 0:a75049de1a82 | 102 | lcd.putc('+'); |
wim | 0:a75049de1a82 | 103 | |
wim | 0:a75049de1a82 | 104 | } |
wim | 0:a75049de1a82 | 105 | |
wim | 0:a75049de1a82 | 106 | // wait_ms(500); |
wim | 0:a75049de1a82 | 107 | // lcd.cls(); // Test timing |
wim | 0:a75049de1a82 | 108 | //} |
wim | 0:a75049de1a82 | 109 | |
wim | 0:a75049de1a82 | 110 | |
wim | 0:a75049de1a82 | 111 | lcd.setCursor(TextLCD::CurOff_BlkOn); |
wim | 0:a75049de1a82 | 112 | |
wim | 1:ef419b21167d | 113 | #if(0) |
wim | 1:ef419b21167d | 114 | lcd.setUDC(0, (char *) udc_AA); |
wim | 1:ef419b21167d | 115 | lcd.putc(0); |
wim | 0:a75049de1a82 | 116 | |
wim | 1:ef419b21167d | 117 | lcd.setUDC(1, (char *) udc_0E); |
wim | 1:ef419b21167d | 118 | lcd.putc(1); |
wim | 0:a75049de1a82 | 119 | |
wim | 1:ef419b21167d | 120 | lcd.setUDC(0, (char *) udc_0); |
wim | 1:ef419b21167d | 121 | lcd.putc(0); |
wim | 1:ef419b21167d | 122 | lcd.setUDC(1, (char *) udc_1); |
wim | 1:ef419b21167d | 123 | lcd.putc(1); |
wim | 1:ef419b21167d | 124 | lcd.setUDC(2, (char *) udc_2); |
wim | 1:ef419b21167d | 125 | lcd.putc(2); |
wim | 1:ef419b21167d | 126 | #endif |
wim | 0:a75049de1a82 | 127 | |
wim | 1:ef419b21167d | 128 | #if(1) |
wim | 0:a75049de1a82 | 129 | lcd.setUDC(0, (char *) udc_Bat_Hi); |
wim | 0:a75049de1a82 | 130 | lcd.setUDC(1, (char *) udc_Bat_Ha); |
wim | 0:a75049de1a82 | 131 | lcd.setUDC(2, (char *) udc_Bat_Lo); |
wim | 0:a75049de1a82 | 132 | lcd.setUDC(3, (char *) udc_AC); |
wim | 0:a75049de1a82 | 133 | lcd.setUDC(4, (char *) udc_4); |
wim | 0:a75049de1a82 | 134 | lcd.setUDC(5, (char *) udc_5); |
wim | 0:a75049de1a82 | 135 | lcd.setUDC(6, (char *) udc_6); |
wim | 0:a75049de1a82 | 136 | lcd.setUDC(7, (char *) udc_7); |
wim | 1:ef419b21167d | 137 | #endif |
wim | 1:ef419b21167d | 138 | |
wim | 1:ef419b21167d | 139 | #if(0) |
wim | 1:ef419b21167d | 140 | lcd.setUDC(0, (char *) udc_ch_1); |
wim | 1:ef419b21167d | 141 | lcd.setUDC(1, (char *) udc_ch_2); |
wim | 1:ef419b21167d | 142 | lcd.setUDC(2, (char *) udc_ch_3); |
wim | 1:ef419b21167d | 143 | lcd.setUDC(3, (char *) udc_ch_4); |
wim | 1:ef419b21167d | 144 | lcd.setUDC(4, (char *) udc_ch_yr); |
wim | 1:ef419b21167d | 145 | lcd.setUDC(5, (char *) udc_ch_mo); |
wim | 1:ef419b21167d | 146 | lcd.setUDC(6, (char *) udc_ch_dy); |
wim | 1:ef419b21167d | 147 | lcd.setUDC(7, (char *) udc_ch_mi); |
wim | 1:ef419b21167d | 148 | #endif |
wim | 0:a75049de1a82 | 149 | |
wim | 0:a75049de1a82 | 150 | lcd.putc(0); |
wim | 0:a75049de1a82 | 151 | lcd.putc(1); |
wim | 0:a75049de1a82 | 152 | lcd.putc(2); |
wim | 0:a75049de1a82 | 153 | lcd.putc(3); |
wim | 0:a75049de1a82 | 154 | lcd.putc(4); |
wim | 0:a75049de1a82 | 155 | lcd.putc(5); |
wim | 0:a75049de1a82 | 156 | lcd.putc(6); |
wim | 0:a75049de1a82 | 157 | lcd.putc(7); |
wim | 0:a75049de1a82 | 158 | |
wim | 0:a75049de1a82 | 159 | #if(0) |
wim | 0:a75049de1a82 | 160 | lcd2.setUDC(0, (char *) udc_Bat_Hi); |
wim | 0:a75049de1a82 | 161 | lcd2.setUDC(1, (char *) udc_Bat_Ha); |
wim | 0:a75049de1a82 | 162 | lcd2.setUDC(2, (char *) udc_Bat_Lo); |
wim | 0:a75049de1a82 | 163 | lcd2.setUDC(3, (char *) udc_AC); |
wim | 0:a75049de1a82 | 164 | lcd2.putc(0); |
wim | 0:a75049de1a82 | 165 | lcd2.putc(1); |
wim | 0:a75049de1a82 | 166 | lcd2.putc(2); |
wim | 0:a75049de1a82 | 167 | lcd2.putc(3); |
wim | 0:a75049de1a82 | 168 | #endif |
wim | 0:a75049de1a82 | 169 | |
wim | 0:a75049de1a82 | 170 | #if(0) |
wim | 0:a75049de1a82 | 171 | while (1) { |
wim | 0:a75049de1a82 | 172 | lcd.locate(4, 2); |
wim | 0:a75049de1a82 | 173 | lcd.printf("Count=%3d", i); |
wim | 0:a75049de1a82 | 174 | i++; |
wim | 0:a75049de1a82 | 175 | if (i==100) i=0; |
wim | 0:a75049de1a82 | 176 | |
wim | 0:a75049de1a82 | 177 | wait(1); |
wim | 0:a75049de1a82 | 178 | } |
wim | 0:a75049de1a82 | 179 | #endif |
wim | 0:a75049de1a82 | 180 | |
wim | 0:a75049de1a82 | 181 | pc.printf("Hello World!\n\r"); |
wim | 0:a75049de1a82 | 182 | show_menu(); |
wim | 0:a75049de1a82 | 183 | |
wim | 2:c2978a6fa79a | 184 | while(running) { |
wim | 0:a75049de1a82 | 185 | count++; |
wim | 0:a75049de1a82 | 186 | |
wim | 0:a75049de1a82 | 187 | if(pc.readable()) { |
wim | 0:a75049de1a82 | 188 | command = pc.getc(); |
wim | 0:a75049de1a82 | 189 | pc.printf("command= %c \n\r", command); |
wim | 0:a75049de1a82 | 190 | |
wim | 0:a75049de1a82 | 191 | switch (command) { |
wim | 0:a75049de1a82 | 192 | case '0' : |
wim | 0:a75049de1a82 | 193 | pc.printf("Done\n\r"); |
wim | 0:a75049de1a82 | 194 | running = false; |
wim | 0:a75049de1a82 | 195 | break; |
wim | 0:a75049de1a82 | 196 | |
wim | 0:a75049de1a82 | 197 | case '1' : |
wim | 0:a75049de1a82 | 198 | show_menu(); |
wim | 0:a75049de1a82 | 199 | break; |
wim | 0:a75049de1a82 | 200 | |
wim | 0:a75049de1a82 | 201 | case '2' : |
wim | 0:a75049de1a82 | 202 | pc.printf("Goto 0,0\n\r"); |
wim | 0:a75049de1a82 | 203 | lcd.locate(0, 0); |
wim | 0:a75049de1a82 | 204 | // lcd2.locate(0, 0); |
wim | 0:a75049de1a82 | 205 | break; |
wim | 0:a75049de1a82 | 206 | |
wim | 0:a75049de1a82 | 207 | case '3' : |
wim | 0:a75049de1a82 | 208 | pc.printf("Goto Col,Row\n\r"); |
wim | 0:a75049de1a82 | 209 | lcd.locate( (lcd.columns() - 1), (lcd.rows() - 1)); |
wim | 0:a75049de1a82 | 210 | // lcd2.locate( (lcd.columns() - 1), (lcd.rows() - 1)); |
wim | 0:a75049de1a82 | 211 | break; |
wim | 0:a75049de1a82 | 212 | |
wim | 0:a75049de1a82 | 213 | case '4' : |
wim | 0:a75049de1a82 | 214 | pc.printf("cls()\n\r"); |
wim | 0:a75049de1a82 | 215 | lcd.cls(); |
wim | 0:a75049de1a82 | 216 | // lcd2.cls(); |
wim | 0:a75049de1a82 | 217 | break; |
wim | 0:a75049de1a82 | 218 | |
wim | 0:a75049de1a82 | 219 | case '5' : |
wim | 0:a75049de1a82 | 220 | pc.printf("UDCs\n\r"); |
wim | 0:a75049de1a82 | 221 | lcd.locate(2, 0); |
wim | 0:a75049de1a82 | 222 | lcd.putc(0); |
wim | 0:a75049de1a82 | 223 | lcd.putc(1); |
wim | 0:a75049de1a82 | 224 | lcd.putc(2); |
wim | 0:a75049de1a82 | 225 | lcd.putc(3); |
wim | 0:a75049de1a82 | 226 | lcd.putc(4); |
wim | 0:a75049de1a82 | 227 | lcd.putc(5); |
wim | 0:a75049de1a82 | 228 | lcd.putc(6); |
wim | 0:a75049de1a82 | 229 | lcd.putc(7); |
wim | 0:a75049de1a82 | 230 | |
wim | 0:a75049de1a82 | 231 | lcd.locate(4, lcd.rows()-1); |
wim | 0:a75049de1a82 | 232 | lcd.putc(0); |
wim | 0:a75049de1a82 | 233 | lcd.putc(1); |
wim | 0:a75049de1a82 | 234 | lcd.putc(2); |
wim | 0:a75049de1a82 | 235 | lcd.putc(3); |
wim | 0:a75049de1a82 | 236 | |
wim | 0:a75049de1a82 | 237 | |
wim | 0:a75049de1a82 | 238 | // lcd2.locate(4, lcd.rows()-1); |
wim | 0:a75049de1a82 | 239 | // lcd2.putc(0); |
wim | 0:a75049de1a82 | 240 | // lcd2.putc(1); |
wim | 0:a75049de1a82 | 241 | // lcd2.putc(2); |
wim | 0:a75049de1a82 | 242 | // lcd2.putc(3); |
wim | 0:a75049de1a82 | 243 | |
wim | 0:a75049de1a82 | 244 | break; |
wim | 0:a75049de1a82 | 245 | case '6' : |
wim | 0:a75049de1a82 | 246 | pc.printf("Fill\n\r"); |
wim | 0:a75049de1a82 | 247 | lcd.locate(0, 0); |
wim | 0:a75049de1a82 | 248 | for (int row=0; row<lcd.rows(); row++) { |
wim | 0:a75049de1a82 | 249 | int col=0; |
wim | 0:a75049de1a82 | 250 | |
wim | 0:a75049de1a82 | 251 | // pc.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row)); |
wim | 0:a75049de1a82 | 252 | // lcd.putc('-'); |
wim | 0:a75049de1a82 | 253 | lcd.putc('0' + row); |
wim | 0:a75049de1a82 | 254 | |
wim | 0:a75049de1a82 | 255 | for (col=1; col<lcd.columns()-1; col++) { |
wim | 0:a75049de1a82 | 256 | lcd.putc('*'); |
wim | 0:a75049de1a82 | 257 | } |
wim | 0:a75049de1a82 | 258 | |
wim | 0:a75049de1a82 | 259 | // pc.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row)); |
wim | 0:a75049de1a82 | 260 | lcd.putc('+'); |
wim | 0:a75049de1a82 | 261 | } |
wim | 0:a75049de1a82 | 262 | |
wim | 0:a75049de1a82 | 263 | break; |
wim | 0:a75049de1a82 | 264 | |
wim | 0:a75049de1a82 | 265 | case '7' : |
wim | 0:a75049de1a82 | 266 | pc.printf("Cursor 0n\n\r"); |
wim | 0:a75049de1a82 | 267 | lcd.setCursor(TextLCD::CurOff_BlkOn); |
wim | 0:a75049de1a82 | 268 | // lcd2.setCursor(TextLCD::CurOff_BlkOn); |
wim | 0:a75049de1a82 | 269 | break; |
wim | 0:a75049de1a82 | 270 | |
wim | 0:a75049de1a82 | 271 | case '8' : |
wim | 0:a75049de1a82 | 272 | pc.printf("Cursor 0ff\n\r"); |
wim | 0:a75049de1a82 | 273 | lcd.setCursor(TextLCD::CurOff_BlkOff); |
wim | 0:a75049de1a82 | 274 | // lcd2.setCursor(TextLCD::CurOff_BlkOff); |
wim | 0:a75049de1a82 | 275 | break; |
wim | 0:a75049de1a82 | 276 | |
wim | 0:a75049de1a82 | 277 | case '9' : |
wim | 0:a75049de1a82 | 278 | pc.printf("Text\n\r"); |
wim | 1:ef419b21167d | 279 | lcd.locate(0, 0); |
wim | 1:ef419b21167d | 280 | lcd.printf(" Hello mbed\n"); |
wim | 1:ef419b21167d | 281 | lcd.printf(" Native I2C\n"); |
wim | 0:a75049de1a82 | 282 | // lcd2.printf("Hello mbed\n"); |
wim | 1:ef419b21167d | 283 | |
wim | 1:ef419b21167d | 284 | #if(0) |
wim | 1:ef419b21167d | 285 | // Needed for PCF2116C and PCF2116K |
wim | 1:ef419b21167d | 286 | lcd.putc('H' ^ 0x80); |
wim | 1:ef419b21167d | 287 | lcd.putc('e' ^ 0x80); |
wim | 1:ef419b21167d | 288 | lcd.putc('l' ^ 0x80); |
wim | 1:ef419b21167d | 289 | lcd.putc('l' ^ 0x80); |
wim | 1:ef419b21167d | 290 | lcd.putc('o' ^ 0x80); |
wim | 1:ef419b21167d | 291 | lcd.putc(' ' ^ 0x80); |
wim | 1:ef419b21167d | 292 | lcd.putc('m' ^ 0x80); |
wim | 1:ef419b21167d | 293 | lcd.putc('b' ^ 0x80); |
wim | 1:ef419b21167d | 294 | lcd.putc('e' ^ 0x80); |
wim | 1:ef419b21167d | 295 | lcd.putc('d' ^ 0x80); |
wim | 1:ef419b21167d | 296 | lcd.putc('\n'); |
wim | 1:ef419b21167d | 297 | lcd.putc('I' ^ 0x80); |
wim | 1:ef419b21167d | 298 | lcd.putc('2' ^ 0x80); |
wim | 1:ef419b21167d | 299 | lcd.putc('C' ^ 0x80); |
wim | 1:ef419b21167d | 300 | lcd.putc(' ' ^ 0x80); |
wim | 1:ef419b21167d | 301 | lcd.putc('P' ^ 0x80); |
wim | 1:ef419b21167d | 302 | lcd.putc('C' ^ 0x80); |
wim | 1:ef419b21167d | 303 | lcd.putc('F' ^ 0x80); |
wim | 1:ef419b21167d | 304 | lcd.putc('2' ^ 0x80); |
wim | 1:ef419b21167d | 305 | lcd.putc('1' ^ 0x80); |
wim | 1:ef419b21167d | 306 | lcd.putc('1' ^ 0x80); |
wim | 1:ef419b21167d | 307 | lcd.putc('6' ^ 0x80); |
wim | 1:ef419b21167d | 308 | #endif |
wim | 1:ef419b21167d | 309 | |
wim | 0:a75049de1a82 | 310 | break; |
wim | 0:a75049de1a82 | 311 | |
wim | 0:a75049de1a82 | 312 | case 'A' : |
wim | 0:a75049de1a82 | 313 | pc.printf("Display On\n\r"); |
wim | 0:a75049de1a82 | 314 | lcd.setMode(TextLCD::DispOn); |
wim | 0:a75049de1a82 | 315 | // lcd2.setMode(TextLCD::DispOn); |
wim | 0:a75049de1a82 | 316 | break; |
wim | 0:a75049de1a82 | 317 | |
wim | 0:a75049de1a82 | 318 | case 'B' : |
wim | 0:a75049de1a82 | 319 | pc.printf("Display Off\n\r"); |
wim | 0:a75049de1a82 | 320 | lcd.setMode(TextLCD::DispOff); |
wim | 0:a75049de1a82 | 321 | // lcd2.setMode(TextLCD::DispOff); |
wim | 0:a75049de1a82 | 322 | break; |
wim | 0:a75049de1a82 | 323 | |
wim | 0:a75049de1a82 | 324 | case 'C' : |
wim | 0:a75049de1a82 | 325 | pc.printf("Backlight On\n\r"); |
wim | 0:a75049de1a82 | 326 | lcd.setBacklight(TextLCD::LightOn); |
wim | 0:a75049de1a82 | 327 | // lcd2.setBacklight(TextLCD::LightOn); |
wim | 0:a75049de1a82 | 328 | break; |
wim | 0:a75049de1a82 | 329 | |
wim | 0:a75049de1a82 | 330 | case 'D' : |
wim | 0:a75049de1a82 | 331 | pc.printf("Backlight Off\n\r"); |
wim | 0:a75049de1a82 | 332 | lcd.setBacklight(TextLCD::LightOff); |
wim | 0:a75049de1a82 | 333 | // lcd2.setBacklight(TextLCD::LightOff); |
wim | 0:a75049de1a82 | 334 | break; |
wim | 0:a75049de1a82 | 335 | |
wim | 0:a75049de1a82 | 336 | |
wim | 0:a75049de1a82 | 337 | // case 'E' : |
wim | 0:a75049de1a82 | 338 | // pc.printf("Test nibble\n\r"); |
wim | 0:a75049de1a82 | 339 | // for (int i=0; i<16; i++) { |
wim | 0:a75049de1a82 | 340 | // lcd._writeNibble(i); |
wim | 0:a75049de1a82 | 341 | // wait(1); |
wim | 0:a75049de1a82 | 342 | // } |
wim | 0:a75049de1a82 | 343 | // break; |
wim | 0:a75049de1a82 | 344 | |
wim | 1:ef419b21167d | 345 | case 'P' : |
wim | 2:c2978a6fa79a | 346 | pc.printf("Init Ctrl test\n\r"); |
wim | 1:ef419b21167d | 347 | //test |
wim | 2:c2978a6fa79a | 348 | // lcd._initCtrl(); |
wim | 1:ef419b21167d | 349 | break; |
wim | 1:ef419b21167d | 350 | |
wim | 0:a75049de1a82 | 351 | default : |
wim | 0:a75049de1a82 | 352 | lcd.putc(command); |
wim | 1:ef419b21167d | 353 | // lcd.putc(command ^ 0x80); // Needed for PCF2116C and PCF2116K |
wim | 0:a75049de1a82 | 354 | // lcd2.putc(command); |
wim | 0:a75049de1a82 | 355 | break; |
wim | 0:a75049de1a82 | 356 | |
wim | 0:a75049de1a82 | 357 | } //switch |
wim | 0:a75049de1a82 | 358 | }//if |
wim | 0:a75049de1a82 | 359 | }//while |
wim | 0:a75049de1a82 | 360 | |
wim | 0:a75049de1a82 | 361 | pc.printf("Bye World!\n\r"); |
wim | 0:a75049de1a82 | 362 | } |