opener-6

Dependencies:   TextLCD_HelloWorld2 TextLCD mbed

Fork of TextLCD_HelloWorld2 by Wim Huiskamp

Revision:
3:f238b4f7874f
Parent:
2:c2978a6fa79a
Child:
4:a3e4bb2053cb
--- a/main.cpp	Sat Jun 28 14:28:08 2014 +0000
+++ b/main.cpp	Sun Aug 24 09:01:56 2014 +0000
@@ -22,6 +22,7 @@
     pc.printf("C: Backlight On\n\r");                    
     pc.printf("D: Backlight Off\n\r");                           
     pc.printf("P: init \n\r");                        
+    pc.printf("Q: contrast \n\r");                            
     pc.printf("\n\r");                
 }
 
@@ -35,6 +36,7 @@
 //DigitalOut cs(p8);
 //DigitalOut cs2(p9);
 
+//4 Bit bus
 //TextLCD lcd2(p15, p16, p17, p18, p19, p20, TextLCD::LCD16x4); // rs, e, d4-d7  =ok
 //TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD20x2); // rs, e, d4-d7 =ok
 //TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD20x4); // rs, e, d4-d7 =ok
@@ -42,44 +44,63 @@
 //TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD24x4D, TextLCD::KS0078); // rs, e, d4-d7 =ok
 //TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD40x2); // rs, e, d4-d7 =ok
 
+//I2C Expander PCF8574
 //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
 
-//Test Adafruit module, change #define
+// I2C Expander MCP23008, Adafruit module (change #define !!)
+//TextLCD_I2C lcd(&i2c_lcd, MCP23008_SA0, TextLCD::LCD16x3F); // I2C bus, MCP23008 Slaveaddress, LCD Type =Ok
 //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
-
-//TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD24x4D, TextLCD::KS0078); // SPI bus, CS pin, LCD Type =ok
-//TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD40x2); // SPI bus, CS pin, LCD Type =ok
-//TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD40x4); // SPI bus, CS pin, LCD Type =ok
-
-//TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD40x4, TextLCD::HD44780); // SPI bus, CS pin, LCD Type, LCD Ctrl =ok
+//TextLCD_I2C lcd(&i2c_lcd, MCP23008_SA0, TextLCD::LCD16x2, TextLCD::WS0010); // I2C bus, MCP23008 Slaveaddress, LCD Type =Ok
+//TextLCD_I2C lcd(&i2c_lcd, MCP23008_SA0, TextLCD::LCD24x4D, TextLCD::KS0078); // I2C bus, MCP23008 Slaveaddress, LCD Type =ok
+//TextLCD_I2C lcd(&i2c_lcd, MCP23008_SA0, TextLCD::LCD16x1C); // I2C bus, MCP23008 Slaveaddress, LCD Type =Ok
 
 
+//SPI Expander
 //TextLCD_SPI lcd2(&spi_lcd, p9, TextLCD::LCD8x2B); // SPI bus, CS pin, LCD Type =ok
 //TextLCD_SPI lcd2(&spi_lcd, p9, TextLCD::LCD16x1C); // 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 lcd(&spi_lcd, p8, TextLCD::LCD40x2); // SPI bus, CS pin, LCD Type =ok
+//TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD40x4); // SPI bus, CS pin, LCD Type =ok
+//TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD40x4, TextLCD::HD44780); // SPI bus, CS pin, LCD Type, LCD Ctrl =ok
+//TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD24x4D, TextLCD::KS0078); // SPI bus, CS pin, LCD Type =ok
 
+
+//WS0010
+//TextLCD_I2C lcd(&i2c_lcd, 0x42, TextLCD::LCD16x2, TextLCD::WS0010); // I2C bus, PCF8574 Slaveaddress, LCD Type, LCD Ctrl           =Ok
+//TextLCD_SPI_N_3_10 lcd(&spi_lcd, p8, TextLCD::LCD16x2, NC, TextLCD::WS0010); // SPI bus, CS, LCDType=LCD16x2, BL=NC, LCDTCtrl=WS0010 =Ok
+
+//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 =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_I2C_N lcd(&i2c_lcd, ST7032_SA, TextLCD::LCD16x2, NC, TextLCD::ST7032_3V3); // I2C bus, slaveaddress, LCDType=LCD16x2, BL=NC, LCDTCtrl=ST7032 =Ok
+
+//ST7036
+//TextLCD_I2C lcd(&i2c_lcd, MCP23008_SA0, TextLCD::LCD16x3G, TextLCD::ST7036_3V3); // I2C bus, MCP23008 Slaveaddress, LCD Type, LCDTCtrl=ST7036
+//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
+
+//SSD1803A
+//TextLCD_I2C_N lcd(&i2c_lcd, SSD1803_SA1, TextLCD::LCD20x4D, NC, TextLCD::SSD1803_3V3); // I2C bus, slaveaddress, LCDType=LCD16x2, BL=NC, LCDTCtrl=SSD1803 =Ok
+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
 
 //Test PCF2113
 //TextLCD_I2C_N lcd(&i2c_lcd, PCF21XX_SA0, TextLCD::LCD12x2, NC, TextLCD::PCF2113_3V3); // I2C bus, slaveaddress, LCDType=LCD12x2, BL=NC, LCDTCtrl=PCF2113 
 
 //PCF2116
