Código para o menu no LCD

Dependencies:   mbed SDFileSystemSD TextLCD

Fork of TextLCD_HelloWorld2 by Wim Huiskamp

Revision:
1:ef419b21167d
Parent:
0:a75049de1a82
Child:
2:c2978a6fa79a
diff -r a75049de1a82 -r ef419b21167d main.cpp
--- a/main.cpp	Fri Jun 13 19:02:38 2014 +0000
+++ b/main.cpp	Tue Jun 17 17:41:59 2014 +0000
@@ -21,7 +21,7 @@
     pc.printf("B: Display Off\n\r");                        
     pc.printf("C: Backlight On\n\r");                    
     pc.printf("D: Backlight Off\n\r");                           
-    pc.printf("P: \n\r");                        
+    pc.printf("P: init \n\r");                        
     pc.printf("\n\r");                
 }
 
@@ -42,11 +42,11 @@
 //TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD24x2); // rs, e, d4-d7 =ok
 //TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD40x2); // rs, e, d4-d7 =ok
 
+//TextLCD_I2C lcd(&i2c_lcd, 0x40, TextLCD::LCD20x4); // I2C bus, PCF8574 Slaveaddress, LCD Type =ok
 //TextLCD_I2C lcd(&i2c_lcd, 0x42, TextLCD::LCD20x4); // I2C bus, PCF8574 Slaveaddress, LCD Type =ok
-//TextLCD_I2C lcd(&i2c_lcd, 0x40, TextLCD::LCD20x4); // I2C bus, PCF8574 Slaveaddress, LCD Type =ok
 
-//Test Adafruit module
-//TextLCD_I2C lcd(&i2c_lcd, MCP23008_SA0, TextLCD::LCD20x4); // I2C bus, MCP23008 Slaveaddress, LCD Type =OK
+//Test Adafruit module, change #define
+TextLCD_I2C lcd(&i2c_lcd, MCP23008_SA0, TextLCD::LCD20x4); // I2C bus, MCP23008 Slaveaddress, LCD Type =OK
 
 //TextLCD_I2C lcd(&i2c_lcd, 0x42, TextLCD::LCD16x2, TextLCD::WS0010); // I2C bus, PCF8574 Slaveaddress, LCD Type, LCD Ctrl
 
@@ -61,8 +61,14 @@
 //TextLCD_SPI lcd2(&spi_lcd, p9, TextLCD::LCD16x1); // SPI bus, CS pin, LCD Type =ok 
 //TextLCD_SPI lcd2(&spi_lcd, p9, TextLCD::LCD16x2); // SPI bus, CS pin, LCD Type (VFD) =ok
 
+//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
+//TextLCD_I2C_N lcd(&i2c_lcd, ST7032_SA, TextLCD::LCD16x2, NC, TextLCD::ST7032_3V3); // I2C bus, slaveaddress, LCDType=LCD16x2, BL=NC, LCDTCtrl=ST7032 
 
