mbed Christmas tree using NeoPixel

Dependencies:   mbed

Fork of JBB_SerialLED_test by Junichi Katsu

Files at this revision

API Documentation at this revision

Comitter:
MACRUM
Date:
Sat Dec 05 15:04:36 2015 +0000
Parent:
3:98b6f181c935
Commit message:
Using array for LED value

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 98b6f181c935 -r 4a02e637a43f main.cpp
--- a/main.cpp	Sat Dec 05 06:10:11 2015 +0000
+++ b/main.cpp	Sat Dec 05 15:04:36 2015 +0000
@@ -12,7 +12,7 @@
 #define MAX_LEVEL 100
 
 Ticker blinker0, blinker1, blinker2, blinker3, blinker4, blinker5, blinker6, blinker7, blinker8, blinker9;
-int led0_val, led1_val, led2_val, led3_val, led4_val, led5_val, led6_val, led7_val, led8_val, led9_val;
+int led_val[NUM_LEDS];
 
 void blink_1()
 {
@@ -105,14 +105,14 @@
 extern int wakeup;
 
 #define led_event(i) \
-	tapeSet(START_ID + 0, led##i##_val, led##i##_val, led##i##_val); \
+	tapeSet(START_ID + 0, led_val[i], led_val[i], led_val[i]); \
 	wakeup = 1; \
-	if (led##i##_val <= 0) \
-        led##i##_val = MAX_LEVEL; \
+	if (led_val[i] <= 0) \
+        led_val[i] = MAX_LEVEL; \
     else \
-        led##i##_val -= INTERVAL##i; \
-    if (led##i##_val < 0) \
-        led##i##_val = 0;
+        led_val[i] -= INTERVAL##i; \
+    if (led_val[i] < 0) \
+        led_val[i] = 0;
 
 
 void led0_event() {
@@ -156,7 +156,7 @@
 }
 
 #define start_led(i) \
-	led##i##_val = MAX_LEVEL; \
+	led_val[i] = MAX_LEVEL; \
 	blinker##i.attach(&led##i##_event, WAIT_TIME##i);
 
 #define stop_led(i) blinker##i.detach();