+//TextLCD_I2C_N lcd(&i2c_lcd, PCF21XX_SA0, TextLCD::LCD12x3D1, NC, TextLCD::PCF2116_5V); // I2C bus, slaveaddress, LCDType=LCD12x3D1, BL=NC, LCDTCtrl=PCF2116 (experimental)
 //TextLCD_I2C_N lcd(&i2c_lcd, PCF21XX_SA0, TextLCD::LCD12x3D1, NC, TextLCD::PCF2116_3V3); // I2C bus, slaveaddress, LCDType=LCD12x3D1, BL=NC, LCDTCtrl=PCF2116 
+//TextLCD_I2C_N lcd(&i2c_lcd, PCF21XX_SA1, TextLCD::LCD12x3D1, NC, TextLCD::PCF2116_3V3); // I2C bus, slaveaddress, LCDType=LCD12x3D1, BL=NC, LCDTCtrl=PCF2116 
 //TextLCD_I2C_N lcd(&i2c_lcd, PCF21XX_SA0, TextLCD::LCD12x4D, NC, TextLCD::PCF2116_3V3); // I2C bus, slaveaddress, LCDType=LCD12x4D, BL=NC, LCDTCtrl=PCF2116 
 //TextLCD_I2C_N lcd(&i2c_lcd, PCF21XX_SA0, TextLCD::LCD24x1, NC, TextLCD::PCF2116_3V3); // I2C bus, slaveaddress, LCDType=LCD24x1, BL=NC, LCDTCtrl=PCF2116 
 //TextLCD_I2C_N lcd(&i2c_lcd, PCF21XX_SA0, TextLCD::LCD24x2, NC, TextLCD::PCF21116_3V3); // I2C bus, slaveaddress, LCDType=LCD24x2, BL=NC, LCDTCtrl=PCF2116 
 
 //AIP31068
