MIDI Interface in progress
Dependencies: SPI_TFT_ILI9341 TFT_fonts Touch_tft PowerControl mbed USBMIDI
Revision 2:478274cba6c3, committed 2014-01-20
- Comitter:
- Vekotin
- Date:
- Mon Jan 20 11:20:51 2014 +0000
- Parent:
- 1:7e2d93d70d2b
- Child:
- 3:c8a476a218e3
- Child:
- 14:31d5531114e0
- Commit message:
- tyhm? nappula layout
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Jan 16 13:06:14 2014 +0000 +++ b/main.cpp Mon Jan 20 11:20:51 2014 +0000 @@ -11,25 +11,6 @@ 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 show_message(MIDIMessage msg) { - switch (msg.type()) { - case MIDIMessage::NoteOnType: - printf("NoteOn key:%d, velocity: %d, channel: %d\n", msg.key(), msg.velocity(), msg.channel()); - break; - case MIDIMessage::NoteOffType: - printf("NoteOff key:%d, velocity: %d, channel: %d\n", msg.key(), msg.velocity(), msg.channel()); - break; - case MIDIMessage::ControlChangeType: - printf("ControlChange controller: %d, data: %d\n", msg.controller(), msg.value()); - break; - case MIDIMessage::PitchWheelType: - printf("PitchWheel channel: %d, pitch: %d\n", msg.channel(), msg.pitch()); - break; - default: - printf("Another message\n"); - } -} -USBMIDI midi; */ void buttons(int b, unsigned short color) { //button field @@ -75,7 +56,49 @@ } -int main() { +void light_pressed(unsigned short color, point p) +{ + + if (p.y > 88 && p.y < 158) { //ROW A + if (p.x > 3 && p.x < 78) { //button 1 + buttons(1, color); + } + if (p.x > 83 && p.x < 158) { //button 2 + buttons(2, color); + } + if (p.x > 163 && p.x < 238) { //button 3 + buttons(3, color); + } + } + + if (p.y > 163 && p.y < 238) { //ROW B + if (p.x > 3 && p.x < 78) { //button 4 + buttons(4, color); + } + 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 > 3 && p.x < 78) { //button 7 + buttons(7, color); + } + if (p.x > 83 && p.x < 158) { //button 8 + buttons(8, color); + } + if (p.x > 163 && p.x < 238) { //button 9 + buttons(9, color); + } + } +} + +int main() { + + // PERUSPOHJA, ÄLÄ MUOKKAA! point p; unsigned short color = White; @@ -84,11 +107,17 @@ tft.background(Black); // set background to black tft.foreground(White); // set chars to white tft.cls(); // clear the screen - tft.set_font((unsigned char*) Arial28x28); // select the font + tft.set_font((unsigned char*) Arial12x12); // select the font tft.set_orientation(0); tft.calibrate(); + + tft.locate(180,0); //show coordinates + printf(" x = "); + tft.locate(180,12); + printf(" y = "); + tft.locate(0,0); printf(" MIDIMAN! "); tft.line(0,83,239,83,White); @@ -99,38 +128,20 @@ draw_buttons(color); while (tft.is_touched(tft.get_touch())) { // touch - p = tft.get_touch(); - - p = tft.to_pixel(p); // convert to pixel pos + p = tft.get_touch(); + p = tft.to_pixel(p); // convert to pixel position + + light_pressed(Red,p); // light pressed button - 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); - } - } - } - - } + tft.locate(216,0); + printf("%3d",p.x); + tft.locate(216,12); + printf("%3d",p.y); + + } + } - - - /* - midi.attach(show_message); // call back for messages received - while (1) { - for(int i=48; i<83; i++) { // send some messages! - midi.write(MIDIMessage::NoteOn(i)); - wait(0.25); - midi.write(MIDIMessage::NoteOff(i)); - wait(0.5); - } - } - */ - + }