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:
MetropoliaMies
Date:
Mon Feb 24 11:11:46 2014 +0000
Parent:
15:c297064a829b
Child:
17:83ba2fe508c7
Commit message:
PowerControl lis?tty, touchscreen slider ei toimi

Changed in this revision

PowerControl.lib Show annotated file Show diff for this revision Revisions of this file
USBDevice.lib Show diff for this revision Revisions of this file
USBMIDI.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
touch_interface.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PowerControl.lib	Mon Feb 24 11:11:46 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/JST2011/code/PowerControl/#57e8ded759f4
--- a/USBDevice.lib	Mon Feb 24 09:54:44 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/Vekotin/code/USBDevice_MIDI_Interface/#27190ac1ff6e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBMIDI.lib	Mon Feb 24 11:11:46 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/USBMIDI/#10d694d6ccdc
--- a/main.cpp	Mon Feb 24 09:54:44 2014 +0000
+++ b/main.cpp	Mon Feb 24 11:11:46 2014 +0000
@@ -5,6 +5,9 @@
 #include "USBMIDI.h"
 #include "touch_interface.h"
 
+
+
+
 point p;
 
 int main()
@@ -27,16 +30,18 @@
     tft.locate(0,0);
     printf(" MIDIMAN! ");
     tft.line(0,83,239,83,White);
+    
+    powerdown();
 
     Draw_buttons(White);
 
     while (1) {     
-
+/*
         tft.locate(90,275);
         printf("DOWN");
         tft.locate(170,275);
         printf("UP");
-
+*/
         if (tft.is_touched(tft.get_touch())) {                          // touch
             p = tft.get_touch();
             p = tft.to_pixel(p);                                        // convert to pixel position
--- 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);
+
         }
     }