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