class library for a TS Keypad and retrieving multiple keys, then press enter and the values are stored and the keypad disappears.
F7_TSKeypad_MultiKey.cpp@0:b3fd90f94e58, 2017-06-07 (annotated)
- Committer:
- Armand
- Date:
- Wed Jun 07 08:45:35 2017 +0000
- Revision:
- 0:b3fd90f94e58
- Child:
- 1:483300d6debd
class library for a TS Keypad and retrieving multiple keys, then press enter and the values are stored and the keypad disappears.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Armand | 0:b3fd90f94e58 | 1 | #include "F7_TSKeypad_MultiKey.h" |
Armand | 0:b3fd90f94e58 | 2 | #include "mbed.h" |
Armand | 0:b3fd90f94e58 | 3 | |
Armand | 0:b3fd90f94e58 | 4 | F7_TSKeypad_MultiKey::F7_TSKeypad_MultiKey() |
Armand | 0:b3fd90f94e58 | 5 | { |
Armand | 0:b3fd90f94e58 | 6 | btnsize = 50; |
Armand | 0:b3fd90f94e58 | 7 | state = 0; |
Armand | 0:b3fd90f94e58 | 8 | |
Armand | 0:b3fd90f94e58 | 9 | status = ts.Init(lcd.GetXSize(), lcd.GetYSize()); |
Armand | 0:b3fd90f94e58 | 10 | if (status != TS_OK) |
Armand | 0:b3fd90f94e58 | 11 | { |
Armand | 0:b3fd90f94e58 | 12 | lcd.Clear(LCD_COLOR_RED); |
Armand | 0:b3fd90f94e58 | 13 | lcd.SetBackColor(LCD_COLOR_RED); |
Armand | 0:b3fd90f94e58 | 14 | lcd.SetTextColor(LCD_COLOR_WHITE); |
Armand | 0:b3fd90f94e58 | 15 | lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT FAIL", CENTER_MODE); |
Armand | 0:b3fd90f94e58 | 16 | while(1); |
Armand | 0:b3fd90f94e58 | 17 | } |
Armand | 0:b3fd90f94e58 | 18 | else |
Armand | 0:b3fd90f94e58 | 19 | { |
Armand | 0:b3fd90f94e58 | 20 | OK = 1; |
Armand | 0:b3fd90f94e58 | 21 | |
Armand | 0:b3fd90f94e58 | 22 | } |
Armand | 0:b3fd90f94e58 | 23 | |
Armand | 0:b3fd90f94e58 | 24 | ticker.attach(callback(this, &F7_TSKeypad_MultiKey::Detect_isr),0.01); |
Armand | 0:b3fd90f94e58 | 25 | } |
Armand | 0:b3fd90f94e58 | 26 | |
Armand | 0:b3fd90f94e58 | 27 | void F7_TSKeypad_MultiKey::Detect_isr() |
Armand | 0:b3fd90f94e58 | 28 | { |
Armand | 0:b3fd90f94e58 | 29 | |
Armand | 0:b3fd90f94e58 | 30 | if(OK) |
Armand | 0:b3fd90f94e58 | 31 | { |
Armand | 0:b3fd90f94e58 | 32 | ts.GetState(&TS_State); |
Armand | 0:b3fd90f94e58 | 33 | |
Armand | 0:b3fd90f94e58 | 34 | if (TS_State.touchDetected) |
Armand | 0:b3fd90f94e58 | 35 | { |
Armand | 0:b3fd90f94e58 | 36 | |
Armand | 0:b3fd90f94e58 | 37 | ///////////////////////check correct touch////////////////////////////////////////////////////////////// |
Armand | 0:b3fd90f94e58 | 38 | if(TS_State.touchX[0]>= keypadstartX[0][0] && TS_State.touchX[0]<= keypadendX[0][0] && TS_State.touchY[0]>= keypadstartY[0][0] && TS_State.touchY[0]<= keypadendY[0][0] && keypad == 1) |
Armand | 0:b3fd90f94e58 | 39 | { |
Armand | 0:b3fd90f94e58 | 40 | correcttouch = 1; |
Armand | 0:b3fd90f94e58 | 41 | button = 1; |
Armand | 0:b3fd90f94e58 | 42 | lcd.SetTextColor(LCD_COLOR_GRAY); |
Armand | 0:b3fd90f94e58 | 43 | lcd.FillRect(keypadstartX[0][0], keypadstartY[0][0], btnsize, btnsize); |
Armand | 0:b3fd90f94e58 | 44 | } |
Armand | 0:b3fd90f94e58 | 45 | else if(TS_State.touchX[0]>= keypadstartX[0][1] && TS_State.touchX[0]<= keypadendX[0][1] && TS_State.touchY[0]>= keypadstartY[0][1] && TS_State.touchY[0]<= keypadendY[0][1] && keypad == 1) |
Armand | 0:b3fd90f94e58 | 46 | { |
Armand | 0:b3fd90f94e58 | 47 | correcttouch = 1; |
Armand | 0:b3fd90f94e58 | 48 | button = 2; |
Armand | 0:b3fd90f94e58 | 49 | lcd.SetTextColor(LCD_COLOR_GRAY); |
Armand | 0:b3fd90f94e58 | 50 | lcd.FillRect(keypadstartX[0][1], keypadstartY[0][1], btnsize, btnsize); |
Armand | 0:b3fd90f94e58 | 51 | } |
Armand | 0:b3fd90f94e58 | 52 | else if(TS_State.touchX[0]>= keypadstartX[0][2] && TS_State.touchX[0]<= keypadendX[0][2] && TS_State.touchY[0]>= keypadstartY[0][2] && TS_State.touchY[0]<= keypadendY[0][2] && keypad == 1) |
Armand | 0:b3fd90f94e58 | 53 | { |
Armand | 0:b3fd90f94e58 | 54 | correcttouch = 1; |
Armand | 0:b3fd90f94e58 | 55 | button = 3; |
Armand | 0:b3fd90f94e58 | 56 | lcd.SetTextColor(LCD_COLOR_GRAY); |
Armand | 0:b3fd90f94e58 | 57 | lcd.FillRect(keypadstartX[0][2], keypadstartY[0][2], btnsize, btnsize); |
Armand | 0:b3fd90f94e58 | 58 | } |
Armand | 0:b3fd90f94e58 | 59 | else if(TS_State.touchX[0]>= keypadstartX[0][3] && TS_State.touchX[0]<= keypadendX[0][3] && TS_State.touchY[0]>= keypadstartY[0][3] && TS_State.touchY[0]<= keypadendY[0][3] && keypad == 1) |
Armand | 0:b3fd90f94e58 | 60 | { |
Armand | 0:b3fd90f94e58 | 61 | correcttouch = 1; |
Armand | 0:b3fd90f94e58 | 62 | button = 4; |
Armand | 0:b3fd90f94e58 | 63 | lcd.SetTextColor(LCD_COLOR_GRAY); |
Armand | 0:b3fd90f94e58 | 64 | lcd.FillRect(keypadstartX[0][3], keypadstartY[0][3], btnsize, btnsize); |
Armand | 0:b3fd90f94e58 | 65 | } |
Armand | 0:b3fd90f94e58 | 66 | else if(TS_State.touchX[0]>= keypadstartX[1][0] && TS_State.touchX[0]<= keypadendX[1][0] && TS_State.touchY[0]>= keypadstartY[1][0] && TS_State.touchY[0]<= keypadendY[1][0] && keypad == 1) |
Armand | 0:b3fd90f94e58 | 67 | { |
Armand | 0:b3fd90f94e58 | 68 | correcttouch = 1; |
Armand | 0:b3fd90f94e58 | 69 | button = 5; |
Armand | 0:b3fd90f94e58 | 70 | lcd.SetTextColor(LCD_COLOR_GRAY); |
Armand | 0:b3fd90f94e58 | 71 | lcd.FillRect(keypadstartX[1][0], keypadstartY[1][0], btnsize, btnsize); |
Armand | 0:b3fd90f94e58 | 72 | } |
Armand | 0:b3fd90f94e58 | 73 | else if(TS_State.touchX[0]>= keypadstartX[1][1] && TS_State.touchX[0]<= keypadendX[1][1] && TS_State.touchY[0]>= keypadstartY[1][1] && TS_State.touchY[0]<= keypadendY[1][1] && keypad == 1) |
Armand | 0:b3fd90f94e58 | 74 | { |
Armand | 0:b3fd90f94e58 | 75 | correcttouch = 1; |
Armand | 0:b3fd90f94e58 | 76 | button = 6; |
Armand | 0:b3fd90f94e58 | 77 | lcd.SetTextColor(LCD_COLOR_GRAY); |
Armand | 0:b3fd90f94e58 | 78 | lcd.FillRect(keypadstartX[1][1], keypadstartY[1][1], btnsize, btnsize); |
Armand | 0:b3fd90f94e58 | 79 | } |
Armand | 0:b3fd90f94e58 | 80 | else if(TS_State.touchX[0]>= keypadstartX[1][2] && TS_State.touchX[0]<= keypadendX[1][2] && TS_State.touchY[0]>= keypadstartY[1][2] && TS_State.touchY[0]<= keypadendY[1][2] && keypad == 1) |
Armand | 0:b3fd90f94e58 | 81 | { |
Armand | 0:b3fd90f94e58 | 82 | correcttouch = 1; |
Armand | 0:b3fd90f94e58 | 83 | button = 7; |
Armand | 0:b3fd90f94e58 | 84 | lcd.SetTextColor(LCD_COLOR_GRAY); |
Armand | 0:b3fd90f94e58 | 85 | lcd.FillRect(keypadstartX[1][2], keypadstartY[1][2], btnsize, btnsize); |
Armand | 0:b3fd90f94e58 | 86 | } |
Armand | 0:b3fd90f94e58 | 87 | else if(TS_State.touchX[0]>= keypadstartX[1][3] && TS_State.touchX[0]<= keypadendX[1][3] && TS_State.touchY[0]>= keypadstartY[1][3] && TS_State.touchY[0]<= keypadendY[1][3] && keypad == 1) |
Armand | 0:b3fd90f94e58 | 88 | { |
Armand | 0:b3fd90f94e58 | 89 | correcttouch = 1; |
Armand | 0:b3fd90f94e58 | 90 | button = 8; |
Armand | 0:b3fd90f94e58 | 91 | lcd.SetTextColor(LCD_COLOR_GRAY); |
Armand | 0:b3fd90f94e58 | 92 | lcd.FillRect(keypadstartX[1][3], keypadstartY[1][3], btnsize, btnsize); |
Armand | 0:b3fd90f94e58 | 93 | } |
Armand | 0:b3fd90f94e58 | 94 | else if(TS_State.touchX[0]>= keypadstartX[2][0] && TS_State.touchX[0]<= keypadendX[2][0] && TS_State.touchY[0]>= keypadstartY[2][0] && TS_State.touchY[0]<= keypadendY[2][0] && keypad == 1) |
Armand | 0:b3fd90f94e58 | 95 | { |
Armand | 0:b3fd90f94e58 | 96 | correcttouch = 1; |
Armand | 0:b3fd90f94e58 | 97 | button = 9; |
Armand | 0:b3fd90f94e58 | 98 | lcd.SetTextColor(LCD_COLOR_GRAY); |
Armand | 0:b3fd90f94e58 | 99 | lcd.FillRect(keypadstartX[2][0], keypadstartY[2][0], btnsize, btnsize); |
Armand | 0:b3fd90f94e58 | 100 | } |
Armand | 0:b3fd90f94e58 | 101 | else if(TS_State.touchX[0]>= keypadstartX[2][1] && TS_State.touchX[0]<= keypadendX[2][1] && TS_State.touchY[0]>= keypadstartY[2][1] && TS_State.touchY[0]<= keypadendY[2][1] && keypad == 1) |
Armand | 0:b3fd90f94e58 | 102 | { |
Armand | 0:b3fd90f94e58 | 103 | correcttouch = 1; |
Armand | 0:b3fd90f94e58 | 104 | button = 10; |
Armand | 0:b3fd90f94e58 | 105 | lcd.SetTextColor(LCD_COLOR_GRAY); |
Armand | 0:b3fd90f94e58 | 106 | lcd.FillRect(keypadstartX[2][1], keypadstartY[2][1], btnsize, btnsize); |
Armand | 0:b3fd90f94e58 | 107 | } |
Armand | 0:b3fd90f94e58 | 108 | else if(TS_State.touchX[0]>= keypadstartX[2][2] && TS_State.touchX[0]<= keypadendX[2][2] && TS_State.touchY[0]>= keypadstartY[2][2] && TS_State.touchY[0]<= keypadendY[2][2] && keypad == 1) |
Armand | 0:b3fd90f94e58 | 109 | { |
Armand | 0:b3fd90f94e58 | 110 | correcttouch = 1; |
Armand | 0:b3fd90f94e58 | 111 | button = 11; |
Armand | 0:b3fd90f94e58 | 112 | lcd.SetTextColor(LCD_COLOR_GRAY); |
Armand | 0:b3fd90f94e58 | 113 | lcd.FillRect(keypadstartX[2][2], keypadstartY[2][2], btnsize, btnsize); |
Armand | 0:b3fd90f94e58 | 114 | } |
Armand | 0:b3fd90f94e58 | 115 | else if(TS_State.touchX[0]>= keypadstartX[2][3] && TS_State.touchX[0]<= keypadendX[2][3] && TS_State.touchY[0]>= keypadstartY[2][3] && TS_State.touchY[0]<= keypadendY[2][3] && keypad == 1) |
Armand | 0:b3fd90f94e58 | 116 | { |
Armand | 0:b3fd90f94e58 | 117 | correcttouch = 1; |
Armand | 0:b3fd90f94e58 | 118 | button = 12; |
Armand | 0:b3fd90f94e58 | 119 | lcd.SetTextColor(LCD_COLOR_GRAY); |
Armand | 0:b3fd90f94e58 | 120 | lcd.FillRect(keypadstartX[2][3], keypadstartY[2][3], btnsize, btnsize); |
Armand | 0:b3fd90f94e58 | 121 | } |
Armand | 0:b3fd90f94e58 | 122 | else if(TS_State.touchX[0]>= keypadstartX[3][0] && TS_State.touchX[0]<= keypadendX[3][0] && TS_State.touchY[0]>= keypadstartY[3][0] && TS_State.touchY[0]<= keypadendY[3][0] && keypad == 1) |
Armand | 0:b3fd90f94e58 | 123 | { |
Armand | 0:b3fd90f94e58 | 124 | correcttouch = 1; |
Armand | 0:b3fd90f94e58 | 125 | button = 13; |
Armand | 0:b3fd90f94e58 | 126 | lcd.SetTextColor(LCD_COLOR_GRAY); |
Armand | 0:b3fd90f94e58 | 127 | lcd.FillRect(keypadstartX[3][0], keypadstartY[3][0], btnsize, btnsize); |
Armand | 0:b3fd90f94e58 | 128 | } |
Armand | 0:b3fd90f94e58 | 129 | else if(TS_State.touchX[0]>= keypadstartX[3][1] && TS_State.touchX[0]<= keypadendX[3][1] && TS_State.touchY[0]>= keypadstartY[3][1] && TS_State.touchY[0]<= keypadendY[3][1] && keypad == 1) |
Armand | 0:b3fd90f94e58 | 130 | { |
Armand | 0:b3fd90f94e58 | 131 | correcttouch = 1; |
Armand | 0:b3fd90f94e58 | 132 | button = 14; |
Armand | 0:b3fd90f94e58 | 133 | lcd.SetTextColor(LCD_COLOR_GRAY); |
Armand | 0:b3fd90f94e58 | 134 | lcd.FillRect(keypadstartX[3][1], keypadstartY[3][1], btnsize, btnsize); |
Armand | 0:b3fd90f94e58 | 135 | } |
Armand | 0:b3fd90f94e58 | 136 | else if(TS_State.touchX[0]>= keypadstartX[3][2] && TS_State.touchX[0]<= keypadendX[3][2] && TS_State.touchY[0]>= keypadstartY[3][2] && TS_State.touchY[0]<= keypadendY[3][2] && keypad == 1) |
Armand | 0:b3fd90f94e58 | 137 | { |
Armand | 0:b3fd90f94e58 | 138 | correcttouch = 1; |
Armand | 0:b3fd90f94e58 | 139 | button = 15; |
Armand | 0:b3fd90f94e58 | 140 | lcd.SetTextColor(LCD_COLOR_GRAY); |
Armand | 0:b3fd90f94e58 | 141 | lcd.FillRect(keypadstartX[3][2], keypadstartY[3][2], btnsize, btnsize); |
Armand | 0:b3fd90f94e58 | 142 | } |
Armand | 0:b3fd90f94e58 | 143 | else if(TS_State.touchX[0]>= keypadstartX[3][3] && TS_State.touchX[0]<= keypadendX[3][3] && TS_State.touchY[0]>= keypadstartY[3][3] && TS_State.touchY[0]<= keypadendY[3][3] && keypad == 1) |
Armand | 0:b3fd90f94e58 | 144 | { |
Armand | 0:b3fd90f94e58 | 145 | correcttouch = 1; |
Armand | 0:b3fd90f94e58 | 146 | button = 16; |
Armand | 0:b3fd90f94e58 | 147 | lcd.SetTextColor(LCD_COLOR_GRAY); |
Armand | 0:b3fd90f94e58 | 148 | lcd.FillRect(keypadstartX[3][3], keypadstartY[3][3], btnsize, btnsize); |
Armand | 0:b3fd90f94e58 | 149 | } |
Armand | 0:b3fd90f94e58 | 150 | else if(TS_State.touchX[0]>= keypadstartX[0][3] + 60 && TS_State.touchX[0]<= keypadendX[0][3] + 60 && TS_State.touchY[0]>= keypadstartY[0][3] && TS_State.touchY[0]<= keypadendY[0][3] && keypad == 1) |
Armand | 0:b3fd90f94e58 | 151 | { |
Armand | 0:b3fd90f94e58 | 152 | correcttouch = 1; |
Armand | 0:b3fd90f94e58 | 153 | button = 17; |
Armand | 0:b3fd90f94e58 | 154 | lcd.SetTextColor(LCD_COLOR_GRAY); |
Armand | 0:b3fd90f94e58 | 155 | lcd.FillRect(keypadstartX[0][3] + 60, keypadstartY[0][3], btnsize, btnsize); |
Armand | 0:b3fd90f94e58 | 156 | } |
Armand | 0:b3fd90f94e58 | 157 | else if(TS_State.touchX[0]>= keypadstartX[1][3] + 60 && TS_State.touchX[0]<= keypadendX[1][3] + 60 && TS_State.touchY[0]>= keypadstartY[1][3] && TS_State.touchY[0]<= keypadendY[1][3] + 120 && keypad == 1) |
Armand | 0:b3fd90f94e58 | 158 | { |
Armand | 0:b3fd90f94e58 | 159 | correcttouch = 1; |
Armand | 0:b3fd90f94e58 | 160 | button = 18; |
Armand | 0:b3fd90f94e58 | 161 | lcd.SetTextColor(LCD_COLOR_GRAY); |
Armand | 0:b3fd90f94e58 | 162 | lcd.FillRect(keypadstartX[1][3] + 60, keypadstartY[1][3], btnsize, 170); |
Armand | 0:b3fd90f94e58 | 163 | } |
Armand | 0:b3fd90f94e58 | 164 | else |
Armand | 0:b3fd90f94e58 | 165 | { |
Armand | 0:b3fd90f94e58 | 166 | correcttouch = 0; |
Armand | 0:b3fd90f94e58 | 167 | button = 0; |
Armand | 0:b3fd90f94e58 | 168 | } |
Armand | 0:b3fd90f94e58 | 169 | ////////////////////////////////////////////////////////////////////////////////////////////////////// |
Armand | 0:b3fd90f94e58 | 170 | } |
Armand | 0:b3fd90f94e58 | 171 | } |
Armand | 0:b3fd90f94e58 | 172 | } |
Armand | 0:b3fd90f94e58 | 173 | |
Armand | 0:b3fd90f94e58 | 174 | void F7_TSKeypad_MultiKey::getkeys(char str[], uint8_t startx, uint8_t starty,char char1, char char2, char char3, char char4, char char5, char char6, char char7, char char8, char char9, char char10, char char11, char char12, char char13, char char14, char char15, char char16) |
Armand | 0:b3fd90f94e58 | 175 | { |
Armand | 0:b3fd90f94e58 | 176 | uint8_t text2[40]; |
Armand | 0:b3fd90f94e58 | 177 | |
Armand | 0:b3fd90f94e58 | 178 | Bckclr = lcd.GetBackColor(); |
Armand | 0:b3fd90f94e58 | 179 | Txtclr = lcd.GetTextColor(); |
Armand | 0:b3fd90f94e58 | 180 | *FontSize = *lcd.GetFont(); |
Armand | 0:b3fd90f94e58 | 181 | |
Armand | 0:b3fd90f94e58 | 182 | lcd.ClearStringLine(0); |
Armand | 0:b3fd90f94e58 | 183 | DrawKeypad(startx, starty, char1, char2, char3, char4, char5, char6, char7, char8, char9, char10, char11, char12, char13, char14, char15, char16); |
Armand | 0:b3fd90f94e58 | 184 | |
Armand | 0:b3fd90f94e58 | 185 | while(Enter != 1) |
Armand | 0:b3fd90f94e58 | 186 | { |
Armand | 0:b3fd90f94e58 | 187 | wait(0.0001); |
Armand | 0:b3fd90f94e58 | 188 | |
Armand | 0:b3fd90f94e58 | 189 | switch(state) |
Armand | 0:b3fd90f94e58 | 190 | {////////check if pressed on screen/////// |
Armand | 0:b3fd90f94e58 | 191 | case 0: |
Armand | 0:b3fd90f94e58 | 192 | { |
Armand | 0:b3fd90f94e58 | 193 | if(TS_State.touchDetected) |
Armand | 0:b3fd90f94e58 | 194 | { |
Armand | 0:b3fd90f94e58 | 195 | frstprsx = TS_State.touchX[0]; |
Armand | 0:b3fd90f94e58 | 196 | frstprsy = TS_State.touchY[0]; |
Armand | 0:b3fd90f94e58 | 197 | state = 10; |
Armand | 0:b3fd90f94e58 | 198 | } |
Armand | 0:b3fd90f94e58 | 199 | //////////////////////////////////////// |
Armand | 0:b3fd90f94e58 | 200 | }break; |
Armand | 0:b3fd90f94e58 | 201 | ////////check if correctly pressed////////// |
Armand | 0:b3fd90f94e58 | 202 | case 10: |
Armand | 0:b3fd90f94e58 | 203 | { |
Armand | 0:b3fd90f94e58 | 204 | for(b = 0; b < 4; b++) |
Armand | 0:b3fd90f94e58 | 205 | { |
Armand | 0:b3fd90f94e58 | 206 | for(a = 0; a < 4; a++) |
Armand | 0:b3fd90f94e58 | 207 | { |
Armand | 0:b3fd90f94e58 | 208 | if(frstprsx >= keypadstartX[a][b] && frstprsx <= keypadendX[a][b] && frstprsy >= keypadstartY[a][b] && frstprsy <= keypadendY[a][b] || frstprsx >= keypadstartX[0][3] + 60 && frstprsx <= keypadendX[0][3] + 60 && frstprsy >= keypadstartY[0][3] && frstprsy <= keypadendY[0][3] || frstprsx >= keypadstartX[1][3] + 60 && frstprsx <= keypadendX[1][3] + 60 && frstprsy >= keypadstartY[1][3] && frstprsy <= keypadendY[1][3] + 120) |
Armand | 0:b3fd90f94e58 | 209 | { |
Armand | 0:b3fd90f94e58 | 210 | state = 15; |
Armand | 0:b3fd90f94e58 | 211 | correcttouch = 1; |
Armand | 0:b3fd90f94e58 | 212 | a = 3; |
Armand | 0:b3fd90f94e58 | 213 | b = 3; |
Armand | 0:b3fd90f94e58 | 214 | } |
Armand | 0:b3fd90f94e58 | 215 | else |
Armand | 0:b3fd90f94e58 | 216 | { |
Armand | 0:b3fd90f94e58 | 217 | state = 30; |
Armand | 0:b3fd90f94e58 | 218 | } |
Armand | 0:b3fd90f94e58 | 219 | } |
Armand | 0:b3fd90f94e58 | 220 | } |
Armand | 0:b3fd90f94e58 | 221 | |
Armand | 0:b3fd90f94e58 | 222 | }break; |
Armand | 0:b3fd90f94e58 | 223 | case 15: |
Armand | 0:b3fd90f94e58 | 224 | { |
Armand | 0:b3fd90f94e58 | 225 | if(correcttouch == 1) |
Armand | 0:b3fd90f94e58 | 226 | { |
Armand | 0:b3fd90f94e58 | 227 | if(TS_State.touchDetected == 0) |
Armand | 0:b3fd90f94e58 | 228 | { |
Armand | 0:b3fd90f94e58 | 229 | DrawKeypad(startx, starty, char1, char2, char3, char4, char5, char6, char7, char8, char9, char10, char11, char12, char13, char14, char15, char16); |
Armand | 0:b3fd90f94e58 | 230 | state = 20; |
Armand | 0:b3fd90f94e58 | 231 | } |
Armand | 0:b3fd90f94e58 | 232 | } |
Armand | 0:b3fd90f94e58 | 233 | else if(correcttouch == 0 && button == 0) |
Armand | 0:b3fd90f94e58 | 234 | { |
Armand | 0:b3fd90f94e58 | 235 | state = 30; |
Armand | 0:b3fd90f94e58 | 236 | } |
Armand | 0:b3fd90f94e58 | 237 | |
Armand | 0:b3fd90f94e58 | 238 | }break; |
Armand | 0:b3fd90f94e58 | 239 | ////////////button functions////////// |
Armand | 0:b3fd90f94e58 | 240 | case 20: |
Armand | 0:b3fd90f94e58 | 241 | { ////////button 1///////////// |
Armand | 0:b3fd90f94e58 | 242 | if(button == 1) |
Armand | 0:b3fd90f94e58 | 243 | { |
Armand | 0:b3fd90f94e58 | 244 | keypressed = char1; |
Armand | 0:b3fd90f94e58 | 245 | a = 0; |
Armand | 0:b3fd90f94e58 | 246 | b = 0; |
Armand | 0:b3fd90f94e58 | 247 | correcttouch = 0; |
Armand | 0:b3fd90f94e58 | 248 | state = 0; |
Armand | 0:b3fd90f94e58 | 249 | } |
Armand | 0:b3fd90f94e58 | 250 | else if(button == 2) |
Armand | 0:b3fd90f94e58 | 251 | { |
Armand | 0:b3fd90f94e58 | 252 | keypressed = char2; |
Armand | 0:b3fd90f94e58 | 253 | a = 0; |
Armand | 0:b3fd90f94e58 | 254 | b = 0; |
Armand | 0:b3fd90f94e58 | 255 | correcttouch = 0; |
Armand | 0:b3fd90f94e58 | 256 | state = 0; |
Armand | 0:b3fd90f94e58 | 257 | } |
Armand | 0:b3fd90f94e58 | 258 | else if(button == 3) |
Armand | 0:b3fd90f94e58 | 259 | { |
Armand | 0:b3fd90f94e58 | 260 | keypressed = char3; |
Armand | 0:b3fd90f94e58 | 261 | a = 0; |
Armand | 0:b3fd90f94e58 | 262 | b = 0; |
Armand | 0:b3fd90f94e58 | 263 | correcttouch = 0; |
Armand | 0:b3fd90f94e58 | 264 | state = 0; |
Armand | 0:b3fd90f94e58 | 265 | } |
Armand | 0:b3fd90f94e58 | 266 | else if(button == 4) |
Armand | 0:b3fd90f94e58 | 267 | { |
Armand | 0:b3fd90f94e58 | 268 | keypressed = char4; |
Armand | 0:b3fd90f94e58 | 269 | a = 0; |
Armand | 0:b3fd90f94e58 | 270 | b = 0; |
Armand | 0:b3fd90f94e58 | 271 | correcttouch = 0; |
Armand | 0:b3fd90f94e58 | 272 | state = 0; |
Armand | 0:b3fd90f94e58 | 273 | } |
Armand | 0:b3fd90f94e58 | 274 | else if(button == 5) |
Armand | 0:b3fd90f94e58 | 275 | { |
Armand | 0:b3fd90f94e58 | 276 | keypressed = char5; |
Armand | 0:b3fd90f94e58 | 277 | a = 0; |
Armand | 0:b3fd90f94e58 | 278 | b = 0; |
Armand | 0:b3fd90f94e58 | 279 | correcttouch = 0; |
Armand | 0:b3fd90f94e58 | 280 | state = 0; |
Armand | 0:b3fd90f94e58 | 281 | } |
Armand | 0:b3fd90f94e58 | 282 | else if(button == 6) |
Armand | 0:b3fd90f94e58 | 283 | { |
Armand | 0:b3fd90f94e58 | 284 | keypressed = char6; |
Armand | 0:b3fd90f94e58 | 285 | a = 0; |
Armand | 0:b3fd90f94e58 | 286 | b = 0; |
Armand | 0:b3fd90f94e58 | 287 | correcttouch = 0; |
Armand | 0:b3fd90f94e58 | 288 | state = 0; |
Armand | 0:b3fd90f94e58 | 289 | } |
Armand | 0:b3fd90f94e58 | 290 | else if(button == 7) |
Armand | 0:b3fd90f94e58 | 291 | { |
Armand | 0:b3fd90f94e58 | 292 | keypressed = char7; |
Armand | 0:b3fd90f94e58 | 293 | a = 0; |
Armand | 0:b3fd90f94e58 | 294 | b = 0; |
Armand | 0:b3fd90f94e58 | 295 | correcttouch = 0; |
Armand | 0:b3fd90f94e58 | 296 | state = 0; |
Armand | 0:b3fd90f94e58 | 297 | } |
Armand | 0:b3fd90f94e58 | 298 | else if(button == 8) |
Armand | 0:b3fd90f94e58 | 299 | { |
Armand | 0:b3fd90f94e58 | 300 | keypressed = char8; |
Armand | 0:b3fd90f94e58 | 301 | a = 0; |
Armand | 0:b3fd90f94e58 | 302 | b = 0; |
Armand | 0:b3fd90f94e58 | 303 | correcttouch = 0; |
Armand | 0:b3fd90f94e58 | 304 | state = 0; |
Armand | 0:b3fd90f94e58 | 305 | } |
Armand | 0:b3fd90f94e58 | 306 | else if(button == 9) |
Armand | 0:b3fd90f94e58 | 307 | { |
Armand | 0:b3fd90f94e58 | 308 | keypressed = char9; |
Armand | 0:b3fd90f94e58 | 309 | a = 0; |
Armand | 0:b3fd90f94e58 | 310 | b = 0; |
Armand | 0:b3fd90f94e58 | 311 | correcttouch = 0; |
Armand | 0:b3fd90f94e58 | 312 | state = 0; |
Armand | 0:b3fd90f94e58 | 313 | } |
Armand | 0:b3fd90f94e58 | 314 | else if(button == 10) |
Armand | 0:b3fd90f94e58 | 315 | { |
Armand | 0:b3fd90f94e58 | 316 | keypressed = char10; |
Armand | 0:b3fd90f94e58 | 317 | a = 0; |
Armand | 0:b3fd90f94e58 | 318 | b = 0; |
Armand | 0:b3fd90f94e58 | 319 | correcttouch = 0; |
Armand | 0:b3fd90f94e58 | 320 | state = 0; |
Armand | 0:b3fd90f94e58 | 321 | } |
Armand | 0:b3fd90f94e58 | 322 | else if(button == 11) |
Armand | 0:b3fd90f94e58 | 323 | { |
Armand | 0:b3fd90f94e58 | 324 | keypressed = char11; |
Armand | 0:b3fd90f94e58 | 325 | a = 0; |
Armand | 0:b3fd90f94e58 | 326 | b = 0; |
Armand | 0:b3fd90f94e58 | 327 | correcttouch = 0; |
Armand | 0:b3fd90f94e58 | 328 | state = 0; |
Armand | 0:b3fd90f94e58 | 329 | } |
Armand | 0:b3fd90f94e58 | 330 | else if(button == 12) |
Armand | 0:b3fd90f94e58 | 331 | { |
Armand | 0:b3fd90f94e58 | 332 | keypressed = char12; |
Armand | 0:b3fd90f94e58 | 333 | a = 0; |
Armand | 0:b3fd90f94e58 | 334 | b = 0; |
Armand | 0:b3fd90f94e58 | 335 | correcttouch = 0; |
Armand | 0:b3fd90f94e58 | 336 | state = 0; |
Armand | 0:b3fd90f94e58 | 337 | } |
Armand | 0:b3fd90f94e58 | 338 | else if(button == 13) |
Armand | 0:b3fd90f94e58 | 339 | { |
Armand | 0:b3fd90f94e58 | 340 | keypressed = char13; |
Armand | 0:b3fd90f94e58 | 341 | a = 0; |
Armand | 0:b3fd90f94e58 | 342 | b = 0; |
Armand | 0:b3fd90f94e58 | 343 | correcttouch = 0; |
Armand | 0:b3fd90f94e58 | 344 | state = 0; |
Armand | 0:b3fd90f94e58 | 345 | } |
Armand | 0:b3fd90f94e58 | 346 | else if(button == 14) |
Armand | 0:b3fd90f94e58 | 347 | { |
Armand | 0:b3fd90f94e58 | 348 | keypressed = char14; |
Armand | 0:b3fd90f94e58 | 349 | a = 0; |
Armand | 0:b3fd90f94e58 | 350 | b = 0; |
Armand | 0:b3fd90f94e58 | 351 | correcttouch = 0; |
Armand | 0:b3fd90f94e58 | 352 | state = 0; |
Armand | 0:b3fd90f94e58 | 353 | } |
Armand | 0:b3fd90f94e58 | 354 | else if(button == 15) |
Armand | 0:b3fd90f94e58 | 355 | { |
Armand | 0:b3fd90f94e58 | 356 | keypressed = char15; |
Armand | 0:b3fd90f94e58 | 357 | a = 0; |
Armand | 0:b3fd90f94e58 | 358 | b = 0; |
Armand | 0:b3fd90f94e58 | 359 | correcttouch = 0; |
Armand | 0:b3fd90f94e58 | 360 | state = 0; |
Armand | 0:b3fd90f94e58 | 361 | } |
Armand | 0:b3fd90f94e58 | 362 | else if(button == 16) |
Armand | 0:b3fd90f94e58 | 363 | { |
Armand | 0:b3fd90f94e58 | 364 | keypressed = char16; |
Armand | 0:b3fd90f94e58 | 365 | a = 0; |
Armand | 0:b3fd90f94e58 | 366 | b = 0; |
Armand | 0:b3fd90f94e58 | 367 | correcttouch = 0; |
Armand | 0:b3fd90f94e58 | 368 | state = 0; |
Armand | 0:b3fd90f94e58 | 369 | } |
Armand | 0:b3fd90f94e58 | 370 | else if(button == 17) |
Armand | 0:b3fd90f94e58 | 371 | { |
Armand | 0:b3fd90f94e58 | 372 | keypressed = ' '; |
Armand | 0:b3fd90f94e58 | 373 | |
Armand | 0:b3fd90f94e58 | 374 | if(m != 0 || textx != 0) |
Armand | 0:b3fd90f94e58 | 375 | { |
Armand | 0:b3fd90f94e58 | 376 | m -= 1; |
Armand | 0:b3fd90f94e58 | 377 | textx -= 12; |
Armand | 0:b3fd90f94e58 | 378 | } |
Armand | 0:b3fd90f94e58 | 379 | |
Armand | 0:b3fd90f94e58 | 380 | a = 0; |
Armand | 0:b3fd90f94e58 | 381 | b = 0; |
Armand | 0:b3fd90f94e58 | 382 | correcttouch = 0; |
Armand | 0:b3fd90f94e58 | 383 | state = 0; |
Armand | 0:b3fd90f94e58 | 384 | } |
Armand | 0:b3fd90f94e58 | 385 | else if(button == 18) |
Armand | 0:b3fd90f94e58 | 386 | { |
Armand | 0:b3fd90f94e58 | 387 | keypressed = '\0'; |
Armand | 0:b3fd90f94e58 | 388 | Enter = 1; |
Armand | 0:b3fd90f94e58 | 389 | a = 0; |
Armand | 0:b3fd90f94e58 | 390 | b = 0; |
Armand | 0:b3fd90f94e58 | 391 | correcttouch = 0; |
Armand | 0:b3fd90f94e58 | 392 | state = 0; |
Armand | 0:b3fd90f94e58 | 393 | } |
Armand | 0:b3fd90f94e58 | 394 | |
Armand | 0:b3fd90f94e58 | 395 | str[m] = keypressed; |
Armand | 0:b3fd90f94e58 | 396 | |
Armand | 0:b3fd90f94e58 | 397 | lcd.SetTextColor(Txtclr); |
Armand | 0:b3fd90f94e58 | 398 | lcd.SetBackColor(Bckclr); |
Armand | 0:b3fd90f94e58 | 399 | lcd.SetFont(&Font20); |
Armand | 0:b3fd90f94e58 | 400 | sprintf((char*)text2, "%c", str[m]); |
Armand | 0:b3fd90f94e58 | 401 | lcd.DisplayStringAt(0 + textx, LINE(0), (uint8_t *)&text2, LEFT_MODE); |
Armand | 0:b3fd90f94e58 | 402 | |
Armand | 0:b3fd90f94e58 | 403 | if(keypressed != ' ') |
Armand | 0:b3fd90f94e58 | 404 | { |
Armand | 0:b3fd90f94e58 | 405 | m++; |
Armand | 0:b3fd90f94e58 | 406 | textx += 12; |
Armand | 0:b3fd90f94e58 | 407 | } |
Armand | 0:b3fd90f94e58 | 408 | |
Armand | 0:b3fd90f94e58 | 409 | }break; |
Armand | 0:b3fd90f94e58 | 410 | case 30: |
Armand | 0:b3fd90f94e58 | 411 | { |
Armand | 0:b3fd90f94e58 | 412 | if(keypad == 1) |
Armand | 0:b3fd90f94e58 | 413 | { |
Armand | 0:b3fd90f94e58 | 414 | DrawKeypad(startx, starty, char1, char2, char3, char4, char5, char6, char7, char8, char9, char10, char11, char12, char13, char14, char15, char16); |
Armand | 0:b3fd90f94e58 | 415 | keypad = 0; |
Armand | 0:b3fd90f94e58 | 416 | } |
Armand | 0:b3fd90f94e58 | 417 | |
Armand | 0:b3fd90f94e58 | 418 | if(TS_State.touchDetected == 0) |
Armand | 0:b3fd90f94e58 | 419 | { |
Armand | 0:b3fd90f94e58 | 420 | DrawKeypad(startx, starty, char1, char2, char3, char4, char5, char6, char7, char8, char9, char10, char11, char12, char13, char14, char15, char16); |
Armand | 0:b3fd90f94e58 | 421 | TS_State.touchX[0]= 0; |
Armand | 0:b3fd90f94e58 | 422 | TS_State.touchY[0]= 0; |
Armand | 0:b3fd90f94e58 | 423 | a = 0; |
Armand | 0:b3fd90f94e58 | 424 | b = 0; |
Armand | 0:b3fd90f94e58 | 425 | correcttouch = 0; |
Armand | 0:b3fd90f94e58 | 426 | state = 0; |
Armand | 0:b3fd90f94e58 | 427 | } |
Armand | 0:b3fd90f94e58 | 428 | }break; |
Armand | 0:b3fd90f94e58 | 429 | } |
Armand | 0:b3fd90f94e58 | 430 | } |
Armand | 0:b3fd90f94e58 | 431 | |
Armand | 0:b3fd90f94e58 | 432 | keypad = 0; |
Armand | 0:b3fd90f94e58 | 433 | Enter = 0; |
Armand | 0:b3fd90f94e58 | 434 | m = 0; |
Armand | 0:b3fd90f94e58 | 435 | textx = 0; |
Armand | 0:b3fd90f94e58 | 436 | state = 0; |
Armand | 0:b3fd90f94e58 | 437 | lcd.ClearStringLine(0); |
Armand | 0:b3fd90f94e58 | 438 | lcd.SetTextColor(Bckclr); |
Armand | 0:b3fd90f94e58 | 439 | lcd.FillRect(keypadstartX[0][0],keypadstartY[0][0], 290, 230); |
Armand | 0:b3fd90f94e58 | 440 | lcd.SetTextColor(Txtclr); |
Armand | 0:b3fd90f94e58 | 441 | lcd.SetFont(FontSize); |
Armand | 0:b3fd90f94e58 | 442 | } |
Armand | 0:b3fd90f94e58 | 443 | |
Armand | 0:b3fd90f94e58 | 444 | void F7_TSKeypad_MultiKey::DrawKeypad(uint8_t startpointx, uint8_t startpointy,char char1, char char2, char char3, char char4, char char5, char char6, char char7, char char8, char char9, char char10, char char11, char char12, char char13, char char14, char char15, char char16) |
Armand | 0:b3fd90f94e58 | 445 | { |
Armand | 0:b3fd90f94e58 | 446 | int i, o, stepx = 0, stepy = 0, Drawpointx, Drawpointy; |
Armand | 0:b3fd90f94e58 | 447 | uint8_t text[30]; |
Armand | 0:b3fd90f94e58 | 448 | |
Armand | 0:b3fd90f94e58 | 449 | char keyval[4][4] = {{char1, char2, char3, char4}, |
Armand | 0:b3fd90f94e58 | 450 | {char5, char6, char7, char8}, |
Armand | 0:b3fd90f94e58 | 451 | {char9, char10, char11, char12}, |
Armand | 0:b3fd90f94e58 | 452 | {char13, char14, char15, char16} |
Armand | 0:b3fd90f94e58 | 453 | }; |
Armand | 0:b3fd90f94e58 | 454 | keypad = 1; |
Armand | 0:b3fd90f94e58 | 455 | |
Armand | 0:b3fd90f94e58 | 456 | for(o= 0; o< 4; o++) |
Armand | 0:b3fd90f94e58 | 457 | { |
Armand | 0:b3fd90f94e58 | 458 | for(i= 0; i < 4; i++) |
Armand | 0:b3fd90f94e58 | 459 | { |
Armand | 0:b3fd90f94e58 | 460 | lcd.SetTextColor(LCD_COLOR_WHITE); |
Armand | 0:b3fd90f94e58 | 461 | |
Armand | 0:b3fd90f94e58 | 462 | lcd.FillRect(Drawpointx = startpointx + stepx, Drawpointy = startpointy + stepy, btnsize, btnsize); |
Armand | 0:b3fd90f94e58 | 463 | keypadstartX[i][o] = Drawpointx; |
Armand | 0:b3fd90f94e58 | 464 | keypadstartY[i][o] = Drawpointy; |
Armand | 0:b3fd90f94e58 | 465 | keypadendX[i][o] = Drawpointx + 50; |
Armand | 0:b3fd90f94e58 | 466 | keypadendY[i][o] = Drawpointy + 50; |
Armand | 0:b3fd90f94e58 | 467 | stepy += 60; |
Armand | 0:b3fd90f94e58 | 468 | |
Armand | 0:b3fd90f94e58 | 469 | lcd.SetBackColor(LCD_COLOR_WHITE); |
Armand | 0:b3fd90f94e58 | 470 | lcd.SetTextColor(LCD_COLOR_BLACK); |
Armand | 0:b3fd90f94e58 | 471 | lcd.SetFont(&Font20); |
Armand | 0:b3fd90f94e58 | 472 | sprintf((char*)text, "%c", keyval[i][o]); |
Armand | 0:b3fd90f94e58 | 473 | lcd.DisplayStringAt(Drawpointx+ 20, Drawpointy+ 20, (uint8_t *)&text, LEFT_MODE); |
Armand | 0:b3fd90f94e58 | 474 | |
Armand | 0:b3fd90f94e58 | 475 | |
Armand | 0:b3fd90f94e58 | 476 | if(stepy > 180) |
Armand | 0:b3fd90f94e58 | 477 | { |
Armand | 0:b3fd90f94e58 | 478 | stepy = 0; |
Armand | 0:b3fd90f94e58 | 479 | } |
Armand | 0:b3fd90f94e58 | 480 | } |
Armand | 0:b3fd90f94e58 | 481 | |
Armand | 0:b3fd90f94e58 | 482 | stepx += 60; |
Armand | 0:b3fd90f94e58 | 483 | } |
Armand | 0:b3fd90f94e58 | 484 | |
Armand | 0:b3fd90f94e58 | 485 | lcd.SetTextColor(LCD_COLOR_WHITE); |
Armand | 0:b3fd90f94e58 | 486 | lcd.FillRect(keypadstartX[0][3] + 60, keypadstartY[0][3], btnsize, btnsize); |
Armand | 0:b3fd90f94e58 | 487 | lcd.FillRect(keypadstartX[1][3] + 60, keypadstartY[1][3], btnsize, 170); |
Armand | 0:b3fd90f94e58 | 488 | |
Armand | 0:b3fd90f94e58 | 489 | lcd.SetBackColor(LCD_COLOR_WHITE); |
Armand | 0:b3fd90f94e58 | 490 | lcd.SetTextColor(LCD_COLOR_BLACK); |
Armand | 0:b3fd90f94e58 | 491 | |
Armand | 0:b3fd90f94e58 | 492 | sprintf((char*)text, "<"); |
Armand | 0:b3fd90f94e58 | 493 | lcd.DisplayStringAt(keypadstartX[0][3] + 80, keypadstartY[0][3] + 20, (uint8_t *)&text, LEFT_MODE); |
Armand | 0:b3fd90f94e58 | 494 | sprintf((char*)text, "E"); |
Armand | 0:b3fd90f94e58 | 495 | lcd.DisplayStringAt(keypadstartX[1][3] + 80, keypadstartY[1][3] + 35, (uint8_t *)&text, LEFT_MODE); |
Armand | 0:b3fd90f94e58 | 496 | sprintf((char*)text, "N"); |
Armand | 0:b3fd90f94e58 | 497 | lcd.DisplayStringAt(keypadstartX[0][3] + 80, keypadstartY[1][3] + 55, (uint8_t *)&text, LEFT_MODE); |
Armand | 0:b3fd90f94e58 | 498 | sprintf((char*)text, "T"); |
Armand | 0:b3fd90f94e58 | 499 | lcd.DisplayStringAt(keypadstartX[0][3] + 80, keypadstartY[1][3] + 75, (uint8_t *)&text, LEFT_MODE); |
Armand | 0:b3fd90f94e58 | 500 | sprintf((char*)text, "E"); |
Armand | 0:b3fd90f94e58 | 501 | lcd.DisplayStringAt(keypadstartX[0][3] + 80, keypadstartY[1][3] + 95, (uint8_t *)&text, LEFT_MODE); |
Armand | 0:b3fd90f94e58 | 502 | sprintf((char*)text, "R"); |
Armand | 0:b3fd90f94e58 | 503 | lcd.DisplayStringAt(keypadstartX[0][3] + 80, keypadstartY[1][3] + 115, (uint8_t *)&text, LEFT_MODE); |
Armand | 0:b3fd90f94e58 | 504 | |
Armand | 0:b3fd90f94e58 | 505 | lcd.SetTextColor(Txtclr); |
Armand | 0:b3fd90f94e58 | 506 | lcd.SetBackColor(Bckclr); |
Armand | 0:b3fd90f94e58 | 507 | lcd.SetFont(FontSize); |
Armand | 0:b3fd90f94e58 | 508 | } |