![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
aaaa
Dependencies: SeeedStudioTFTv2 TFT_fonts mbed
Fork of Seeed_TFT_Touch_Shield by
Diff: main.cpp
- Revision:
- 6:2a920ec91d2b
- Parent:
- 5:c1af1f8fa026
- Child:
- 7:5cf5aeae1954
- Child:
- 8:b579a63f8b07
--- a/main.cpp Sat Oct 25 20:21:17 2014 +0000 +++ b/main.cpp Sat Oct 25 20:42:30 2014 +0000 @@ -216,7 +216,7 @@ int prevKey; do { prevKey = key = getKey(); - }while(prevKey == -1); + }while(prevKey == -1 && strcmp(cmd, "Text") == 0); point cursor = x; char* ptr = *pt; @@ -246,7 +246,6 @@ } break; case 2: - pc.printf("AAYA\r\n"); touchCount = (touchCount-1)%(sizeof(ip2)/sizeof(ip2[0])); if(displayChar(cursor, ip2[touchCount])) { *ptr = ip2[touchCount]; @@ -350,7 +349,10 @@ int main() { point p; - + bool isMsg = false; + char numbuffer[140]; + char msgbuffer[140]; + //Configure the display driver TFT.background(Black); TFT.foreground(White); @@ -378,7 +380,7 @@ TFT.printf("TEXT"); TFT.circle(180,240,50,Maroon); - while(true) + while(!(strcmp(cmd, "Call") == 0)) { if (TFT.getTouch(p) == TFT.YES) { @@ -407,12 +409,14 @@ if(strcmp(cmd, "Call") == 0) { initKeypad(); - printKey(130,280,"CALL","" ); + if(!isMsg) + printKey(130,280,"CALL","" ); + else + printKey(130,280,"SEND","" ); point cursor; cursor.x = 0; cursor.y = 5; - char buffer[140]; - char *ptr = buffer; + char *ptr = numbuffer; while(strcmp(cmd, "Call") == 0) { TFT.foreground(Black); @@ -492,14 +496,19 @@ } break; case 43: - cmd = "Make"; + if(isMsg) + cmd = "Send"; + else + cmd = "Make"; + isMsg = false; *ptr= '\0'; break; case 60: cmd = "Back"; + isMsg = false; break; case 127: - if(ptr > buffer) + if(ptr > numbuffer) { ptr--; if(cursor.x - 12 >= 0) @@ -526,8 +535,8 @@ cursor.y = 5; TFT.locate(0,0); int ret = gsm.call_phone(buffer); - while(&buffer[i] < ptr) - displayChar(cursor, buffer[i++]); + while(&numbuffer[i] < ptr) + displayChar(cursor, numbuffer[i++]); TFT.line(0,270,240,270,Red); TFT.foreground(Red); TFT.locate(60,280); @@ -541,6 +550,20 @@ } } } + else if(strcmp(cmd,"Send") == 0) + { + // numbuffer has number + // msgbuffer has msg + TFT.background(Black); + TFT.foreground(White); + TFT.cls(); + TFT.locate(90,60); + TFT.printf("Text %s",msgbuffer); + TFT.locate(90,95); + TFT.printf("Sent to %s!",numbuffer); + wait(2.5); + cmd = "Back"; + } if(strcmp(cmd, "Back") == 0) { //Home screen @@ -553,8 +576,7 @@ point cursor; cursor.x = 0; cursor.y = 5; - char buffer[140]; - char *ptr = buffer; + char *ptr = msgbuffer; //TFT.line(80,100,80,320,Black); // TFT.line(160,100,160,320,Black); // TFT.line(0,100,240,100,Black); @@ -569,13 +591,14 @@ switch(key) { case 43: - cmd = "Send"; + isMsg = true; + cmd = "Call"; break; case 60: cmd = "Back"; break; case 127: - if(ptr > buffer) + if(ptr > msgbuffer) { ptr--; if(cursor.x - 12 >= 0) @@ -592,46 +615,68 @@ break; } } - if(strcmp(cmd,"Send") == 0) - { - TFT.background(Black); - TFT.foreground(White); - TFT.cls(); - TFT.locate(90,60); - TFT.printf("Text"); - TFT.locate(90,95); - TFT.printf("Sent!"); - wait(2.5); - cmd = "Back"; - } - }else if (strcmp(cmd, "Ring") == 0) + } + else if (strcmp(cmd, "Ring") == 0) { TFT.background(Black); TFT.foreground(White); TFT.cls(); -// int i=0; - //point cursor; -// cursor.x = 0; -// cursor.y = 5; TFT.locate(0,0); TFT.printf("Incoming Call..."); TFT.foreground(Green); TFT.set_font((unsigned char*) Arial24x23); TFT.locate(28,230); TFT.printf("ANS"); - TFT.circle(60,240,50,Maroon); + TFT.circle(60,240,50,Green); TFT.foreground(Red); - TFT.locate(140,230); - TFT.printf("HANG UP"); - TFT.circle(180,240,50,Maroon); - while(strcmp(cmd, "Make") == 0) + TFT.locate(140,220); + TFT.printf("HANG"); + TFT.locate(160,240); + TFT.printf("UP"); + TFT.circle(180,240,50,Red); + while(strcmp(cmd, "Ring") == 0) { - if(TFT.getTouch(p) == TFT.YES && p.x >= 6300 && p.x <= 7250) - cmd = "Back"; + if (TFT.getTouch(p) == TFT.YES) + { + if(p.x >= 4500 && p.x <= 6600) + { + if(p.y >= 1500 && p.y <= 3800) + { + //answer cal + cmd = "Answer"; + break; + } + else if(p.y >= 4500 && p.y <= 7100) + { + //hang up + cmd = "Back"; + break; + } + + } + } + } + if(strcmp(cmd, "Answer") == 0) + { + TFT.background(Black); + TFT.foreground(White); + TFT.cls(); + TFT.locate(0,0); + TFT.printf("Call in Progress..."); + TFT.line(0,270,240,270,Red); + TFT.foreground(Red); + TFT.locate(60,280); + TFT.set_font((unsigned char*) Arial24x23); + TFT.printf("Hang Up"); + while(strcmp(cmd, "Answer") == 0) + { + if(TFT.getTouch(p) == TFT.YES && p.x >= 6300 && p.x <= 7250) + cmd = "Back"; + } } } - - + else if(strcmp(cmd, "RecvM") == 0) + {} } }