MIDI Interface in progress

Dependencies:   SPI_TFT_ILI9341 TFT_fonts Touch_tft PowerControl mbed USBMIDI

Revision:
16:f4d090f1e6ed
Parent:
15:c297064a829b
--- a/touch_interface.h	Mon Feb 24 09:54:44 2014 +0000
+++ b/touch_interface.h	Mon Feb 24 11:11:46 2014 +0000
@@ -1,6 +1,28 @@
 #include "touch_tft.h"
 #include "SPI_TFT_ILI9341.h"
 #include "USBMIDI.h"
+#include "PowerControl/PowerControl.h"
+#include "PowerControl/EthernetPowerControl.h"
+
+// Function to power down magic USB interface chip with new firmware
+#define USR_POWERDOWN    (0x104)
+int semihost_powerdown() {
+    uint32_t arg;
+    return __semihost(USR_POWERDOWN, &arg);
+}
+
+void powerdown(void)
+{
+
+    PHY_PowerDown();
+    semihost_powerdown();
+    //Peripheral_PowerDown(0xFFFF7FFF);
+
+    PHY_PowerDown();                    //Ethernet disabled
+    semihost_powerdown();               //USB disabled
+    Peripheral_PowerDown(0x80080);      //Unused I2C disabled
+
+}
 
 // short slider = 8192;
 extern unsigned short Oct = 36;        //default octave C1
@@ -39,9 +61,22 @@
     }
     if (b == 3) {                                      //Octave DOWN
         tft.fillrect(83,243,158,318,color);
+        tft.locate(90,275);
+        tft.foreground(Black);
+        tft.background(White);
+        printf("DOWN");
+        tft.foreground(White);
+        tft.background(Black);
+
     }
     if (b == 4) {                                      //Octave UP
         tft.fillrect(163,243,238,318,color);
+        tft.locate(170,275);
+        tft.foreground(Black);
+        tft.background(White);
+        printf("UP");
+        tft.foreground(White);
+        tft.background(Black);
     }
 }
 
@@ -55,47 +90,49 @@
     }
 }
 
+
+
 void Slider_action(point p)
 {
     if (p.x > 3 && p.x < 78) {                          //Slider
         if (p.y > 88 && p.y < 111) {
-            //tft.fillrect(3,88,78,111,Red);
+            tft.fillrect(3,88,78,111,Red);
             midi.write(MIDIMessage::PitchWheel(8192));
         }
         if (p.y > 111 && p.y < 134) {
-            //tft.fillrect(3,111,78,134,Red);
+            tft.fillrect(3,111,78,134,Red);
             midi.write(MIDIMessage::PitchWheel(6400));
         }
         if (p.y > 134 && p.y < 157) {
-            //tft.fillrect(3,111,78,157,Red);
+            tft.fillrect(3,111,78,157,Red);
             midi.write(MIDIMessage::PitchWheel(4915));
         }
         if (p.y > 157 && p.y < 180) {
-            //tft.fillrect(3,111,78,180,Red);
+            tft.fillrect(3,111,78,180,Red);
             midi.write(MIDIMessage::PitchWheel(3277));
         }
         if (p.y > 180 && p.y < 203) {
-            //tft.fillrect(3,111,78,203,Red);
+            tft.fillrect(3,111,78,203,Red);
             midi.write(MIDIMessage::PitchWheel(1638));
         }
         if (p.y > 203 && p.y < 226) {
-            //tft.fillrect(3,111,78,226,Red);
+            tft.fillrect(3,111,78,226,Red);
             midi.write(MIDIMessage::PitchWheel(0));
         }
         if (p.y > 226 && p.y < 249) {
-            //tft.fillrect(3,111,78,249,Red);
+            tft.fillrect(3,111,78,249,Red);
             midi.write(MIDIMessage::PitchWheel(-1638));
         }
         if (p.y > 249 && p.y < 272) {
-            //tft.fillrect(3,111,78,272,Red);
+            tft.fillrect(3,111,78,272,Red);
             midi.write(MIDIMessage::PitchWheel(-3277));
         }
         if (p.y > 272 && p.y < 295) {
-            //tft.fillrect(3,111,78,295,Red);
+            tft.fillrect(3,111,78,295,Red);
             midi.write(MIDIMessage::PitchWheel(-4915));
         }
         if (p.y > 295 && p.y < 318) {
-            //tft.fillrect(3,111,78,318,Red);
+            tft.fillrect(3,111,78,318,Red);
             midi.write(MIDIMessage::PitchWheel(-8192));
         }
     }
@@ -108,14 +145,27 @@
         if (p.x > 83 && p.x < 158) {        //Octave down
             Buttons(3, color);
             Oct -= 12;
+            tft.locate(90,275);
+            tft.foreground(Black);
+            tft.background(Red);
+            printf("Down");
+            tft.foreground(Black);
+            tft.background(White);
             wait(0.2);
             Buttons(3, White);
         }
         if (p.x > 163 && p.x < 238) {       //Octave up
             Buttons(4, color);
             Oct += 12;
+            tft.locate(170,275);
+            tft.foreground(Black);
+            tft.background(Red);
+            printf("UP");
+            tft.foreground(Black);
+            tft.background(White);
             wait(0.2);
             Buttons(4, White);
+
         }
     }