Cell phone

Dependencies:   TFT_fonts mbed

Fork of Seeed_TFT_Touch_Shield by Shields

Revision:
5:99eff39b92a0
Parent:
4:73d44ef604d6
Child:
7:d0cf0f1411eb
--- a/main.cpp	Wed Sep 17 00:19:58 2014 +0000
+++ b/main.cpp	Fri Sep 19 17:00:24 2014 +0000
@@ -39,6 +39,8 @@
 #define PIN_BL_TFT      D7
 #define PIN_CS_SD       D4
 
+typedef enum { YES, MAYBE, NO } TOUCH;
+
 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);
 
 void head() {
@@ -77,6 +79,7 @@
         TFT.circle(190,220,26,White);
         TFT.circle(50,280,26,White);
         TFT.circle(190,280,26,White);
+        TFT.circle(190,40,26,White);
         TFT.set_font((unsigned char*) Arial24x23);
         TFT.locate(40,84);
         TFT.printf("1");
@@ -122,6 +125,8 @@
         TFT.printf("C");
         TFT.locate(180,270);
         TFT.printf("T");
+        TFT.locate(180,27);
+        TFT.printf("X");
         
       
 }
@@ -208,16 +213,164 @@
 
 int main()
 {
-    while(1) {
+        int curr_x = 5;
+        int curr_y = 20;
+        int flag = 100;
         //Configure the display driver
         TFT.background(Black);
         TFT.foreground(White);
         TFT.cls();
-
-    
+        point p;
+        keypad();
+        int number[10];
+        int in = 0;
+        
+        while(1) {
+            TFT.set_font((unsigned char*) Arial24x23);
+            while(TFT.getTouch(p) != YES && TFT.getTouch(p) != MAYBE);
+            
+            while (TFT.getTouch(p) != NO && TFT.getTouch(p) != MAYBE) {
+                
+                    //TFT.locate(50, 20);
+                    //TFT.printf("%i %i",p.x,p.y);
+                   
+                    if((2000 < p.x && p.x < 3100) && (1500 < p.y && p.y < 2800)) {
+                        flag = 1;
+                        
+                    }
+                    else if((2000 < p.x && p.x < 3100) && (3300 < p.y && p.y < 4800)) {
+                        flag = 2;
+                        
+                    }
+                    else if((2000 < p.x && p.x < 3100) && (5300 < p.y && p.y < 6800)) {
+                        flag = 3;
+                        
+                    }
+                    else if((3300 < p.x && p.x < 4400) && (1500 < p.y && p.y < 2800))  {
+                        flag = 4;
+                        
+                    }
+                    else if((3300 < p.x && p.x < 4400) && (3300 < p.y && p.y < 4800)) {
+                        flag = 5;
+                        number[in++] = flag;
+                    }
+                    else if((3300 < p.x && p.x < 4400) && (5300 < p.y && p.y < 6800)) {
+                        flag = 6;
+                        
+                    }
+                    else if((4600 < p.x && p.x < 5700) && (1500 < p.y && p.y < 2800)) {
+                        flag = 7;
+                       
+                    }
+                    else if((4600 < p.x && p.x < 5700) && (3300 < p.y && p.y < 4800)) {
+                        flag = 8;
+                       
+                    }
+                    else if((4600 < p.x && p.x < 5700) && (5300 < p.y && p.y < 6800)) {
+                        flag = 9;
+                        
+                    }
+                    else if((5800 < p.x && p.x < 6900) && (3300 < p.y && p.y < 4800)) {
+                        flag = 0;
+                        
+                    }
+                    else if((5800 < p.x && p.x < 6900) && (1500 < p.y && p.y < 2800)) {
+                        flag = 10;
+                        
+                    }
+                    else if((5800 < p.x && p.x < 6900) && (5300 < p.y && p.y < 6800)) {
+                        flag = 11;
+                        
+                    } 
+                    else if((1000 < p.x && p.x < 2000) && (5300 < p.y && p.y < 6800)) {
+                        flag = 20;
+                        if (in > 0)
+                            in--;
+                    } 
+                    else
+                        flag = 100;
+            }
+            
+            TFT.locate(curr_y,curr_x);
+            if (flag == 1) {
+                number[in++] = flag;
+                TFT.printf("%i",flag);
+                curr_y += 15;
+                wait_ms(30);
+                
+            }
+            else if (flag == 2) {
+                number[in++] = flag;
+                TFT.printf("%i",flag);
+                curr_y += 15;
+                wait_ms(30);
+            }
+            else if (flag == 3) {
+                number[in++] = flag;
+                TFT.printf("%i",flag);
+                curr_y += 15;
+                wait_ms(30);
+            }
+            else if (flag == 4) {
+                number[in++] = flag;
+                TFT.printf("%i",flag);
+                curr_y += 15;
+                wait_ms(30);
+            }
+            else if (flag == 5) {
+                number[in++] = flag;
+                TFT.printf("%i",flag);
+                curr_y += 15;
+                wait_ms(30);
+            }
+            else if (flag == 6) {
+                number[in++] = flag;
+                TFT.printf("%i",flag);
+                curr_y += 15;
+                wait_ms(30);
+            }
+            else if (flag == 7) {
+                number[in++] = flag;
+                TFT.printf("%i",flag);
+                curr_y += 15;
+                wait_ms(30);
+            }
+            else if (flag == 8) {
+                number[in++] = flag;
+                TFT.printf("%i",flag);
+                curr_y += 15;
+                wait_ms(30);
+            }
+            else if (flag == 9) {
+                number[in++] = flag;
+                TFT.printf("%i",flag);
+                curr_y += 15;
+                wait_ms(30);
+            }
+            else if (flag == 0) {
+                number[in++] = flag;
+                TFT.printf("%i",flag);
+                curr_y += 15;
+                wait_ms(30);
+            }
+            else if (flag == 20) {
+                if (in > 0)
+                    in--;
+                if(curr_y > 20){
+                    curr_y -= 15;
+                    TFT.locate(curr_y,curr_x);
+                    TFT.printf(" ");
+                }
+                wait_ms(30);
+            }
+            else {
+            }
+        }
+        
+        /*
         head();
         
-        TFT.set_font((unsigned char*) Arial24x23);
+        
         TFT.locate(50,280);
         TFT.printf("Call/Text");
         TFT.line(40,270,190,270,White);
@@ -228,12 +381,13 @@
         
         wait(5);
         keypad();
+        
         wait(5);
         call();
         wait(5);
         text();
         wait(5);     
-    
+        */
         //Draw some graphics
         //TFT.cls();
         //TFT.set_font((unsigned char*) Arial24x23);
@@ -275,5 +429,5 @@
         TFT.set_font((unsigned char*) Arial12x12);
         TFT.locate(35,120);
         TFT.printf("Hello Mbed 3");*/
-    }
+    
 }