Manejo de pantallas de texto con varias interfaces de comunicación

Dependencies:   mbed TextLCD

Files at this revision

API Documentation at this revision

Comitter:
lscordovar
Date:
Wed Feb 12 21:51:46 2020 +0000
Parent:
5:2e4e5085d597
Commit message:
Ejemplos de uso de la libreria LCD pro I2C

Changed in this revision

TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/TextLCD.lib	Wed Feb 12 21:20:37 2020 +0000
+++ b/TextLCD.lib	Wed Feb 12 21:51:46 2020 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/wim/code/TextLCD/#24850e751517
+https://os.mbed.com/users/lscordovar/code/TextLCD/#baf112053ac8
--- a/main.cpp	Wed Feb 12 21:20:37 2020 +0000
+++ b/main.cpp	Wed Feb 12 21:51:46 2020 +0000
@@ -1,26 +1,35 @@
-/* Hello World! for the TextLCD Enhanced Library*/
-
 #include "mbed.h"
 #include "TextLCD.h"
 
-// Host PC Communication channels
 Serial pc(PA_2,PA_3); // tx, rx
+I2C i2c_lcd(PB_9, PB_8); // SDA, SCL
+TextLCD_I2C lcd(&i2c_lcd, 0x4E, TextLCD::LCD20x4);
 
-// I2C Communication
-I2C i2c_lcd(PB_9, PB_8); // SDA, SCL
-//I2C i2c_lcd(p28,p27); // SDA, SCL
+/*
+Para usar su LCD con el PCF8574 o el PCF8574A deben cambiar en la linea 73 del
+archivo TextLCD_Config.h que esta en la libreria adjunta esto:
+            #define DFROBOT        0
+Por esto:
+            #define DFROBOT        1
+
+Pueden probar tambien estas otras opciones, me funciona bien casi para todas
+excepto las que tienen un comentario con un //no
 
-// SPI Communication
-//SPI spi_lcd(p5, NC, p7); // MOSI, MISO, SCLK
+#define DEFAULT        0//no
+#define ADAFRUIT       0//no
+#define DFROBOT        0
+#define LCM1602        0
+#define YWROBOT        0
+#define GYLCD          0//no
+#define MJKDZ          0//no
+#define SYDZ           1
+#define WIDEHK         0//no
+#define LCDPLUG        0//no
+*/
 
-// LCD instantiation
-//TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD20x2);        // 4bit bus: rs, e, d4-d7
-TextLCD_I2C lcd(&i2c_lcd, 0x4E, TextLCD::LCD20x4);                  // I2C exp: I2C bus, PCF8574 Slaveaddress, LCD Type
-//TextLCD_I2C lcd(&i2c_lcd, 0x42, TextLCD::LCD16x2, TextLCD::WS0010); // I2C exp: I2C bus, PCF8574 Slaveaddress, LCD Type, Ctrl Type
-//TextLCD_I2C lcd(&spi_lcd, p8, TextLCD::LCD24x4D);                   // I2C exp: SPI bus, CS pin, LCD Type
-//TextLCD_SPI_N lcd(&spi_lcd, p8, p9, TextLCD::LCD16x2, NC, TextLCD::ST7032_3V3); // SPI native: SPI bus, CS pin, RS pin, LCDType=LCD16x2, BL=NC, LCDTCtrl=ST7032
-//TextLCD_I2C_N lcd(&i2c_lcd, ST7032_SA, TextLCD::LCD16x2, NC, TextLCD::ST7032_3V3); // I2C native: I2C bus, slaveaddress, LCDType=LCD16x2, BL=NC, LCDTCtrl=ST7032 =Ok
-//TextLCD_I2C_N lcd(&i2c_lcd, SSD1803_SA1, TextLCD::LCD20x4D, NC, TextLCD::SSD1803_3V3); // I2C native: I2C bus, slaveaddress, LCDType=LCD20x4D, BL=NC, LCDTCtrl=SSD1803 =Ok
+//Para el ejemplo presente use #define SYDZ           1
+//esto debe ir solo en el archivo mencionado
+
 
 int main()
 {
@@ -72,10 +81,14 @@
     lcd.setUDC(1, (char *) udc_1);  // Show <|
     lcd.putc(1);
 
-    pc.printf("Bye now\r\n");
+    pc.printf("Bye now in original example \r\n");
 
     wait(1);
 
+
+    /*****************************************************************************/
+    pc.printf("From here is a new example for Master classes in UPS Guayaquil \r\n");
+
     // Clear the screen and locate to 0,0
     lcd.cls();
 
@@ -92,32 +105,48 @@
     int col = 0;
     int row = 0;
     lcd.locate(col,row);
+    lcd.printf("Iniciando...");
     wait(1);
 
+    //No Show cursor as blinking character
+    lcd.setCursor(TextLCD::CurOff_BlkOff);
+
     // Write a character to the LCD "ARROW"
     int c = 1;
-    for (int row=0; row<lcd.rows(); row++) {
-        lcd.putc(c);wait(0.1);
+    lcd.cls();
+    lcd.locate(0,0);
+    for (int row=0; row<4; row++) {
+        lcd.putc(c);
+        wait(0.01);
 
-        for (col=1; col<lcd.columns()-1; col++) {
-            lcd.putc(c);wait(0.1);
+        for (col=0; col<19; col++) {
+            lcd.putc(c);
+            wait(0.01);
         }
     }
     wait(2);
 
     // Write a raw string to the LCD
-    const char* text = "Hola text";
+    const char* text = "Hola a todos!!";
     lcd.cls();
-    lcd.locate(1,1);
+    lcd.locate(3,0);
     lcd.printf(text);
     wait(1);
 
     // Write a raw string to the LCD *-> pointer*
-    const char* msg = "Hello printf";
+
+    lcd.locate(0,1);
+    lcd.printf("/*----------------*/");
+
+    const char* msg = "Mensaje con punteros";
     int string_size = strlen (msg);
-    lcd.setCursor(TextLCD::CurOff_BlkOff);
-    lcd.locate(1,2);
-    lcd.printf("msg: %.*s", string_size, msg);
+    lcd.locate(0,2);
+    lcd.printf("%.*s", string_size, msg);
+
+    lcd.locate(0,3);
+    const char* msg2 = "\"TXT: %.*s\",size,msg";
+    int string_size2 = strlen (msg2);
+    lcd.printf("%.*s", string_size2, msg2);
     wait(1);