MIDI Interface in progress
Dependencies: SPI_TFT_ILI9341 TFT_fonts Touch_tft PowerControl mbed USBMIDI
main.cpp@4:76c054f8b97e, 2014-02-06 (annotated)
- Committer:
- MetropoliaMies
- Date:
- Thu Feb 06 06:41:30 2014 +0000
- Revision:
- 4:76c054f8b97e
- Parent:
- 3:c8a476a218e3
- Child:
- 5:8e13103b41be
teeeeesti;
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 | buttons(i, color); |
MetropoliaMies | 4:76c054f8b97e | 24 | tft.locate(10,50); |
MetropoliaMies | 4:76c054f8b97e | 25 | printf("Shift"); |
Vekotin | 2:478274cba6c3 | 26 | |
Vekotin | 2:478274cba6c3 | 27 | } |
Vekotin | 2:478274cba6c3 | 28 | } |
Vekotin | 2:478274cba6c3 | 29 | |
MetropoliaMies | 4:76c054f8b97e | 30 | int main() |
MetropoliaMies | 4:76c054f8b97e | 31 | { |
MetropoliaMies | 4:76c054f8b97e | 32 | |
Vekotin | 2:478274cba6c3 | 33 | // PERUSPOHJA, ÄLÄ MUOKKAA! |
MetropoliaMies | 4:76c054f8b97e | 34 | |
Vekotin | 0:98b5cd030eee | 35 | point p; |
Vekotin | 0:98b5cd030eee | 36 | unsigned short color = White; |
MetropoliaMies | 4:76c054f8b97e | 37 | unsigned short color2 = Blue; |
MetropoliaMies | 4:76c054f8b97e | 38 | |
Vekotin | 0:98b5cd030eee | 39 | |
Vekotin | 0:98b5cd030eee | 40 | tft.claim(stdout); // send stdout to the TFT display |
Vekotin | 0:98b5cd030eee | 41 | tft.background(Black); // set background to black |
Vekotin | 0:98b5cd030eee | 42 | tft.foreground(White); // set chars to white |
Vekotin | 0:98b5cd030eee | 43 | tft.cls(); // clear the screen |
Vekotin | 2:478274cba6c3 | 44 | tft.set_font((unsigned char*) Arial12x12); // select the font |
MetropoliaMies | 4:76c054f8b97e | 45 | |
Vekotin | 0:98b5cd030eee | 46 | tft.set_orientation(0); |
Vekotin | 0:98b5cd030eee | 47 | tft.calibrate(); |
MetropoliaMies | 4:76c054f8b97e | 48 | |
MetropoliaMies | 4:76c054f8b97e | 49 | |
Vekotin | 2:478274cba6c3 | 50 | tft.locate(180,0); //show coordinates |
Vekotin | 2:478274cba6c3 | 51 | printf(" x = "); |
Vekotin | 2:478274cba6c3 | 52 | tft.locate(180,12); |
MetropoliaMies | 4:76c054f8b97e | 53 | printf(" y = "); |
MetropoliaMies | 4:76c054f8b97e | 54 | |
MetropoliaMies | 4:76c054f8b97e | 55 | tft.locate(85,0); |
MetropoliaMies | 4:76c054f8b97e | 56 | printf(" Octave = "); |
MetropoliaMies | 4:76c054f8b97e | 57 | tft.locate(85, 12); |
MetropoliaMies | 4:76c054f8b97e | 58 | printf(" Slider = "); |
MetropoliaMies | 4:76c054f8b97e | 59 | |
MetropoliaMies | 4:76c054f8b97e | 60 | |
MetropoliaMies | 4:76c054f8b97e | 61 | |
Vekotin | 0:98b5cd030eee | 62 | tft.locate(0,0); |
MetropoliaMies | 4:76c054f8b97e | 63 | printf(" MIDIMAN! "); |
MetropoliaMies | 4:76c054f8b97e | 64 | tft.line(0,83,239,83,White); |
MetropoliaMies | 4:76c054f8b97e | 65 | |
Vekotin | 0:98b5cd030eee | 66 | while (1) { |
MetropoliaMies | 4:76c054f8b97e | 67 | |
Vekotin | 0:98b5cd030eee | 68 | color = White; |
MetropoliaMies | 4:76c054f8b97e | 69 | draw_buttons(color); |
MetropoliaMies | 4:76c054f8b97e | 70 | |
MetropoliaMies | 4:76c054f8b97e | 71 | |
MetropoliaMies | 4:76c054f8b97e | 72 | |
MetropoliaMies | 4:76c054f8b97e | 73 | |
Vekotin | 1:7e2d93d70d2b | 74 | while (tft.is_touched(tft.get_touch())) { // touch |
MetropoliaMies | 4:76c054f8b97e | 75 | p = tft.get_touch(); |
Vekotin | 2:478274cba6c3 | 76 | p = tft.to_pixel(p); // convert to pixel position |
MetropoliaMies | 4:76c054f8b97e | 77 | |
MetropoliaMies | 4:76c054f8b97e | 78 | if (shift == 1) { |
MetropoliaMies | 4:76c054f8b97e | 79 | light_pressed2(color2, p); |
MetropoliaMies | 4:76c054f8b97e | 80 | } else { |
MetropoliaMies | 4:76c054f8b97e | 81 | light_pressed(color, p); |
MetropoliaMies | 4:76c054f8b97e | 82 | } |
MetropoliaMies | 4:76c054f8b97e | 83 | |
MetropoliaMies | 4:76c054f8b97e | 84 | |
MetropoliaMies | 3:c8a476a218e3 | 85 | tft.locate(210,0); |
Vekotin | 2:478274cba6c3 | 86 | printf("%3d",p.x); |
MetropoliaMies | 3:c8a476a218e3 | 87 | tft.locate(210,12); |
MetropoliaMies | 4:76c054f8b97e | 88 | printf("%3d",p.y); |
MetropoliaMies | 4:76c054f8b97e | 89 | |
MetropoliaMies | 4:76c054f8b97e | 90 | tft.locate(160, 0); |
MetropoliaMies | 4:76c054f8b97e | 91 | // printf("%3d", octave); |
MetropoliaMies | 4:76c054f8b97e | 92 | tft.locate(160, 12); |
MetropoliaMies | 4:76c054f8b97e | 93 | printf("%i", slider); |
Vekotin | 2:478274cba6c3 | 94 | |
MetropoliaMies | 4:76c054f8b97e | 95 | |
MetropoliaMies | 4:76c054f8b97e | 96 | |
MetropoliaMies | 4:76c054f8b97e | 97 | } |
MetropoliaMies | 4:76c054f8b97e | 98 | } |
MetropoliaMies | 4:76c054f8b97e | 99 | |
MetropoliaMies | 4:76c054f8b97e | 100 | |
Vekotin | 0:98b5cd030eee | 101 | } |
Vekotin | 0:98b5cd030eee | 102 | |
Vekotin | 0:98b5cd030eee | 103 | |
Vekotin | 0:98b5cd030eee | 104 | |
Vekotin | 0:98b5cd030eee | 105 |