Henrique Rosa / Mbed 2 deprecated LCD_20X4_I2C_testt

Dependencies:   TextLCD mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 // projeto: 2018_I2C_LCD_03
00002 // testado com PCF8574 em 2018-04-27 << Funcionando Ok
00003 // Hello World! for the TextLCD
00004  
00005 #include "mbed.h"
00006 #include "TextLCD.h"
00007  
00008 // Host PC Communication channels
00009 Serial pc(USBTX, USBRX); // tx, rx
00010  
00011 // I2C Communication
00012 I2C i2c_lcd(I2C_SDA, I2C_SCL); // SDA, SCL >>> NUCLEO: D14,D15
00013  
00014 // SPI Communication
00015 //SPI spi_lcd(D14, NC, D15); // MOSI, MISO, SCLK
00016  
00017 //4-bit bus
00018 //TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD40x2); // RS, E, D4-D7
00019 //TextLCD lcd(p15, p16, p17, p18, p19, p20);  // RS, E, D4-D7, LCDType=LCD16x2, BL=NC, E2=NC, LCDTCtrl=HD44780
00020  
00021 //I2C Portexpander PCF8574
00022 TextLCD_I2C lcd(&i2c_lcd, 0x7E, TextLCD::LCD20x4); // I2C bus, PCF8574 Slaveaddress, LCD Type Original = 0x42, Usando I2C scanner = 0x3F
00023 //TextLCD_I2C lcd(&i2c_lcd, 0x7e, TextLCD::LCD16x2, TextLCD::WS0010); // I2C bus, PCF8574 addr, LCD Type, Ctrl Type
00024  
00025 //I2C Portexpander MCP23008
00026 //TextLCD_I2C lcd(&i2c_lcd, MCP23008_SA0, TextLCD::LCD16x3G, TextLCD::ST7036_3V3); // I2C bus, MCP23008 Slaveaddress, LCD Type, LCDTCtrl=ST7036
00027  
00028 //SPI Portexpander SN74595
00029 //TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD24x4D; TextLCD::KS0078); // SPI bus, CS pin, LCD Type
00030 //TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD40x2); // SPI bus, CS pin, LCD Type
00031 //TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD40x4); // SPI bus, CS pin, LCD Type
00032  
00033 //Native I2C
00034 //TextLCD_I2C_N lcd(&i2c_lcd, ST7032_SA, TextLCD::LCD16x2, NC, TextLCD::ST7032_3V3); // I2C bus, Slaveaddress, LCD Type, BL=NC, LCDTCtrl=ST7032_3V3  
00035 //TextLCD_I2C_N lcd(&i2c_lcd, PCF2116_SA0, TextLCD::LCD12x4D, NC, TextLCD::PCF2116_3V3); // I2C bus, Slaveaddress, LCD Type, BL=NC, LCDTCtrl=PCF2116_3V3  
00036 //TextLCD_I2C_N lcd(&i2c_lcd, PCF2116_SA0, TextLCD::LCD24x2, NC, TextLCD::PCF2116_3V3); // I2C bus, Slaveaddress, LCD Type, BL=NC, LCDTCtrl=PCF2116_3V3  
00037 //TextLCD_I2C_N lcd(&i2c_lcd, SSD1803_SA1, TextLCD::LCD20x4D, NC, TextLCD::SSD1803_3V3); // I2C bus, slaveaddress, LCDType=LCD16x2, BL=NC, LCDTCtrl=SSD1803A 
00038  
00039 //Native SPI 4 wire, 8 bits
00040 //TextLCD_SPI_N lcd(&spi_lcd, p8, p9);    // SPI bus, CS pin, RS pin, LCDType=LCD16x2, BL=NC, LCDTCtrl=ST7032_3V3   
00041  
00042 //Native SPI 3 wire, 10bits
00043 //TextLCD_SPI_N_3_10 lcd(&spi_lcd, p8, TextLCD::LCD16x2, NC, TextLCD::WS0010); // SPI bus, CS, LCDType=LCD16x2, BL=NC, LCDTCtrl=WS0010
00044 //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
00045  
00046 //Native SPI 3 wire, 24 bits, SSD1803A
00047 //TextLCD_SPI_N_3_24 lcd(&spi_lcd, p8, TextLCD::LCD20x4D, NC, TextLCD::SSD1803_3V3); // SPI bus, CS pin, LCDType=LCD20x4, BL=NC, LCDTCtrl=SSD1803A
00048  
00049 int main() {
00050     pc.printf("LCD Test. Columns=%d, Rows=%d\n\r", lcd.columns(), lcd.rows());
00051     
00052    // for (int row=0; row<lcd.rows(); row++) { 
00053     //  int col=0;
00054       
00055      // pc.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row));      
00056 //      lcd.putc('-');
00057       //lcd.putc('l' + row);      
00058       
00059      // for (col=1; col<lcd.columns()-1; col++) { 
00060         lcd.locate(2,0);  
00061         lcd.printf("TESTE LCD 20X4");
00062         
00063         lcd.locate(4,2);  
00064         lcd.printf("HENRIQUE");
00065       //}
00066  
00067      /// pc.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row));      
00068      // lcd.putc('+');       
00069   //  }    
00070     
00071 // Show cursor as blinking character
00072 
00073 
00074 
00075     lcd.setCursor(TextLCD::CurOff_BlkOn);
00076     lcd.setBacklight(TextLCD::LightOn);
00077     //lcd.setUDC(0, (char *) udc_AC);  // Show |>
00078      //lcd.putc('LTH');
00079     
00080 
00081 }