MIDI Interface in progress

Dependencies:   SPI_TFT_ILI9341 TFT_fonts Touch_tft PowerControl mbed USBMIDI

Files at this revision

API Documentation at this revision

Comitter:
Vekotin
Date:
Thu Jan 16 13:06:14 2014 +0000
Parent:
0:98b5cd030eee
Child:
2:478274cba6c3
Commit message:
n?pp?inpohja

Changed in this revision

Touch_tft.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Touch_tft.lib	Thu Jan 16 07:48:24 2014 +0000
+++ b/Touch_tft.lib	Thu Jan 16 13:06:14 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/Vekotin/code/Touch_tft/#ef67f9068850
+http://mbed.org/users/Vekotin/code/Touch_tft/#cef5cdc775ea
--- a/main.cpp	Thu Jan 16 07:48:24 2014 +0000
+++ b/main.cpp	Thu Jan 16 13:06:14 2014 +0000
@@ -29,8 +29,51 @@
             printf("Another message\n");
     }    
 } 
+USBMIDI midi; */
 
-USBMIDI midi; */
+void buttons(int b, unsigned short color) {            //button field
+        
+        if (b == 1) { 
+            tft.fillrect(3,88,78,158,color); 
+        }
+        if (b == 2) {
+            tft.fillrect(83,88,158,158,color);            
+        }
+        if (b == 3) {
+            tft.fillrect(163,88,238,158,color); 
+        }
+                           
+        if (b == 4) {
+            tft.fillrect(3,163,78,238,color);
+        }
+        if (b == 5) {       
+            tft.fillrect(83,163,158,238,color); 
+        }            
+        if (b == 6) {     
+            tft.fillrect(163,163,238,238,color);
+        }   
+             
+        if (b == 7) {
+            tft.fillrect(3,243,78,318,color);
+        }     
+        if (b == 8) {
+            tft.fillrect(83,243,158,318,color); 
+        }
+        if (b == 9) {
+            tft.fillrect(163,243,238,318,color);
+        }
+        
+}
+
+void draw_buttons(unsigned short color) {
+                
+                unsigned int i = 1;
+                
+                for (i = 1; i<10; i++){                                         //draw buttons
+                buttons(i, color);
+                }
+                
+}
 
 int main() {
     
@@ -47,24 +90,30 @@
     tft.calibrate();
     
     tft.locate(0,0);
-    printf(" HOPPODIHOI! ");    
+    printf(" MIDIMAN! "); 
+    tft.line(0,83,239,83,White);   
     
     while (1) {
         
         color = White;
-        tft.fillrect(20,140,220,180,color);
-
-        p = tft.get_touch();
-        if (tft.is_touched(p)) {  // touch
+        draw_buttons(color);        
+        
+        while (tft.is_touched(tft.get_touch())) {                       // touch
+            p = tft.get_touch();
         
-            p = tft.to_pixel(p);                          // convert to pixel pos
-            if (p.y > 140 && p.y < 180) {                             // a button field
-                if (p.x > 20 && p.x < 220) {            
-                    color = Cyan;
-                    tft.fillrect(20,140,220,180,color);                                    
+            p = tft.to_pixel(p);                                      // convert to pixel pos
+            
+            if (p.y > 88 && p.y < 158) {                            //which column    
+                if (p.x > 3 && p.x < 78) {            
+                    buttons(1, Red);                                                  
                 }
             }
-        }
+            if (p.y > 163 && p.y < 238) {                            //which column    
+                if (p.x > 83 && p.x < 158) {            
+                    buttons(5, Red);                                                  
+                }
+            }
+        } 
         
     }