AGH UST mbed part 3

Dependencies:   LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI

Revision:
0:f4a48c08fea7
Child:
1:36b3fd4a01fd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Keyboard_Ts.cpp	Thu May 07 15:13:01 2020 +0000
@@ -0,0 +1,26 @@
+#include "Keyboard_Ts.h"
+
+KeyboardTs::KeyboardTs(unsigned char ucIdx) {
+    ucColIdx = ucIdx;
+    Init(240,320);
+}
+
+enum KeyboardState KeyboardTs::eRead(void) {
+    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;
+    }
+    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;
+    }
+    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;
+    } 
+    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;
+    } 
+    else{
+        return RELASED;
+    }   
+}
\ No newline at end of file