LED sequences for bot
Dependencies: mbed C12832_lcd LCD_fonts NeoStrip
main.cpp@0:56f7b47bf357, 2021-05-20 (annotated)
- Committer:
- slackerjacker
- Date:
- Thu May 20 11:04:22 2021 +0000
- Revision:
- 0:56f7b47bf357
LED for bot
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
slackerjacker | 0:56f7b47bf357 | 1 | #include "mbed.h" |
slackerjacker | 0:56f7b47bf357 | 2 | #include "NeoStrip.h" |
slackerjacker | 0:56f7b47bf357 | 3 | #include "gt.h" |
slackerjacker | 0:56f7b47bf357 | 4 | #include "C12832_lcd.h" |
slackerjacker | 0:56f7b47bf357 | 5 | #include "Arial_9.h" |
slackerjacker | 0:56f7b47bf357 | 6 | #include "Small_7.h" |
slackerjacker | 0:56f7b47bf357 | 7 | |
slackerjacker | 0:56f7b47bf357 | 8 | |
slackerjacker | 0:56f7b47bf357 | 9 | #define N 17 //number of leds |
slackerjacker | 0:56f7b47bf357 | 10 | #define PATTERNS 3 |
slackerjacker | 0:56f7b47bf357 | 11 | |
slackerjacker | 0:56f7b47bf357 | 12 | Serial pc(USBTX, USBRX); |
slackerjacker | 0:56f7b47bf357 | 13 | NeoStrip strip(p25, N); // DIN PIN with number of LEDs |
slackerjacker | 0:56f7b47bf357 | 14 | NeoStrip led1(p25, 0); |
slackerjacker | 0:56f7b47bf357 | 15 | |
slackerjacker | 0:56f7b47bf357 | 16 | //////////////////////////////////// |
slackerjacker | 0:56f7b47bf357 | 17 | //////note colours value below////// |
slackerjacker | 0:56f7b47bf357 | 18 | //////////////////////////////////// |
slackerjacker | 0:56f7b47bf357 | 19 | |
slackerjacker | 0:56f7b47bf357 | 20 | float bright = 0.20; // 20% is plenty for indoor use |
slackerjacker | 0:56f7b47bf357 | 21 | int red = 0xFF0000; |
slackerjacker | 0:56f7b47bf357 | 22 | int orange = 0xFF8000; |
slackerjacker | 0:56f7b47bf357 | 23 | int yellow = 0xFFFF00; |
slackerjacker | 0:56f7b47bf357 | 24 | int green = 0x00FF44; |
slackerjacker | 0:56f7b47bf357 | 25 | int blue = 0x00BFFF; |
slackerjacker | 0:56f7b47bf357 | 26 | int indigo = 0x0F0082; |
slackerjacker | 0:56f7b47bf357 | 27 | int violet = 0x8000B4; |
slackerjacker | 0:56f7b47bf357 | 28 | int white = 0xFFFFFF; |
slackerjacker | 0:56f7b47bf357 | 29 | int i = 0; |
slackerjacker | 0:56f7b47bf357 | 30 | int z = 0xFFFFFF; |
slackerjacker | 0:56f7b47bf357 | 31 | int hueToRGB(float h); |
slackerjacker | 0:56f7b47bf357 | 32 | |
slackerjacker | 0:56f7b47bf357 | 33 | int array[]={0xFF0000,0xFF8000,0xFFFF00,0x00FF44,0x00BFFF,0x0F0082,0x8000B4}; |
slackerjacker | 0:56f7b47bf357 | 34 | |
slackerjacker | 0:56f7b47bf357 | 35 | C12832_LCD LCD("LCD"); |
slackerjacker | 0:56f7b47bf357 | 36 | //C12832_LCD lcd(p5, p7, p6, p8, p11); //jtb |
slackerjacker | 0:56f7b47bf357 | 37 | |
slackerjacker | 0:56f7b47bf357 | 38 | //variable that hold 1ms timer count, this can used in main to time stuff |
slackerjacker | 0:56f7b47bf357 | 39 | int play_led_1ms_timer = 0; |
slackerjacker | 0:56f7b47bf357 | 40 | |
slackerjacker | 0:56f7b47bf357 | 41 | //set up a ticker funtion |
slackerjacker | 0:56f7b47bf357 | 42 | ////////////////////////////////////////////////////////////////////////// |
slackerjacker | 0:56f7b47bf357 | 43 | |
slackerjacker | 0:56f7b47bf357 | 44 | Ticker play_led_1ms_ticker; |
slackerjacker | 0:56f7b47bf357 | 45 | |
slackerjacker | 0:56f7b47bf357 | 46 | //this funtion runs every ms and increments lay_led_1ms_timer by 1 |
slackerjacker | 0:56f7b47bf357 | 47 | void play_led_1ms(void) |
slackerjacker | 0:56f7b47bf357 | 48 | { |
slackerjacker | 0:56f7b47bf357 | 49 | play_led_1ms_timer = play_led_1ms_timer+1; |
slackerjacker | 0:56f7b47bf357 | 50 | |
slackerjacker | 0:56f7b47bf357 | 51 | //stop overflow |
slackerjacker | 0:56f7b47bf357 | 52 | if(play_led_1ms_timer> 1000000) |
slackerjacker | 0:56f7b47bf357 | 53 | { |
slackerjacker | 0:56f7b47bf357 | 54 | play_led_1ms_timer = 0; |
slackerjacker | 0:56f7b47bf357 | 55 | } |
slackerjacker | 0:56f7b47bf357 | 56 | } |
slackerjacker | 0:56f7b47bf357 | 57 | |
slackerjacker | 0:56f7b47bf357 | 58 | int main() |
slackerjacker | 0:56f7b47bf357 | 59 | { |
slackerjacker | 0:56f7b47bf357 | 60 | // set up a function to play every 1.5 sec |
slackerjacker | 0:56f7b47bf357 | 61 | play_led_1ms_ticker.attach(&play_led_1ms, 0.001); |
slackerjacker | 0:56f7b47bf357 | 62 | |
slackerjacker | 0:56f7b47bf357 | 63 | ///////////////////////////////////////////////////////////////////////////// |
slackerjacker | 0:56f7b47bf357 | 64 | |
slackerjacker | 0:56f7b47bf357 | 65 | strip.setBrightness(bright); // set default brightness |
slackerjacker | 0:56f7b47bf357 | 66 | strip.clear(); |
slackerjacker | 0:56f7b47bf357 | 67 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 68 | |
slackerjacker | 0:56f7b47bf357 | 69 | pc.printf("1 - Bootup\n\r"); |
slackerjacker | 0:56f7b47bf357 | 70 | pc.printf("2 - Bootdown\n\r"); |
slackerjacker | 0:56f7b47bf357 | 71 | pc.printf("3 - Clear\n\r"); |
slackerjacker | 0:56f7b47bf357 | 72 | pc.printf("4 - Happy\n\r"); |
slackerjacker | 0:56f7b47bf357 | 73 | pc.printf("5 - Sad\n\r"); |
slackerjacker | 0:56f7b47bf357 | 74 | pc.printf("6 - Idle\n\r"); |
slackerjacker | 0:56f7b47bf357 | 75 | pc.printf("7 - Understood\n\r"); |
slackerjacker | 0:56f7b47bf357 | 76 | while(true) |
slackerjacker | 0:56f7b47bf357 | 77 | { |
slackerjacker | 0:56f7b47bf357 | 78 | if (pc.readable()) |
slackerjacker | 0:56f7b47bf357 | 79 | { |
slackerjacker | 0:56f7b47bf357 | 80 | switch(pc.getc()) |
slackerjacker | 0:56f7b47bf357 | 81 | { |
slackerjacker | 0:56f7b47bf357 | 82 | case '1'://bootup sequence |
slackerjacker | 0:56f7b47bf357 | 83 | |
slackerjacker | 0:56f7b47bf357 | 84 | play_led_1ms_timer= 0; |
slackerjacker | 0:56f7b47bf357 | 85 | do |
slackerjacker | 0:56f7b47bf357 | 86 | { |
slackerjacker | 0:56f7b47bf357 | 87 | LCD.cls(); |
slackerjacker | 0:56f7b47bf357 | 88 | LCD.claim(stdout); |
slackerjacker | 0:56f7b47bf357 | 89 | LCD.locate(10,0); |
slackerjacker | 0:56f7b47bf357 | 90 | LCD.set_font((unsigned char*) Arial_9); |
slackerjacker | 0:56f7b47bf357 | 91 | printf("Bot bootup"); |
slackerjacker | 0:56f7b47bf357 | 92 | LCD.copy_to_lcd(); |
slackerjacker | 0:56f7b47bf357 | 93 | LCD.set_font((unsigned char*) Small_7); |
slackerjacker | 0:56f7b47bf357 | 94 | strip.clear(); |
slackerjacker | 0:56f7b47bf357 | 95 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 96 | wait_ms(1); |
slackerjacker | 0:56f7b47bf357 | 97 | |
slackerjacker | 0:56f7b47bf357 | 98 | strip.setPixel(0,red); |
slackerjacker | 0:56f7b47bf357 | 99 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 100 | wait_ms(100); |
slackerjacker | 0:56f7b47bf357 | 101 | |
slackerjacker | 0:56f7b47bf357 | 102 | strip.setPixel(1,orange); |
slackerjacker | 0:56f7b47bf357 | 103 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 104 | wait_ms(100); |
slackerjacker | 0:56f7b47bf357 | 105 | |
slackerjacker | 0:56f7b47bf357 | 106 | strip.setPixel(2,yellow); |
slackerjacker | 0:56f7b47bf357 | 107 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 108 | wait_ms(100); |
slackerjacker | 0:56f7b47bf357 | 109 | |
slackerjacker | 0:56f7b47bf357 | 110 | strip.setPixel(3,green); |
slackerjacker | 0:56f7b47bf357 | 111 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 112 | wait_ms(100); |
slackerjacker | 0:56f7b47bf357 | 113 | |
slackerjacker | 0:56f7b47bf357 | 114 | strip.setPixel(4,blue); |
slackerjacker | 0:56f7b47bf357 | 115 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 116 | wait_ms(100); |
slackerjacker | 0:56f7b47bf357 | 117 | |
slackerjacker | 0:56f7b47bf357 | 118 | strip.setPixel(5,indigo); |
slackerjacker | 0:56f7b47bf357 | 119 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 120 | wait_ms(100); |
slackerjacker | 0:56f7b47bf357 | 121 | |
slackerjacker | 0:56f7b47bf357 | 122 | strip.setPixel(6,violet); |
slackerjacker | 0:56f7b47bf357 | 123 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 124 | wait_ms(100); |
slackerjacker | 0:56f7b47bf357 | 125 | |
slackerjacker | 0:56f7b47bf357 | 126 | strip.setPixel(7,indigo); |
slackerjacker | 0:56f7b47bf357 | 127 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 128 | wait_ms(100); |
slackerjacker | 0:56f7b47bf357 | 129 | |
slackerjacker | 0:56f7b47bf357 | 130 | strip.setPixel(8,blue); |
slackerjacker | 0:56f7b47bf357 | 131 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 132 | wait_ms(100); |
slackerjacker | 0:56f7b47bf357 | 133 | |
slackerjacker | 0:56f7b47bf357 | 134 | strip.setPixel(9,green); |
slackerjacker | 0:56f7b47bf357 | 135 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 136 | wait_ms(100); |
slackerjacker | 0:56f7b47bf357 | 137 | |
slackerjacker | 0:56f7b47bf357 | 138 | strip.setPixel(10,yellow); |
slackerjacker | 0:56f7b47bf357 | 139 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 140 | wait_ms(100); |
slackerjacker | 0:56f7b47bf357 | 141 | |
slackerjacker | 0:56f7b47bf357 | 142 | strip.setPixel(11,orange); |
slackerjacker | 0:56f7b47bf357 | 143 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 144 | wait_ms(100); |
slackerjacker | 0:56f7b47bf357 | 145 | |
slackerjacker | 0:56f7b47bf357 | 146 | } |
slackerjacker | 0:56f7b47bf357 | 147 | |
slackerjacker | 0:56f7b47bf357 | 148 | while(play_led_1ms_timer < 1900); |
slackerjacker | 0:56f7b47bf357 | 149 | |
slackerjacker | 0:56f7b47bf357 | 150 | |
slackerjacker | 0:56f7b47bf357 | 151 | |
slackerjacker | 0:56f7b47bf357 | 152 | break; |
slackerjacker | 0:56f7b47bf357 | 153 | |
slackerjacker | 0:56f7b47bf357 | 154 | case '2'://bootdown sequence |
slackerjacker | 0:56f7b47bf357 | 155 | |
slackerjacker | 0:56f7b47bf357 | 156 | play_led_1ms_timer= 0; |
slackerjacker | 0:56f7b47bf357 | 157 | |
slackerjacker | 0:56f7b47bf357 | 158 | do |
slackerjacker | 0:56f7b47bf357 | 159 | { |
slackerjacker | 0:56f7b47bf357 | 160 | LCD.cls(); |
slackerjacker | 0:56f7b47bf357 | 161 | LCD.claim(stdout); |
slackerjacker | 0:56f7b47bf357 | 162 | LCD.locate(10,0); |
slackerjacker | 0:56f7b47bf357 | 163 | LCD.set_font((unsigned char*) Arial_9); |
slackerjacker | 0:56f7b47bf357 | 164 | printf("Shutting down"); |
slackerjacker | 0:56f7b47bf357 | 165 | LCD.copy_to_lcd(); |
slackerjacker | 0:56f7b47bf357 | 166 | LCD.set_font((unsigned char*) Small_7); |
slackerjacker | 0:56f7b47bf357 | 167 | |
slackerjacker | 0:56f7b47bf357 | 168 | |
slackerjacker | 0:56f7b47bf357 | 169 | strip.setPixel(11,orange); |
slackerjacker | 0:56f7b47bf357 | 170 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 171 | wait_ms(1); |
slackerjacker | 0:56f7b47bf357 | 172 | |
slackerjacker | 0:56f7b47bf357 | 173 | strip.setPixel(10,yellow); |
slackerjacker | 0:56f7b47bf357 | 174 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 175 | wait_ms(1); |
slackerjacker | 0:56f7b47bf357 | 176 | |
slackerjacker | 0:56f7b47bf357 | 177 | strip.setPixel(9,green); |
slackerjacker | 0:56f7b47bf357 | 178 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 179 | wait_ms(1); |
slackerjacker | 0:56f7b47bf357 | 180 | |
slackerjacker | 0:56f7b47bf357 | 181 | strip.setPixel(8,blue); |
slackerjacker | 0:56f7b47bf357 | 182 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 183 | wait_ms(1); |
slackerjacker | 0:56f7b47bf357 | 184 | |
slackerjacker | 0:56f7b47bf357 | 185 | strip.setPixel(7,indigo); |
slackerjacker | 0:56f7b47bf357 | 186 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 187 | wait_ms(1); |
slackerjacker | 0:56f7b47bf357 | 188 | |
slackerjacker | 0:56f7b47bf357 | 189 | strip.setPixel(6,violet); |
slackerjacker | 0:56f7b47bf357 | 190 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 191 | wait_ms(1); |
slackerjacker | 0:56f7b47bf357 | 192 | |
slackerjacker | 0:56f7b47bf357 | 193 | strip.setPixel(5,indigo); |
slackerjacker | 0:56f7b47bf357 | 194 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 195 | wait_ms(1); |
slackerjacker | 0:56f7b47bf357 | 196 | |
slackerjacker | 0:56f7b47bf357 | 197 | strip.setPixel(4,blue); |
slackerjacker | 0:56f7b47bf357 | 198 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 199 | wait_ms(1); |
slackerjacker | 0:56f7b47bf357 | 200 | |
slackerjacker | 0:56f7b47bf357 | 201 | strip.setPixel(3,green); |
slackerjacker | 0:56f7b47bf357 | 202 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 203 | wait_ms(1); |
slackerjacker | 0:56f7b47bf357 | 204 | |
slackerjacker | 0:56f7b47bf357 | 205 | strip.setPixel(2,yellow); |
slackerjacker | 0:56f7b47bf357 | 206 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 207 | wait_ms(1); |
slackerjacker | 0:56f7b47bf357 | 208 | |
slackerjacker | 0:56f7b47bf357 | 209 | strip.setPixel(1,orange); |
slackerjacker | 0:56f7b47bf357 | 210 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 211 | wait_ms(1); |
slackerjacker | 0:56f7b47bf357 | 212 | |
slackerjacker | 0:56f7b47bf357 | 213 | strip.setPixel(0,red); |
slackerjacker | 0:56f7b47bf357 | 214 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 215 | wait_ms(1); |
slackerjacker | 0:56f7b47bf357 | 216 | |
slackerjacker | 0:56f7b47bf357 | 217 | |
slackerjacker | 0:56f7b47bf357 | 218 | for (int i = 11; i >= 0; i--) |
slackerjacker | 0:56f7b47bf357 | 219 | { |
slackerjacker | 0:56f7b47bf357 | 220 | strip.setPixel(i,0,0,0); |
slackerjacker | 0:56f7b47bf357 | 221 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 222 | wait_ms(200); |
slackerjacker | 0:56f7b47bf357 | 223 | } |
slackerjacker | 0:56f7b47bf357 | 224 | } |
slackerjacker | 0:56f7b47bf357 | 225 | |
slackerjacker | 0:56f7b47bf357 | 226 | while(play_led_1ms_timer < 3000); |
slackerjacker | 0:56f7b47bf357 | 227 | |
slackerjacker | 0:56f7b47bf357 | 228 | break; |
slackerjacker | 0:56f7b47bf357 | 229 | |
slackerjacker | 0:56f7b47bf357 | 230 | case '3'://clear |
slackerjacker | 0:56f7b47bf357 | 231 | LCD.cls(); |
slackerjacker | 0:56f7b47bf357 | 232 | strip.clear(); |
slackerjacker | 0:56f7b47bf357 | 233 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 234 | |
slackerjacker | 0:56f7b47bf357 | 235 | break; |
slackerjacker | 0:56f7b47bf357 | 236 | |
slackerjacker | 0:56f7b47bf357 | 237 | case '4': //happy |
slackerjacker | 0:56f7b47bf357 | 238 | |
slackerjacker | 0:56f7b47bf357 | 239 | |
slackerjacker | 0:56f7b47bf357 | 240 | |
slackerjacker | 0:56f7b47bf357 | 241 | //reset timer value to 0 |
slackerjacker | 0:56f7b47bf357 | 242 | ////////////////////////////////////// |
slackerjacker | 0:56f7b47bf357 | 243 | play_led_1ms_timer= 0; |
slackerjacker | 0:56f7b47bf357 | 244 | |
slackerjacker | 0:56f7b47bf357 | 245 | //repeat do while for 2000 ms see line 247 for while part |
slackerjacker | 0:56f7b47bf357 | 246 | // this code will repeat untill play_led_1ms_timer > 2000 |
slackerjacker | 0:56f7b47bf357 | 247 | do |
slackerjacker | 0:56f7b47bf357 | 248 | { |
slackerjacker | 0:56f7b47bf357 | 249 | LCD.cls(); |
slackerjacker | 0:56f7b47bf357 | 250 | LCD.claim(stdout); |
slackerjacker | 0:56f7b47bf357 | 251 | LCD.locate(10,0); |
slackerjacker | 0:56f7b47bf357 | 252 | LCD.set_font((unsigned char*) Arial_9); |
slackerjacker | 0:56f7b47bf357 | 253 | printf("Happy Bot"); |
slackerjacker | 0:56f7b47bf357 | 254 | LCD.copy_to_lcd(); |
slackerjacker | 0:56f7b47bf357 | 255 | LCD.set_font((unsigned char*) Small_7); |
slackerjacker | 0:56f7b47bf357 | 256 | |
slackerjacker | 0:56f7b47bf357 | 257 | |
slackerjacker | 0:56f7b47bf357 | 258 | for (int i = 0; i < N; i++) |
slackerjacker | 0:56f7b47bf357 | 259 | { |
slackerjacker | 0:56f7b47bf357 | 260 | strip.setPixel(i,white); |
slackerjacker | 0:56f7b47bf357 | 261 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 262 | wait_ms(30); |
slackerjacker | 0:56f7b47bf357 | 263 | } |
slackerjacker | 0:56f7b47bf357 | 264 | |
slackerjacker | 0:56f7b47bf357 | 265 | for (int i = 0; i < N; i++) |
slackerjacker | 0:56f7b47bf357 | 266 | { |
slackerjacker | 0:56f7b47bf357 | 267 | strip.setPixel(i,yellow); |
slackerjacker | 0:56f7b47bf357 | 268 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 269 | wait_ms(30); |
slackerjacker | 0:56f7b47bf357 | 270 | } |
slackerjacker | 0:56f7b47bf357 | 271 | |
slackerjacker | 0:56f7b47bf357 | 272 | for (int i =0; i < N; i++) |
slackerjacker | 0:56f7b47bf357 | 273 | { |
slackerjacker | 0:56f7b47bf357 | 274 | strip.setPixel(i,orange); |
slackerjacker | 0:56f7b47bf357 | 275 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 276 | wait_ms(30); |
slackerjacker | 0:56f7b47bf357 | 277 | } |
slackerjacker | 0:56f7b47bf357 | 278 | } |
slackerjacker | 0:56f7b47bf357 | 279 | while(play_led_1ms_timer < 2000); //timer value you want here i.e 2000 2s, 3500 3.5s etc |
slackerjacker | 0:56f7b47bf357 | 280 | |
slackerjacker | 0:56f7b47bf357 | 281 | strip.clear(); |
slackerjacker | 0:56f7b47bf357 | 282 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 283 | |
slackerjacker | 0:56f7b47bf357 | 284 | break; |
slackerjacker | 0:56f7b47bf357 | 285 | |
slackerjacker | 0:56f7b47bf357 | 286 | case '5': |
slackerjacker | 0:56f7b47bf357 | 287 | play_led_1ms_timer= 0; |
slackerjacker | 0:56f7b47bf357 | 288 | do |
slackerjacker | 0:56f7b47bf357 | 289 | { |
slackerjacker | 0:56f7b47bf357 | 290 | LCD.cls(); |
slackerjacker | 0:56f7b47bf357 | 291 | LCD.claim(stdout); |
slackerjacker | 0:56f7b47bf357 | 292 | LCD.locate(10,0); |
slackerjacker | 0:56f7b47bf357 | 293 | LCD.set_font((unsigned char*) Arial_9); |
slackerjacker | 0:56f7b47bf357 | 294 | printf("Sad Bot"); |
slackerjacker | 0:56f7b47bf357 | 295 | LCD.copy_to_lcd(); |
slackerjacker | 0:56f7b47bf357 | 296 | LCD.set_font((unsigned char*) Small_7); |
slackerjacker | 0:56f7b47bf357 | 297 | |
slackerjacker | 0:56f7b47bf357 | 298 | for (float j = 0; j < 0.25; j=j+0.01) //float jack float i :-) , i = i+0.01 |
slackerjacker | 0:56f7b47bf357 | 299 | { |
slackerjacker | 0:56f7b47bf357 | 300 | //pc.printf("%f ",j); debug |
slackerjacker | 0:56f7b47bf357 | 301 | strip.setBrightness(j); |
slackerjacker | 0:56f7b47bf357 | 302 | |
slackerjacker | 0:56f7b47bf357 | 303 | //need to write to pixcel to change brightness |
slackerjacker | 0:56f7b47bf357 | 304 | for (int i = 0; i < 12; i++) |
slackerjacker | 0:56f7b47bf357 | 305 | { |
slackerjacker | 0:56f7b47bf357 | 306 | strip.setPixel(i,blue); |
slackerjacker | 0:56f7b47bf357 | 307 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 308 | wait_ms(3); |
slackerjacker | 0:56f7b47bf357 | 309 | } |
slackerjacker | 0:56f7b47bf357 | 310 | } |
slackerjacker | 0:56f7b47bf357 | 311 | } |
slackerjacker | 0:56f7b47bf357 | 312 | |
slackerjacker | 0:56f7b47bf357 | 313 | while(play_led_1ms_timer < 2000); |
slackerjacker | 0:56f7b47bf357 | 314 | |
slackerjacker | 0:56f7b47bf357 | 315 | |
slackerjacker | 0:56f7b47bf357 | 316 | |
slackerjacker | 0:56f7b47bf357 | 317 | break; |
slackerjacker | 0:56f7b47bf357 | 318 | |
slackerjacker | 0:56f7b47bf357 | 319 | case '6': |
slackerjacker | 0:56f7b47bf357 | 320 | play_led_1ms_timer= 0; |
slackerjacker | 0:56f7b47bf357 | 321 | do |
slackerjacker | 0:56f7b47bf357 | 322 | { |
slackerjacker | 0:56f7b47bf357 | 323 | LCD.cls(); |
slackerjacker | 0:56f7b47bf357 | 324 | LCD.claim(stdout); |
slackerjacker | 0:56f7b47bf357 | 325 | LCD.locate(10,0); |
slackerjacker | 0:56f7b47bf357 | 326 | LCD.set_font((unsigned char*) Arial_9); |
slackerjacker | 0:56f7b47bf357 | 327 | printf("Idle bot"); |
slackerjacker | 0:56f7b47bf357 | 328 | LCD.copy_to_lcd(); |
slackerjacker | 0:56f7b47bf357 | 329 | LCD.set_font((unsigned char*) Small_7); |
slackerjacker | 0:56f7b47bf357 | 330 | |
slackerjacker | 0:56f7b47bf357 | 331 | for (int i=0;i<7;i++) |
slackerjacker | 0:56f7b47bf357 | 332 | { |
slackerjacker | 0:56f7b47bf357 | 333 | wait_ms(250); |
slackerjacker | 0:56f7b47bf357 | 334 | for (int Q = 0; Q<12; Q++) |
slackerjacker | 0:56f7b47bf357 | 335 | { |
slackerjacker | 0:56f7b47bf357 | 336 | strip.setPixel(Q,array[i]); |
slackerjacker | 0:56f7b47bf357 | 337 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 338 | wait_ms(1); |
slackerjacker | 0:56f7b47bf357 | 339 | } |
slackerjacker | 0:56f7b47bf357 | 340 | } |
slackerjacker | 0:56f7b47bf357 | 341 | } |
slackerjacker | 0:56f7b47bf357 | 342 | while(play_led_1ms_timer < 3000); |
slackerjacker | 0:56f7b47bf357 | 343 | |
slackerjacker | 0:56f7b47bf357 | 344 | |
slackerjacker | 0:56f7b47bf357 | 345 | |
slackerjacker | 0:56f7b47bf357 | 346 | |
slackerjacker | 0:56f7b47bf357 | 347 | |
slackerjacker | 0:56f7b47bf357 | 348 | break; |
slackerjacker | 0:56f7b47bf357 | 349 | |
slackerjacker | 0:56f7b47bf357 | 350 | case '7': |
slackerjacker | 0:56f7b47bf357 | 351 | play_led_1ms_timer= 0; |
slackerjacker | 0:56f7b47bf357 | 352 | do |
slackerjacker | 0:56f7b47bf357 | 353 | { |
slackerjacker | 0:56f7b47bf357 | 354 | LCD.cls(); |
slackerjacker | 0:56f7b47bf357 | 355 | LCD.claim(stdout); |
slackerjacker | 0:56f7b47bf357 | 356 | LCD.locate(10,0); |
slackerjacker | 0:56f7b47bf357 | 357 | LCD.set_font((unsigned char*) Arial_9); |
slackerjacker | 0:56f7b47bf357 | 358 | printf("Affirmative"); |
slackerjacker | 0:56f7b47bf357 | 359 | LCD.copy_to_lcd(); |
slackerjacker | 0:56f7b47bf357 | 360 | LCD.set_font((unsigned char*) Small_7); |
slackerjacker | 0:56f7b47bf357 | 361 | |
slackerjacker | 0:56f7b47bf357 | 362 | for (float j = 0; j < 0.25; j=j+0.01) //float jack float i :-) , i = i+0.01 |
slackerjacker | 0:56f7b47bf357 | 363 | { |
slackerjacker | 0:56f7b47bf357 | 364 | //pc.printf("%f ",j); debug |
slackerjacker | 0:56f7b47bf357 | 365 | strip.setBrightness(j); |
slackerjacker | 0:56f7b47bf357 | 366 | |
slackerjacker | 0:56f7b47bf357 | 367 | //need to write to pixel to change brightness |
slackerjacker | 0:56f7b47bf357 | 368 | for (int i = 17; i > 0; i--) |
slackerjacker | 0:56f7b47bf357 | 369 | { |
slackerjacker | 0:56f7b47bf357 | 370 | strip.setPixel(i,green); |
slackerjacker | 0:56f7b47bf357 | 371 | strip.write(); |
slackerjacker | 0:56f7b47bf357 | 372 | wait_ms(3); |
slackerjacker | 0:56f7b47bf357 | 373 | } |
slackerjacker | 0:56f7b47bf357 | 374 | } |
slackerjacker | 0:56f7b47bf357 | 375 | } |
slackerjacker | 0:56f7b47bf357 | 376 | |
slackerjacker | 0:56f7b47bf357 | 377 | while(play_led_1ms_timer < 2000); |
slackerjacker | 0:56f7b47bf357 | 378 | |
slackerjacker | 0:56f7b47bf357 | 379 | |
slackerjacker | 0:56f7b47bf357 | 380 | |
slackerjacker | 0:56f7b47bf357 | 381 | break; |
slackerjacker | 0:56f7b47bf357 | 382 | }//End of switch |
slackerjacker | 0:56f7b47bf357 | 383 | |
slackerjacker | 0:56f7b47bf357 | 384 | }//end of if readable |
slackerjacker | 0:56f7b47bf357 | 385 | |
slackerjacker | 0:56f7b47bf357 | 386 | }//end of while(1) |
slackerjacker | 0:56f7b47bf357 | 387 | |
slackerjacker | 0:56f7b47bf357 | 388 | }//end of main() |