Veikko Kero / Mbed 2 deprecated MIDI_Interface_ver_1

Dependencies:   SPI_TFT_ILI9341 TFT_fonts Touch_tft PowerControl mbed USBMIDI

Committer:
MetropoliaMies
Date:
Thu Feb 13 09:04:51 2014 +0000
Revision:
13:f72d45d919b4
Parent:
10:ff7cdaeb8b9a
Workare v4.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MetropoliaMies 4:76c054f8b97e 1 #include "touch_tft.h"
MetropoliaMies 4:76c054f8b97e 2 #include "SPI_TFT_ILI9341.h"
Vekotin 10:ff7cdaeb8b9a 3 #include "USBMIDI.h"
MetropoliaMies 4:76c054f8b97e 4
MetropoliaMies 4:76c054f8b97e 5 int slider;
Vekotin 10:ff7cdaeb8b9a 6 //extern int Octaves[10] = [-24, -12, 0, 12, 24, 36, 48, 60, 72, 84];
tanssisatu 9:df3bff3a0b76 7 extern int Oct = 0;
Vekotin 10:ff7cdaeb8b9a 8 extern USBMIDI midi;
MetropoliaMies 4:76c054f8b97e 9
MetropoliaMies 13:f72d45d919b4 10
MetropoliaMies 4:76c054f8b97e 11 touch_tft tft(p20,p19,p18,p17,p5, p6, p7, p14, p15, p21, "TFT"); // x+,x-,y+,y-,mosi, miso, sclk, cs, reset, dc
MetropoliaMies 13:f72d45d919b4 12 int oktaavi[11] = {-2,-1,0,1,2,3,4,5,6};
MetropoliaMies 13:f72d45d919b4 13 int o = 5;
MetropoliaMies 4:76c054f8b97e 14
MetropoliaMies 4:76c054f8b97e 15 void buttons(int b, unsigned short color) //button field
MetropoliaMies 4:76c054f8b97e 16 {
MetropoliaMies 4:76c054f8b97e 17
MetropoliaMies 5:8e13103b41be 18 if (b == 1) {
MetropoliaMies 4:76c054f8b97e 19 tft.fillrect(3,88,78,318,color);
MetropoliaMies 5:8e13103b41be 20 }
MetropoliaMies 5:8e13103b41be 21 if (b == 2) {
MetropoliaMies 5:8e13103b41be 22 tft.fillrect(83,88,158,158,color);
MetropoliaMies 4:76c054f8b97e 23 }
MetropoliaMies 5:8e13103b41be 24 if (b == 3) {
MetropoliaMies 5:8e13103b41be 25 tft.fillrect(163,88,238,158,color);
MetropoliaMies 5:8e13103b41be 26 }
MetropoliaMies 5:8e13103b41be 27 if (b == 4) {
MetropoliaMies 4:76c054f8b97e 28 tft.fillrect(3,163,78,238,color);
MetropoliaMies 4:76c054f8b97e 29 }
MetropoliaMies 4:76c054f8b97e 30 if (b == 5) {
MetropoliaMies 4:76c054f8b97e 31 tft.fillrect(83,163,158,238,color);
MetropoliaMies 4:76c054f8b97e 32 }
MetropoliaMies 4:76c054f8b97e 33 if (b == 6) {
MetropoliaMies 4:76c054f8b97e 34 tft.fillrect(163,163,238,238,color);
MetropoliaMies 4:76c054f8b97e 35 }
MetropoliaMies 4:76c054f8b97e 36
MetropoliaMies 5:8e13103b41be 37 if (b == 7) {
MetropoliaMies 4:76c054f8b97e 38 tft.fillrect(3,243,78,318,color);
MetropoliaMies 4:76c054f8b97e 39 }
MetropoliaMies 4:76c054f8b97e 40 if (b == 8) {
MetropoliaMies 4:76c054f8b97e 41 tft.fillrect(83,243,158,318,color);
MetropoliaMies 4:76c054f8b97e 42 }
MetropoliaMies 4:76c054f8b97e 43 if (b == 9) {
MetropoliaMies 4:76c054f8b97e 44 tft.fillrect(163,243,238,318,color);
MetropoliaMies 4:76c054f8b97e 45 }
MetropoliaMies 4:76c054f8b97e 46 }
MetropoliaMies 4:76c054f8b97e 47
MetropoliaMies 13:f72d45d919b4 48 void buttons_text(){
MetropoliaMies 13:f72d45d919b4 49 tft.locate(180,270);
MetropoliaMies 13:f72d45d919b4 50 tft.foreground(Black);
MetropoliaMies 13:f72d45d919b4 51 tft.background(White);
MetropoliaMies 13:f72d45d919b4 52 printf("Octave");
MetropoliaMies 13:f72d45d919b4 53 tft.locate(190,282);
MetropoliaMies 13:f72d45d919b4 54 printf("Up");
MetropoliaMies 13:f72d45d919b4 55 tft.locate(100,270);
MetropoliaMies 13:f72d45d919b4 56 printf("Octave");
MetropoliaMies 13:f72d45d919b4 57 tft.locate(102,282);
MetropoliaMies 13:f72d45d919b4 58 printf("Down");
MetropoliaMies 13:f72d45d919b4 59 tft.background(Black); // set background to black
MetropoliaMies 13:f72d45d919b4 60 tft.foreground(White); // set chars to white
MetropoliaMies 13:f72d45d919b4 61
MetropoliaMies 13:f72d45d919b4 62 }
MetropoliaMies 13:f72d45d919b4 63
MetropoliaMies 5:8e13103b41be 64 void light_pressed(unsigned short color, point p)
MetropoliaMies 4:76c054f8b97e 65 {
MetropoliaMies 4:76c054f8b97e 66
MetropoliaMies 5:8e13103b41be 67 if (p.x > 3 && p.x < 78) { //Slider
Vekotin 10:ff7cdaeb8b9a 68 if (p.y > 88 && p.y < 111) {
Vekotin 10:ff7cdaeb8b9a 69 slider = 8192;
MetropoliaMies 4:76c054f8b97e 70 }
Vekotin 10:ff7cdaeb8b9a 71 if (p.y > 111 && p.y < 134) {
Vekotin 10:ff7cdaeb8b9a 72 slider = 6400;
Vekotin 10:ff7cdaeb8b9a 73 midi.write(MIDIMessage::PitchWheel(slider));
MetropoliaMies 4:76c054f8b97e 74 }
Vekotin 10:ff7cdaeb8b9a 75 if (p.y > 134 && p.y < 157) {
Vekotin 10:ff7cdaeb8b9a 76 slider = 4915;
Vekotin 10:ff7cdaeb8b9a 77 midi.write(MIDIMessage::PitchWheel(slider));
MetropoliaMies 4:76c054f8b97e 78 }
Vekotin 10:ff7cdaeb8b9a 79 if (p.y > 157 && p.y < 180) {
Vekotin 10:ff7cdaeb8b9a 80 slider = 3277;
Vekotin 10:ff7cdaeb8b9a 81 midi.write(MIDIMessage::PitchWheel(slider));
MetropoliaMies 4:76c054f8b97e 82 }
Vekotin 10:ff7cdaeb8b9a 83 if (p.y > 180 && p.y < 203) {
Vekotin 10:ff7cdaeb8b9a 84 slider = 1638;
Vekotin 10:ff7cdaeb8b9a 85 midi.write(MIDIMessage::PitchWheel(slider));
MetropoliaMies 4:76c054f8b97e 86 }
Vekotin 10:ff7cdaeb8b9a 87 if (p.y > 203&& p.y < 226) {
Vekotin 10:ff7cdaeb8b9a 88 slider = 0;
Vekotin 10:ff7cdaeb8b9a 89 midi.write(MIDIMessage::PitchWheel(slider));
MetropoliaMies 4:76c054f8b97e 90 }
Vekotin 10:ff7cdaeb8b9a 91 if (p.y > 226 && p.y < 249) {
Vekotin 10:ff7cdaeb8b9a 92 slider = -1638;
Vekotin 10:ff7cdaeb8b9a 93 midi.write(MIDIMessage::PitchWheel(slider));
MetropoliaMies 4:76c054f8b97e 94 }
Vekotin 10:ff7cdaeb8b9a 95 if (p.y > 249 && p.y < 272) {
Vekotin 10:ff7cdaeb8b9a 96 slider = -3277;
Vekotin 10:ff7cdaeb8b9a 97 midi.write(MIDIMessage::PitchWheel(slider));
MetropoliaMies 4:76c054f8b97e 98 }
Vekotin 10:ff7cdaeb8b9a 99 if (p.y > 272 && p.y < 295) {
Vekotin 10:ff7cdaeb8b9a 100 slider = -4915;
Vekotin 10:ff7cdaeb8b9a 101 midi.write(MIDIMessage::PitchWheel(slider));
MetropoliaMies 4:76c054f8b97e 102 }
Vekotin 10:ff7cdaeb8b9a 103 if (p.y > 295 && p.y < 318) {
Vekotin 10:ff7cdaeb8b9a 104 slider = -8192;
Vekotin 10:ff7cdaeb8b9a 105 midi.write(MIDIMessage::PitchWheel(slider));
MetropoliaMies 4:76c054f8b97e 106 }
MetropoliaMies 4:76c054f8b97e 107 }
MetropoliaMies 4:76c054f8b97e 108 if (p.y > 163 && p.y < 238) { //ROW B
MetropoliaMies 4:76c054f8b97e 109 if (p.x > 83 && p.x < 158) { //button 5
MetropoliaMies 4:76c054f8b97e 110 buttons(5, color);
MetropoliaMies 4:76c054f8b97e 111 }
MetropoliaMies 4:76c054f8b97e 112 if (p.x > 163 && p.x < 238) { //button 6
MetropoliaMies 4:76c054f8b97e 113 buttons(6, color);
MetropoliaMies 4:76c054f8b97e 114 }
MetropoliaMies 4:76c054f8b97e 115 }
MetropoliaMies 4:76c054f8b97e 116
MetropoliaMies 4:76c054f8b97e 117 if (p.y > 243 && p.y < 318) { //ROW C
Vekotin 10:ff7cdaeb8b9a 118 if (p.x > 83 && p.x < 158) { //Octave down
MetropoliaMies 5:8e13103b41be 119 buttons(8, color);
Vekotin 10:ff7cdaeb8b9a 120 Oct -= 12;
MetropoliaMies 13:f72d45d919b4 121 o--;
MetropoliaMies 13:f72d45d919b4 122 wait(0.1);
MetropoliaMies 4:76c054f8b97e 123 }
MetropoliaMies 5:8e13103b41be 124 if (p.x > 163 && p.x < 238) { //Octave up
MetropoliaMies 4:76c054f8b97e 125 buttons(9, color);
Vekotin 10:ff7cdaeb8b9a 126 Oct += 12;
MetropoliaMies 13:f72d45d919b4 127 o++;
MetropoliaMies 13:f72d45d919b4 128 wait(0.1);
MetropoliaMies 4:76c054f8b97e 129 }
MetropoliaMies 4:76c054f8b97e 130 }
MetropoliaMies 4:76c054f8b97e 131 }
MetropoliaMies 4:76c054f8b97e 132
MetropoliaMies 4:76c054f8b97e 133
MetropoliaMies 4:76c054f8b97e 134