MIDI Interface in progress
Dependencies: SPI_TFT_ILI9341 TFT_fonts Touch_tft PowerControl mbed USBMIDI
main.cpp@5:8e13103b41be, 2014-02-06 (annotated)
- Committer:
- MetropoliaMies
- Date:
- Thu Feb 06 07:36:01 2014 +0000
- Revision:
- 5:8e13103b41be
- Parent:
- 4:76c054f8b97e
- Child:
- 6:17e0520e346f
uusin;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Vekotin | 0:98b5cd030eee | 1 | #include "mbed.h" |
MetropoliaMies | 4:76c054f8b97e | 2 | |
Vekotin | 0:98b5cd030eee | 3 | #include "Arial12x12.h" |
Vekotin | 0:98b5cd030eee | 4 | #include "Arial28x28.h" |
MetropoliaMies | 4:76c054f8b97e | 5 | |
Vekotin | 0:98b5cd030eee | 6 | #include "USBMIDI.h" |
MetropoliaMies | 4:76c054f8b97e | 7 | #include "light_pressed.h" |
Vekotin | 0:98b5cd030eee | 8 | |
Vekotin | 0:98b5cd030eee | 9 | |
Vekotin | 0:98b5cd030eee | 10 | // the TFT is connected to SPI pin 5-7 |
Vekotin | 0:98b5cd030eee | 11 | // the touch is connected to 19,20,16,17 |
Vekotin | 0:98b5cd030eee | 12 | |
Vekotin | 0:98b5cd030eee | 13 | |
Vekotin | 0:98b5cd030eee | 14 | |
MetropoliaMies | 4:76c054f8b97e | 15 | Serial pc(USBTX, USBRX); |
MetropoliaMies | 4:76c054f8b97e | 16 | |
MetropoliaMies | 4:76c054f8b97e | 17 | void draw_buttons(unsigned short color) |
MetropoliaMies | 4:76c054f8b97e | 18 | { |
Vekotin | 1:7e2d93d70d2b | 19 | |
MetropoliaMies | 4:76c054f8b97e | 20 | unsigned int i = 0; |
Vekotin | 2:478274cba6c3 | 21 | |
MetropoliaMies | 4:76c054f8b97e | 22 | for (i = 0; i<10; i++) { //draw buttons |
MetropoliaMies | 4:76c054f8b97e | 23 | tft.locate(10,50); |
MetropoliaMies | 4:76c054f8b97e | 24 | printf("Shift"); |
Vekotin | 2:478274cba6c3 | 25 | |
Vekotin | 2:478274cba6c3 | 26 | } |
Vekotin | 2:478274cba6c3 | 27 | } |
Vekotin | 2:478274cba6c3 | 28 | |
MetropoliaMies | 4:76c054f8b97e | 29 | int main() |
MetropoliaMies | 4:76c054f8b97e | 30 | { |
MetropoliaMies | 4:76c054f8b97e | 31 | |
Vekotin | 2:478274cba6c3 | 32 | // PERUSPOHJA, ÄLÄ MUOKKAA! |
MetropoliaMies | 4:76c054f8b97e | 33 | |
Vekotin | 0:98b5cd030eee | 34 | point p; |
Vekotin | 0:98b5cd030eee | 35 | unsigned short color = White; |
Vekotin | 0:98b5cd030eee | 36 | |
Vekotin | 0:98b5cd030eee | 37 | tft.claim(stdout); // send stdout to the TFT display |
Vekotin | 0:98b5cd030eee | 38 | tft.background(Black); // set background to black |
Vekotin | 0:98b5cd030eee | 39 | tft.foreground(White); // set chars to white |
Vekotin | 0:98b5cd030eee | 40 | tft.cls(); // clear the screen |
Vekotin | 2:478274cba6c3 | 41 | tft.set_font((unsigned char*) Arial12x12); // select the font |
MetropoliaMies | 4:76c054f8b97e | 42 | |
Vekotin | 0:98b5cd030eee | 43 | tft.set_orientation(0); |
Vekotin | 0:98b5cd030eee | 44 | tft.calibrate(); |
MetropoliaMies | 4:76c054f8b97e | 45 | |
MetropoliaMies | 4:76c054f8b97e | 46 | |
Vekotin | 2:478274cba6c3 | 47 | tft.locate(180,0); //show coordinates |
Vekotin | 2:478274cba6c3 | 48 | printf(" x = "); |
Vekotin | 2:478274cba6c3 | 49 | tft.locate(180,12); |
MetropoliaMies | 4:76c054f8b97e | 50 | printf(" y = "); |
MetropoliaMies | 4:76c054f8b97e | 51 | |
MetropoliaMies | 4:76c054f8b97e | 52 | tft.locate(85,0); |
MetropoliaMies | 4:76c054f8b97e | 53 | printf(" Octave = "); |
MetropoliaMies | 4:76c054f8b97e | 54 | tft.locate(85, 12); |
MetropoliaMies | 4:76c054f8b97e | 55 | printf(" Slider = "); |
MetropoliaMies | 4:76c054f8b97e | 56 | |
MetropoliaMies | 4:76c054f8b97e | 57 | |
MetropoliaMies | 4:76c054f8b97e | 58 | |
Vekotin | 0:98b5cd030eee | 59 | tft.locate(0,0); |
MetropoliaMies | 4:76c054f8b97e | 60 | printf(" MIDIMAN! "); |
MetropoliaMies | 4:76c054f8b97e | 61 | tft.line(0,83,239,83,White); |
MetropoliaMies | 4:76c054f8b97e | 62 | |
MetropoliaMies | 5:8e13103b41be | 63 | tft.locate(163,250); |
MetropoliaMies | 5:8e13103b41be | 64 | printf("Octave up"); |
MetropoliaMies | 5:8e13103b41be | 65 | tft.locate(83,250); |
MetropoliaMies | 5:8e13103b41be | 66 | printf("Octave dwn"); |
MetropoliaMies | 5:8e13103b41be | 67 | |
Vekotin | 0:98b5cd030eee | 68 | while (1) { |
MetropoliaMies | 4:76c054f8b97e | 69 | |
Vekotin | 0:98b5cd030eee | 70 | color = White; |
MetropoliaMies | 4:76c054f8b97e | 71 | draw_buttons(color); |
MetropoliaMies | 4:76c054f8b97e | 72 | |
MetropoliaMies | 4:76c054f8b97e | 73 | |
MetropoliaMies | 4:76c054f8b97e | 74 | |
MetropoliaMies | 4:76c054f8b97e | 75 | |
Vekotin | 1:7e2d93d70d2b | 76 | while (tft.is_touched(tft.get_touch())) { // touch |
MetropoliaMies | 4:76c054f8b97e | 77 | p = tft.get_touch(); |
Vekotin | 2:478274cba6c3 | 78 | p = tft.to_pixel(p); // convert to pixel position |
MetropoliaMies | 4:76c054f8b97e | 79 | |
MetropoliaMies | 3:c8a476a218e3 | 80 | tft.locate(210,0); |
Vekotin | 2:478274cba6c3 | 81 | printf("%3d",p.x); |
MetropoliaMies | 3:c8a476a218e3 | 82 | tft.locate(210,12); |
MetropoliaMies | 4:76c054f8b97e | 83 | printf("%3d",p.y); |
MetropoliaMies | 4:76c054f8b97e | 84 | |
MetropoliaMies | 4:76c054f8b97e | 85 | tft.locate(160, 0); |
MetropoliaMies | 5:8e13103b41be | 86 | printf("%i", Octave); |
MetropoliaMies | 4:76c054f8b97e | 87 | tft.locate(160, 12); |
MetropoliaMies | 4:76c054f8b97e | 88 | printf("%i", slider); |
Vekotin | 2:478274cba6c3 | 89 | |
MetropoliaMies | 4:76c054f8b97e | 90 | |
MetropoliaMies | 4:76c054f8b97e | 91 | |
MetropoliaMies | 4:76c054f8b97e | 92 | } |
MetropoliaMies | 4:76c054f8b97e | 93 | } |
MetropoliaMies | 4:76c054f8b97e | 94 | |
MetropoliaMies | 4:76c054f8b97e | 95 | |
Vekotin | 0:98b5cd030eee | 96 | } |
Vekotin | 0:98b5cd030eee | 97 | |
Vekotin | 0:98b5cd030eee | 98 | |
Vekotin | 0:98b5cd030eee | 99 | |
Vekotin | 0:98b5cd030eee | 100 |