aaaa
Dependencies: SeeedStudioTFTv2 TFT_fonts mbed
Fork of Seeed_TFT_Touch_Shield by
main.cpp@8:b579a63f8b07, 2014-10-25 (annotated)
- Committer:
- bhavk11
- Date:
- Sat Oct 25 21:46:04 2014 +0000
- Revision:
- 8:b579a63f8b07
- Parent:
- 6:2a920ec91d2b
abc
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lawliet | 1:b2794eb7c940 | 1 | /* |
lawliet | 1:b2794eb7c940 | 2 | main.cpp |
lawliet | 1:b2794eb7c940 | 3 | 2014 Copyright (c) Seeed Technology Inc. All right reserved. |
lawliet | 1:b2794eb7c940 | 4 | |
lawliet | 1:b2794eb7c940 | 5 | Author:lawliet zou(lawliet.zou@gmail.com) |
lawliet | 1:b2794eb7c940 | 6 | 2014-02-17 |
lawliet | 1:b2794eb7c940 | 7 | |
lawliet | 1:b2794eb7c940 | 8 | This library is free software; you can redistribute it and/or |
lawliet | 1:b2794eb7c940 | 9 | modify it under the terms of the GNU Lesser General Public |
lawliet | 1:b2794eb7c940 | 10 | License as published by the Free Software Foundation; either |
lawliet | 1:b2794eb7c940 | 11 | version 2.1 of the License, or (at your option) any later version. |
lawliet | 1:b2794eb7c940 | 12 | |
lawliet | 1:b2794eb7c940 | 13 | This library is distributed in the hope that it will be useful, |
lawliet | 1:b2794eb7c940 | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
lawliet | 1:b2794eb7c940 | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
lawliet | 1:b2794eb7c940 | 16 | Lesser General Public License for more details. |
lawliet | 1:b2794eb7c940 | 17 | |
lawliet | 1:b2794eb7c940 | 18 | You should have received a copy of the GNU Lesser General Public |
lawliet | 1:b2794eb7c940 | 19 | License along with this library; if not, write to the Free Software |
lawliet | 1:b2794eb7c940 | 20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
lawliet | 1:b2794eb7c940 | 21 | */ |
lawliet | 1:b2794eb7c940 | 22 | |
neilt6 | 0:407dafce805d | 23 | #include "mbed.h" |
neilt6 | 0:407dafce805d | 24 | #include "SeeedStudioTFTv2.h" |
neilt6 | 0:407dafce805d | 25 | #include "Arial12x12.h" |
neilt6 | 0:407dafce805d | 26 | #include "Arial24x23.h" |
neilt6 | 0:407dafce805d | 27 | #include "Arial28x28.h" |
neilt6 | 0:407dafce805d | 28 | #include "font_big.h" |
neilt6 | 0:407dafce805d | 29 | |
screamer | 2:5c2f6ff36ff1 | 30 | #define PIN_XP A3 |
screamer | 2:5c2f6ff36ff1 | 31 | #define PIN_XM A1 |
screamer | 2:5c2f6ff36ff1 | 32 | #define PIN_YP A2 |
screamer | 2:5c2f6ff36ff1 | 33 | #define PIN_YM A0 |
screamer | 2:5c2f6ff36ff1 | 34 | #define PIN_MOSI D11 |
screamer | 2:5c2f6ff36ff1 | 35 | #define PIN_MISO D12 |
screamer | 2:5c2f6ff36ff1 | 36 | #define PIN_SCLK D13 |
screamer | 2:5c2f6ff36ff1 | 37 | #define PIN_CS_TFT D5 |
screamer | 2:5c2f6ff36ff1 | 38 | #define PIN_DC_TFT D6 |
screamer | 2:5c2f6ff36ff1 | 39 | #define PIN_BL_TFT D7 |
screamer | 2:5c2f6ff36ff1 | 40 | #define PIN_CS_SD D4 |
lawliet | 1:b2794eb7c940 | 41 | |
bhavk11 | 4:5b088ba4f1f1 | 42 | Timer t; |
bhavk11 | 4:5b088ba4f1f1 | 43 | Serial pc(USBTX,USBRX); |
screamer | 2:5c2f6ff36ff1 | 44 | SeeedStudioTFTv2 TFT(PIN_XP, PIN_XM, PIN_YP, PIN_YM, PIN_MOSI, PIN_MISO, PIN_SCLK, PIN_CS_TFT, PIN_DC_TFT, PIN_BL_TFT, PIN_CS_SD); |
uswickra | 5:c1af1f8fa026 | 45 | #define PHONE_NUMBER "+13174806512" |
uswickra | 5:c1af1f8fa026 | 46 | #include "Modem.h" |
uswickra | 5:c1af1f8fa026 | 47 | |
uswickra | 5:c1af1f8fa026 | 48 | Modem gsm (D10, D2, 19200, PHONE_NUMBER); |
uswickra | 5:c1af1f8fa026 | 49 | DigitalOut modem_power(D9); |
uswickra | 5:c1af1f8fa026 | 50 | char* cmd = NULL; |
uswickra | 5:c1af1f8fa026 | 51 | |
uswickra | 5:c1af1f8fa026 | 52 | void messageHandle(void) |
uswickra | 5:c1af1f8fa026 | 53 | { |
uswickra | 5:c1af1f8fa026 | 54 | __disable_irq(); |
uswickra | 5:c1af1f8fa026 | 55 | int messageType = gsm.loopHandle(); |
uswickra | 5:c1af1f8fa026 | 56 | if(MESSAGE_RING == messageType) { |
uswickra | 5:c1af1f8fa026 | 57 | // gsm.answer(); |
uswickra | 5:c1af1f8fa026 | 58 | cmd = "Ring"; |
uswickra | 5:c1af1f8fa026 | 59 | pc.printf("recieved call.. \r\n"); |
uswickra | 5:c1af1f8fa026 | 60 | } else if(MESSAGE_SMS == messageType) { |
uswickra | 5:c1af1f8fa026 | 61 | char smsMessage[SMS_MAX_LENGTH]; |
uswickra | 5:c1af1f8fa026 | 62 | // gsm.getSMS(smsMessage); |
uswickra | 5:c1af1f8fa026 | 63 | pc.printf("recieved sms.. \r\n"); |
uswickra | 5:c1af1f8fa026 | 64 | int i = 0 ; |
uswickra | 5:c1af1f8fa026 | 65 | for(i = 0 ; i < SMS_MAX_LENGTH ; i++){ |
uswickra | 5:c1af1f8fa026 | 66 | pc.putc(smsMessage[i]); |
uswickra | 5:c1af1f8fa026 | 67 | } |
uswickra | 5:c1af1f8fa026 | 68 | } |
uswickra | 5:c1af1f8fa026 | 69 | __enable_irq(); |
uswickra | 5:c1af1f8fa026 | 70 | } |
uswickra | 5:c1af1f8fa026 | 71 | |
neilt6 | 0:407dafce805d | 72 | |
bhavk11 | 4:5b088ba4f1f1 | 73 | void printKey(int x, int y, char* digit, char* alphas) |
bhavk11 | 4:5b088ba4f1f1 | 74 | { |
bhavk11 | 4:5b088ba4f1f1 | 75 | TFT.foreground(Blue); |
bhavk11 | 4:5b088ba4f1f1 | 76 | TFT.set_font((unsigned char*) Arial24x23); |
bhavk11 | 4:5b088ba4f1f1 | 77 | TFT.locate(x,y); |
bhavk11 | 4:5b088ba4f1f1 | 78 | TFT.printf(digit); |
bhavk11 | 4:5b088ba4f1f1 | 79 | TFT.foreground(Black); |
bhavk11 | 4:5b088ba4f1f1 | 80 | TFT.set_font((unsigned char*) Arial12x12); |
bhavk11 | 4:5b088ba4f1f1 | 81 | TFT.locate(x+15,y+10); |
bhavk11 | 4:5b088ba4f1f1 | 82 | TFT.printf(alphas); |
bhavk11 | 4:5b088ba4f1f1 | 83 | } |
bhavk11 | 4:5b088ba4f1f1 | 84 | |
bhavk11 | 4:5b088ba4f1f1 | 85 | void initKeypad() |
bhavk11 | 4:5b088ba4f1f1 | 86 | { |
bhavk11 | 4:5b088ba4f1f1 | 87 | TFT.background(White); |
bhavk11 | 4:5b088ba4f1f1 | 88 | TFT.cls(); |
bhavk11 | 4:5b088ba4f1f1 | 89 | TFT.foreground(Black); |
bhavk11 | 4:5b088ba4f1f1 | 90 | TFT.set_font((unsigned char*) Arial12x12); |
bhavk11 | 4:5b088ba4f1f1 | 91 | TFT.locate(210,84); |
bhavk11 | 4:5b088ba4f1f1 | 92 | TFT.printf("Del"); |
bhavk11 | 4:5b088ba4f1f1 | 93 | TFT.line(0,100,240,100,Black); |
bhavk11 | 4:5b088ba4f1f1 | 94 | TFT.rect(205,80,235,95,Black); |
bhavk11 | 4:5b088ba4f1f1 | 95 | TFT.line(205,80,195,95,White); |
bhavk11 | 4:5b088ba4f1f1 | 96 | TFT.line(192,87,205,80,Black); |
bhavk11 | 4:5b088ba4f1f1 | 97 | TFT.line(192,87,205,95,Black); |
bhavk11 | 4:5b088ba4f1f1 | 98 | printKey(20,120,"1"," "); |
bhavk11 | 4:5b088ba4f1f1 | 99 | printKey(95,120,"2","ABC"); |
bhavk11 | 4:5b088ba4f1f1 | 100 | printKey(170,120,"3","DEF"); |
bhavk11 | 4:5b088ba4f1f1 | 101 | printKey(20,160,"4","GHI"); |
bhavk11 | 4:5b088ba4f1f1 | 102 | printKey(95,160,"5","JKL"); |
bhavk11 | 4:5b088ba4f1f1 | 103 | printKey(170,160,"6","MNO"); |
bhavk11 | 4:5b088ba4f1f1 | 104 | printKey(20,200,"7","PQRS"); |
bhavk11 | 4:5b088ba4f1f1 | 105 | printKey(95,200,"8","TUV"); |
bhavk11 | 4:5b088ba4f1f1 | 106 | printKey(170,200,"9","WXYZ"); |
bhavk11 | 4:5b088ba4f1f1 | 107 | printKey(20,240,"*",""); |
bhavk11 | 4:5b088ba4f1f1 | 108 | printKey(95,240,"0","+"); |
bhavk11 | 4:5b088ba4f1f1 | 109 | printKey(170,240,"#",""); |
bhavk11 | 4:5b088ba4f1f1 | 110 | printKey(20,280,"<--",""); |
bhavk11 | 4:5b088ba4f1f1 | 111 | } |
bhavk11 | 4:5b088ba4f1f1 | 112 | |
bhavk11 | 4:5b088ba4f1f1 | 113 | int getKey() |
bhavk11 | 4:5b088ba4f1f1 | 114 | { |
bhavk11 | 4:5b088ba4f1f1 | 115 | int key = -1; |
bhavk11 | 4:5b088ba4f1f1 | 116 | point p; |
bhavk11 | 4:5b088ba4f1f1 | 117 | int count = 0; |
bhavk11 | 4:5b088ba4f1f1 | 118 | if(TFT.getTouch(p) == TFT.NO || TFT.getTouch(p) == TFT.MAYBE) |
bhavk11 | 4:5b088ba4f1f1 | 119 | { return key; |
bhavk11 | 4:5b088ba4f1f1 | 120 | } |
bhavk11 | 4:5b088ba4f1f1 | 121 | while(TFT.getTouch(p) == TFT.YES) |
bhavk11 | 4:5b088ba4f1f1 | 122 | { |
bhavk11 | 4:5b088ba4f1f1 | 123 | count++; |
bhavk11 | 4:5b088ba4f1f1 | 124 | } |
bhavk11 | 4:5b088ba4f1f1 | 125 | if(count > 300) |
bhavk11 | 4:5b088ba4f1f1 | 126 | { |
bhavk11 | 4:5b088ba4f1f1 | 127 | //TFT.foreground(Black); |
bhavk11 | 4:5b088ba4f1f1 | 128 | // TFT.set_font((unsigned char*) Arial12x12); |
bhavk11 | 4:5b088ba4f1f1 | 129 | // TFT.locate(0,0); |
bhavk11 | 4:5b088ba4f1f1 | 130 | // TFT.printf("X:%d, Y:%d\n\r",p.x,p.y); |
bhavk11 | 4:5b088ba4f1f1 | 131 | if (p.x>2700 && p.x<7250) |
bhavk11 | 4:5b088ba4f1f1 | 132 | { |
bhavk11 | 4:5b088ba4f1f1 | 133 | if(p.x<3750) |
bhavk11 | 4:5b088ba4f1f1 | 134 | { |
bhavk11 | 4:5b088ba4f1f1 | 135 | if(p.y<3000) |
bhavk11 | 4:5b088ba4f1f1 | 136 | key = 1; //1 |
bhavk11 | 4:5b088ba4f1f1 | 137 | else if(p.y<5250) |
bhavk11 | 4:5b088ba4f1f1 | 138 | key = 2; //2 |
bhavk11 | 4:5b088ba4f1f1 | 139 | else |
bhavk11 | 4:5b088ba4f1f1 | 140 | key = 3; //3 |
bhavk11 | 4:5b088ba4f1f1 | 141 | } |
bhavk11 | 4:5b088ba4f1f1 | 142 | else if(p.x<4600) |
bhavk11 | 4:5b088ba4f1f1 | 143 | { |
bhavk11 | 4:5b088ba4f1f1 | 144 | if(p.y<3000) |
bhavk11 | 4:5b088ba4f1f1 | 145 | key = 4; //4 |
bhavk11 | 4:5b088ba4f1f1 | 146 | else if(p.y<5250) |
bhavk11 | 4:5b088ba4f1f1 | 147 | key = 5; //5 |
bhavk11 | 4:5b088ba4f1f1 | 148 | else |
bhavk11 | 4:5b088ba4f1f1 | 149 | key = 6; //6 |
bhavk11 | 4:5b088ba4f1f1 | 150 | } |
bhavk11 | 4:5b088ba4f1f1 | 151 | else if(p.x<5400) |
bhavk11 | 4:5b088ba4f1f1 | 152 | { |
bhavk11 | 4:5b088ba4f1f1 | 153 | if(p.y<3000) |
bhavk11 | 4:5b088ba4f1f1 | 154 | key = 7; //7 |
bhavk11 | 4:5b088ba4f1f1 | 155 | else if(p.y<5250) |
bhavk11 | 4:5b088ba4f1f1 | 156 | key = 8; //8 |
bhavk11 | 4:5b088ba4f1f1 | 157 | else |
bhavk11 | 4:5b088ba4f1f1 | 158 | key = 9; //9 |
bhavk11 | 4:5b088ba4f1f1 | 159 | } |
bhavk11 | 4:5b088ba4f1f1 | 160 | else if(p.x<6300) |
bhavk11 | 4:5b088ba4f1f1 | 161 | { |
bhavk11 | 4:5b088ba4f1f1 | 162 | if(p.y<3000) |
bhavk11 | 4:5b088ba4f1f1 | 163 | key = 42; //* |
bhavk11 | 4:5b088ba4f1f1 | 164 | else if(p.y<5250) |
bhavk11 | 4:5b088ba4f1f1 | 165 | key = 0; //0 |
bhavk11 | 4:5b088ba4f1f1 | 166 | else |
bhavk11 | 4:5b088ba4f1f1 | 167 | key = 35; //# |
bhavk11 | 4:5b088ba4f1f1 | 168 | } |
bhavk11 | 4:5b088ba4f1f1 | 169 | else |
bhavk11 | 4:5b088ba4f1f1 | 170 | { |
bhavk11 | 4:5b088ba4f1f1 | 171 | if(p.y<3000) |
bhavk11 | 4:5b088ba4f1f1 | 172 | key = 60; // back |
bhavk11 | 4:5b088ba4f1f1 | 173 | else |
bhavk11 | 4:5b088ba4f1f1 | 174 | key = 43; // go (call/text) |
bhavk11 | 4:5b088ba4f1f1 | 175 | } |
bhavk11 | 4:5b088ba4f1f1 | 176 | } |
bhavk11 | 4:5b088ba4f1f1 | 177 | if(p.x > 2200 && p.x < 2500 && p.y > 6200 && p.y < 7000) |
bhavk11 | 4:5b088ba4f1f1 | 178 | key = 127; |
bhavk11 | 4:5b088ba4f1f1 | 179 | } |
bhavk11 | 4:5b088ba4f1f1 | 180 | return key; |
bhavk11 | 4:5b088ba4f1f1 | 181 | } |
bhavk11 | 4:5b088ba4f1f1 | 182 | |
uswickra | 5:c1af1f8fa026 | 183 | char ip0[] = {' ','0','+'}; |
uswickra | 5:c1af1f8fa026 | 184 | char ip2[] = {'a','b','c','2'}; |
uswickra | 5:c1af1f8fa026 | 185 | char ip3[] = {'d','e','f','3'}; |
uswickra | 5:c1af1f8fa026 | 186 | char ip4[] = {'g','h','i','4'}; |
uswickra | 5:c1af1f8fa026 | 187 | char ip5[] = {'j','k','l','5'}; |
uswickra | 5:c1af1f8fa026 | 188 | char ip6[] = {'m','o','p','6'}; |
uswickra | 5:c1af1f8fa026 | 189 | char ip7[] = {'p','q','r','s','7'}; |
uswickra | 5:c1af1f8fa026 | 190 | char ip8[] = {'t','u','v','8'}; |
uswickra | 5:c1af1f8fa026 | 191 | char ip9[] = {'w','x','y','z','9'}; |
bhavk11 | 4:5b088ba4f1f1 | 192 | |
bhavk11 | 4:5b088ba4f1f1 | 193 | |
bhavk11 | 4:5b088ba4f1f1 | 194 | bool displayChar(point& cursor, char letter) |
bhavk11 | 4:5b088ba4f1f1 | 195 | { |
bhavk11 | 4:5b088ba4f1f1 | 196 | TFT.locate(cursor.x,cursor.y); |
uswickra | 5:c1af1f8fa026 | 197 | if(cursor.x + 12 <= 228) |
uswickra | 5:c1af1f8fa026 | 198 | cursor.x += 12; |
bhavk11 | 4:5b088ba4f1f1 | 199 | else |
bhavk11 | 4:5b088ba4f1f1 | 200 | { |
bhavk11 | 4:5b088ba4f1f1 | 201 | cursor.x = 0; |
bhavk11 | 4:5b088ba4f1f1 | 202 | if(cursor.y + 21 <= 65 ) |
bhavk11 | 4:5b088ba4f1f1 | 203 | cursor.y += 21; |
bhavk11 | 4:5b088ba4f1f1 | 204 | else |
bhavk11 | 4:5b088ba4f1f1 | 205 | return false; |
bhavk11 | 4:5b088ba4f1f1 | 206 | } |
uswickra | 5:c1af1f8fa026 | 207 | TFT.set_font((unsigned char*) Arial12x12); |
bhavk11 | 4:5b088ba4f1f1 | 208 | TFT.printf("%c",letter); |
bhavk11 | 4:5b088ba4f1f1 | 209 | return true; |
bhavk11 | 4:5b088ba4f1f1 | 210 | } |
bhavk11 | 4:5b088ba4f1f1 | 211 | |
uswickra | 5:c1af1f8fa026 | 212 | int getAlpha(point& x, char** pt) |
uswickra | 5:c1af1f8fa026 | 213 | { |
uswickra | 5:c1af1f8fa026 | 214 | int touchCount = 1, count = 1; |
uswickra | 5:c1af1f8fa026 | 215 | int key, begin, end; |
uswickra | 5:c1af1f8fa026 | 216 | int prevKey; |
uswickra | 5:c1af1f8fa026 | 217 | do { |
uswickra | 5:c1af1f8fa026 | 218 | prevKey = key = getKey(); |
bhavk11 | 6:2a920ec91d2b | 219 | }while(prevKey == -1 && strcmp(cmd, "Text") == 0); |
uswickra | 5:c1af1f8fa026 | 220 | |
uswickra | 5:c1af1f8fa026 | 221 | point cursor = x; |
uswickra | 5:c1af1f8fa026 | 222 | char* ptr = *pt; |
uswickra | 5:c1af1f8fa026 | 223 | t.reset(); |
uswickra | 5:c1af1f8fa026 | 224 | t.start(); |
uswickra | 5:c1af1f8fa026 | 225 | begin = t.read_ms(); |
uswickra | 5:c1af1f8fa026 | 226 | end = t.read_ms(); |
uswickra | 5:c1af1f8fa026 | 227 | while((end - begin) < 2000) |
uswickra | 5:c1af1f8fa026 | 228 | { |
uswickra | 5:c1af1f8fa026 | 229 | cursor = x; |
uswickra | 5:c1af1f8fa026 | 230 | ptr = *pt; |
uswickra | 5:c1af1f8fa026 | 231 | touchCount = count; |
uswickra | 5:c1af1f8fa026 | 232 | START: |
uswickra | 5:c1af1f8fa026 | 233 | switch(key) |
uswickra | 5:c1af1f8fa026 | 234 | { |
uswickra | 5:c1af1f8fa026 | 235 | case 0: |
uswickra | 5:c1af1f8fa026 | 236 | touchCount = (touchCount-1)%(sizeof(ip0)/sizeof(ip0[0])); |
uswickra | 5:c1af1f8fa026 | 237 | if(displayChar(cursor, ip0[touchCount])) { |
uswickra | 5:c1af1f8fa026 | 238 | *ptr = ip0[touchCount]; |
uswickra | 5:c1af1f8fa026 | 239 | ptr++; |
uswickra | 5:c1af1f8fa026 | 240 | } |
uswickra | 5:c1af1f8fa026 | 241 | break; |
uswickra | 5:c1af1f8fa026 | 242 | case 1: |
uswickra | 5:c1af1f8fa026 | 243 | if(displayChar(cursor, '1')) { |
uswickra | 5:c1af1f8fa026 | 244 | *ptr = '1'; |
uswickra | 5:c1af1f8fa026 | 245 | ptr++; |
uswickra | 5:c1af1f8fa026 | 246 | } |
uswickra | 5:c1af1f8fa026 | 247 | break; |
uswickra | 5:c1af1f8fa026 | 248 | case 2: |
uswickra | 5:c1af1f8fa026 | 249 | touchCount = (touchCount-1)%(sizeof(ip2)/sizeof(ip2[0])); |
uswickra | 5:c1af1f8fa026 | 250 | if(displayChar(cursor, ip2[touchCount])) { |
uswickra | 5:c1af1f8fa026 | 251 | *ptr = ip2[touchCount]; |
uswickra | 5:c1af1f8fa026 | 252 | ptr++; |
uswickra | 5:c1af1f8fa026 | 253 | } |
uswickra | 5:c1af1f8fa026 | 254 | break; |
uswickra | 5:c1af1f8fa026 | 255 | case 3: |
uswickra | 5:c1af1f8fa026 | 256 | touchCount = (touchCount-1)%(sizeof(ip3)/sizeof(ip3[0])); |
uswickra | 5:c1af1f8fa026 | 257 | if(displayChar(cursor, ip3[touchCount])) { |
uswickra | 5:c1af1f8fa026 | 258 | *ptr = ip3[touchCount]; |
uswickra | 5:c1af1f8fa026 | 259 | ptr++; |
uswickra | 5:c1af1f8fa026 | 260 | } |
uswickra | 5:c1af1f8fa026 | 261 | break; |
uswickra | 5:c1af1f8fa026 | 262 | case 4: |
uswickra | 5:c1af1f8fa026 | 263 | touchCount = (touchCount-1)%(sizeof(ip4)/sizeof(ip4[0])); |
uswickra | 5:c1af1f8fa026 | 264 | if(displayChar(cursor, ip4[touchCount])) { |
uswickra | 5:c1af1f8fa026 | 265 | *ptr = ip4[touchCount]; |
uswickra | 5:c1af1f8fa026 | 266 | ptr++; |
uswickra | 5:c1af1f8fa026 | 267 | } |
uswickra | 5:c1af1f8fa026 | 268 | break; |
uswickra | 5:c1af1f8fa026 | 269 | case 5: |
uswickra | 5:c1af1f8fa026 | 270 | touchCount = (touchCount-1)%(sizeof(ip5)/sizeof(ip5[0])); |
uswickra | 5:c1af1f8fa026 | 271 | if(displayChar(cursor, ip5[touchCount])) { |
uswickra | 5:c1af1f8fa026 | 272 | *ptr = ip5[touchCount]; |
uswickra | 5:c1af1f8fa026 | 273 | ptr++; |
uswickra | 5:c1af1f8fa026 | 274 | } |
uswickra | 5:c1af1f8fa026 | 275 | break; |
uswickra | 5:c1af1f8fa026 | 276 | case 6: |
uswickra | 5:c1af1f8fa026 | 277 | touchCount = (touchCount-1)%(sizeof(ip6)/sizeof(ip6[0])); |
uswickra | 5:c1af1f8fa026 | 278 | if(displayChar(cursor, ip6[touchCount])) { |
uswickra | 5:c1af1f8fa026 | 279 | *ptr = ip6[touchCount]; |
uswickra | 5:c1af1f8fa026 | 280 | ptr++; |
uswickra | 5:c1af1f8fa026 | 281 | } |
uswickra | 5:c1af1f8fa026 | 282 | break; |
uswickra | 5:c1af1f8fa026 | 283 | case 7: |
uswickra | 5:c1af1f8fa026 | 284 | touchCount = (touchCount-1)%(sizeof(ip7)/sizeof(ip7[0])); |
uswickra | 5:c1af1f8fa026 | 285 | if(displayChar(cursor, ip7[touchCount])) { |
uswickra | 5:c1af1f8fa026 | 286 | *ptr = ip7[touchCount]; |
uswickra | 5:c1af1f8fa026 | 287 | ptr++; |
uswickra | 5:c1af1f8fa026 | 288 | } |
uswickra | 5:c1af1f8fa026 | 289 | break; |
uswickra | 5:c1af1f8fa026 | 290 | case 8: |
uswickra | 5:c1af1f8fa026 | 291 | touchCount = (touchCount-1)%(sizeof(ip8)/sizeof(ip8[0])); |
uswickra | 5:c1af1f8fa026 | 292 | if(displayChar(cursor, ip8[touchCount])) { |
uswickra | 5:c1af1f8fa026 | 293 | *ptr = ip8[touchCount]; |
uswickra | 5:c1af1f8fa026 | 294 | ptr++; |
uswickra | 5:c1af1f8fa026 | 295 | } |
uswickra | 5:c1af1f8fa026 | 296 | break; |
uswickra | 5:c1af1f8fa026 | 297 | case 9: |
uswickra | 5:c1af1f8fa026 | 298 | touchCount = (touchCount-1)%(sizeof(ip9)/sizeof(ip9[0])); |
uswickra | 5:c1af1f8fa026 | 299 | if(displayChar(cursor, ip9[touchCount])) { |
uswickra | 5:c1af1f8fa026 | 300 | *ptr = ip9[touchCount]; |
uswickra | 5:c1af1f8fa026 | 301 | ptr++; |
uswickra | 5:c1af1f8fa026 | 302 | } |
uswickra | 5:c1af1f8fa026 | 303 | break; |
uswickra | 5:c1af1f8fa026 | 304 | case 35: |
uswickra | 5:c1af1f8fa026 | 305 | if(displayChar(cursor, '#')) { |
uswickra | 5:c1af1f8fa026 | 306 | *ptr = '#'; |
uswickra | 5:c1af1f8fa026 | 307 | ptr++; |
uswickra | 5:c1af1f8fa026 | 308 | } |
uswickra | 5:c1af1f8fa026 | 309 | break; |
uswickra | 5:c1af1f8fa026 | 310 | case 42: |
uswickra | 5:c1af1f8fa026 | 311 | if(displayChar(cursor, '*')) { |
uswickra | 5:c1af1f8fa026 | 312 | *ptr = '*'; |
uswickra | 5:c1af1f8fa026 | 313 | ptr++; |
uswickra | 5:c1af1f8fa026 | 314 | } |
uswickra | 5:c1af1f8fa026 | 315 | break; |
uswickra | 5:c1af1f8fa026 | 316 | } |
uswickra | 5:c1af1f8fa026 | 317 | |
uswickra | 5:c1af1f8fa026 | 318 | key = getKey(); |
uswickra | 5:c1af1f8fa026 | 319 | end = t.read_ms(); |
uswickra | 5:c1af1f8fa026 | 320 | if(key == -1 && ((end - begin) < 2000)) goto START; |
uswickra | 5:c1af1f8fa026 | 321 | |
uswickra | 5:c1af1f8fa026 | 322 | if(!(prevKey == key)){ |
uswickra | 5:c1af1f8fa026 | 323 | break; |
uswickra | 5:c1af1f8fa026 | 324 | } |
uswickra | 5:c1af1f8fa026 | 325 | count++; |
uswickra | 5:c1af1f8fa026 | 326 | |
uswickra | 5:c1af1f8fa026 | 327 | pc.printf("ok curr count :%d key : %d prev_key : %d \r\n", touchCount,key, prevKey); |
uswickra | 5:c1af1f8fa026 | 328 | } |
uswickra | 5:c1af1f8fa026 | 329 | t.stop(); |
uswickra | 5:c1af1f8fa026 | 330 | pc.printf("ok count is :%d \r\n", touchCount); |
uswickra | 5:c1af1f8fa026 | 331 | |
uswickra | 5:c1af1f8fa026 | 332 | x = cursor; |
uswickra | 5:c1af1f8fa026 | 333 | *pt = ptr; |
uswickra | 5:c1af1f8fa026 | 334 | return prevKey; |
uswickra | 5:c1af1f8fa026 | 335 | } |
uswickra | 5:c1af1f8fa026 | 336 | |
uswickra | 5:c1af1f8fa026 | 337 | |
uswickra | 5:c1af1f8fa026 | 338 | void init_modem(){ |
uswickra | 5:c1af1f8fa026 | 339 | modem_power = 1 ; |
uswickra | 5:c1af1f8fa026 | 340 | wait(1); |
uswickra | 5:c1af1f8fa026 | 341 | // gsm.serial_modem.attach(&messageHandle); |
uswickra | 5:c1af1f8fa026 | 342 | while(gsm.init() != 1) { |
uswickra | 5:c1af1f8fa026 | 343 | // TFT.printf("waiting... \r\n"); |
uswickra | 5:c1af1f8fa026 | 344 | wait(1); |
uswickra | 5:c1af1f8fa026 | 345 | } |
uswickra | 5:c1af1f8fa026 | 346 | } |
uswickra | 5:c1af1f8fa026 | 347 | |
uswickra | 5:c1af1f8fa026 | 348 | |
neilt6 | 0:407dafce805d | 349 | int main() |
neilt6 | 0:407dafce805d | 350 | { |
bhavk11 | 4:5b088ba4f1f1 | 351 | point p; |
bhavk11 | 6:2a920ec91d2b | 352 | bool isMsg = false; |
bhavk11 | 6:2a920ec91d2b | 353 | char numbuffer[140]; |
bhavk11 | 6:2a920ec91d2b | 354 | char msgbuffer[140]; |
bhavk11 | 6:2a920ec91d2b | 355 | |
neilt6 | 0:407dafce805d | 356 | //Configure the display driver |
neilt6 | 0:407dafce805d | 357 | TFT.background(Black); |
neilt6 | 0:407dafce805d | 358 | TFT.foreground(White); |
neilt6 | 0:407dafce805d | 359 | TFT.cls(); |
uswickra | 5:c1af1f8fa026 | 360 | //initialize the modem - may take few seconds |
uswickra | 5:c1af1f8fa026 | 361 | init_modem(); |
uswickra | 5:c1af1f8fa026 | 362 | |
bhavk11 | 4:5b088ba4f1f1 | 363 | while(true) |
bhavk11 | 4:5b088ba4f1f1 | 364 | { |
bhavk11 | 4:5b088ba4f1f1 | 365 | //Print a welcome message |
bhavk11 | 4:5b088ba4f1f1 | 366 | TFT.background(White); |
bhavk11 | 4:5b088ba4f1f1 | 367 | TFT.set_font((unsigned char*) Neu42x35); |
bhavk11 | 4:5b088ba4f1f1 | 368 | TFT.foreground(Maroon); |
bhavk11 | 4:5b088ba4f1f1 | 369 | TFT.cls(); |
uswickra | 5:c1af1f8fa026 | 370 | |
bhavk11 | 4:5b088ba4f1f1 | 371 | TFT.locate(100,60); |
bhavk11 | 4:5b088ba4f1f1 | 372 | TFT.printf("IU"); |
bhavk11 | 4:5b088ba4f1f1 | 373 | |
bhavk11 | 4:5b088ba4f1f1 | 374 | TFT.set_font((unsigned char*) Arial24x23); |
bhavk11 | 4:5b088ba4f1f1 | 375 | TFT.locate(28,230); |
bhavk11 | 4:5b088ba4f1f1 | 376 | TFT.printf("CALL"); |
bhavk11 | 4:5b088ba4f1f1 | 377 | TFT.circle(60,240,50,Maroon); |
bhavk11 | 4:5b088ba4f1f1 | 378 | |
bhavk11 | 4:5b088ba4f1f1 | 379 | TFT.locate(140,230); |
bhavk11 | 4:5b088ba4f1f1 | 380 | TFT.printf("TEXT"); |
bhavk11 | 4:5b088ba4f1f1 | 381 | TFT.circle(180,240,50,Maroon); |
bhavk11 | 4:5b088ba4f1f1 | 382 | |
bhavk11 | 8:b579a63f8b07 | 383 | while((strcmp(cmd, "Back") == 0) || cmd == NULL) |
bhavk11 | 4:5b088ba4f1f1 | 384 | { |
bhavk11 | 4:5b088ba4f1f1 | 385 | if (TFT.getTouch(p) == TFT.YES) |
bhavk11 | 4:5b088ba4f1f1 | 386 | { |
bhavk11 | 4:5b088ba4f1f1 | 387 | if(p.x >= 4500 && p.x <= 6600) |
bhavk11 | 4:5b088ba4f1f1 | 388 | { |
bhavk11 | 4:5b088ba4f1f1 | 389 | if(p.y >= 1500 && p.y <= 3800) |
bhavk11 | 4:5b088ba4f1f1 | 390 | { |
bhavk11 | 4:5b088ba4f1f1 | 391 | //call |
bhavk11 | 4:5b088ba4f1f1 | 392 | cmd = "Call"; |
bhavk11 | 4:5b088ba4f1f1 | 393 | } |
bhavk11 | 4:5b088ba4f1f1 | 394 | else if(p.y >= 4500 && p.y <= 7100) |
bhavk11 | 4:5b088ba4f1f1 | 395 | { |
bhavk11 | 4:5b088ba4f1f1 | 396 | //text |
bhavk11 | 4:5b088ba4f1f1 | 397 | cmd = "Text"; |
bhavk11 | 4:5b088ba4f1f1 | 398 | } |
bhavk11 | 4:5b088ba4f1f1 | 399 | } |
bhavk11 | 8:b579a63f8b07 | 400 | } |
bhavk11 | 4:5b088ba4f1f1 | 401 | } |
bhavk11 | 4:5b088ba4f1f1 | 402 | |
bhavk11 | 4:5b088ba4f1f1 | 403 | if(strcmp(cmd, "Call") == 0) |
bhavk11 | 4:5b088ba4f1f1 | 404 | { |
bhavk11 | 4:5b088ba4f1f1 | 405 | initKeypad(); |
bhavk11 | 6:2a920ec91d2b | 406 | if(!isMsg) |
bhavk11 | 6:2a920ec91d2b | 407 | printKey(130,280,"CALL","" ); |
bhavk11 | 6:2a920ec91d2b | 408 | else |
bhavk11 | 6:2a920ec91d2b | 409 | printKey(130,280,"SEND","" ); |
bhavk11 | 4:5b088ba4f1f1 | 410 | point cursor; |
bhavk11 | 4:5b088ba4f1f1 | 411 | cursor.x = 0; |
bhavk11 | 4:5b088ba4f1f1 | 412 | cursor.y = 5; |
bhavk11 | 6:2a920ec91d2b | 413 | char *ptr = numbuffer; |
bhavk11 | 4:5b088ba4f1f1 | 414 | while(strcmp(cmd, "Call") == 0) |
bhavk11 | 4:5b088ba4f1f1 | 415 | { |
bhavk11 | 4:5b088ba4f1f1 | 416 | TFT.foreground(Black); |
bhavk11 | 4:5b088ba4f1f1 | 417 | int key = getKey(); |
bhavk11 | 4:5b088ba4f1f1 | 418 | switch(key) |
bhavk11 | 4:5b088ba4f1f1 | 419 | { |
bhavk11 | 4:5b088ba4f1f1 | 420 | case 0: |
bhavk11 | 4:5b088ba4f1f1 | 421 | if(displayChar(cursor, '0')) { |
bhavk11 | 4:5b088ba4f1f1 | 422 | *ptr = '0'; |
bhavk11 | 4:5b088ba4f1f1 | 423 | ptr++; |
bhavk11 | 4:5b088ba4f1f1 | 424 | } |
bhavk11 | 4:5b088ba4f1f1 | 425 | break; |
bhavk11 | 4:5b088ba4f1f1 | 426 | case 1: |
bhavk11 | 4:5b088ba4f1f1 | 427 | if(displayChar(cursor, '1')) { |
bhavk11 | 4:5b088ba4f1f1 | 428 | *ptr = '1'; |
bhavk11 | 4:5b088ba4f1f1 | 429 | ptr++; |
bhavk11 | 4:5b088ba4f1f1 | 430 | } |
bhavk11 | 4:5b088ba4f1f1 | 431 | break; |
bhavk11 | 4:5b088ba4f1f1 | 432 | case 2: |
bhavk11 | 4:5b088ba4f1f1 | 433 | if(displayChar(cursor, '2')) { |
bhavk11 | 4:5b088ba4f1f1 | 434 | *ptr = '2'; |
bhavk11 | 4:5b088ba4f1f1 | 435 | ptr++; |
bhavk11 | 4:5b088ba4f1f1 | 436 | } |
bhavk11 | 4:5b088ba4f1f1 | 437 | break; |
bhavk11 | 4:5b088ba4f1f1 | 438 | case 3: |
bhavk11 | 4:5b088ba4f1f1 | 439 | if(displayChar(cursor, '3')) { |
bhavk11 | 4:5b088ba4f1f1 | 440 | *ptr = '3'; |
bhavk11 | 4:5b088ba4f1f1 | 441 | ptr++; |
bhavk11 | 4:5b088ba4f1f1 | 442 | } |
bhavk11 | 4:5b088ba4f1f1 | 443 | break; |
bhavk11 | 4:5b088ba4f1f1 | 444 | case 4: |
bhavk11 | 4:5b088ba4f1f1 | 445 | if(displayChar(cursor, '4')) { |
bhavk11 | 4:5b088ba4f1f1 | 446 | *ptr = '4'; |
bhavk11 | 4:5b088ba4f1f1 | 447 | ptr++; |
bhavk11 | 4:5b088ba4f1f1 | 448 | } |
bhavk11 | 4:5b088ba4f1f1 | 449 | break; |
bhavk11 | 4:5b088ba4f1f1 | 450 | case 5: |
bhavk11 | 4:5b088ba4f1f1 | 451 | if(displayChar(cursor, '5')) { |
bhavk11 | 4:5b088ba4f1f1 | 452 | *ptr = '5'; |
bhavk11 | 4:5b088ba4f1f1 | 453 | ptr++; |
bhavk11 | 4:5b088ba4f1f1 | 454 | } |
bhavk11 | 4:5b088ba4f1f1 | 455 | break; |
bhavk11 | 4:5b088ba4f1f1 | 456 | case 6: |
bhavk11 | 4:5b088ba4f1f1 | 457 | if(displayChar(cursor, '6')) { |
bhavk11 | 4:5b088ba4f1f1 | 458 | *ptr = '6'; |
bhavk11 | 4:5b088ba4f1f1 | 459 | ptr++; |
bhavk11 | 4:5b088ba4f1f1 | 460 | } |
bhavk11 | 4:5b088ba4f1f1 | 461 | break; |
bhavk11 | 4:5b088ba4f1f1 | 462 | case 7: |
bhavk11 | 4:5b088ba4f1f1 | 463 | if(displayChar(cursor, '7')) { |
bhavk11 | 4:5b088ba4f1f1 | 464 | *ptr = '7'; |
bhavk11 | 4:5b088ba4f1f1 | 465 | ptr++; |
bhavk11 | 4:5b088ba4f1f1 | 466 | } |
bhavk11 | 4:5b088ba4f1f1 | 467 | break; |
bhavk11 | 4:5b088ba4f1f1 | 468 | case 8: |
bhavk11 | 4:5b088ba4f1f1 | 469 | if(displayChar(cursor, '8')) { |
bhavk11 | 4:5b088ba4f1f1 | 470 | *ptr = '8'; |
bhavk11 | 4:5b088ba4f1f1 | 471 | ptr++; |
bhavk11 | 4:5b088ba4f1f1 | 472 | } |
bhavk11 | 4:5b088ba4f1f1 | 473 | break; |
bhavk11 | 4:5b088ba4f1f1 | 474 | case 9: |
bhavk11 | 4:5b088ba4f1f1 | 475 | if(displayChar(cursor, '9')) { |
bhavk11 | 4:5b088ba4f1f1 | 476 | *ptr = '9'; |
bhavk11 | 4:5b088ba4f1f1 | 477 | ptr++; |
bhavk11 | 4:5b088ba4f1f1 | 478 | } |
bhavk11 | 4:5b088ba4f1f1 | 479 | break; |
bhavk11 | 4:5b088ba4f1f1 | 480 | case 35: |
bhavk11 | 4:5b088ba4f1f1 | 481 | if(displayChar(cursor, '#')) { |
bhavk11 | 4:5b088ba4f1f1 | 482 | *ptr = '#'; |
bhavk11 | 4:5b088ba4f1f1 | 483 | ptr++; |
bhavk11 | 4:5b088ba4f1f1 | 484 | } |
bhavk11 | 4:5b088ba4f1f1 | 485 | break; |
bhavk11 | 4:5b088ba4f1f1 | 486 | case 42: |
bhavk11 | 4:5b088ba4f1f1 | 487 | if(displayChar(cursor, '*')) { |
bhavk11 | 4:5b088ba4f1f1 | 488 | *ptr = '*'; |
bhavk11 | 4:5b088ba4f1f1 | 489 | ptr++; |
bhavk11 | 4:5b088ba4f1f1 | 490 | } |
bhavk11 | 4:5b088ba4f1f1 | 491 | break; |
bhavk11 | 4:5b088ba4f1f1 | 492 | case 43: |
bhavk11 | 6:2a920ec91d2b | 493 | if(isMsg) |
bhavk11 | 6:2a920ec91d2b | 494 | cmd = "Send"; |
bhavk11 | 6:2a920ec91d2b | 495 | else |
bhavk11 | 6:2a920ec91d2b | 496 | cmd = "Make"; |
bhavk11 | 6:2a920ec91d2b | 497 | isMsg = false; |
uswickra | 5:c1af1f8fa026 | 498 | *ptr= '\0'; |
bhavk11 | 4:5b088ba4f1f1 | 499 | break; |
bhavk11 | 4:5b088ba4f1f1 | 500 | case 60: |
bhavk11 | 4:5b088ba4f1f1 | 501 | cmd = "Back"; |
bhavk11 | 6:2a920ec91d2b | 502 | isMsg = false; |
bhavk11 | 4:5b088ba4f1f1 | 503 | break; |
bhavk11 | 4:5b088ba4f1f1 | 504 | case 127: |
bhavk11 | 6:2a920ec91d2b | 505 | if(ptr > numbuffer) |
bhavk11 | 4:5b088ba4f1f1 | 506 | { |
bhavk11 | 4:5b088ba4f1f1 | 507 | ptr--; |
uswickra | 5:c1af1f8fa026 | 508 | if(cursor.x - 12 >= 0) |
uswickra | 5:c1af1f8fa026 | 509 | cursor.x -= 12; |
bhavk11 | 4:5b088ba4f1f1 | 510 | else |
bhavk11 | 4:5b088ba4f1f1 | 511 | { |
uswickra | 5:c1af1f8fa026 | 512 | cursor.x = 240; |
bhavk11 | 4:5b088ba4f1f1 | 513 | if(cursor.y - 21 >= 5 ) |
bhavk11 | 4:5b088ba4f1f1 | 514 | cursor.y -= 21; |
bhavk11 | 4:5b088ba4f1f1 | 515 | } |
bhavk11 | 4:5b088ba4f1f1 | 516 | TFT.locate(cursor.x,cursor.y); |
bhavk11 | 4:5b088ba4f1f1 | 517 | TFT.printf(" "); |
bhavk11 | 4:5b088ba4f1f1 | 518 | } |
bhavk11 | 4:5b088ba4f1f1 | 519 | break; |
bhavk11 | 4:5b088ba4f1f1 | 520 | } |
bhavk11 | 4:5b088ba4f1f1 | 521 | } |
bhavk11 | 4:5b088ba4f1f1 | 522 | if(strcmp(cmd, "Make") == 0) |
bhavk11 | 4:5b088ba4f1f1 | 523 | { |
bhavk11 | 4:5b088ba4f1f1 | 524 | TFT.background(Black); |
bhavk11 | 4:5b088ba4f1f1 | 525 | TFT.foreground(White); |
bhavk11 | 4:5b088ba4f1f1 | 526 | TFT.cls(); |
bhavk11 | 4:5b088ba4f1f1 | 527 | int i=0; |
bhavk11 | 4:5b088ba4f1f1 | 528 | cursor.x = 0; |
bhavk11 | 4:5b088ba4f1f1 | 529 | cursor.y = 5; |
bhavk11 | 4:5b088ba4f1f1 | 530 | TFT.locate(0,0); |
uswickra | 5:c1af1f8fa026 | 531 | int ret = gsm.call_phone(buffer); |
bhavk11 | 6:2a920ec91d2b | 532 | while(&numbuffer[i] < ptr) |
bhavk11 | 6:2a920ec91d2b | 533 | displayChar(cursor, numbuffer[i++]); |
bhavk11 | 4:5b088ba4f1f1 | 534 | TFT.line(0,270,240,270,Red); |
bhavk11 | 4:5b088ba4f1f1 | 535 | TFT.foreground(Red); |
bhavk11 | 4:5b088ba4f1f1 | 536 | TFT.locate(60,280); |
bhavk11 | 4:5b088ba4f1f1 | 537 | TFT.printf("Hang Up"); |
bhavk11 | 4:5b088ba4f1f1 | 538 | while(strcmp(cmd, "Make") == 0) |
bhavk11 | 4:5b088ba4f1f1 | 539 | { |
uswickra | 5:c1af1f8fa026 | 540 | if(TFT.getTouch(p) == TFT.YES && p.x >= 6300 && p.x <= 7250){ |
uswickra | 5:c1af1f8fa026 | 541 | gsm.hangup_phone(); |
bhavk11 | 4:5b088ba4f1f1 | 542 | cmd = "Back"; |
uswickra | 5:c1af1f8fa026 | 543 | |
uswickra | 5:c1af1f8fa026 | 544 | } |
bhavk11 | 4:5b088ba4f1f1 | 545 | } |
bhavk11 | 4:5b088ba4f1f1 | 546 | } |
bhavk11 | 6:2a920ec91d2b | 547 | else if(strcmp(cmd,"Send") == 0) |
bhavk11 | 6:2a920ec91d2b | 548 | { |
bhavk11 | 6:2a920ec91d2b | 549 | // numbuffer has number |
bhavk11 | 6:2a920ec91d2b | 550 | // msgbuffer has msg |
bhavk11 | 6:2a920ec91d2b | 551 | TFT.background(Black); |
bhavk11 | 6:2a920ec91d2b | 552 | TFT.foreground(White); |
bhavk11 | 6:2a920ec91d2b | 553 | TFT.cls(); |
bhavk11 | 6:2a920ec91d2b | 554 | TFT.locate(90,60); |
bhavk11 | 6:2a920ec91d2b | 555 | TFT.printf("Text %s",msgbuffer); |
bhavk11 | 6:2a920ec91d2b | 556 | TFT.locate(90,95); |
bhavk11 | 6:2a920ec91d2b | 557 | TFT.printf("Sent to %s!",numbuffer); |
bhavk11 | 6:2a920ec91d2b | 558 | wait(2.5); |
bhavk11 | 6:2a920ec91d2b | 559 | cmd = "Back"; |
bhavk11 | 6:2a920ec91d2b | 560 | } |
bhavk11 | 4:5b088ba4f1f1 | 561 | if(strcmp(cmd, "Back") == 0) |
bhavk11 | 4:5b088ba4f1f1 | 562 | { |
bhavk11 | 4:5b088ba4f1f1 | 563 | //Home screen |
bhavk11 | 4:5b088ba4f1f1 | 564 | } |
bhavk11 | 4:5b088ba4f1f1 | 565 | } |
bhavk11 | 4:5b088ba4f1f1 | 566 | else if(strcmp(cmd, "Text") == 0) |
bhavk11 | 4:5b088ba4f1f1 | 567 | { |
bhavk11 | 4:5b088ba4f1f1 | 568 | initKeypad(); |
bhavk11 | 4:5b088ba4f1f1 | 569 | printKey(130,280,"SEND","" ); |
bhavk11 | 4:5b088ba4f1f1 | 570 | point cursor; |
bhavk11 | 4:5b088ba4f1f1 | 571 | cursor.x = 0; |
bhavk11 | 4:5b088ba4f1f1 | 572 | cursor.y = 5; |
bhavk11 | 6:2a920ec91d2b | 573 | char *ptr = msgbuffer; |
bhavk11 | 4:5b088ba4f1f1 | 574 | //TFT.line(80,100,80,320,Black); |
bhavk11 | 4:5b088ba4f1f1 | 575 | // TFT.line(160,100,160,320,Black); |
bhavk11 | 4:5b088ba4f1f1 | 576 | // TFT.line(0,100,240,100,Black); |
bhavk11 | 4:5b088ba4f1f1 | 577 | // TFT.line(0,150,240,150,Black); |
bhavk11 | 4:5b088ba4f1f1 | 578 | // TFT.line(0,190,240,190,Black); |
bhavk11 | 4:5b088ba4f1f1 | 579 | // TFT.line(0,230,240,230,Black); |
bhavk11 | 4:5b088ba4f1f1 | 580 | // TFT.line(0,270,240,270,Black); |
bhavk11 | 4:5b088ba4f1f1 | 581 | while(strcmp(cmd, "Text") == 0) |
bhavk11 | 4:5b088ba4f1f1 | 582 | { |
uswickra | 5:c1af1f8fa026 | 583 | int key = getAlpha(cursor, &ptr); |
uswickra | 5:c1af1f8fa026 | 584 | |
bhavk11 | 4:5b088ba4f1f1 | 585 | switch(key) |
bhavk11 | 4:5b088ba4f1f1 | 586 | { |
bhavk11 | 4:5b088ba4f1f1 | 587 | case 43: |
bhavk11 | 6:2a920ec91d2b | 588 | isMsg = true; |
bhavk11 | 6:2a920ec91d2b | 589 | cmd = "Call"; |
bhavk11 | 4:5b088ba4f1f1 | 590 | break; |
bhavk11 | 4:5b088ba4f1f1 | 591 | case 60: |
bhavk11 | 4:5b088ba4f1f1 | 592 | cmd = "Back"; |
bhavk11 | 4:5b088ba4f1f1 | 593 | break; |
bhavk11 | 4:5b088ba4f1f1 | 594 | case 127: |
bhavk11 | 6:2a920ec91d2b | 595 | if(ptr > msgbuffer) |
bhavk11 | 4:5b088ba4f1f1 | 596 | { |
bhavk11 | 4:5b088ba4f1f1 | 597 | ptr--; |
uswickra | 5:c1af1f8fa026 | 598 | if(cursor.x - 12 >= 0) |
uswickra | 5:c1af1f8fa026 | 599 | cursor.x -= 12; |
bhavk11 | 4:5b088ba4f1f1 | 600 | else |
bhavk11 | 4:5b088ba4f1f1 | 601 | { |
uswickra | 5:c1af1f8fa026 | 602 | cursor.x = 240; |
bhavk11 | 4:5b088ba4f1f1 | 603 | if(cursor.y - 21 >= 5 ) |
bhavk11 | 4:5b088ba4f1f1 | 604 | cursor.y -= 21; |
bhavk11 | 4:5b088ba4f1f1 | 605 | } |
bhavk11 | 4:5b088ba4f1f1 | 606 | TFT.locate(cursor.x,cursor.y); |
bhavk11 | 4:5b088ba4f1f1 | 607 | TFT.printf(" "); |
bhavk11 | 4:5b088ba4f1f1 | 608 | } |
bhavk11 | 4:5b088ba4f1f1 | 609 | break; |
bhavk11 | 4:5b088ba4f1f1 | 610 | } |
bhavk11 | 4:5b088ba4f1f1 | 611 | } |
bhavk11 | 6:2a920ec91d2b | 612 | } |
bhavk11 | 6:2a920ec91d2b | 613 | else if (strcmp(cmd, "Ring") == 0) |
uswickra | 5:c1af1f8fa026 | 614 | { |
uswickra | 5:c1af1f8fa026 | 615 | TFT.background(Black); |
uswickra | 5:c1af1f8fa026 | 616 | TFT.foreground(White); |
uswickra | 5:c1af1f8fa026 | 617 | TFT.cls(); |
uswickra | 5:c1af1f8fa026 | 618 | TFT.locate(0,0); |
uswickra | 5:c1af1f8fa026 | 619 | TFT.printf("Incoming Call..."); |
uswickra | 5:c1af1f8fa026 | 620 | TFT.foreground(Green); |
uswickra | 5:c1af1f8fa026 | 621 | TFT.set_font((unsigned char*) Arial24x23); |
uswickra | 5:c1af1f8fa026 | 622 | TFT.locate(28,230); |
uswickra | 5:c1af1f8fa026 | 623 | TFT.printf("ANS"); |
bhavk11 | 6:2a920ec91d2b | 624 | TFT.circle(60,240,50,Green); |
uswickra | 5:c1af1f8fa026 | 625 | |
uswickra | 5:c1af1f8fa026 | 626 | TFT.foreground(Red); |
bhavk11 | 6:2a920ec91d2b | 627 | TFT.locate(140,220); |
bhavk11 | 6:2a920ec91d2b | 628 | TFT.printf("HANG"); |
bhavk11 | 6:2a920ec91d2b | 629 | TFT.locate(160,240); |
bhavk11 | 6:2a920ec91d2b | 630 | TFT.printf("UP"); |
bhavk11 | 6:2a920ec91d2b | 631 | TFT.circle(180,240,50,Red); |
bhavk11 | 6:2a920ec91d2b | 632 | while(strcmp(cmd, "Ring") == 0) |
uswickra | 5:c1af1f8fa026 | 633 | { |
bhavk11 | 6:2a920ec91d2b | 634 | if (TFT.getTouch(p) == TFT.YES) |
bhavk11 | 6:2a920ec91d2b | 635 | { |
bhavk11 | 6:2a920ec91d2b | 636 | if(p.x >= 4500 && p.x <= 6600) |
bhavk11 | 6:2a920ec91d2b | 637 | { |
bhavk11 | 6:2a920ec91d2b | 638 | if(p.y >= 1500 && p.y <= 3800) |
bhavk11 | 6:2a920ec91d2b | 639 | { |
bhavk11 | 6:2a920ec91d2b | 640 | //answer cal |
bhavk11 | 6:2a920ec91d2b | 641 | cmd = "Answer"; |
bhavk11 | 6:2a920ec91d2b | 642 | break; |
bhavk11 | 6:2a920ec91d2b | 643 | } |
bhavk11 | 6:2a920ec91d2b | 644 | else if(p.y >= 4500 && p.y <= 7100) |
bhavk11 | 6:2a920ec91d2b | 645 | { |
bhavk11 | 6:2a920ec91d2b | 646 | //hang up |
bhavk11 | 6:2a920ec91d2b | 647 | cmd = "Back"; |
bhavk11 | 6:2a920ec91d2b | 648 | break; |
bhavk11 | 6:2a920ec91d2b | 649 | } |
bhavk11 | 6:2a920ec91d2b | 650 | |
bhavk11 | 6:2a920ec91d2b | 651 | } |
bhavk11 | 6:2a920ec91d2b | 652 | } |
bhavk11 | 6:2a920ec91d2b | 653 | } |
bhavk11 | 6:2a920ec91d2b | 654 | if(strcmp(cmd, "Answer") == 0) |
bhavk11 | 6:2a920ec91d2b | 655 | { |
bhavk11 | 6:2a920ec91d2b | 656 | TFT.background(Black); |
bhavk11 | 6:2a920ec91d2b | 657 | TFT.foreground(White); |
bhavk11 | 6:2a920ec91d2b | 658 | TFT.cls(); |
bhavk11 | 6:2a920ec91d2b | 659 | TFT.locate(0,0); |
bhavk11 | 6:2a920ec91d2b | 660 | TFT.printf("Call in Progress..."); |
bhavk11 | 6:2a920ec91d2b | 661 | TFT.line(0,270,240,270,Red); |
bhavk11 | 6:2a920ec91d2b | 662 | TFT.foreground(Red); |
bhavk11 | 6:2a920ec91d2b | 663 | TFT.locate(60,280); |
bhavk11 | 6:2a920ec91d2b | 664 | TFT.set_font((unsigned char*) Arial24x23); |
bhavk11 | 6:2a920ec91d2b | 665 | TFT.printf("Hang Up"); |
bhavk11 | 6:2a920ec91d2b | 666 | while(strcmp(cmd, "Answer") == 0) |
bhavk11 | 6:2a920ec91d2b | 667 | { |
bhavk11 | 6:2a920ec91d2b | 668 | if(TFT.getTouch(p) == TFT.YES && p.x >= 6300 && p.x <= 7250) |
bhavk11 | 6:2a920ec91d2b | 669 | cmd = "Back"; |
bhavk11 | 6:2a920ec91d2b | 670 | } |
uswickra | 5:c1af1f8fa026 | 671 | } |
bhavk11 | 4:5b088ba4f1f1 | 672 | } |
bhavk11 | 6:2a920ec91d2b | 673 | else if(strcmp(cmd, "RecvM") == 0) |
bhavk11 | 6:2a920ec91d2b | 674 | {} |
neilt6 | 0:407dafce805d | 675 | } |
neilt6 | 0:407dafce805d | 676 | } |