Initial setup for FC-113 controller of TextLCD(1602A)
This example is a simple use case for the user of Text LCD with the FC-113 controller, based on Mbed OS 5.
Note that PCF8574T has Mbed base addresses 0x40 ~ 0x4E, while PCF8574AT has base addresses 0x70 ~ 0x7E.
I used 0x4E for Text LCD with the FC-113 controller.
If you need to fine-tune the Text LCD or using another type the TextLCD, please see here.
Revision 7:9fcc3c0acd50, committed 2019-12-24
- Comitter:
- Daniel_Lee
- Date:
- Tue Dec 24 05:30:57 2019 +0000
- Parent:
- 6:4e6ec83d3c83
- Commit message:
- Initialized for FC-113 controller of TextLCD
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Tue Dec 24 05:30:57 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/Daniel_Lee/code/TextLCD/#03adee64f79b
--- a/main.cpp Wed Sep 13 11:30:50 2017 +0000 +++ b/main.cpp Tue Dec 24 05:30:57 2019 +0000 @@ -1,12 +1,56 @@ #include "mbed.h" +#include "TextLCD.h" + +// I2C Communication +I2C i2c_lcd(A4,A5); // SDA, SCL - I2C3 + +// SPI Communication +//SPI spi_lcd(p5, NC, p7); // MOSI, MISO, SCLK -DigitalOut myled(LED1); +//TextLCD lcd(p15, p16, p17, p18, p19, p20); // RS, E, D4-D7, LCDType=LCD16x2, BL=NC, E2=NC, LCDTCtrl=HD44780 +//TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD40x4); // SPI bus, 74595 expander, CS pin, LCD Type +//TextLCD_I2C lcd(&i2c_lcd, 0x40, TextLCD::LCD16x2); // I2C bus, PCF8574 Slaveaddress, LCD Type +TextLCD_I2C lcd(&i2c_lcd, 0x4E); // I2C bus, PCF8574(FC-113) Slaveaddress, LCD Type(1602A) + +//TextLCD_I2C lcd(&i2c_lcd, 0x42, TextLCD::LCD16x2, TextLCD::WS0010); // I2C bus, PCF8574 Slaveaddress, LCD Type, Device Type +//TextLCD_SPI_N lcd(&spi_lcd, p8, p9); // SPI bus, CS pin, RS pin, LCDType=LCD16x2, BL=NC, LCDTCtrl=ST7032_3V3 +//TextLCD_I2C_N lcd(&i2c_lcd, ST7032_SA, TextLCD::LCD16x2, NC, TextLCD::ST7032_3V3); // I2C bus, Slaveaddress, LCD Type, BL=NC, LCDTCtrl=ST7032_3V3 -int main() { - while(1) { - myled = 1; // LED is ON - wait(0.2); // 200 ms - myled = 0; // LED is OFF - wait(1.0); // 1 sec - } -} +int main() +{ +#if 0 + pc.printf("LCD Test. Columns=%d, Rows=%d\n\r", lcd.columns(), lcd.rows()); + + for (int row=0; row<lcd.rows(); row++) { + int col=0; + + pc.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row)); +// lcd.putc('-'); + lcd.putc('0' + row); + + for (col=1; col<lcd.columns()-1; col++) { + lcd.putc('*'); + } + + pc.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row)); + lcd.putc('+'); + + } + +// Show cursor as blinking character + lcd.setCursor(TextLCD::CurOff_BlkOn); + +// Set and show user defined characters. A maximum of 8 UDCs are supported by the HD44780. +// They are defined by a 5x7 bitpattern. + lcd.setUDC(0, (char *) udc_0); // Show |> + lcd.putc(0); + lcd.setUDC(1, (char *) udc_1); // Show <| + lcd.putc(1); +#else + lcd.cls (); + lcd.setBacklight (TextLCD :: LightOn); + lcd.printf ("LCD check - online compile"); + lcd.setAddress (0, 1); + lcd.printf ("Hello MBED\n"); +#endif +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Tue Dec 24 05:30:57 2019 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os.git/#51143eab02266eb4f9c9f25ce8518332be1fb0a9
--- a/mbed.bld Wed Sep 13 11:30:50 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://mbed.org/users/mbed_official/code/mbed/builds/a330f0fddbec \ No newline at end of file