AGH MTM PPO MBED

Dependencies:   LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI

Files at this revision

API Documentation at this revision

Comitter:
matis755
Date:
Sat May 09 08:31:59 2020 +0000
Parent:
0:f4a48c08fea7
Commit message:
Add second column on display

Changed in this revision

Keyboard_Ts.cpp Show annotated file Show diff for this revision Revisions of this file
Keyboard_Ts.h Show annotated file Show diff for this revision Revisions of this file
Keyboard_Ts_Lcd.cpp Show annotated file Show diff for this revision Revisions of this file
Keyboard_Ts_Lcd.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
diff -r f4a48c08fea7 -r 36b3fd4a01fd Keyboard_Ts.cpp
--- a/Keyboard_Ts.cpp	Thu May 07 15:13:01 2020 +0000
+++ b/Keyboard_Ts.cpp	Sat May 09 08:31:59 2020 +0000
@@ -9,16 +9,16 @@
     TS_StateTypeDef TS_State;
     GetState(&TS_State); 
     if ((TS_State.TouchDetected) && (TS_State.Y > 0 ) && (TS_State.Y < 80) && (TS_State.X > (80 * ucColIdx)) && (TS_State.X < (80 * (ucColIdx + 1)))) {
-        return BUTTON_1;
+        return BUTTON_0;
     }
     else if ((TS_State.TouchDetected) && (TS_State.Y > 80 ) && (TS_State.Y < 160) && (TS_State.X > (80 * ucColIdx)) && (TS_State.X < (80 * (ucColIdx + 1)))) {
-        return BUTTON_2;
+        return BUTTON_1;
     }
     else if ((TS_State.TouchDetected) && (TS_State.Y > 160 ) && (TS_State.Y < 240) && (TS_State.X > (80 * ucColIdx)) && (TS_State.X < (80 * (ucColIdx + 1)))) {
-        return BUTTON_3;
+        return BUTTON_2;
     } 
     else if ((TS_State.TouchDetected) && (TS_State.Y > 240 ) && (TS_State.Y < 320) && (TS_State.X > (80 * ucColIdx)) && (TS_State.X < (80 * (ucColIdx + 1)))) {
-        return BUTTON_4;
+        return BUTTON_3;
     } 
     else{
         return RELASED;
diff -r f4a48c08fea7 -r 36b3fd4a01fd Keyboard_Ts.h
--- a/Keyboard_Ts.h	Thu May 07 15:13:01 2020 +0000
+++ b/Keyboard_Ts.h	Sat May 09 08:31:59 2020 +0000
@@ -5,10 +5,10 @@
 
 enum KeyboardState{
     RELASED,
+    BUTTON_0,
     BUTTON_1,
     BUTTON_2,
-    BUTTON_3,
-    BUTTON_4
+    BUTTON_3
 };
 
 class KeyboardTs : private TS_DISCO_F429ZI {
diff -r f4a48c08fea7 -r 36b3fd4a01fd Keyboard_Ts_Lcd.cpp
--- a/Keyboard_Ts_Lcd.cpp	Thu May 07 15:13:01 2020 +0000
+++ b/Keyboard_Ts_Lcd.cpp	Sat May 09 08:31:59 2020 +0000
@@ -6,22 +6,24 @@
     pLed = new LedLcd(_ucColumn);
 };
 
-void KeyboardTsLcd::eRead(void) {
-    switch(pKeyboard -> eRead()) {
+enum KeyboardState KeyboardTsLcd::eRead(void) {
+    enum KeyboardState eButton = pKeyboard -> eRead();
+    switch(eButton) {
+        case BUTTON_0:
+            pLed -> On(0);
+            break;
         case BUTTON_1:
-            pLed -> On(0);
+            pLed -> On(1);
             break;
         case BUTTON_2:
-            pLed -> On(1);
+            pLed -> On(2);
             break;
         case BUTTON_3:
-            pLed -> On(2);
-            break;
-        case BUTTON_4:
             pLed -> On(3);
             break;
         default :
             pLed -> On(4);
             break;
-    }    
+    }  
+    return eButton;
 }
\ No newline at end of file
diff -r f4a48c08fea7 -r 36b3fd4a01fd Keyboard_Ts_Lcd.h
--- a/Keyboard_Ts_Lcd.h	Thu May 07 15:13:01 2020 +0000
+++ b/Keyboard_Ts_Lcd.h	Sat May 09 08:31:59 2020 +0000
@@ -1,5 +1,5 @@
-#ifndef KEYBOARDLCD
-#define KEYBOARDLCD
+#ifndef KEYBOARD_TS_LCD
+#define KEYBOARD_TS_LCD
 
 #include "Led_Lcd.h"
 #include "Keyboard_Ts.h"
@@ -7,7 +7,7 @@
 class KeyboardTsLcd {
     public:
         KeyboardTsLcd(unsigned char);
-        void eRead(void);
+        enum KeyboardState eRead(void);
     private:
         LedLcd *pLed;
         KeyboardTs *pKeyboard;
diff -r f4a48c08fea7 -r 36b3fd4a01fd main.cpp
--- a/main.cpp	Thu May 07 15:13:01 2020 +0000
+++ b/main.cpp	Sat May 09 08:31:59 2020 +0000
@@ -1,11 +1,27 @@
-#include "mbed.h"
 #include "Keyboard_Ts_Lcd.h"
 
 int main() {
-    KeyboardTsLcd Keyboard(1);
+    KeyboardTsLcd Keyboard(0);
+    LedLcd Led(2);
     
     while(1) {
-        Keyboard.eRead();
+        switch(Keyboard.eRead()) {
+            case BUTTON_0:
+                Led.On(3);
+                break;
+            case BUTTON_1:
+                Led.On(2);
+                break;
+            case BUTTON_2:
+                Led.On(1);
+                break;
+            case BUTTON_3:
+                Led.On(0);
+                break;
+            default :
+                Led.On(4);
+                break;
+        }   
         wait(0.1);
     }
 }
\ No newline at end of file