TextLCD library for controlling various LCD panels based on the HD44780 4-bit interface

Dependencies:   mbed

Fork of TextLCD by Simon Ford

Files at this revision

API Documentation at this revision

Comitter:
a00958821
Date:
Wed Oct 05 21:47:44 2016 +0000
Parent:
8:308d188a2d3a
Commit message:
Laboratio 4, clase de micro controladores. Basic LCD

Changed in this revision

mainLCD.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mainLCD.cpp	Wed Oct 05 21:47:44 2016 +0000
@@ -0,0 +1,186 @@
+#include "mbed.h"
+#include "TextLCD.h"
+
+TextLCD lcd(D2, D3, D4, D5, D6, D7); // rs, e, d4-d7
+
+DigitalOut col1 (D8);
+DigitalOut col2 (D9);
+DigitalOut col3 (D10);
+DigitalOut col4 (D11);
+DigitalIn fila1 (A5);
+DigitalIn fila2 (A4);
+DigitalIn fila3 (A3);
+DigitalIn fila4 (A2);
+DigitalIn Reset (D12);
+DigitalIn Next (USER_BUTTON);
+
+char Simbolos[4][4] = {
+                     {'1','2','3','A'},
+                     {'4','5','6','B'},
+                     {'7','8','9','C'},
+                     {'*','0','#','D'}
+                     };                  
+int usrInput();
+void turnOffteclado();
+int * teclado();
+void printLCD(int a, int b);
+
+
+int n = 0;
+
+int main() {
+    
+    int j = 0;
+    while(1){
+    if (n == 0)
+    {
+        j=0;
+        lcd.cls();
+        wait(1);
+        lcd.printf("A");
+         while (j == 0)
+         {
+            if (Next == 0)
+            {
+                j = 1;
+                n = 1;   
+            }
+        }  
+    }
+    if (n == 1)
+    {
+        j = 0;
+        lcd.cls();
+        wait(1);
+        lcd.printf("Unas kguamas o k");
+        while (j == 0)
+        {
+        if (Next == 0)
+        {
+            j = 1;
+            n =2;  
+        }
+        }
+    }
+    while (n == 2)
+    {
+        j = 0;
+        lcd.cls();
+        wait(1);
+        lcd.printf("Unas kguamas o kDos kguamas o k?");
+        while (j == 0)
+        {
+        if (Next == 0)
+        {
+            j = 1;
+            n =3;
+        }
+        }
+    }
+    lcd.cls();
+        wait(1);
+    while (n == 3)
+    {
+        j = 0;
+        int *Index ;
+        Index = teclado();
+        printLCD(Index[0],Index[1]);
+        
+    }
+        
+    
+    }
+}
+
+void printLCD(int a, int b)
+{
+    lcd.printf("%c",Simbolos[a][b]);
+    wait(.3);
+}
+
+int * teclado() 
+{
+    static int r[2];
+    turnOffteclado();
+    int numero;
+  while(1) 
+  {    
+    if (Next == 0)
+        {
+            lcd.cls();
+            n = 0;
+            wait_ms(30);
+            break;   
+        }
+        
+    col1 = 1;
+    numero = usrInput();
+    if (numero != 0)
+    {
+    r[0]=numero-1;
+    r[1]=0;
+    //wait_ms(30);
+    return r;
+    }
+    turnOffteclado();
+    col2 = 1;
+    numero = usrInput();
+    if (numero != 0)
+    {
+    r[0]=numero-1;
+    r[1]=1;
+    //wait_ms(30);
+    return r;
+    }
+    turnOffteclado();
+    col3 = 1;
+    numero = usrInput();
+    if (numero != 0)
+    {
+     r[0]=numero-1;
+     r[1]=2;
+     //wait_ms(30);
+     return r;
+    }
+    turnOffteclado();
+    col4 = 1;
+    numero = usrInput();
+    if (numero != 0)
+    {
+     r[0]=numero-1;
+     r[1]=3;
+     //wait_ms(30);
+     return r;
+    }
+    turnOffteclado();
+    
+  }
+}
+
+void turnOffteclado()
+{
+    col1 = col2 = col3 = col4 = 0;
+}
+ 
+int usrInput()
+{
+    if (fila1 == 1)
+    {
+        return 1;
+    }
+    else if (fila2 == 1)
+    {
+        return 2;
+    }
+    else if (fila3 == 1)
+    {
+        return 3;
+    }
+    else if (fila4 == 1)
+    {
+        return 4;
+    }  
+    else{
+    return 0;  
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Oct 05 21:47:44 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/2241e3a39974
\ No newline at end of file