Veikko Kero / Mbed 2 deprecated MIDI_Interface_ver_1

Dependencies:   SPI_TFT_ILI9341 TFT_fonts Touch_tft PowerControl mbed USBMIDI

light_pressed.h

Committer:
Vekotin
Date:
2014-02-10
Revision:
10:ff7cdaeb8b9a
Parent:
9:df3bff3a0b76
Child:
13:f72d45d919b4

File content as of revision 10:ff7cdaeb8b9a:

#include "touch_tft.h"
#include "SPI_TFT_ILI9341.h"
#include "USBMIDI.h"

int slider;
//extern int Octaves[10] = [-24, -12, 0, 12, 24, 36, 48, 60, 72, 84];
extern int Oct = 0;
extern USBMIDI midi;

touch_tft tft(p20,p19,p18,p17,p5, p6, p7, p14, p15, p21, "TFT"); // x+,x-,y+,y-,mosi, miso, sclk, cs, reset, dc

void buttons(int b, unsigned short color)              //button field
{

    if (b == 1) {
        tft.fillrect(3,88,78,318,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 light_pressed(unsigned short color, point p)
{

    if (p.x > 3 && p.x < 78) {              //Slider
        if (p.y > 88 && p.y < 111) {
            slider = 8192;
        }
        if (p.y > 111 && p.y < 134) {
            slider = 6400;
            midi.write(MIDIMessage::PitchWheel(slider));
        }
        if (p.y > 134 && p.y < 157) {
            slider = 4915;
            midi.write(MIDIMessage::PitchWheel(slider));
        }
        if (p.y > 157 && p.y < 180) {
            slider = 3277;
            midi.write(MIDIMessage::PitchWheel(slider));
        }
        if (p.y > 180 && p.y < 203) {
            slider = 1638;
            midi.write(MIDIMessage::PitchWheel(slider));
        }
        if (p.y > 203&& p.y < 226) {
            slider = 0;
            midi.write(MIDIMessage::PitchWheel(slider));
        }
        if (p.y > 226 && p.y < 249) {
            slider = -1638;
            midi.write(MIDIMessage::PitchWheel(slider));
        }
        if (p.y > 249 && p.y < 272) {
            slider = -3277;
            midi.write(MIDIMessage::PitchWheel(slider));
        }
        if (p.y > 272 && p.y < 295) {
            slider = -4915;
            midi.write(MIDIMessage::PitchWheel(slider));
        }
        if (p.y > 295 && p.y < 318) {
            slider = -8192;
            midi.write(MIDIMessage::PitchWheel(slider));
        }
    }
    if (p.y > 163 && p.y < 238) {           //ROW B
        if (p.x > 83 && p.x < 158) {        //button 5
            buttons(5, color);
        }
        if (p.x > 163 && p.x < 238) {       //button 6
            buttons(6, color);
        }
    }

    if (p.y > 243 && p.y < 318) {           //ROW C
        if (p.x > 83 && p.x < 158) {        //Octave down
            buttons(8, color);
            Oct -= 12;
            wait(1);
        }
        if (p.x > 163 && p.x < 238) {       //Octave up
            buttons(9, color);
            Oct += 12;
            wait(1);
        }
    }
}