Menu para a IHM

Dependencies:   TextLCD mbed

Fork of TextLCD_HelloWorld2 by Wim Huiskamp

Committer:
wim
Date:
Sun Aug 24 09:01:56 2014 +0000
Revision:
3:f238b4f7874f
Parent:
2:c2978a6fa79a
Child:
4:a3e4bb2053cb
Tested with SSD1803, ST7036

Who changed what in which revision?

UserRevisionLine numberNew 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 3:f238b4f7874f 25 pc.printf("Q: contrast \n\r");
wim 0:a75049de1a82 26 pc.printf("\n\r");
wim 0:a75049de1a82 27 }
wim 0:a75049de1a82 28
wim 0:a75049de1a82 29
wim 0:a75049de1a82 30 // I2C Communication
wim 0:a75049de1a82 31 I2C i2c_lcd(p28,p27); // SDA, SCL
wim 0:a75049de1a82 32 //I2C i2c_lcd(p9,p10); // SDA, SCL
wim 0:a75049de1a82 33
wim 0:a75049de1a82 34 // SPI Communication
wim 0:a75049de1a82 35 SPI spi_lcd(p5, NC, p7); // MOSI, MISO, SCLK
wim 0:a75049de1a82 36 //DigitalOut cs(p8);
wim 0:a75049de1a82 37 //DigitalOut cs2(p9);
wim 0:a75049de1a82 38
wim 3:f238b4f7874f 39 //4 Bit bus
wim 0:a75049de1a82 40 //TextLCD lcd2(p15, p16, p17, p18, p19, p20, TextLCD::LCD16x4); // rs, e, d4-d7 =ok
wim 0:a75049de1a82 41 //TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD20x2); // rs, e, d4-d7 =ok
wim 0:a75049de1a82 42 //TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD20x4); // rs, e, d4-d7 =ok
wim 0:a75049de1a82 43 //TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD24x2); // rs, e, d4-d7 =ok
wim 2:c2978a6fa79a 44 //TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD24x4D, TextLCD::KS0078); // rs, e, d4-d7 =ok
wim 0:a75049de1a82 45 //TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD40x2); // rs, e, d4-d7 =ok
wim 0:a75049de1a82 46
wim 3:f238b4f7874f 47 //I2C Expander PCF8574
wim 1:ef419b21167d 48 //TextLCD_I2C lcd(&i2c_lcd, 0x40, TextLCD::LCD20x4); // I2C bus, PCF8574 Slaveaddress, LCD Type =ok
wim 0:a75049de1a82 49 //TextLCD_I2C lcd(&i2c_lcd, 0x42, TextLCD::LCD20x4); // I2C bus, PCF8574 Slaveaddress, LCD Type =ok
wim 0:a75049de1a82 50
wim 3:f238b4f7874f 51 // I2C Expander MCP23008, Adafruit module (change #define !!)
wim 3:f238b4f7874f 52 //TextLCD_I2C lcd(&i2c_lcd, MCP23008_SA0, TextLCD::LCD16x3F); // I2C bus, MCP23008 Slaveaddress, LCD Type =Ok
wim 2:c2978a6fa79a 53 //TextLCD_I2C lcd(&i2c_lcd, MCP23008_SA0, TextLCD::LCD20x4); // I2C bus, MCP23008 Slaveaddress, LCD Type =OK
wim 3:f238b4f7874f 54 //TextLCD_I2C lcd(&i2c_lcd, MCP23008_SA0, TextLCD::LCD16x2, TextLCD::WS0010); // I2C bus, MCP23008 Slaveaddress, LCD Type =Ok
wim 3:f238b4f7874f 55 //TextLCD_I2C lcd(&i2c_lcd, MCP23008_SA0, TextLCD::LCD24x4D, TextLCD::KS0078); // I2C bus, MCP23008 Slaveaddress, LCD Type =ok
wim 3:f238b4f7874f 56 //TextLCD_I2C lcd(&i2c_lcd, MCP23008_SA0, TextLCD::LCD16x1C); // I2C bus, MCP23008 Slaveaddress, LCD Type =Ok
wim 2:c2978a6fa79a 57
wim 0:a75049de1a82 58
wim 3:f238b4f7874f 59 //SPI Expander
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 3:f238b4f7874f 63 //TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD40x2); // SPI bus, CS pin, LCD Type =ok
wim 3:f238b4f7874f 64 //TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD40x4); // SPI bus, CS pin, LCD Type =ok
wim 3:f238b4f7874f 65 //TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD40x4, TextLCD::HD44780); // SPI bus, CS pin, LCD Type, LCD Ctrl =ok
wim 3:f238b4f7874f 66 //TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD24x4D, TextLCD::KS0078); // SPI bus, CS pin, LCD Type =ok
wim 0:a75049de1a82 67
wim 3:f238b4f7874f 68
wim 3:f238b4f7874f 69 //WS0010
wim 3:f238b4f7874f 70 //TextLCD_I2C lcd(&i2c_lcd, 0x42, TextLCD::LCD16x2, TextLCD::WS0010); // I2C bus, PCF8574 Slaveaddress, LCD Type, LCD Ctrl =Ok
wim 3:f238b4f7874f 71 //TextLCD_SPI_N_3_10 lcd(&spi_lcd, p8, TextLCD::LCD16x2, NC, TextLCD::WS0010); // SPI bus, CS, LCDType=LCD16x2, BL=NC, LCDTCtrl=WS0010 =Ok
wim 3:f238b4f7874f 72
wim 3:f238b4f7874f 73 //ST7032
wim 1:ef419b21167d 74 //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 3:f238b4f7874f 75 //TextLCD_I2C_N lcd(&i2c_lcd, ST7032_SA, TextLCD::LCD16x2, NC, TextLCD::ST7032_3V3); // I2C bus, slaveaddress, LCDType=LCD16x2, BL=NC, LCDTCtrl=ST7032 =Ok
wim 3:f238b4f7874f 76
wim 3:f238b4f7874f 77 //ST7036
wim 3:f238b4f7874f 78 //TextLCD_I2C lcd(&i2c_lcd, MCP23008_SA0, TextLCD::LCD16x3G, TextLCD::ST7036_3V3); // I2C bus, MCP23008 Slaveaddress, LCD Type, LCDTCtrl=ST7036
wim 3:f238b4f7874f 79 //TextLCD_SPI_N lcd(&spi_lcd, p8, p9, TextLCD::LCD16x3G, NC, TextLCD::ST7036_3V3); // SPI bus, CS pin, RS pin, LCDType=LCD16x2, BL=NC, LCDTCtrl=ST7036 =Ok
wim 3:f238b4f7874f 80
wim 3:f238b4f7874f 81 //SSD1803A
wim 3:f238b4f7874f 82 //TextLCD_I2C_N lcd(&i2c_lcd, SSD1803_SA1, TextLCD::LCD20x4D, NC, TextLCD::SSD1803_3V3); // I2C bus, slaveaddress, LCDType=LCD16x2, BL=NC, LCDTCtrl=SSD1803 =Ok
wim 3:f238b4f7874f 83 TextLCD_SPI_N_3_24 lcd(&spi_lcd, p8, TextLCD::LCD20x4D, NC, TextLCD::SSD1803_3V3); // SPI bus, CS pin, LCDType=LCD20x4, BL=NC, LCDTCtrl=SSD1803 =Ok
wim 0:a75049de1a82 84
wim 2:c2978a6fa79a 85 //Test PCF2113
wim 2:c2978a6fa79a 86 //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 87
wim 2:c2978a6fa79a 88 //PCF2116
wim 3:f238b4f7874f 89 //TextLCD_I2C_N lcd(&i2c_lcd, PCF21XX_SA0, TextLCD::LCD12x3D1, NC, TextLCD::PCF2116_5V); // I2C bus, slaveaddress, LCDType=LCD12x3D1, BL=NC, LCDTCtrl=PCF2116 (experimental)
wim 2:c2978a6fa79a 90 //TextLCD_I2C_N lcd(&i2c_lcd, PCF21XX_SA0, TextLCD::LCD12x3D1, NC, TextLCD::PCF2116_3V3); // I2C bus, slaveaddress, LCDType=LCD12x3D1, BL=NC, LCDTCtrl=PCF2116
wim 3:f238b4f7874f 91 //TextLCD_I2C_N lcd(&i2c_lcd, PCF21XX_SA1, TextLCD::LCD12x3D1, NC, TextLCD::PCF2116_3V3); // I2C bus, slaveaddress, LCDType=LCD12x3D1, BL=NC, LCDTCtrl=PCF2116
wim 2:c2978a6fa79a 92 //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 93 //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 94 //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 95
wim 2:c2978a6fa79a 96 //AIP31068
wim 3:f238b4f7874f 97 //TextLCD_I2C_N lcd(&i2c_lcd, AIP31068_SA, TextLCD::LCD16x2, NC, TextLCD::AIP31068); // I2C bus, slaveaddress, LCDType=LCD16x2, BL=NC, LCDTCtrl=AIP31068 =Ok
wim 3:f238b4f7874f 98 //TextLCD_SPI_N_3_9 lcd(&spi_lcd, p8, TextLCD::LCD16x2, NC, TextLCD::AIP31068); // SPI bus, CS, LCDType=LCD16x2, BL=NC, LCDTCtrl=AIP31068 Niet Ok
wim 3:f238b4f7874f 99
wim 3:f238b4f7874f 100
wim 0:a75049de1a82 101
wim 0:a75049de1a82 102 int main() {
wim 3:f238b4f7874f 103 int i=0;
wim 0:a75049de1a82 104 int count=0;
wim 0:a75049de1a82 105 bool running=true;
wim 0:a75049de1a82 106 char command;
wim 0:a75049de1a82 107
wim 0:a75049de1a82 108 pc.printf("LCD Test. Colums=%d, Rows=%d\n\r", lcd.columns(), lcd.rows());
wim 0:a75049de1a82 109
wim 0:a75049de1a82 110 //while (1) {
wim 0:a75049de1a82 111 for (int row=0; row<lcd.rows(); row++) {
wim 0:a75049de1a82 112 int col=0;
wim 0:a75049de1a82 113
wim 0:a75049de1a82 114 pc.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row));
wim 0:a75049de1a82 115 // lcd.putc('-');
wim 0:a75049de1a82 116 lcd.putc('0' + row);
wim 0:a75049de1a82 117
wim 0:a75049de1a82 118 for (col=1; col<lcd.columns()-1; col++) {
wim 0:a75049de1a82 119 lcd.putc('*');
wim 0:a75049de1a82 120 }
wim 0:a75049de1a82 121
wim 0:a75049de1a82 122 pc.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row));
wim 0:a75049de1a82 123 lcd.putc('+');
wim 0:a75049de1a82 124
wim 0:a75049de1a82 125 }
wim 0:a75049de1a82 126
wim 0:a75049de1a82 127 // wait_ms(500);
wim 0:a75049de1a82 128 // lcd.cls(); // Test timing
wim 0:a75049de1a82 129 //}
wim 0:a75049de1a82 130
wim 0:a75049de1a82 131 lcd.setCursor(TextLCD::CurOff_BlkOn);
wim 0:a75049de1a82 132
wim 1:ef419b21167d 133 #if(0)
wim 1:ef419b21167d 134 lcd.setUDC(0, (char *) udc_AA);
wim 1:ef419b21167d 135 lcd.putc(0);
wim 1:ef419b21167d 136 lcd.setUDC(1, (char *) udc_0E);
wim 1:ef419b21167d 137 lcd.putc(1);
wim 1:ef419b21167d 138 lcd.setUDC(0, (char *) udc_0);
wim 1:ef419b21167d 139 lcd.putc(0);
wim 1:ef419b21167d 140 lcd.setUDC(1, (char *) udc_1);
wim 1:ef419b21167d 141 lcd.putc(1);
wim 1:ef419b21167d 142 lcd.setUDC(2, (char *) udc_2);
wim 1:ef419b21167d 143 lcd.putc(2);
wim 1:ef419b21167d 144 #endif
wim 0:a75049de1a82 145
wim 3:f238b4f7874f 146 #if(0)
wim 3:f238b4f7874f 147 lcd.setUDC(0, (char *) udc_None);
wim 3:f238b4f7874f 148 lcd.setUDC(1, (char *) udc_None);
wim 3:f238b4f7874f 149 lcd.setUDC(2, (char *) udc_None);
wim 3:f238b4f7874f 150 lcd.setUDC(3, (char *) udc_None);
wim 3:f238b4f7874f 151 lcd.setUDC(4, (char *) udc_None);
wim 3:f238b4f7874f 152 lcd.setUDC(5, (char *) udc_None);
wim 3:f238b4f7874f 153 lcd.setUDC(6, (char *) udc_None);
wim 3:f238b4f7874f 154 lcd.setUDC(7, (char *) udc_None);
wim 3:f238b4f7874f 155 #endif
wim 3:f238b4f7874f 156
wim 3:f238b4f7874f 157 #if(0)
wim 3:f238b4f7874f 158 lcd.setUDC(0, (char *) udc_All);
wim 3:f238b4f7874f 159 lcd.setUDC(1, (char *) udc_All);
wim 3:f238b4f7874f 160 lcd.setUDC(2, (char *) udc_All);
wim 3:f238b4f7874f 161 lcd.setUDC(3, (char *) udc_All);
wim 3:f238b4f7874f 162 lcd.setUDC(4, (char *) udc_All);
wim 3:f238b4f7874f 163 lcd.setUDC(5, (char *) udc_All);
wim 3:f238b4f7874f 164 lcd.setUDC(6, (char *) udc_All);
wim 3:f238b4f7874f 165 lcd.setUDC(7, (char *) udc_All);
wim 3:f238b4f7874f 166 #endif
wim 3:f238b4f7874f 167
wim 1:ef419b21167d 168 #if(1)
wim 0:a75049de1a82 169 lcd.setUDC(0, (char *) udc_Bat_Hi);
wim 0:a75049de1a82 170 lcd.setUDC(1, (char *) udc_Bat_Ha);
wim 0:a75049de1a82 171 lcd.setUDC(2, (char *) udc_Bat_Lo);
wim 0:a75049de1a82 172 lcd.setUDC(3, (char *) udc_AC);
wim 0:a75049de1a82 173 lcd.setUDC(4, (char *) udc_4);
wim 0:a75049de1a82 174 lcd.setUDC(5, (char *) udc_5);
wim 0:a75049de1a82 175 lcd.setUDC(6, (char *) udc_6);
wim 0:a75049de1a82 176 lcd.setUDC(7, (char *) udc_7);
wim 1:ef419b21167d 177 #endif
wim 1:ef419b21167d 178
wim 1:ef419b21167d 179 #if(0)
wim 1:ef419b21167d 180 lcd.setUDC(0, (char *) udc_ch_1);
wim 1:ef419b21167d 181 lcd.setUDC(1, (char *) udc_ch_2);
wim 1:ef419b21167d 182 lcd.setUDC(2, (char *) udc_ch_3);
wim 1:ef419b21167d 183 lcd.setUDC(3, (char *) udc_ch_4);
wim 1:ef419b21167d 184 lcd.setUDC(4, (char *) udc_ch_yr);
wim 1:ef419b21167d 185 lcd.setUDC(5, (char *) udc_ch_mo);
wim 1:ef419b21167d 186 lcd.setUDC(6, (char *) udc_ch_dy);
wim 1:ef419b21167d 187 lcd.setUDC(7, (char *) udc_ch_mi);
wim 1:ef419b21167d 188 #endif
wim 0:a75049de1a82 189
wim 3:f238b4f7874f 190 #if(0)
wim 0:a75049de1a82 191 lcd.putc(0);
wim 0:a75049de1a82 192 lcd.putc(1);
wim 0:a75049de1a82 193 lcd.putc(2);
wim 0:a75049de1a82 194 lcd.putc(3);
wim 0:a75049de1a82 195 lcd.putc(4);
wim 0:a75049de1a82 196 lcd.putc(5);
wim 0:a75049de1a82 197 lcd.putc(6);
wim 0:a75049de1a82 198 lcd.putc(7);
wim 3:f238b4f7874f 199 #endif
wim 0:a75049de1a82 200
wim 0:a75049de1a82 201 #if(0)
wim 0:a75049de1a82 202 lcd2.setUDC(0, (char *) udc_Bat_Hi);
wim 0:a75049de1a82 203 lcd2.setUDC(1, (char *) udc_Bat_Ha);
wim 0:a75049de1a82 204 lcd2.setUDC(2, (char *) udc_Bat_Lo);
wim 0:a75049de1a82 205 lcd2.setUDC(3, (char *) udc_AC);
wim 0:a75049de1a82 206 lcd2.putc(0);
wim 0:a75049de1a82 207 lcd2.putc(1);
wim 0:a75049de1a82 208 lcd2.putc(2);
wim 0:a75049de1a82 209 lcd2.putc(3);
wim 0:a75049de1a82 210 #endif
wim 0:a75049de1a82 211
wim 0:a75049de1a82 212 #if(0)
wim 0:a75049de1a82 213 while (1) {
wim 0:a75049de1a82 214 lcd.locate(4, 2);
wim 0:a75049de1a82 215 lcd.printf("Count=%3d", i);
wim 0:a75049de1a82 216 i++;
wim 0:a75049de1a82 217 if (i==100) i=0;
wim 0:a75049de1a82 218
wim 0:a75049de1a82 219 wait(1);
wim 0:a75049de1a82 220 }
wim 0:a75049de1a82 221 #endif
wim 0:a75049de1a82 222
wim 0:a75049de1a82 223 pc.printf("Hello World!\n\r");
wim 0:a75049de1a82 224 show_menu();
wim 0:a75049de1a82 225
wim 2:c2978a6fa79a 226 while(running) {
wim 0:a75049de1a82 227 count++;
wim 0:a75049de1a82 228
wim 0:a75049de1a82 229 if(pc.readable()) {
wim 0:a75049de1a82 230 command = pc.getc();
wim 3:f238b4f7874f 231 // pc.printf("command= %c \n\r", command);
wim 3:f238b4f7874f 232 pc.printf("\n\r");
wim 0:a75049de1a82 233 switch (command) {
wim 0:a75049de1a82 234 case '0' :
wim 0:a75049de1a82 235 pc.printf("Done\n\r");
wim 0:a75049de1a82 236 running = false;
wim 0:a75049de1a82 237 break;
wim 0:a75049de1a82 238
wim 0:a75049de1a82 239 case '1' :
wim 0:a75049de1a82 240 show_menu();
wim 0:a75049de1a82 241 break;
wim 0:a75049de1a82 242
wim 0:a75049de1a82 243 case '2' :
wim 0:a75049de1a82 244 pc.printf("Goto 0,0\n\r");
wim 0:a75049de1a82 245 lcd.locate(0, 0);
wim 0:a75049de1a82 246 // lcd2.locate(0, 0);
wim 0:a75049de1a82 247 break;
wim 0:a75049de1a82 248
wim 0:a75049de1a82 249 case '3' :
wim 0:a75049de1a82 250 pc.printf("Goto Col,Row\n\r");
wim 0:a75049de1a82 251 lcd.locate( (lcd.columns() - 1), (lcd.rows() - 1));
wim 0:a75049de1a82 252 // lcd2.locate( (lcd.columns() - 1), (lcd.rows() - 1));
wim 0:a75049de1a82 253 break;
wim 0:a75049de1a82 254
wim 0:a75049de1a82 255 case '4' :
wim 0:a75049de1a82 256 pc.printf("cls()\n\r");
wim 0:a75049de1a82 257 lcd.cls();
wim 0:a75049de1a82 258 // lcd2.cls();
wim 0:a75049de1a82 259 break;
wim 0:a75049de1a82 260
wim 0:a75049de1a82 261 case '5' :
wim 0:a75049de1a82 262 pc.printf("UDCs\n\r");
wim 0:a75049de1a82 263 lcd.locate(2, 0);
wim 0:a75049de1a82 264 lcd.putc(0);
wim 0:a75049de1a82 265 lcd.putc(1);
wim 0:a75049de1a82 266 lcd.putc(2);
wim 0:a75049de1a82 267 lcd.putc(3);
wim 0:a75049de1a82 268 lcd.putc(4);
wim 0:a75049de1a82 269 lcd.putc(5);
wim 0:a75049de1a82 270 lcd.putc(6);
wim 0:a75049de1a82 271 lcd.putc(7);
wim 0:a75049de1a82 272
wim 3:f238b4f7874f 273 // lcd.locate(4, lcd.rows()-1);
wim 3:f238b4f7874f 274 // lcd.putc(0);
wim 3:f238b4f7874f 275 // lcd.putc(1);
wim 3:f238b4f7874f 276 // lcd.putc(2);
wim 3:f238b4f7874f 277 // lcd.putc(3);
wim 0:a75049de1a82 278
wim 0:a75049de1a82 279
wim 0:a75049de1a82 280 // lcd2.locate(4, lcd.rows()-1);
wim 0:a75049de1a82 281 // lcd2.putc(0);
wim 0:a75049de1a82 282 // lcd2.putc(1);
wim 0:a75049de1a82 283 // lcd2.putc(2);
wim 0:a75049de1a82 284 // lcd2.putc(3);
wim 0:a75049de1a82 285
wim 0:a75049de1a82 286 break;
wim 0:a75049de1a82 287 case '6' :
wim 0:a75049de1a82 288 pc.printf("Fill\n\r");
wim 0:a75049de1a82 289 lcd.locate(0, 0);
wim 0:a75049de1a82 290 for (int row=0; row<lcd.rows(); row++) {
wim 0:a75049de1a82 291 int col=0;
wim 0:a75049de1a82 292
wim 0:a75049de1a82 293 // pc.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row));
wim 0:a75049de1a82 294 // lcd.putc('-');
wim 0:a75049de1a82 295 lcd.putc('0' + row);
wim 0:a75049de1a82 296
wim 0:a75049de1a82 297 for (col=1; col<lcd.columns()-1; col++) {
wim 0:a75049de1a82 298 lcd.putc('*');
wim 0:a75049de1a82 299 }
wim 0:a75049de1a82 300
wim 0:a75049de1a82 301 // pc.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row));
wim 0:a75049de1a82 302 lcd.putc('+');
wim 0:a75049de1a82 303 }
wim 0:a75049de1a82 304
wim 0:a75049de1a82 305 break;
wim 0:a75049de1a82 306
wim 0:a75049de1a82 307 case '7' :
wim 0:a75049de1a82 308 pc.printf("Cursor 0n\n\r");
wim 0:a75049de1a82 309 lcd.setCursor(TextLCD::CurOff_BlkOn);
wim 0:a75049de1a82 310 // lcd2.setCursor(TextLCD::CurOff_BlkOn);
wim 0:a75049de1a82 311 break;
wim 0:a75049de1a82 312
wim 0:a75049de1a82 313 case '8' :
wim 0:a75049de1a82 314 pc.printf("Cursor 0ff\n\r");
wim 0:a75049de1a82 315 lcd.setCursor(TextLCD::CurOff_BlkOff);
wim 0:a75049de1a82 316 // lcd2.setCursor(TextLCD::CurOff_BlkOff);
wim 0:a75049de1a82 317 break;
wim 0:a75049de1a82 318
wim 0:a75049de1a82 319 case '9' :
wim 0:a75049de1a82 320 pc.printf("Text\n\r");
wim 1:ef419b21167d 321 lcd.locate(0, 0);
wim 3:f238b4f7874f 322
wim 3:f238b4f7874f 323 #if(1)
wim 3:f238b4f7874f 324 // 01234567890123456789
wim 3:f238b4f7874f 325 lcd.printf("Hello mbed\n");
wim 3:f238b4f7874f 326 lcd.printf(" SSD1803 Native I2C\n");
wim 3:f238b4f7874f 327 lcd.printf(" LCD20x4D\n");
wim 3:f238b4f7874f 328 lcd.printf("TextLCD lib");
wim 3:f238b4f7874f 329 #endif
wim 3:f238b4f7874f 330
wim 3:f238b4f7874f 331 #if(0)
wim 3:f238b4f7874f 332 lcd.printf("Hello mbed\n");
wim 3:f238b4f7874f 333 lcd.printf("I2C Exp MCP23008");
wim 3:f238b4f7874f 334 lcd.printf(" 16x3F (=24x2)\n");
wim 3:f238b4f7874f 335 // lcd.printf(" OLED I2C Exp\n");
wim 3:f238b4f7874f 336 // lcd.printf(" Native I2C\n");
wim 0:a75049de1a82 337 // lcd2.printf("Hello mbed\n");
wim 3:f238b4f7874f 338 #endif
wim 1:ef419b21167d 339
wim 1:ef419b21167d 340 #if(0)
wim 1:ef419b21167d 341 // Needed for PCF2116C and PCF2116K
wim 1:ef419b21167d 342 lcd.putc('H' ^ 0x80);
wim 1:ef419b21167d 343 lcd.putc('e' ^ 0x80);
wim 1:ef419b21167d 344 lcd.putc('l' ^ 0x80);
wim 1:ef419b21167d 345 lcd.putc('l' ^ 0x80);
wim 1:ef419b21167d 346 lcd.putc('o' ^ 0x80);
wim 1:ef419b21167d 347 lcd.putc(' ' ^ 0x80);
wim 1:ef419b21167d 348 lcd.putc('m' ^ 0x80);
wim 1:ef419b21167d 349 lcd.putc('b' ^ 0x80);
wim 1:ef419b21167d 350 lcd.putc('e' ^ 0x80);
wim 1:ef419b21167d 351 lcd.putc('d' ^ 0x80);
wim 1:ef419b21167d 352 lcd.putc('\n');
wim 1:ef419b21167d 353 lcd.putc('I' ^ 0x80);
wim 1:ef419b21167d 354 lcd.putc('2' ^ 0x80);
wim 1:ef419b21167d 355 lcd.putc('C' ^ 0x80);
wim 1:ef419b21167d 356 lcd.putc(' ' ^ 0x80);
wim 1:ef419b21167d 357 lcd.putc('P' ^ 0x80);
wim 1:ef419b21167d 358 lcd.putc('C' ^ 0x80);
wim 1:ef419b21167d 359 lcd.putc('F' ^ 0x80);
wim 1:ef419b21167d 360 lcd.putc('2' ^ 0x80);
wim 1:ef419b21167d 361 lcd.putc('1' ^ 0x80);
wim 1:ef419b21167d 362 lcd.putc('1' ^ 0x80);
wim 1:ef419b21167d 363 lcd.putc('6' ^ 0x80);
wim 3:f238b4f7874f 364 lcd.putc('\n');
wim 3:f238b4f7874f 365
wim 3:f238b4f7874f 366 lcd.putc(' ' ^ 0x80);
wim 3:f238b4f7874f 367 lcd.putc('(' ^ 0x80);
wim 3:f238b4f7874f 368 lcd.putc('N' ^ 0x80);
wim 3:f238b4f7874f 369 lcd.putc('o' ^ 0x80);
wim 3:f238b4f7874f 370 lcd.putc(' ' ^ 0x80);
wim 3:f238b4f7874f 371 lcd.putc('A' ^ 0x80);
wim 3:f238b4f7874f 372 lcd.putc('c' ^ 0x80);
wim 3:f238b4f7874f 373 lcd.putc('k' ^ 0x80);
wim 3:f238b4f7874f 374 lcd.putc(')' ^ 0x80);
wim 3:f238b4f7874f 375 lcd.putc(' ' ^ 0x80);
wim 3:f238b4f7874f 376 lcd.putc(' ' ^ 0x80);
wim 3:f238b4f7874f 377 #endif
wim 0:a75049de1a82 378 break;
wim 0:a75049de1a82 379
wim 0:a75049de1a82 380 case 'A' :
wim 0:a75049de1a82 381 pc.printf("Display On\n\r");
wim 0:a75049de1a82 382 lcd.setMode(TextLCD::DispOn);
wim 0:a75049de1a82 383 // lcd2.setMode(TextLCD::DispOn);
wim 0:a75049de1a82 384 break;
wim 0:a75049de1a82 385
wim 0:a75049de1a82 386 case 'B' :
wim 0:a75049de1a82 387 pc.printf("Display Off\n\r");
wim 0:a75049de1a82 388 lcd.setMode(TextLCD::DispOff);
wim 0:a75049de1a82 389 // lcd2.setMode(TextLCD::DispOff);
wim 0:a75049de1a82 390 break;
wim 0:a75049de1a82 391
wim 0:a75049de1a82 392 case 'C' :
wim 0:a75049de1a82 393 pc.printf("Backlight On\n\r");
wim 0:a75049de1a82 394 lcd.setBacklight(TextLCD::LightOn);
wim 0:a75049de1a82 395 // lcd2.setBacklight(TextLCD::LightOn);
wim 0:a75049de1a82 396 break;
wim 0:a75049de1a82 397
wim 0:a75049de1a82 398 case 'D' :
wim 0:a75049de1a82 399 pc.printf("Backlight Off\n\r");
wim 0:a75049de1a82 400 lcd.setBacklight(TextLCD::LightOff);
wim 0:a75049de1a82 401 // lcd2.setBacklight(TextLCD::LightOff);
wim 0:a75049de1a82 402 break;
wim 0:a75049de1a82 403
wim 0:a75049de1a82 404
wim 0:a75049de1a82 405 // case 'E' :
wim 0:a75049de1a82 406 // pc.printf("Test nibble\n\r");
wim 0:a75049de1a82 407 // for (int i=0; i<16; i++) {
wim 0:a75049de1a82 408 // lcd._writeNibble(i);
wim 0:a75049de1a82 409 // wait(1);
wim 0:a75049de1a82 410 // }
wim 0:a75049de1a82 411 // break;
wim 0:a75049de1a82 412
wim 1:ef419b21167d 413 case 'P' :
wim 2:c2978a6fa79a 414 pc.printf("Init Ctrl test\n\r");
wim 1:ef419b21167d 415 //test
wim 2:c2978a6fa79a 416 // lcd._initCtrl();
wim 1:ef419b21167d 417 break;
wim 1:ef419b21167d 418
wim 3:f238b4f7874f 419
wim 3:f238b4f7874f 420 case 'Q' :
wim 3:f238b4f7874f 421 pc.printf("Contrast test\n\r");
wim 3:f238b4f7874f 422 for (i=0; i<64; i++) {
wim 3:f238b4f7874f 423 lcd.setContrast(i);
wim 3:f238b4f7874f 424 pc.printf("Contrast = %d\r", i);
wim 3:f238b4f7874f 425 wait(0.5);
wim 3:f238b4f7874f 426 }
wim 3:f238b4f7874f 427
wim 3:f238b4f7874f 428 pc.printf("\n\rMax Contrast\n\r");
wim 3:f238b4f7874f 429 wait(1);
wim 3:f238b4f7874f 430 // lcd.setContrast(LCD_CONTRAST); //set default
wim 3:f238b4f7874f 431 lcd.setContrast(); //set default
wim 3:f238b4f7874f 432 pc.printf("\n\rContrast test done\n\r");
wim 3:f238b4f7874f 433
wim 3:f238b4f7874f 434 break;
wim 3:f238b4f7874f 435
wim 0:a75049de1a82 436 default :
wim 0:a75049de1a82 437 lcd.putc(command);
wim 1:ef419b21167d 438 // lcd.putc(command ^ 0x80); // Needed for PCF2116C and PCF2116K
wim 0:a75049de1a82 439 // lcd2.putc(command);
wim 0:a75049de1a82 440 break;
wim 3:f238b4f7874f 441
wim 0:a75049de1a82 442
wim 0:a75049de1a82 443 } //switch
wim 0:a75049de1a82 444 }//if
wim 0:a75049de1a82 445 }//while
wim 0:a75049de1a82 446
wim 0:a75049de1a82 447 pc.printf("Bye World!\n\r");
wim 0:a75049de1a82 448 }