-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 
+
+//TextLCD_I2C_N lcd(&i2c_lcd, PCF21XX_SA0, TextLCD::LCD12x3B, NC, TextLCD::PCF21XX_3V3); // I2C bus, slaveaddress, LCDType=LCD12x3B, BL=NC, LCDTCtrl=PCF21XX 
+//TextLCD_I2C_N lcd(&i2c_lcd, PCF21XX_SA0, TextLCD::LCD12x4B, NC, TextLCD::PCF21XX_3V3); // I2C bus, slaveaddress, LCDType=LCD12x4B, BL=NC, LCDTCtrl=PCF21XX 
+//TextLCD_I2C_N lcd(&i2c_lcd, PCF21XX_SA0, TextLCD::LCD24x1, NC, TextLCD::PCF21XX_3V3); // I2C bus, slaveaddress, LCDType=LCD24x1, BL=NC, LCDTCtrl=PCF21XX 
+//TextLCD_I2C_N lcd(&i2c_lcd, PCF21XX_SA0, TextLCD::LCD24x2, NC, TextLCD::PCF21XX_3V3); // I2C bus, slaveaddress, LCDType=LCD24x2, BL=NC, LCDTCtrl=PCF21XX 
 
 int main() {
 //  int i=0;
@@ -96,19 +102,22 @@
 
     lcd.setCursor(TextLCD::CurOff_BlkOn);
 
-//    lcd.setUDC(0, (char *) udc_AA);
-//    lcd.putc(0);    
+#if(0)
+    lcd.setUDC(0, (char *) udc_AA);
+    lcd.putc(0);    
 
-//    lcd.setUDC(1, (char *) udc_0E);
-//    lcd.putc(1);    
+    lcd.setUDC(1, (char *) udc_0E);
+    lcd.putc(1);    
 
-//    lcd.setUDC(0, (char *) udc_0);
-//    lcd.putc(0);    
-//    lcd.setUDC(1, (char *) udc_1);
-//    lcd.putc(1);    
-//    lcd.setUDC(2, (char *) udc_2);
-//    lcd.putc(2);    
+    lcd.setUDC(0, (char *) udc_0);
+    lcd.putc(0);    
+    lcd.setUDC(1, (char *) udc_1);
+    lcd.putc(1);    
+    lcd.setUDC(2, (char *) udc_2);
+    lcd.putc(2);    
+#endif
 
+#if(1)
     lcd.setUDC(0, (char *) udc_Bat_Hi);
     lcd.setUDC(1, (char *) udc_Bat_Ha);
     lcd.setUDC(2, (char *) udc_Bat_Lo);
@@ -117,6 +126,18 @@
     lcd.setUDC(5, (char *) udc_5);
     lcd.setUDC(6, (char *) udc_6);
     lcd.setUDC(7, (char *) udc_7);
+#endif
+
+#if(0)
+    lcd.setUDC(0, (char *) udc_ch_1);
+    lcd.setUDC(1, (char *) udc_ch_2);
+    lcd.setUDC(2, (char *) udc_ch_3);
+    lcd.setUDC(3, (char *) udc_ch_4);
+    lcd.setUDC(4, (char *) udc_ch_yr);
+    lcd.setUDC(5, (char *) udc_ch_mo);
+    lcd.setUDC(6, (char *) udc_ch_dy);
+    lcd.setUDC(7, (char *) udc_ch_mi);
+#endif
 
     lcd.putc(0);    
     lcd.putc(1);    
@@ -248,9 +269,37 @@
 
           case '9' :
                      pc.printf("Text\n\r");    
-                     lcd.printf("Hello mbed\n");                            
+                     lcd.locate(0, 0);                                                
+                     lcd.printf(" Hello mbed\n");                            
+                     lcd.printf("   Native I2C\n");                                                 
 //                     lcd2.printf("Hello mbed\n");                            
-                               
+
+#if(0)  
+  // Needed for PCF2116C and PCF2116K
+                     lcd.putc('H' ^ 0x80);
+                     lcd.putc('e' ^ 0x80);
+                     lcd.putc('l' ^ 0x80);
+                     lcd.putc('l' ^ 0x80);
+                     lcd.putc('o' ^ 0x80);
+                     lcd.putc(' ' ^ 0x80);
+                     lcd.putc('m' ^ 0x80);
+                     lcd.putc('b' ^ 0x80);
+                     lcd.putc('e' ^ 0x80);
+                     lcd.putc('d' ^ 0x80);                      
+                     lcd.putc('\n');                      
+                     lcd.putc('I' ^ 0x80);
+                     lcd.putc('2' ^ 0x80);
+                     lcd.putc('C' ^ 0x80);
+                     lcd.putc(' ' ^ 0x80);
+                     lcd.putc('P' ^ 0x80);
+                     lcd.putc('C' ^ 0x80);
+                     lcd.putc('F' ^ 0x80);
+                     lcd.putc('2' ^ 0x80);                      
+                     lcd.putc('1' ^ 0x80);
+                     lcd.putc('1' ^ 0x80);
+                     lcd.putc('6' ^ 0x80);                     
+#endif
+                                                    
                      break;
 
           case 'A' :
@@ -286,10 +335,14 @@
 //                     }
 //                     break;
 
-
-
+          case 'P' :
+//test
+                    lcd._initCtrl();
+                    break;
+                    
           default :
                     lcd.putc(command);          
+//                    lcd.putc(command ^ 0x80);   // Needed for PCF2116C and PCF2116K
 //                    lcd2.putc(command);                              
                     break;