Program of McLighTT
Dependencies: TS_DISCO_F746NG mbed LCD_DISCO_F746NG BSP_DISCO_F746NG DISCO_F746NG_USBDevice
main.cpp@0:cb5e943e3cf8, 2019-05-10 (annotated)
- Committer:
- Natthaphan
- Date:
- Fri May 10 13:45:29 2019 +0000
- Revision:
- 0:cb5e943e3cf8
McLighTT
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Natthaphan | 0:cb5e943e3cf8 | 1 | #include "mbed.h" |
Natthaphan | 0:cb5e943e3cf8 | 2 | #include "USBMIDI.h" |
Natthaphan | 0:cb5e943e3cf8 | 3 | #include "LCD_DISCO_F746NG.h" |
Natthaphan | 0:cb5e943e3cf8 | 4 | #include "TS_DISCO_F746NG.h" |
Natthaphan | 0:cb5e943e3cf8 | 5 | |
Natthaphan | 0:cb5e943e3cf8 | 6 | void set1(void); |
Natthaphan | 0:cb5e943e3cf8 | 7 | void set2(void); |
Natthaphan | 0:cb5e943e3cf8 | 8 | void set3(void); |
Natthaphan | 0:cb5e943e3cf8 | 9 | |
Natthaphan | 0:cb5e943e3cf8 | 10 | #define FastSpeedInterface 0 |
Natthaphan | 0:cb5e943e3cf8 | 11 | #define HighSpeedInterface 1 |
Natthaphan | 0:cb5e943e3cf8 | 12 | |
Natthaphan | 0:cb5e943e3cf8 | 13 | Ticker s1; |
Natthaphan | 0:cb5e943e3cf8 | 14 | Ticker s2; |
Natthaphan | 0:cb5e943e3cf8 | 15 | Ticker s3; |
Natthaphan | 0:cb5e943e3cf8 | 16 | |
Natthaphan | 0:cb5e943e3cf8 | 17 | USBMIDI midi(FastSpeedInterface); |
Natthaphan | 0:cb5e943e3cf8 | 18 | LCD_DISCO_F746NG lcd; |
Natthaphan | 0:cb5e943e3cf8 | 19 | TS_DISCO_F746NG ts; |
Natthaphan | 0:cb5e943e3cf8 | 20 | DigitalOut l1(D1),l2(D0),l3(D2); |
Natthaphan | 0:cb5e943e3cf8 | 21 | AnalogIn Ain0(A0),Ain1(A1),Ain2(A2),Ain3(A3),Ain4(A4); |
Natthaphan | 0:cb5e943e3cf8 | 22 | |
Natthaphan | 0:cb5e943e3cf8 | 23 | int a0=0; |
Natthaphan | 0:cb5e943e3cf8 | 24 | int a1=0; |
Natthaphan | 0:cb5e943e3cf8 | 25 | int a2=0; |
Natthaphan | 0:cb5e943e3cf8 | 26 | int a3=0; |
Natthaphan | 0:cb5e943e3cf8 | 27 | int a4=0; |
Natthaphan | 0:cb5e943e3cf8 | 28 | |
Natthaphan | 0:cb5e943e3cf8 | 29 | |
Natthaphan | 0:cb5e943e3cf8 | 30 | int last_a0=0; |
Natthaphan | 0:cb5e943e3cf8 | 31 | int last_a1=0; |
Natthaphan | 0:cb5e943e3cf8 | 32 | int last_a2=0; |
Natthaphan | 0:cb5e943e3cf8 | 33 | int last_a3=0; |
Natthaphan | 0:cb5e943e3cf8 | 34 | int last_a4=0; |
Natthaphan | 0:cb5e943e3cf8 | 35 | |
Natthaphan | 0:cb5e943e3cf8 | 36 | |
Natthaphan | 0:cb5e943e3cf8 | 37 | int main(){ |
Natthaphan | 0:cb5e943e3cf8 | 38 | TS_StateTypeDef TS_State; |
Natthaphan | 0:cb5e943e3cf8 | 39 | |
Natthaphan | 0:cb5e943e3cf8 | 40 | lcd.Clear(LCD_COLOR_WHITE); |
Natthaphan | 0:cb5e943e3cf8 | 41 | lcd.SetBackColor(LCD_COLOR_WHITE); |
Natthaphan | 0:cb5e943e3cf8 | 42 | |
Natthaphan | 0:cb5e943e3cf8 | 43 | |
Natthaphan | 0:cb5e943e3cf8 | 44 | lcd.SetTextColor(LCD_COLOR_DARKGREEN); |
Natthaphan | 0:cb5e943e3cf8 | 45 | lcd.FillEllipse(95,57,80,35); |
Natthaphan | 0:cb5e943e3cf8 | 46 | |
Natthaphan | 0:cb5e943e3cf8 | 47 | lcd.SetTextColor(LCD_COLOR_WHITE); |
Natthaphan | 0:cb5e943e3cf8 | 48 | lcd.FillRect(13,20,45,80); |
Natthaphan | 0:cb5e943e3cf8 | 49 | |
Natthaphan | 0:cb5e943e3cf8 | 50 | lcd.SetTextColor(LCD_COLOR_BLACK); |
Natthaphan | 0:cb5e943e3cf8 | 51 | lcd.FillRect(200,20,90,80); |
Natthaphan | 0:cb5e943e3cf8 | 52 | |
Natthaphan | 0:cb5e943e3cf8 | 53 | |
Natthaphan | 0:cb5e943e3cf8 | 54 | lcd.SetTextColor(LCD_COLOR_DARKRED); |
Natthaphan | 0:cb5e943e3cf8 | 55 | lcd.FillCircle(390,60,45); |
Natthaphan | 0:cb5e943e3cf8 | 56 | |
Natthaphan | 0:cb5e943e3cf8 | 57 | |
Natthaphan | 0:cb5e943e3cf8 | 58 | |
Natthaphan | 0:cb5e943e3cf8 | 59 | //set lcd to select sound |
Natthaphan | 0:cb5e943e3cf8 | 60 | lcd.SetTextColor(LCD_COLOR_YELLOW); |
Natthaphan | 0:cb5e943e3cf8 | 61 | lcd.FillRect(40,130,50,50); |
Natthaphan | 0:cb5e943e3cf8 | 62 | |
Natthaphan | 0:cb5e943e3cf8 | 63 | lcd.SetTextColor(LCD_COLOR_YELLOW); |
Natthaphan | 0:cb5e943e3cf8 | 64 | lcd.FillRect(40,210,50,50); |
Natthaphan | 0:cb5e943e3cf8 | 65 | |
Natthaphan | 0:cb5e943e3cf8 | 66 | lcd.SetTextColor(LCD_COLOR_YELLOW); |
Natthaphan | 0:cb5e943e3cf8 | 67 | lcd.FillRect(120,130,50,50); |
Natthaphan | 0:cb5e943e3cf8 | 68 | |
Natthaphan | 0:cb5e943e3cf8 | 69 | lcd.SetTextColor(LCD_COLOR_YELLOW); |
Natthaphan | 0:cb5e943e3cf8 | 70 | lcd.FillRect(120,210,50,50); |
Natthaphan | 0:cb5e943e3cf8 | 71 | |
Natthaphan | 0:cb5e943e3cf8 | 72 | lcd.SetTextColor(LCD_COLOR_YELLOW); |
Natthaphan | 0:cb5e943e3cf8 | 73 | lcd.FillRect(200,130,50,50); |
Natthaphan | 0:cb5e943e3cf8 | 74 | |
Natthaphan | 0:cb5e943e3cf8 | 75 | lcd.SetTextColor(LCD_COLOR_YELLOW); |
Natthaphan | 0:cb5e943e3cf8 | 76 | lcd.FillRect(200,210,50,50); |
Natthaphan | 0:cb5e943e3cf8 | 77 | |
Natthaphan | 0:cb5e943e3cf8 | 78 | lcd.SetTextColor(LCD_COLOR_YELLOW); |
Natthaphan | 0:cb5e943e3cf8 | 79 | lcd.FillRect(280,130,50,50); |
Natthaphan | 0:cb5e943e3cf8 | 80 | |
Natthaphan | 0:cb5e943e3cf8 | 81 | lcd.SetTextColor(LCD_COLOR_YELLOW); |
Natthaphan | 0:cb5e943e3cf8 | 82 | lcd.FillRect(280,210,50,50); |
Natthaphan | 0:cb5e943e3cf8 | 83 | |
Natthaphan | 0:cb5e943e3cf8 | 84 | //mute midi |
Natthaphan | 0:cb5e943e3cf8 | 85 | |
Natthaphan | 0:cb5e943e3cf8 | 86 | lcd.SetTextColor(LCD_COLOR_ORANGE); |
Natthaphan | 0:cb5e943e3cf8 | 87 | lcd.FillRect(360,155,80,80); |
Natthaphan | 0:cb5e943e3cf8 | 88 | |
Natthaphan | 0:cb5e943e3cf8 | 89 | |
Natthaphan | 0:cb5e943e3cf8 | 90 | //write message |
Natthaphan | 0:cb5e943e3cf8 | 91 | |
Natthaphan | 0:cb5e943e3cf8 | 92 | lcd.SetBackColor(LCD_COLOR_DARKGREEN); |
Natthaphan | 0:cb5e943e3cf8 | 93 | lcd.SetTextColor(LCD_COLOR_WHITE); |
Natthaphan | 0:cb5e943e3cf8 | 94 | lcd.DisplayStringAt(75,50,(uint8_t*)"PLAY",LEFT_MODE); |
Natthaphan | 0:cb5e943e3cf8 | 95 | |
Natthaphan | 0:cb5e943e3cf8 | 96 | lcd.SetBackColor(LCD_COLOR_BLACK); |
Natthaphan | 0:cb5e943e3cf8 | 97 | lcd.SetTextColor(LCD_COLOR_WHITE); |
Natthaphan | 0:cb5e943e3cf8 | 98 | lcd.DisplayStringAt(205,50,(uint8_t*)"PAUSE",LEFT_MODE); |
Natthaphan | 0:cb5e943e3cf8 | 99 | |
Natthaphan | 0:cb5e943e3cf8 | 100 | lcd.SetBackColor(LCD_COLOR_DARKRED); |
Natthaphan | 0:cb5e943e3cf8 | 101 | lcd.SetTextColor(LCD_COLOR_WHITE); |
Natthaphan | 0:cb5e943e3cf8 | 102 | lcd.DisplayStringAt(366,55,(uint8_t*)"REC",LEFT_MODE); |
Natthaphan | 0:cb5e943e3cf8 | 103 | |
Natthaphan | 0:cb5e943e3cf8 | 104 | |
Natthaphan | 0:cb5e943e3cf8 | 105 | lcd.SetBackColor(LCD_COLOR_ORANGE); |
Natthaphan | 0:cb5e943e3cf8 | 106 | lcd.SetTextColor(LCD_COLOR_WHITE); |
Natthaphan | 0:cb5e943e3cf8 | 107 | lcd.DisplayStringAt(375,187,(uint8_t*)"OFF",LEFT_MODE); |
Natthaphan | 0:cb5e943e3cf8 | 108 | |
Natthaphan | 0:cb5e943e3cf8 | 109 | |
Natthaphan | 0:cb5e943e3cf8 | 110 | |
Natthaphan | 0:cb5e943e3cf8 | 111 | lcd.SetBackColor(LCD_COLOR_YELLOW); |
Natthaphan | 0:cb5e943e3cf8 | 112 | lcd.SetTextColor(LCD_COLOR_BLACK); |
Natthaphan | 0:cb5e943e3cf8 | 113 | lcd.DisplayStringAt(58,145,(uint8_t*)"1",LEFT_MODE); |
Natthaphan | 0:cb5e943e3cf8 | 114 | lcd.DisplayStringAt(58,225,(uint8_t*)"5",LEFT_MODE); |
Natthaphan | 0:cb5e943e3cf8 | 115 | lcd.DisplayStringAt(138,145,(uint8_t*)"2",LEFT_MODE); |
Natthaphan | 0:cb5e943e3cf8 | 116 | lcd.DisplayStringAt(138,225,(uint8_t*)"6",LEFT_MODE); |
Natthaphan | 0:cb5e943e3cf8 | 117 | lcd.DisplayStringAt(218,145,(uint8_t*)"3",LEFT_MODE); |
Natthaphan | 0:cb5e943e3cf8 | 118 | lcd.DisplayStringAt(218,225,(uint8_t*)"7",LEFT_MODE); |
Natthaphan | 0:cb5e943e3cf8 | 119 | lcd.DisplayStringAt(298,145,(uint8_t*)"4",LEFT_MODE); |
Natthaphan | 0:cb5e943e3cf8 | 120 | lcd.DisplayStringAt(298,225,(uint8_t*)"8",LEFT_MODE); |
Natthaphan | 0:cb5e943e3cf8 | 121 | |
Natthaphan | 0:cb5e943e3cf8 | 122 | s2.attach(&set2,0.1); |
Natthaphan | 0:cb5e943e3cf8 | 123 | while(1){ |
Natthaphan | 0:cb5e943e3cf8 | 124 | |
Natthaphan | 0:cb5e943e3cf8 | 125 | a0=((Ain0.read()*(127))-10); |
Natthaphan | 0:cb5e943e3cf8 | 126 | a1=((Ain1.read()*(-127))+5); |
Natthaphan | 0:cb5e943e3cf8 | 127 | a2=((Ain2.read()*(-127))+5); |
Natthaphan | 0:cb5e943e3cf8 | 128 | a3=((Ain3.read()*(-127))+10); |
Natthaphan | 0:cb5e943e3cf8 | 129 | a4=((Ain4.read()*(-127))+10); |
Natthaphan | 0:cb5e943e3cf8 | 130 | ts.GetState(&TS_State); |
Natthaphan | 0:cb5e943e3cf8 | 131 | if((TS_State.touchDetected)) |
Natthaphan | 0:cb5e943e3cf8 | 132 | { |
Natthaphan | 0:cb5e943e3cf8 | 133 | //Play |
Natthaphan | 0:cb5e943e3cf8 | 134 | if(TS_State.touchY[0]>20&TS_State.touchY[0]<100&TS_State.touchX[0]>58&TS_State.touchX[0]<170) |
Natthaphan | 0:cb5e943e3cf8 | 135 | { |
Natthaphan | 0:cb5e943e3cf8 | 136 | s2.detach(); |
Natthaphan | 0:cb5e943e3cf8 | 137 | s3.detach(); |
Natthaphan | 0:cb5e943e3cf8 | 138 | s1.attach(&set3,0.3); |
Natthaphan | 0:cb5e943e3cf8 | 139 | midi.write(MIDIMessage::ControlChange(7,1)); |
Natthaphan | 0:cb5e943e3cf8 | 140 | } |
Natthaphan | 0:cb5e943e3cf8 | 141 | |
Natthaphan | 0:cb5e943e3cf8 | 142 | //Pause |
Natthaphan | 0:cb5e943e3cf8 | 143 | if(TS_State.touchY[0]>20&TS_State.touchY[0]<100&TS_State.touchX[0]>200&TS_State.touchX[0]<280) |
Natthaphan | 0:cb5e943e3cf8 | 144 | { |
Natthaphan | 0:cb5e943e3cf8 | 145 | s1.detach(); |
Natthaphan | 0:cb5e943e3cf8 | 146 | s3.detach(); |
Natthaphan | 0:cb5e943e3cf8 | 147 | s2.attach(&set2,0.1); |
Natthaphan | 0:cb5e943e3cf8 | 148 | midi.write(MIDIMessage::ControlChange(8,1)); |
Natthaphan | 0:cb5e943e3cf8 | 149 | } |
Natthaphan | 0:cb5e943e3cf8 | 150 | |
Natthaphan | 0:cb5e943e3cf8 | 151 | //REC |
Natthaphan | 0:cb5e943e3cf8 | 152 | if(TS_State.touchY[0]>20&TS_State.touchY[0]<100&TS_State.touchX[0]>345&TS_State.touchX[0]<435) |
Natthaphan | 0:cb5e943e3cf8 | 153 | { |
Natthaphan | 0:cb5e943e3cf8 | 154 | midi.write(MIDIMessage::ControlChange(9,1)); |
Natthaphan | 0:cb5e943e3cf8 | 155 | s1.detach(); |
Natthaphan | 0:cb5e943e3cf8 | 156 | s2.detach(); |
Natthaphan | 0:cb5e943e3cf8 | 157 | s3.attach(&set1,0.2); |
Natthaphan | 0:cb5e943e3cf8 | 158 | } |
Natthaphan | 0:cb5e943e3cf8 | 159 | |
Natthaphan | 0:cb5e943e3cf8 | 160 | // select sound |
Natthaphan | 0:cb5e943e3cf8 | 161 | //1 |
Natthaphan | 0:cb5e943e3cf8 | 162 | if(TS_State.touchY[0]>130&TS_State.touchY[0]<180&TS_State.touchX[0]>40&TS_State.touchX[0]<90) |
Natthaphan | 0:cb5e943e3cf8 | 163 | { |
Natthaphan | 0:cb5e943e3cf8 | 164 | midi.write(MIDIMessage::NoteOn(127)); |
Natthaphan | 0:cb5e943e3cf8 | 165 | wait(1); |
Natthaphan | 0:cb5e943e3cf8 | 166 | l1=0; |
Natthaphan | 0:cb5e943e3cf8 | 167 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 168 | l1=1; |
Natthaphan | 0:cb5e943e3cf8 | 169 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 170 | l2=0; |
Natthaphan | 0:cb5e943e3cf8 | 171 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 172 | l2=1; |
Natthaphan | 0:cb5e943e3cf8 | 173 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 174 | l3=0; |
Natthaphan | 0:cb5e943e3cf8 | 175 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 176 | l3=1; |
Natthaphan | 0:cb5e943e3cf8 | 177 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 178 | } |
Natthaphan | 0:cb5e943e3cf8 | 179 | |
Natthaphan | 0:cb5e943e3cf8 | 180 | //2 |
Natthaphan | 0:cb5e943e3cf8 | 181 | if(TS_State.touchY[0]>210&TS_State.touchY[0]<260&TS_State.touchX[0]>40&TS_State.touchX[0]<90) |
Natthaphan | 0:cb5e943e3cf8 | 182 | { |
Natthaphan | 0:cb5e943e3cf8 | 183 | midi.write(MIDIMessage::NoteOn(126)); |
Natthaphan | 0:cb5e943e3cf8 | 184 | wait(1); |
Natthaphan | 0:cb5e943e3cf8 | 185 | l1=0; |
Natthaphan | 0:cb5e943e3cf8 | 186 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 187 | l1=1; |
Natthaphan | 0:cb5e943e3cf8 | 188 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 189 | l2=0; |
Natthaphan | 0:cb5e943e3cf8 | 190 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 191 | l2=1; |
Natthaphan | 0:cb5e943e3cf8 | 192 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 193 | l3=0; |
Natthaphan | 0:cb5e943e3cf8 | 194 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 195 | l3=1; |
Natthaphan | 0:cb5e943e3cf8 | 196 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 197 | } |
Natthaphan | 0:cb5e943e3cf8 | 198 | |
Natthaphan | 0:cb5e943e3cf8 | 199 | //3 |
Natthaphan | 0:cb5e943e3cf8 | 200 | if(TS_State.touchY[0]>130&TS_State.touchY[0]<180&TS_State.touchX[0]>120&TS_State.touchX[0]<170) |
Natthaphan | 0:cb5e943e3cf8 | 201 | { |
Natthaphan | 0:cb5e943e3cf8 | 202 | midi.write(MIDIMessage::NoteOn(125)); |
Natthaphan | 0:cb5e943e3cf8 | 203 | wait(1); |
Natthaphan | 0:cb5e943e3cf8 | 204 | l1=0; |
Natthaphan | 0:cb5e943e3cf8 | 205 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 206 | l1=1; |
Natthaphan | 0:cb5e943e3cf8 | 207 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 208 | l2=0; |
Natthaphan | 0:cb5e943e3cf8 | 209 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 210 | l2=1; |
Natthaphan | 0:cb5e943e3cf8 | 211 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 212 | l3=0; |
Natthaphan | 0:cb5e943e3cf8 | 213 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 214 | l3=1; |
Natthaphan | 0:cb5e943e3cf8 | 215 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 216 | } |
Natthaphan | 0:cb5e943e3cf8 | 217 | |
Natthaphan | 0:cb5e943e3cf8 | 218 | //4 |
Natthaphan | 0:cb5e943e3cf8 | 219 | if(TS_State.touchY[0]>210&TS_State.touchY[0]<260&TS_State.touchX[0]>120&TS_State.touchX[0]<170) |
Natthaphan | 0:cb5e943e3cf8 | 220 | { |
Natthaphan | 0:cb5e943e3cf8 | 221 | midi.write(MIDIMessage::NoteOn(124)); |
Natthaphan | 0:cb5e943e3cf8 | 222 | wait(1); |
Natthaphan | 0:cb5e943e3cf8 | 223 | l1=0; |
Natthaphan | 0:cb5e943e3cf8 | 224 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 225 | l1=1; |
Natthaphan | 0:cb5e943e3cf8 | 226 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 227 | l2=0; |
Natthaphan | 0:cb5e943e3cf8 | 228 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 229 | l2=1; |
Natthaphan | 0:cb5e943e3cf8 | 230 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 231 | l3=0; |
Natthaphan | 0:cb5e943e3cf8 | 232 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 233 | l3=1; |
Natthaphan | 0:cb5e943e3cf8 | 234 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 235 | } |
Natthaphan | 0:cb5e943e3cf8 | 236 | |
Natthaphan | 0:cb5e943e3cf8 | 237 | //5 |
Natthaphan | 0:cb5e943e3cf8 | 238 | if(TS_State.touchY[0]>130&TS_State.touchY[0]<180&TS_State.touchX[0]>200&TS_State.touchX[0]<250) |
Natthaphan | 0:cb5e943e3cf8 | 239 | { |
Natthaphan | 0:cb5e943e3cf8 | 240 | midi.write(MIDIMessage::NoteOn(123)); |
Natthaphan | 0:cb5e943e3cf8 | 241 | wait(1); |
Natthaphan | 0:cb5e943e3cf8 | 242 | l1=0; |
Natthaphan | 0:cb5e943e3cf8 | 243 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 244 | l1=1; |
Natthaphan | 0:cb5e943e3cf8 | 245 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 246 | l2=0; |
Natthaphan | 0:cb5e943e3cf8 | 247 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 248 | l2=1; |
Natthaphan | 0:cb5e943e3cf8 | 249 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 250 | l3=0; |
Natthaphan | 0:cb5e943e3cf8 | 251 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 252 | l3=1; |
Natthaphan | 0:cb5e943e3cf8 | 253 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 254 | } |
Natthaphan | 0:cb5e943e3cf8 | 255 | |
Natthaphan | 0:cb5e943e3cf8 | 256 | //6 |
Natthaphan | 0:cb5e943e3cf8 | 257 | if(TS_State.touchY[0]>210&TS_State.touchY[0]<260&TS_State.touchX[0]>200&TS_State.touchX[0]<250) |
Natthaphan | 0:cb5e943e3cf8 | 258 | { |
Natthaphan | 0:cb5e943e3cf8 | 259 | midi.write(MIDIMessage::NoteOn(122)); |
Natthaphan | 0:cb5e943e3cf8 | 260 | wait(1); |
Natthaphan | 0:cb5e943e3cf8 | 261 | l1=0; |
Natthaphan | 0:cb5e943e3cf8 | 262 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 263 | l1=1; |
Natthaphan | 0:cb5e943e3cf8 | 264 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 265 | l2=0; |
Natthaphan | 0:cb5e943e3cf8 | 266 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 267 | l2=1; |
Natthaphan | 0:cb5e943e3cf8 | 268 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 269 | l3=0; |
Natthaphan | 0:cb5e943e3cf8 | 270 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 271 | l3=1; |
Natthaphan | 0:cb5e943e3cf8 | 272 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 273 | } |
Natthaphan | 0:cb5e943e3cf8 | 274 | |
Natthaphan | 0:cb5e943e3cf8 | 275 | //7 |
Natthaphan | 0:cb5e943e3cf8 | 276 | if(TS_State.touchY[0]>130&TS_State.touchY[0]<180&TS_State.touchX[0]>280&TS_State.touchX[0]<330) |
Natthaphan | 0:cb5e943e3cf8 | 277 | { |
Natthaphan | 0:cb5e943e3cf8 | 278 | midi.write(MIDIMessage::NoteOn(121)); |
Natthaphan | 0:cb5e943e3cf8 | 279 | wait(1); |
Natthaphan | 0:cb5e943e3cf8 | 280 | l1=0; |
Natthaphan | 0:cb5e943e3cf8 | 281 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 282 | l1=1; |
Natthaphan | 0:cb5e943e3cf8 | 283 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 284 | l2=0; |
Natthaphan | 0:cb5e943e3cf8 | 285 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 286 | l2=1; |
Natthaphan | 0:cb5e943e3cf8 | 287 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 288 | l3=0; |
Natthaphan | 0:cb5e943e3cf8 | 289 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 290 | l3=1; |
Natthaphan | 0:cb5e943e3cf8 | 291 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 292 | } |
Natthaphan | 0:cb5e943e3cf8 | 293 | |
Natthaphan | 0:cb5e943e3cf8 | 294 | //8 |
Natthaphan | 0:cb5e943e3cf8 | 295 | if(TS_State.touchY[0]>210&TS_State.touchY[0]<260&TS_State.touchX[0]>280&TS_State.touchX[0]<330) |
Natthaphan | 0:cb5e943e3cf8 | 296 | { |
Natthaphan | 0:cb5e943e3cf8 | 297 | midi.write(MIDIMessage::NoteOn(120)); |
Natthaphan | 0:cb5e943e3cf8 | 298 | wait(1); |
Natthaphan | 0:cb5e943e3cf8 | 299 | l1=0; |
Natthaphan | 0:cb5e943e3cf8 | 300 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 301 | l1=1; |
Natthaphan | 0:cb5e943e3cf8 | 302 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 303 | l2=0; |
Natthaphan | 0:cb5e943e3cf8 | 304 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 305 | l2=1; |
Natthaphan | 0:cb5e943e3cf8 | 306 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 307 | l3=0; |
Natthaphan | 0:cb5e943e3cf8 | 308 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 309 | l3=1; |
Natthaphan | 0:cb5e943e3cf8 | 310 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 311 | } |
Natthaphan | 0:cb5e943e3cf8 | 312 | |
Natthaphan | 0:cb5e943e3cf8 | 313 | //off |
Natthaphan | 0:cb5e943e3cf8 | 314 | if(TS_State.touchY[0]>155&TS_State.touchY[0]<235&TS_State.touchX[0]>360&TS_State.touchX[0]<440) |
Natthaphan | 0:cb5e943e3cf8 | 315 | { |
Natthaphan | 0:cb5e943e3cf8 | 316 | midi.write(MIDIMessage::NoteOn(119)); |
Natthaphan | 0:cb5e943e3cf8 | 317 | wait(1); |
Natthaphan | 0:cb5e943e3cf8 | 318 | |
Natthaphan | 0:cb5e943e3cf8 | 319 | l1=0; |
Natthaphan | 0:cb5e943e3cf8 | 320 | wait(0.5); |
Natthaphan | 0:cb5e943e3cf8 | 321 | l1=1; |
Natthaphan | 0:cb5e943e3cf8 | 322 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 323 | l2=0; |
Natthaphan | 0:cb5e943e3cf8 | 324 | wait(0.4); |
Natthaphan | 0:cb5e943e3cf8 | 325 | l2=1; |
Natthaphan | 0:cb5e943e3cf8 | 326 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 327 | l3=0; |
Natthaphan | 0:cb5e943e3cf8 | 328 | wait(0.3); |
Natthaphan | 0:cb5e943e3cf8 | 329 | l3=1; |
Natthaphan | 0:cb5e943e3cf8 | 330 | wait(0.1); |
Natthaphan | 0:cb5e943e3cf8 | 331 | |
Natthaphan | 0:cb5e943e3cf8 | 332 | } |
Natthaphan | 0:cb5e943e3cf8 | 333 | } |
Natthaphan | 0:cb5e943e3cf8 | 334 | |
Natthaphan | 0:cb5e943e3cf8 | 335 | |
Natthaphan | 0:cb5e943e3cf8 | 336 | else{ |
Natthaphan | 0:cb5e943e3cf8 | 337 | |
Natthaphan | 0:cb5e943e3cf8 | 338 | |
Natthaphan | 0:cb5e943e3cf8 | 339 | //Write MIDI |
Natthaphan | 0:cb5e943e3cf8 | 340 | |
Natthaphan | 0:cb5e943e3cf8 | 341 | |
Natthaphan | 0:cb5e943e3cf8 | 342 | //a0 |
Natthaphan | 0:cb5e943e3cf8 | 343 | if(a0!=last_a0){ |
Natthaphan | 0:cb5e943e3cf8 | 344 | last_a0=a0; |
Natthaphan | 0:cb5e943e3cf8 | 345 | |
Natthaphan | 0:cb5e943e3cf8 | 346 | midi.write(MIDIMessage::ControlChange(1,a0)); |
Natthaphan | 0:cb5e943e3cf8 | 347 | wait(0.008); |
Natthaphan | 0:cb5e943e3cf8 | 348 | } |
Natthaphan | 0:cb5e943e3cf8 | 349 | //a1 |
Natthaphan | 0:cb5e943e3cf8 | 350 | if(a1!=last_a1){ |
Natthaphan | 0:cb5e943e3cf8 | 351 | last_a1=a1; |
Natthaphan | 0:cb5e943e3cf8 | 352 | |
Natthaphan | 0:cb5e943e3cf8 | 353 | midi.write(MIDIMessage::ControlChange(2,a1)); |
Natthaphan | 0:cb5e943e3cf8 | 354 | wait(0.008); |
Natthaphan | 0:cb5e943e3cf8 | 355 | } |
Natthaphan | 0:cb5e943e3cf8 | 356 | //a2 |
Natthaphan | 0:cb5e943e3cf8 | 357 | |
Natthaphan | 0:cb5e943e3cf8 | 358 | if(a2!=last_a2){ |
Natthaphan | 0:cb5e943e3cf8 | 359 | last_a2=a2; |
Natthaphan | 0:cb5e943e3cf8 | 360 | |
Natthaphan | 0:cb5e943e3cf8 | 361 | midi.write(MIDIMessage::ControlChange(3,a2)); |
Natthaphan | 0:cb5e943e3cf8 | 362 | wait(0.008); |
Natthaphan | 0:cb5e943e3cf8 | 363 | } |
Natthaphan | 0:cb5e943e3cf8 | 364 | //a3 |
Natthaphan | 0:cb5e943e3cf8 | 365 | if(a3!=last_a3){ |
Natthaphan | 0:cb5e943e3cf8 | 366 | last_a3=a3; |
Natthaphan | 0:cb5e943e3cf8 | 367 | |
Natthaphan | 0:cb5e943e3cf8 | 368 | midi.write(MIDIMessage::ControlChange(4,a3)); |
Natthaphan | 0:cb5e943e3cf8 | 369 | wait(0.008); |
Natthaphan | 0:cb5e943e3cf8 | 370 | } |
Natthaphan | 0:cb5e943e3cf8 | 371 | //a4 |
Natthaphan | 0:cb5e943e3cf8 | 372 | if(a4!=last_a4){ |
Natthaphan | 0:cb5e943e3cf8 | 373 | last_a4=a4; |
Natthaphan | 0:cb5e943e3cf8 | 374 | |
Natthaphan | 0:cb5e943e3cf8 | 375 | midi.write(MIDIMessage::ControlChange(5,a4)); |
Natthaphan | 0:cb5e943e3cf8 | 376 | wait(0.008); |
Natthaphan | 0:cb5e943e3cf8 | 377 | } |
Natthaphan | 0:cb5e943e3cf8 | 378 | }} |
Natthaphan | 0:cb5e943e3cf8 | 379 | } |
Natthaphan | 0:cb5e943e3cf8 | 380 | //red |
Natthaphan | 0:cb5e943e3cf8 | 381 | void set1(){ |
Natthaphan | 0:cb5e943e3cf8 | 382 | l1=!l1; |
Natthaphan | 0:cb5e943e3cf8 | 383 | l2=1; |
Natthaphan | 0:cb5e943e3cf8 | 384 | l3=1; |
Natthaphan | 0:cb5e943e3cf8 | 385 | } |
Natthaphan | 0:cb5e943e3cf8 | 386 | |
Natthaphan | 0:cb5e943e3cf8 | 387 | //blue |
Natthaphan | 0:cb5e943e3cf8 | 388 | void set2(){ |
Natthaphan | 0:cb5e943e3cf8 | 389 | l1=1; |
Natthaphan | 0:cb5e943e3cf8 | 390 | l2=0; |
Natthaphan | 0:cb5e943e3cf8 | 391 | l3=1; |
Natthaphan | 0:cb5e943e3cf8 | 392 | } |
Natthaphan | 0:cb5e943e3cf8 | 393 | |
Natthaphan | 0:cb5e943e3cf8 | 394 | |
Natthaphan | 0:cb5e943e3cf8 | 395 | //green |
Natthaphan | 0:cb5e943e3cf8 | 396 | void set3(){ |
Natthaphan | 0:cb5e943e3cf8 | 397 | l1=1; |
Natthaphan | 0:cb5e943e3cf8 | 398 | l2=1; |
Natthaphan | 0:cb5e943e3cf8 | 399 | l3=0; |
Natthaphan | 0:cb5e943e3cf8 | 400 | } |
Natthaphan | 0:cb5e943e3cf8 | 401 | |
Natthaphan | 0:cb5e943e3cf8 | 402 | |
Natthaphan | 0:cb5e943e3cf8 | 403 | |
Natthaphan | 0:cb5e943e3cf8 | 404 | |
Natthaphan | 0:cb5e943e3cf8 | 405 | |
Natthaphan | 0:cb5e943e3cf8 | 406 |