Mbed cz.1 cwiczenie ostatnie (2d2)
Dependencies: LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI
Diff: Keyboard_Ts.cpp
- Revision:
- 0:036c13c6cbb6
diff -r 000000000000 -r 036c13c6cbb6 Keyboard_Ts.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Keyboard_Ts.cpp Mon May 18 05:54:39 2020 +0000 @@ -0,0 +1,27 @@ +#include "Keyboard_Ts.h" + +KeyboardTs::KeyboardTs(unsigned char ucColumnIndex){ + ucLeftBoundary = ucColumnIndex*80; + ucRightBoundary = ucColumnIndex*80 + 80; +} + +enum KeyboardState KeyboardTs::eRead(){ + ts.GetState(&TS_State); + if (TS_State.TouchDetected & (TS_State.X >= ucLeftBoundary) & (TS_State.X < ucRightBoundary)){ + if(TS_State.Y <80){ + return BUTTON_0; + } + else if(TS_State.Y <160){ + return BUTTON_1; + } + else if(TS_State.Y <240){ + return BUTTON_2; + } + else{ + return BUTTON_3; + } + } + else{ + return RELASED; + } +}