![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
t
Dependencies: mbed wave_player mbed-rtos C12832_lcd 4DGL-uLCD-SE LCD_fonts SDFileSystem
main.cpp@3:431877852f14, 2019-12-04 (annotated)
- Committer:
- yqin70
- Date:
- Wed Dec 04 18:09:19 2019 +0000
- Revision:
- 3:431877852f14
- Parent:
- 2:765774781bb1
- Child:
- 4:59b73f321c0e
w/ songs
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
yqin70 | 0:4f77ae831ee7 | 1 | #include "mbed.h" |
yqin70 | 0:4f77ae831ee7 | 2 | #include "SDFileSystem.h" |
yqin70 | 0:4f77ae831ee7 | 3 | #include "wave_player.h" |
yqin70 | 0:4f77ae831ee7 | 4 | #include "uLCD_4DGL.h" |
yqin70 | 0:4f77ae831ee7 | 5 | //setup some color objects in flash using const's |
yqin70 | 0:4f77ae831ee7 | 6 | |
yqin70 | 0:4f77ae831ee7 | 7 | #include "rtos.h" |
yqin70 | 0:4f77ae831ee7 | 8 | #include "Small_6.h" |
yqin70 | 0:4f77ae831ee7 | 9 | #include "Small_7.h" |
yqin70 | 0:4f77ae831ee7 | 10 | #include "Arial_9.h" |
yqin70 | 0:4f77ae831ee7 | 11 | #include "stdio.h" |
yqin70 | 0:4f77ae831ee7 | 12 | #include "C12832_lcd.h" |
yqin70 | 0:4f77ae831ee7 | 13 | |
yqin70 | 0:4f77ae831ee7 | 14 | //class for 3 PWM color values for RGBLED |
yqin70 | 0:4f77ae831ee7 | 15 | class LEDColor |
yqin70 | 0:4f77ae831ee7 | 16 | { |
yqin70 | 0:4f77ae831ee7 | 17 | public: |
yqin70 | 0:4f77ae831ee7 | 18 | LEDColor(float r, float g, float b); |
yqin70 | 0:4f77ae831ee7 | 19 | float red; |
yqin70 | 0:4f77ae831ee7 | 20 | float green; |
yqin70 | 0:4f77ae831ee7 | 21 | float blue; |
yqin70 | 0:4f77ae831ee7 | 22 | }; |
yqin70 | 0:4f77ae831ee7 | 23 | LEDColor:: LEDColor(float r, float g, float b) |
yqin70 | 0:4f77ae831ee7 | 24 | : red(r), green(g), blue(b) |
yqin70 | 0:4f77ae831ee7 | 25 | { |
yqin70 | 0:4f77ae831ee7 | 26 | } |
yqin70 | 0:4f77ae831ee7 | 27 | //Operator overload to adjust brightness with no color change |
yqin70 | 0:4f77ae831ee7 | 28 | LEDColor operator * (const LEDColor& x, const float& b) |
yqin70 | 0:4f77ae831ee7 | 29 | { |
yqin70 | 0:4f77ae831ee7 | 30 | return LEDColor(x.red*b,x.green*b,x.blue*b); |
yqin70 | 0:4f77ae831ee7 | 31 | } |
yqin70 | 0:4f77ae831ee7 | 32 | //Operator overload to add colors |
yqin70 | 0:4f77ae831ee7 | 33 | LEDColor operator + (const LEDColor& x, const LEDColor& y) |
yqin70 | 0:4f77ae831ee7 | 34 | { |
yqin70 | 0:4f77ae831ee7 | 35 | return LEDColor(x.red+y.red,x.green+y.green,x.blue+y.blue); |
yqin70 | 0:4f77ae831ee7 | 36 | } |
yqin70 | 0:4f77ae831ee7 | 37 | |
yqin70 | 0:4f77ae831ee7 | 38 | //Class to control an RGB LED using three PWM pins |
yqin70 | 0:4f77ae831ee7 | 39 | class RGBLed |
yqin70 | 0:4f77ae831ee7 | 40 | { |
yqin70 | 0:4f77ae831ee7 | 41 | public: |
yqin70 | 0:4f77ae831ee7 | 42 | RGBLed(PinName redpin, PinName greenpin, PinName bluepin); |
yqin70 | 0:4f77ae831ee7 | 43 | void write(float red,float green, float blue); |
yqin70 | 0:4f77ae831ee7 | 44 | void write(LEDColor c); |
yqin70 | 0:4f77ae831ee7 | 45 | RGBLed operator = (LEDColor c) { |
yqin70 | 0:4f77ae831ee7 | 46 | write(c); |
yqin70 | 0:4f77ae831ee7 | 47 | return *this; |
yqin70 | 0:4f77ae831ee7 | 48 | }; |
yqin70 | 0:4f77ae831ee7 | 49 | private: |
yqin70 | 0:4f77ae831ee7 | 50 | PwmOut _redpin; |
yqin70 | 0:4f77ae831ee7 | 51 | PwmOut _greenpin; |
yqin70 | 0:4f77ae831ee7 | 52 | PwmOut _bluepin; |
yqin70 | 0:4f77ae831ee7 | 53 | }; |
yqin70 | 0:4f77ae831ee7 | 54 | |
yqin70 | 0:4f77ae831ee7 | 55 | RGBLed::RGBLed (PinName redpin, PinName greenpin, PinName bluepin) |
yqin70 | 0:4f77ae831ee7 | 56 | : _redpin(redpin), _greenpin(greenpin), _bluepin(bluepin) |
yqin70 | 0:4f77ae831ee7 | 57 | { |
yqin70 | 0:4f77ae831ee7 | 58 | //50Hz PWM clock default a bit too low, go to 2000Hz (less flicker) |
yqin70 | 0:4f77ae831ee7 | 59 | _redpin.period(0.0005); |
yqin70 | 0:4f77ae831ee7 | 60 | } |
yqin70 | 0:4f77ae831ee7 | 61 | |
yqin70 | 0:4f77ae831ee7 | 62 | void RGBLed::write(float red,float green, float blue) |
yqin70 | 0:4f77ae831ee7 | 63 | { |
yqin70 | 0:4f77ae831ee7 | 64 | _redpin = red; |
yqin70 | 0:4f77ae831ee7 | 65 | _greenpin = green; |
yqin70 | 0:4f77ae831ee7 | 66 | _bluepin = blue; |
yqin70 | 0:4f77ae831ee7 | 67 | } |
yqin70 | 0:4f77ae831ee7 | 68 | void RGBLed::write(LEDColor c) |
yqin70 | 0:4f77ae831ee7 | 69 | { |
yqin70 | 0:4f77ae831ee7 | 70 | _redpin = c.red; |
yqin70 | 0:4f77ae831ee7 | 71 | _greenpin = c.green; |
yqin70 | 0:4f77ae831ee7 | 72 | _bluepin = c.blue; |
yqin70 | 0:4f77ae831ee7 | 73 | } |
yqin70 | 0:4f77ae831ee7 | 74 | |
yqin70 | 0:4f77ae831ee7 | 75 | //classes could be moved to include file |
yqin70 | 0:4f77ae831ee7 | 76 | |
yqin70 | 0:4f77ae831ee7 | 77 | //Setup RGB led using PWM pins and class |
yqin70 | 0:4f77ae831ee7 | 78 | RGBLed myRGBled(p23,p22,p21); //RGB PWM pins |
yqin70 | 0:4f77ae831ee7 | 79 | const LEDColor red(1.0,0.0,0.0); |
yqin70 | 0:4f77ae831ee7 | 80 | const LEDColor green(0.0,0.2,0.0); |
yqin70 | 0:4f77ae831ee7 | 81 | //brighter green LED is scaled down to same as red and |
yqin70 | 0:4f77ae831ee7 | 82 | //blue LED outputs on Sparkfun RGBLED |
yqin70 | 0:4f77ae831ee7 | 83 | const LEDColor blue(0.0,0.0,1.0); |
yqin70 | 0:4f77ae831ee7 | 84 | const LEDColor yellow(1.0,0.2,0.0); |
yqin70 | 0:4f77ae831ee7 | 85 | const LEDColor white(1.0,0.2,1.0); |
yqin70 | 0:4f77ae831ee7 | 86 | const LEDColor black(0.0,0.0,0.0); |
yqin70 | 0:4f77ae831ee7 | 87 | char bred=0; |
yqin70 | 0:4f77ae831ee7 | 88 | char bgreen=0; |
yqin70 | 0:4f77ae831ee7 | 89 | char bblue=0; |
yqin70 | 0:4f77ae831ee7 | 90 | |
yqin70 | 0:4f77ae831ee7 | 91 | volatile bool songselect = false; |
yqin70 | 0:4f77ae831ee7 | 92 | volatile bool homescreen = true; |
yqin70 | 0:4f77ae831ee7 | 93 | uLCD_4DGL uLCD(p28,p27,p30); |
yqin70 | 0:4f77ae831ee7 | 94 | SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card |
yqin70 | 0:4f77ae831ee7 | 95 | DigitalOut myled(LED1); |
yqin70 | 0:4f77ae831ee7 | 96 | DigitalIn pb1(p20); |
yqin70 | 0:4f77ae831ee7 | 97 | DigitalIn pb2(p19); |
yqin70 | 1:a1aa9a79070a | 98 | AnalogOut DACout(p18); |
yqin70 | 1:a1aa9a79070a | 99 | wave_player waver(&DACout); |
yqin70 | 0:4f77ae831ee7 | 100 | |
yqin70 | 0:4f77ae831ee7 | 101 | // mutex to make the lcd lib thread safe |
yqin70 | 0:4f77ae831ee7 | 102 | Mutex lcd_mutex; |
yqin70 | 0:4f77ae831ee7 | 103 | int songnum = 1; |
yqin70 | 0:4f77ae831ee7 | 104 | AnalogIn joy_pot(p16); |
yqin70 | 0:4f77ae831ee7 | 105 | // Thread 1 |
yqin70 | 1:a1aa9a79070a | 106 | // print homescreen to LCD |
yqin70 | 0:4f77ae831ee7 | 107 | void thread1(void const *args) |
yqin70 | 0:4f77ae831ee7 | 108 | { |
yqin70 | 0:4f77ae831ee7 | 109 | |
yqin70 | 0:4f77ae831ee7 | 110 | while(true) { // thread loop |
yqin70 | 0:4f77ae831ee7 | 111 | |
yqin70 | 0:4f77ae831ee7 | 112 | if (homescreen){ |
yqin70 | 0:4f77ae831ee7 | 113 | lcd_mutex.lock(); |
yqin70 | 0:4f77ae831ee7 | 114 | uLCD.cls(); |
yqin70 | 2:765774781bb1 | 115 | uLCD.text_height(1.9); |
yqin70 | 2:765774781bb1 | 116 | uLCD.text_width(1.9); |
yqin70 | 0:4f77ae831ee7 | 117 | uLCD.color(WHITE); |
yqin70 | 0:4f77ae831ee7 | 118 | uLCD.locate(0,0); |
yqin70 | 0:4f77ae831ee7 | 119 | uLCD.printf("Pick a song"); |
yqin70 | 2:765774781bb1 | 120 | uLCD.text_height(1.9); |
yqin70 | 2:765774781bb1 | 121 | uLCD.text_width(1.9); |
yqin70 | 0:4f77ae831ee7 | 122 | uLCD.locate(1,2); |
yqin70 | 0:4f77ae831ee7 | 123 | uLCD.printf("Song1"); |
yqin70 | 0:4f77ae831ee7 | 124 | uLCD.locate(1,4); |
yqin70 | 0:4f77ae831ee7 | 125 | uLCD.printf("Song2"); |
yqin70 | 0:4f77ae831ee7 | 126 | uLCD.locate(1,6); |
yqin70 | 0:4f77ae831ee7 | 127 | uLCD.printf("Song3"); |
yqin70 | 2:765774781bb1 | 128 | uLCD.locate(1,8); |
yqin70 | 2:765774781bb1 | 129 | uLCD.printf("Song4"); |
yqin70 | 2:765774781bb1 | 130 | uLCD.rectangle(5, songnum*16-2, 100, songnum*16+8 ,GREEN); |
yqin70 | 0:4f77ae831ee7 | 131 | lcd_mutex.unlock(); |
yqin70 | 1:a1aa9a79070a | 132 | |
yqin70 | 0:4f77ae831ee7 | 133 | } |
yqin70 | 0:4f77ae831ee7 | 134 | Thread::wait(200); |
yqin70 | 0:4f77ae831ee7 | 135 | } |
yqin70 | 0:4f77ae831ee7 | 136 | } |
yqin70 | 0:4f77ae831ee7 | 137 | |
yqin70 | 1:a1aa9a79070a | 138 | //for song selection during homescreen |
yqin70 | 0:4f77ae831ee7 | 139 | void thread2(void const *args) |
yqin70 | 0:4f77ae831ee7 | 140 | { |
yqin70 | 0:4f77ae831ee7 | 141 | |
yqin70 | 0:4f77ae831ee7 | 142 | while(1){ |
yqin70 | 1:a1aa9a79070a | 143 | if (homescreen){ |
yqin70 | 0:4f77ae831ee7 | 144 | if ((joy_pot <= (1.4/3.3)) && songnum>1) { |
yqin70 | 0:4f77ae831ee7 | 145 | songnum--; |
yqin70 | 0:4f77ae831ee7 | 146 | } |
yqin70 | 2:765774781bb1 | 147 | else if ((joy_pot >= (1.8/3.3)) && songnum<4){ |
yqin70 | 0:4f77ae831ee7 | 148 | songnum++; |
yqin70 | 0:4f77ae831ee7 | 149 | } |
yqin70 | 1:a1aa9a79070a | 150 | } |
yqin70 | 0:4f77ae831ee7 | 151 | Thread::wait(250); |
yqin70 | 0:4f77ae831ee7 | 152 | |
yqin70 | 0:4f77ae831ee7 | 153 | } |
yqin70 | 0:4f77ae831ee7 | 154 | } |
yqin70 | 0:4f77ae831ee7 | 155 | |
yqin70 | 0:4f77ae831ee7 | 156 | // Thread 3 |
yqin70 | 1:a1aa9a79070a | 157 | //pb1 is to select song |
yqin70 | 1:a1aa9a79070a | 158 | //pb2 is to return to homescreen |
yqin70 | 0:4f77ae831ee7 | 159 | void thread3(void const *args) |
yqin70 | 0:4f77ae831ee7 | 160 | { |
yqin70 | 0:4f77ae831ee7 | 161 | pb1.mode(PullUp); |
yqin70 | 0:4f77ae831ee7 | 162 | pb2.mode(PullUp); |
yqin70 | 0:4f77ae831ee7 | 163 | while(true) { // thread loop |
yqin70 | 0:4f77ae831ee7 | 164 | if (!pb2) |
yqin70 | 0:4f77ae831ee7 | 165 | { |
yqin70 | 0:4f77ae831ee7 | 166 | homescreen = true; |
yqin70 | 0:4f77ae831ee7 | 167 | songselect = false; |
yqin70 | 0:4f77ae831ee7 | 168 | } |
yqin70 | 0:4f77ae831ee7 | 169 | if (!pb1) |
yqin70 | 0:4f77ae831ee7 | 170 | { |
yqin70 | 0:4f77ae831ee7 | 171 | songselect = true; |
yqin70 | 0:4f77ae831ee7 | 172 | } |
yqin70 | 0:4f77ae831ee7 | 173 | Thread::wait(100); // value of pot1 / 100 |
yqin70 | 0:4f77ae831ee7 | 174 | } |
yqin70 | 0:4f77ae831ee7 | 175 | } |
yqin70 | 0:4f77ae831ee7 | 176 | |
yqin70 | 0:4f77ae831ee7 | 177 | int main() |
yqin70 | 0:4f77ae831ee7 | 178 | { |
yqin70 | 3:431877852f14 | 179 | //timestamp in terms of seconds |
yqin70 | 3:431877852f14 | 180 | int the_middle[62][5] = {2, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 181 | 3, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 182 | 4, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 183 | 5, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 184 | 6, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 185 | 7, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 186 | 8, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 187 | 9, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 188 | 10, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 189 | 11, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 190 | 12, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 191 | 13, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 192 | 15, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 193 | 16, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 194 | 17, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 195 | 18, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 196 | 19, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 197 | 20, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 198 | 21, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 199 | 22, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 200 | 23, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 201 | 24, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 202 | 25, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 203 | 27, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 204 | 28, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 205 | 29, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 206 | 30, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 207 | 31, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 208 | 32, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 209 | 33, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 210 | 34, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 211 | 35, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 212 | 36, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 213 | 37, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 214 | 38, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 215 | 39, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 216 | 40, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 217 | 42, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 218 | 43, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 219 | 44, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 220 | 45, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 221 | 46, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 222 | 47, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 223 | 48, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 224 | 49, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 225 | 51, 0, 1, 1, 1, |
yqin70 | 3:431877852f14 | 226 | 52, 0, 1, 1, 1, |
yqin70 | 3:431877852f14 | 227 | 53, 0, 1, 1, 1, |
yqin70 | 3:431877852f14 | 228 | 54, 0, 1, 1, 1, |
yqin70 | 3:431877852f14 | 229 | 56, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 230 | 57, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 231 | 58, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 232 | 59, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 233 | 61, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 234 | 62, 0, 1, 1, 1, |
yqin70 | 3:431877852f14 | 235 | 63, 0, 1, 1, 1, |
yqin70 | 3:431877852f14 | 236 | 64, 0, 1, 1, 1, |
yqin70 | 3:431877852f14 | 237 | 66, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 238 | 67, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 239 | 68, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 240 | 69, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 241 | 70, 0, 1, 1, 0}; |
yqin70 | 3:431877852f14 | 242 | |
yqin70 | 3:431877852f14 | 243 | int stacys_mom[70][5] = {1, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 244 | 2, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 245 | 3, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 246 | 4, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 247 | 5, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 248 | 6, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 249 | 8, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 250 | 9, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 251 | 10, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 252 | 11, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 253 | 12, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 254 | 13, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 255 | 15, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 256 | 16, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 257 | 17, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 258 | 18, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 259 | 20, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 260 | 21, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 261 | 22, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 262 | 24, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 263 | 25, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 264 | 26, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 265 | 27, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 266 | 28, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 267 | 29, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 268 | 31, 0, 1, 1, 1, |
yqin70 | 3:431877852f14 | 269 | 32, 0, 1, 0, 1, |
yqin70 | 3:431877852f14 | 270 | 33, 0, 1, 0, 1, |
yqin70 | 3:431877852f14 | 271 | 34, 0, 1, 0, 1, |
yqin70 | 3:431877852f14 | 272 | 35, 0, 1, 0, 1, |
yqin70 | 3:431877852f14 | 273 | 36, 0, 1, 0, 1, |
yqin70 | 3:431877852f14 | 274 | 37, 0, 1, 0, 1, |
yqin70 | 3:431877852f14 | 275 | 39, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 276 | 40, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 277 | 41, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 278 | 42, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 279 | 43, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 280 | 44, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 281 | 45, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 282 | 46, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 283 | 47, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 284 | 48, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 285 | 49, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 286 | 51, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 287 | 52, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 288 | 53, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 289 | 54, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 290 | 55, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 291 | 56, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 292 | 57, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 293 | 58, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 294 | 59, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 295 | 60, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 296 | 61, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 297 | 62, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 298 | 64, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 299 | 65, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 300 | 66, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 301 | 67, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 302 | 68, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 303 | 69, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 304 | 70, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 305 | 73, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 306 | 74, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 307 | 75, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 308 | 76, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 309 | 77, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 310 | 78, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 311 | 79, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 312 | 80, 0, 0, 0, 1}; |
yqin70 | 3:431877852f14 | 313 | |
yqin70 | 3:431877852f14 | 314 | int sins[60][5] = {2, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 315 | 3, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 316 | 4, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 317 | 5, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 318 | 6, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 319 | 7, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 320 | 8, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 321 | 9, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 322 | 10, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 323 | 11, 0, 1, 1, 1, |
yqin70 | 3:431877852f14 | 324 | 13, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 325 | 14, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 326 | 15, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 327 | 16, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 328 | 17, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 329 | 18, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 330 | 19, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 331 | 20, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 332 | 22, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 333 | 23, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 334 | 24, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 335 | 25, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 336 | 26, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 337 | 27, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 338 | 28, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 339 | 29, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 340 | 30, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 341 | 31, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 342 | 33, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 343 | 34, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 344 | 35, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 345 | 36, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 346 | 37, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 347 | 38, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 348 | 39, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 349 | 40, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 350 | 42, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 351 | 43, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 352 | 44, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 353 | 45, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 354 | 46, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 355 | 47, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 356 | 48, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 357 | 49, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 358 | 50, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 359 | 51, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 360 | 52, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 361 | 53, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 362 | 54, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 363 | 55, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 364 | 56, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 365 | 57, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 366 | 58, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 367 | 59, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 368 | 60, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 369 | 62, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 370 | 63, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 371 | 64, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 372 | 65, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 373 | 66, 0, 1, 1, 0}; |
yqin70 | 3:431877852f14 | 374 | |
yqin70 | 3:431877852f14 | 375 | int fireflies[58][5] = { |
yqin70 | 3:431877852f14 | 376 | 1, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 377 | 2, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 378 | 3, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 379 | 4, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 380 | 5, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 381 | 6, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 382 | 7, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 383 | 8, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 384 | 9, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 385 | 10, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 386 | 11, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 387 | 12, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 388 | 13, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 389 | 14, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 390 | 15, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 391 | 16, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 392 | 17, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 393 | 18, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 394 | 19, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 395 | 21, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 396 | 22, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 397 | 23, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 398 | 24, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 399 | 25, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 400 | 26, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 401 | 27, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 402 | 28, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 403 | 29, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 404 | 30, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 405 | 32, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 406 | 33, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 407 | 34, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 408 | 35, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 409 | 36, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 410 | 37, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 411 | 38, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 412 | 39, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 413 | 40, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 414 | 41, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 415 | 43, 0, 1, 1, 1, |
yqin70 | 3:431877852f14 | 416 | 44, 0, 1, 1, 1, |
yqin70 | 3:431877852f14 | 417 | 45, 0, 1, 1, 1, |
yqin70 | 3:431877852f14 | 418 | 46, 0, 1, 1, 1, |
yqin70 | 3:431877852f14 | 419 | 47, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 420 | 48, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 421 | 49, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 422 | 50, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 423 | 51, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 424 | 53, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 425 | 54, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 426 | 55, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 427 | 56, 0, 1, 1, 0, |
yqin70 | 3:431877852f14 | 428 | 57, 0, 0, 1, 1, |
yqin70 | 3:431877852f14 | 429 | 59, 0, 1, 0, 0, |
yqin70 | 3:431877852f14 | 430 | 60, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 431 | 61, 0, 0, 0, 1, |
yqin70 | 3:431877852f14 | 432 | 62, 0, 0, 1, 0, |
yqin70 | 3:431877852f14 | 433 | 63, 0, 1, 0, 0}; |
yqin70 | 3:431877852f14 | 434 | //doesnt work yet, nee,d to ask hamblen |
yqin70 | 0:4f77ae831ee7 | 435 | uLCD.media_init(); |
yqin70 | 0:4f77ae831ee7 | 436 | uLCD.set_sector_address(0x001D, 0x4C01); |
yqin70 | 0:4f77ae831ee7 | 437 | uLCD.display_image(0,0); |
yqin70 | 0:4f77ae831ee7 | 438 | // t1.start(thread1); |
yqin70 | 0:4f77ae831ee7 | 439 | // t2.start(thread2); |
yqin70 | 0:4f77ae831ee7 | 440 | // t3.start(thread3); |
yqin70 | 0:4f77ae831ee7 | 441 | Thread t1(thread1); |
yqin70 | 0:4f77ae831ee7 | 442 | Thread t2(thread2); |
yqin70 | 0:4f77ae831ee7 | 443 | Thread t3(thread3); |
yqin70 | 1:a1aa9a79070a | 444 | //startup sound. Commented out for testing without SD card |
yqin70 | 1:a1aa9a79070a | 445 | //FILE *wave_file; |
yqin70 | 1:a1aa9a79070a | 446 | //wave_file=fopen("/sd/cheer.wav","r"); |
yqin70 | 1:a1aa9a79070a | 447 | //waver.play(wave_file); |
yqin70 | 1:a1aa9a79070a | 448 | //fclose(wave_file); |
yqin70 | 0:4f77ae831ee7 | 449 | while(1) |
yqin70 | 0:4f77ae831ee7 | 450 | { |
yqin70 | 0:4f77ae831ee7 | 451 | |
yqin70 | 1:a1aa9a79070a | 452 | if (songselect){ |
yqin70 | 1:a1aa9a79070a | 453 | myled = 0; |
yqin70 | 1:a1aa9a79070a | 454 | homescreen = false; |
yqin70 | 1:a1aa9a79070a | 455 | lcd_mutex.lock(); |
yqin70 | 1:a1aa9a79070a | 456 | uLCD.cls(); |
yqin70 | 1:a1aa9a79070a | 457 | uLCD.printf("You selected song %2d",songnum); |
yqin70 | 1:a1aa9a79070a | 458 | lcd_mutex.unlock(); |
yqin70 | 1:a1aa9a79070a | 459 | //add case statement based on songnum or something |
yqin70 | 1:a1aa9a79070a | 460 | //code for playing song from sd |
yqin70 | 1:a1aa9a79070a | 461 | //FILE *wave_file; |
yqin70 | 1:a1aa9a79070a | 462 | //wave_file=fopen("/sd/sample1.wav","r"); |
yqin70 | 1:a1aa9a79070a | 463 | //waver.play(wave_file); |
yqin70 | 1:a1aa9a79070a | 464 | //fclose(wave_file); |
yqin70 | 1:a1aa9a79070a | 465 | //end |
yqin70 | 1:a1aa9a79070a | 466 | } |
yqin70 | 0:4f77ae831ee7 | 467 | Thread::wait(100); |
yqin70 | 0:4f77ae831ee7 | 468 | } |
yqin70 | 0:4f77ae831ee7 | 469 | } |
yqin70 | 0:4f77ae831ee7 | 470 | |
yqin70 | 0:4f77ae831ee7 | 471 |