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:
- tanssisatu
- Date:
- 2014-02-13
- Revision:
- 12:f78afb23f7e2
- Parent:
- 11:258abdee25b1
- Child:
- 13:f72d45d919b4
File content as of revision 12:f78afb23f7e2:
#include "mbed.h" #include "Arial12x12.h" #include "Arial28x28.h" #include "USBMIDI.h" #include "light_pressed.h" #include "PowerControl/PowerControl.h" #include "PowerControl/EthernetPowerControl.h" // the TFT is connected to SPI pin 5-7 // the touch is connected to 19,20,16,17 //Serial pc(USBTX, USBRX); DigitalIn key[9] = {p22, p23, p24, p25, p26, p27, p28, p29, p30}; //inputit int input = 0; int i; int painetut_nappaimet[9] = {0}; USBMIDI midi; // 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 draw_buttons(unsigned short color) { unsigned int i = 0; for (i = 0; i<10; i++) { //draw buttons tft.locate(10,50); printf("Shift"); buttons(i, color); } } void nine_keys(void) { for (i = 0; i < 9; i++) { if (!key[i].read() & !painetut_nappaimet[i]) { midi.write(MIDIMessage::NoteOn(36 + i + Oct)); painetut_nappaimet[i] = true; } } for (i = 0; i < 9; i++) { if (key[i].read()) midi.write(MIDIMessage::NoteOff(36 + i + Oct)); } for (i = 0; i < 9; i++) { if (key[i].read()) painetut_nappaimet[i] = false; } } void powerdown(void) { PHY_PowerDown(); semihost_powerdown(); //Peripheral_PowerDown(0xFFFF7FFF); } int main() { // PERUSPOHJA, ÄLÄ MUOKKAA! powerdown(); 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*) 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(85,0); printf(" Octave = "); tft.locate(85, 12); printf(" Slider = "); tft.locate(0,0); printf(" MIDIMAN! "); tft.line(0,83,239,83,White); tft.locate(180,270); tft.foreground(Black); tft.background(White); printf("Octave"); tft.locate(190,282); printf("Up"); tft.locate(100,270); printf("Octave"); tft.locate(102,282); printf("Down"); tft.background(Black); // set background to black tft.foreground(White); // set chars to 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 position tft.locate(210,0); printf("%3d",p.x); tft.locate(210,12); printf("%3d",p.y); light_pressed(Red,p); tft.locate(160, 0); printf("%i", Oct); tft.locate(160, 12); printf("%i", slider); nine_keys(); } nine_keys(); } }