-TextLCD_I2C_N lcd(&i2c_lcd, AIP31068_SA, TextLCD::LCD16x2, NC, TextLCD::AIP31068); // I2C bus, slaveaddress, LCDType=LCD16x2, BL=NC, LCDTCtrl=AIP31068
-//TextLCD_SPI_N_3_9 lcd(&spi_lcd, p8, TextLCD::LCD16x2, NC, TextLCD::AIP31068); // I2C bus, slaveaddress, LCDType=LCD16x2, BL=NC, LCDTCtrl=AIP31068
-//TextLCD_SPI_N_3_10 lcd(&spi_lcd, p8, TextLCD::LCD16x2, NC, TextLCD::WS0010); // I2C bus, slaveaddress, LCDType=LCD16x2, BL=NC, LCDTCtrl=WS0010
+//TextLCD_I2C_N lcd(&i2c_lcd, AIP31068_SA, TextLCD::LCD16x2, NC, TextLCD::AIP31068); // I2C bus, slaveaddress, LCDType=LCD16x2, BL=NC, LCDTCtrl=AIP31068  =Ok
+//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   
+
+
 
 int main() {
-//  int i=0;
+  int i=0;
   int count=0;
   bool running=true;
   char command;    
@@ -106,17 +127,14 @@
 //   wait_ms(500);    
 //   lcd.cls();    // Test timing
 //}
- 
 
     lcd.setCursor(TextLCD::CurOff_BlkOn);
 
 #if(0)
     lcd.setUDC(0, (char *) udc_AA);
     lcd.putc(0);    
-
     lcd.setUDC(1, (char *) udc_0E);
     lcd.putc(1);    
-
     lcd.setUDC(0, (char *) udc_0);
     lcd.putc(0);    
     lcd.setUDC(1, (char *) udc_1);
@@ -125,6 +143,28 @@
     lcd.putc(2);    
 #endif
 
+#if(0)
+    lcd.setUDC(0, (char *) udc_None);    
+    lcd.setUDC(1, (char *) udc_None);    
+    lcd.setUDC(2, (char *) udc_None);    
+    lcd.setUDC(3, (char *) udc_None);    
+    lcd.setUDC(4, (char *) udc_None);    
+    lcd.setUDC(5, (char *) udc_None);    
+    lcd.setUDC(6, (char *) udc_None);    
+    lcd.setUDC(7, (char *) udc_None);                                
+#endif
+
+#if(0)
+    lcd.setUDC(0, (char *) udc_All);    
+    lcd.setUDC(1, (char *) udc_All);    
+    lcd.setUDC(2, (char *) udc_All);    
+    lcd.setUDC(3, (char *) udc_All);    
+    lcd.setUDC(4, (char *) udc_All);    
+    lcd.setUDC(5, (char *) udc_All);    
+    lcd.setUDC(6, (char *) udc_All);    
+    lcd.setUDC(7, (char *) udc_All);                                
+#endif
+
 #if(1)
     lcd.setUDC(0, (char *) udc_Bat_Hi);
     lcd.setUDC(1, (char *) udc_Bat_Ha);
@@ -147,6 +187,7 @@
     lcd.setUDC(7, (char *) udc_ch_mi);
 #endif
 
+#if(0)
     lcd.putc(0);    
     lcd.putc(1);    
     lcd.putc(2);    
@@ -155,6 +196,7 @@
     lcd.putc(5);    
     lcd.putc(6);    
     lcd.putc(7);    
+#endif
 
 #if(0)
     lcd2.setUDC(0, (char *) udc_Bat_Hi);
@@ -186,8 +228,8 @@
     
        if(pc.readable()) {
          command = pc.getc();       
-         pc.printf("command= %c \n\r", command);         
-
+//         pc.printf("command= %c \n\r", command);         
+         pc.printf("\n\r");         
          switch (command) {
           case '0' :
                      pc.printf("Done\n\r");                    
@@ -228,11 +270,11 @@
                      lcd.putc(6);    
                      lcd.putc(7);                         
                                           
-                     lcd.locate(4, lcd.rows()-1);      
-                     lcd.putc(0);    
-                     lcd.putc(1);                         
-                     lcd.putc(2);                         
-                     lcd.putc(3);                                              
+//                     lcd.locate(4, lcd.rows()-1);      
+//                     lcd.putc(0);    
+//                     lcd.putc(1);                         
+//                     lcd.putc(2);                         
+//                     lcd.putc(3);                                              
 
 
 //                     lcd2.locate(4, lcd.rows()-1);      
@@ -277,9 +319,23 @@
           case '9' :
                      pc.printf("Text\n\r");    
                      lcd.locate(0, 0);                                                
-                     lcd.printf(" Hello mbed\n");                            
-                     lcd.printf("   Native I2C\n");                                                 
+
+#if(1)
+//                               01234567890123456789
+                     lcd.printf("Hello mbed\n");
+                     lcd.printf(" SSD1803 Native I2C\n");                     
+                     lcd.printf(" LCD20x4D\n");    
+                     lcd.printf("TextLCD lib");                                                           
+#endif
+
+#if(0)
+                     lcd.printf("Hello mbed\n");
+                     lcd.printf("I2C Exp MCP23008");                     
+                     lcd.printf(" 16x3F (=24x2)\n");                                          
+//                     lcd.printf("  OLED I2C Exp\n");
+//                     lcd.printf("   Native I2C\n");                                                 
 //                     lcd2.printf("Hello mbed\n");                            
+#endif
 
 #if(0)  
   // Needed for PCF2116C and PCF2116K
@@ -305,8 +361,20 @@
                      lcd.putc('1' ^ 0x80);
                      lcd.putc('1' ^ 0x80);
                      lcd.putc('6' ^ 0x80);                     
-#endif
-                                                    
+                     lcd.putc('\n');
+
+                     lcd.putc(' ' ^ 0x80);
+                     lcd.putc('(' ^ 0x80);                      
+                     lcd.putc('N' ^ 0x80);
+                     lcd.putc('o' ^ 0x80);
+                     lcd.putc(' ' ^ 0x80);
+                     lcd.putc('A' ^ 0x80);
+                     lcd.putc('c' ^ 0x80);
+                     lcd.putc('k' ^ 0x80);
+                     lcd.putc(')' ^ 0x80);
+                     lcd.putc(' ' ^ 0x80);
+                     lcd.putc(' ' ^ 0x80);                     
+#endif                                                   
                      break;
 
           case 'A' :
@@ -348,11 +416,29 @@
 //                    lcd._initCtrl();
                     break;
                     
+
+          case 'Q' :
+                     pc.printf("Contrast test\n\r");                                           
+                     for (i=0; i<64; i++) {
+                       lcd.setContrast(i);
+                       pc.printf("Contrast = %d\r", i);                                                                  
+                       wait(0.5);
+                     }  
+
+                    pc.printf("\n\rMax Contrast\n\r");
+                    wait(1);
+//                    lcd.setContrast(LCD_CONTRAST); //set default
+                    lcd.setContrast(); //set default                    
+                    pc.printf("\n\rContrast test done\n\r");                                           
+                                          
+                    break;
+                    
           default :
                     lcd.putc(command);          
 //                    lcd.putc(command ^ 0x80);   // Needed for PCF2116C and PCF2116K
 //                    lcd2.putc(command);                              
                     break;
+
                               
         } //switch
       }//if