LDC_TECLADO_MATRICIAL

Dependencies:   TextLCD mbed

Files at this revision

API Documentation at this revision

Comitter:
grupo3
Date:
Sat Sep 16 21:55:16 2017 +0000
Commit message:
Grupo 3; LCD_TECLADO_MATRICIAL;

Changed in this revision

TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
keypad.cpp Show annotated file Show diff for this revision Revisions of this file
keypad.h 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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 5ea4be70fe49 TextLCD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Sat Sep 16 21:55:16 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/simon/code/TextLCD/#308d188a2d3a
diff -r 000000000000 -r 5ea4be70fe49 keypad.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keypad.cpp	Sat Sep 16 21:55:16 2017 +0000
@@ -0,0 +1,82 @@
+/*   Copyright (c) 2010 Dimiter Kentri
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+/*Simple example
+
+#include "mbed.h"
+#include "keypad.h"
+
+Serial pc(USBTX, USBRX);
+Keypad telepad(p13,p14,p15,p16,p17,p18,p19,p20);
+
+int main(void){
+  char key;
+  pc.printf("Enter codes\n\r");
+  while(1){
+    key = telepad.getKey();
+    if(key != KEY_RELEASED){
+    pc.printf("%c\n",key);
+    wait(0.6);
+     }
+    }
+}       */
+
+#include "mbed.h"
+#include "keypad.h"
+
+using namespace mbed;
+
+Keypad::Keypad(PinName col1, PinName col2, PinName col3, PinName col4, PinName row1,PinName row2, PinName row3, PinName row4): _col1(col1),
+    _col2(col2),_col3(col3),_col4(col4),_rows(row1,row2,row3,row4)
+{
+
+}
+
+int Keypad::getKeyIndex()
+{
+    for(int k=0; k<4; k++) {
+        _rows = 0;
+    }
+    for(int i=0; i<4; i++) {
+        _rows = 1 << i;
+        for(int j=0; j<4; j++) {
+            if (_col1)
+                return 1+(i*4);
+            else if (_col2)
+                return 2+(i*4);
+            else if (_col3)
+                return 3+(i*4);
+            else if (_col4)
+                return 4+(i*4);
+        }
+    }
+    return -1;
+}
+
+char Keypad::getKey()
+{
+    int k = getKeyIndex();
+    if(k != -1)
+        return  keys[k-1];
+    else
+        return 0;
+}
+
diff -r 000000000000 -r 5ea4be70fe49 keypad.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keypad.h	Sat Sep 16 21:55:16 2017 +0000
@@ -0,0 +1,53 @@
+/*   Copyright (c) 2010 Dimiter Kentri
+ 
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+ 
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+ 
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+ 
+#ifndef KEYPAD_H
+#define KEYPAD_H
+ 
+#include "DigitalIn.h"
+#include "BusOut.h"
+ 
+ 
+namespace mbed{
+ 
+const char NO_KEY = '\0';
+#define KEY_RELEASED NO_KEY
+          
+ 
+       
+const int keys[16] = {'1','2','3','A',
+                      '4','5','6','B',
+                      '7','8','9','C',
+                      '*','0','#','D'};
+                      
+class Keypad{    
+    public:
+        Keypad(PinName col1, PinName col2, PinName col3, PinName col4, PinName row1,PinName row2, PinName row3, PinName row4);
+        int getKeyIndex();
+        char getKey();
+ 
+    protected:
+        DigitalIn _col1,_col2,_col3,_col4;    
+        BusOut _rows;
+};
+ 
+}
+#endif
\ No newline at end of file
diff -r 000000000000 -r 5ea4be70fe49 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Sep 16 21:55:16 2017 +0000
@@ -0,0 +1,71 @@
+#include "mbed.h"
+#include "TextLCD.h"
+#include "keypad.h"
+Serial pc(USBTX,USBRX);
+TextLCD lcd(D10,D11,D12,D13,D14,D15);
+
+int filas[5]= {0,1,2,4,8};
+int lec;
+char boton[5][5];
+int main()
+{
+    BusOut sal(D2,D3,D4,D5);
+    BusIn entrada(D6,D7,D8,D9);
+
+    boton[1][1]='1';
+    boton[2][1]='4';
+    boton[3][1]='7';
+    boton[4][1]='*';
+    boton[1][2]='2';
+    boton[2][2]='5';
+    boton[3][2]='8';
+    boton[4][2]='0';
+    boton[1][3]='3';
+    boton[2][3]='6';
+    boton[3][3]='9';
+    boton[4][3]='!';
+    boton[1][4]='h';
+    boton[2][4]='e';
+    boton[3][4]='l';
+    boton[4][4]='p';
+
+    int count=0;
+    int count1=20;
+
+
+    while(1) {
+
+        for(int i=1; i<5; i++) {
+
+            sal=filas[i];
+            lec=entrada.read();
+            if(lec==4) {
+                lec=3;
+            }
+            if(lec==8) {
+                lec=4;
+            }
+            if(lec!=0) {
+                if(count<=15) {
+                    lcd.locate(count,0);
+                    lcd.printf("%c",boton[i][lec]);
+                    wait(0.2);
+                    count++;
+                }
+                if(count==15) {
+                    count1=0;
+                    lcd.locate(count1,1);
+                    
+                }
+                if(count1<=15) {
+                    lcd.printf("%c",boton[i][lec]);
+                    count1++;
+                    if(count1>15) {
+                        lcd.cls();
+                        count=0;
+                    }
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 5ea4be70fe49 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Sep 16 21:55:16 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/e2bfab296f20
\ No newline at end of file