MBED cz1 GAWEDA
KeyboardTs.cpp@0:eaf97ac7b4c5, 2020-06-01 (annotated)
- Committer:
- kacpergaweda
- Date:
- Mon Jun 01 11:13:23 2020 +0000
- Revision:
- 0:eaf97ac7b4c5
MBED cz1 GAWEDA
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kacpergaweda | 0:eaf97ac7b4c5 | 1 | #include "TS_DISCO_F429ZI.h" |
kacpergaweda | 0:eaf97ac7b4c5 | 2 | #include "KeyboardTs.h" |
kacpergaweda | 0:eaf97ac7b4c5 | 3 | |
kacpergaweda | 0:eaf97ac7b4c5 | 4 | TS_DISCO_F429ZI ts; |
kacpergaweda | 0:eaf97ac7b4c5 | 5 | |
kacpergaweda | 0:eaf97ac7b4c5 | 6 | TS_StateTypeDef TS_State; |
kacpergaweda | 0:eaf97ac7b4c5 | 7 | |
kacpergaweda | 0:eaf97ac7b4c5 | 8 | KeyboardTs::KeyboardTs(uint8_t iColumnNumberConstructor){ |
kacpergaweda | 0:eaf97ac7b4c5 | 9 | iColumnNumber = iColumnNumberConstructor; |
kacpergaweda | 0:eaf97ac7b4c5 | 10 | } |
kacpergaweda | 0:eaf97ac7b4c5 | 11 | |
kacpergaweda | 0:eaf97ac7b4c5 | 12 | |
kacpergaweda | 0:eaf97ac7b4c5 | 13 | |
kacpergaweda | 0:eaf97ac7b4c5 | 14 | enum eKEYBOARD_KEY KeyboardTs::eRead(){ |
kacpergaweda | 0:eaf97ac7b4c5 | 15 | ts.GetState(&TS_State); |
kacpergaweda | 0:eaf97ac7b4c5 | 16 | if (TS_State.TouchDetected) |
kacpergaweda | 0:eaf97ac7b4c5 | 17 | { |
kacpergaweda | 0:eaf97ac7b4c5 | 18 | x = TS_State.X; |
kacpergaweda | 0:eaf97ac7b4c5 | 19 | y = TS_State.Y; |
kacpergaweda | 0:eaf97ac7b4c5 | 20 | if(x >= iColumnNumber*80 & x <= iColumnNumber*80+80 & y >= 0 & y <= 80) |
kacpergaweda | 0:eaf97ac7b4c5 | 21 | { |
kacpergaweda | 0:eaf97ac7b4c5 | 22 | return BUTTON_0; |
kacpergaweda | 0:eaf97ac7b4c5 | 23 | } |
kacpergaweda | 0:eaf97ac7b4c5 | 24 | else if (x >= iColumnNumber*80 & x <= iColumnNumber*80+80 & y >=80 & y <= 160) |
kacpergaweda | 0:eaf97ac7b4c5 | 25 | { |
kacpergaweda | 0:eaf97ac7b4c5 | 26 | return BUTTON_1; |
kacpergaweda | 0:eaf97ac7b4c5 | 27 | } |
kacpergaweda | 0:eaf97ac7b4c5 | 28 | else if (x >= iColumnNumber*80 & x <= iColumnNumber*80+80 & y >=160 & y <= 240) |
kacpergaweda | 0:eaf97ac7b4c5 | 29 | { |
kacpergaweda | 0:eaf97ac7b4c5 | 30 | return BUTTON_2; |
kacpergaweda | 0:eaf97ac7b4c5 | 31 | } |
kacpergaweda | 0:eaf97ac7b4c5 | 32 | else if (x >= iColumnNumber*80 & x <= iColumnNumber*80+80 & y >=240 & y <= 320) |
kacpergaweda | 0:eaf97ac7b4c5 | 33 | { |
kacpergaweda | 0:eaf97ac7b4c5 | 34 | return BUTTON_3; |
kacpergaweda | 0:eaf97ac7b4c5 | 35 | } |
kacpergaweda | 0:eaf97ac7b4c5 | 36 | else |
kacpergaweda | 0:eaf97ac7b4c5 | 37 | { |
kacpergaweda | 0:eaf97ac7b4c5 | 38 | return NOT_TOUCHED; |
kacpergaweda | 0:eaf97ac7b4c5 | 39 | } |
kacpergaweda | 0:eaf97ac7b4c5 | 40 | } |
kacpergaweda | 0:eaf97ac7b4c5 | 41 | else |
kacpergaweda | 0:eaf97ac7b4c5 | 42 | { |
kacpergaweda | 0:eaf97ac7b4c5 | 43 | return NOT_TOUCHED; |
kacpergaweda | 0:eaf97ac7b4c5 | 44 | } |
kacpergaweda | 0:eaf97ac7b4c5 | 45 | } |
kacpergaweda | 0:eaf97ac7b4c5 | 46 |