AGH UST mbed part 3
Dependencies: LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI
Diff: Keyboard.cpp
- Revision:
- 2:db40a2b0b177
- Parent:
- 1:36b3fd4a01fd
- Child:
- 4:459a0389bb9f
diff -r 36b3fd4a01fd -r db40a2b0b177 Keyboard.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Keyboard.cpp Sat May 23 07:11:44 2020 +0000 @@ -0,0 +1,26 @@ +#include "Keyboard.h" + +Keyboard::Keyboard(unsigned char ucIdx) { + ucColIdx = ucIdx; + Init(240,320); +} + +enum KeyboardState Keyboard::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_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_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_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_3; + } + else{ + return RELASED; + } +} \ No newline at end of file