mbed Christmas tree using NeoPixel

Dependencies:   mbed

Fork of JBB_SerialLED_test by Junichi Katsu

Revision:
3:98b6f181c935
Parent:
2:435f94e9bb06
Child:
4:4a02e637a43f
--- a/main.cpp	Sat Dec 05 05:01:15 2015 +0000
+++ b/main.cpp	Sat Dec 05 06:10:11 2015 +0000
@@ -155,42 +155,37 @@
 	led_event(9);
 }
 
+#define start_led(i) \
+	led##i##_val = MAX_LEVEL; \
+	blinker##i.attach(&led##i##_event, WAIT_TIME##i);
+
+#define stop_led(i) blinker##i.detach();
+
 void blink_4()
 {
-    led0_val = MAX_LEVEL;
-    led1_val = MAX_LEVEL;
-    led2_val = MAX_LEVEL;
-    led3_val = MAX_LEVEL;
-    led4_val = MAX_LEVEL;
-    led5_val = MAX_LEVEL;
-    led6_val = MAX_LEVEL;
-    led7_val = MAX_LEVEL;
-    led8_val = MAX_LEVEL;
-    led9_val = MAX_LEVEL;
-
-    blinker0.attach(&led0_event, WAIT_TIME0);
-    blinker1.attach(&led1_event, WAIT_TIME1);
-    blinker2.attach(&led2_event, WAIT_TIME2);
-    blinker3.attach(&led3_event, WAIT_TIME3);
-    blinker4.attach(&led4_event, WAIT_TIME4);
-    blinker5.attach(&led5_event, WAIT_TIME5);
-    blinker6.attach(&led6_event, WAIT_TIME6);
-    blinker7.attach(&led7_event, WAIT_TIME7);
-    blinker8.attach(&led8_event, WAIT_TIME8);
-    blinker9.attach(&led9_event, WAIT_TIME9);
+    start_led(0);
+    start_led(1);
+    start_led(2);
+    start_led(3);
+    start_led(4);
+    start_led(5);
+    start_led(6);
+    start_led(7);
+    start_led(8);
+    start_led(9);
 
     wait(8);
 
-    blinker0.detach();
-    blinker1.detach();
-    blinker2.detach();
-    blinker3.detach();
-    blinker4.detach();
-    blinker5.detach();
-    blinker6.detach();
-    blinker7.detach();
-    blinker8.detach();
-    blinker9.detach();
+    stop_led(0);
+    stop_led(1);
+    stop_led(2);
+    stop_led(3);
+    stop_led(4);
+    stop_led(5);
+    stop_led(6);
+    stop_led(7);
+    stop_led(8);
+    stop_led(9);
 }
 
 int main()