Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SPI_TFT_ILI9341 TFT_fonts Touch_tft PowerControl mbed USBMIDI
main.cpp
- Committer:
- Vekotin
- Date:
- 2014-01-16
- Revision:
- 1:7e2d93d70d2b
- Parent:
- 0:98b5cd030eee
- Child:
- 2:478274cba6c3
File content as of revision 1:7e2d93d70d2b:
#include "mbed.h" #include "SPI_TFT_ILI9341.h" #include "Arial12x12.h" #include "Arial28x28.h" #include "touch_tft.h" #include "USBMIDI.h" // the TFT is connected to SPI pin 5-7 // the touch is connected to 19,20,16,17 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 if (b == 1) { tft.fillrect(3,88,78,158,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 draw_buttons(unsigned short color) { unsigned int i = 1; for (i = 1; i<10; i++){ //draw buttons buttons(i, color); } } int main() { point p; unsigned short color = White; tft.claim(stdout); // send stdout to the TFT display 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_orientation(0); tft.calibrate(); tft.locate(0,0); printf(" MIDIMAN! "); tft.line(0,83,239,83,White); while (1) { color = White; draw_buttons(color); while (tft.is_touched(tft.get_touch())) { // touch p = tft.get_touch(); p = tft.to_pixel(p); // convert to pixel pos 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); } } } } /* 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); } } */ }