A program that fades between a selection of colors.
Dependencies: PixelArray WS2812 mbed
Revision 2:381421ec57e1, committed 2017-03-12
- Comitter:
- theros
- Date:
- Sun Mar 12 22:23:08 2017 +0000
- Parent:
- 1:ad5c2cfb2002
- Child:
- 3:b99f66d3e77e
- Commit message:
- Corrected assignment of colorFrom/colorTo values at end of each loop
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun Mar 12 16:51:05 2017 +0000
+++ b/main.cpp Sun Mar 12 22:23:08 2017 +0000
@@ -4,7 +4,7 @@
#define WS2812_BUF 77 //number of LEDs in the array
#define NUM_COLORS 6 //number of colors to store in the array
-#define NUM_STEPS 32 //number of steps between colors
+#define NUM_STEPS 8 //number of steps between colors
DigitalIn usrBtn(USER_BUTTON);
DigitalOut usrLed(LED1);
@@ -42,15 +42,6 @@
// Now the buffer is written, write it to the led array.
while (1)
{
- if ((colorIdx + 1) > NUM_COLORS)
- {
- colorTo = 0;
- }
- else
- {
- colorTo = (colorIdx + 1);
- }
-
//get starting RGB components for interpolation
std::size_t c1 = colorbuf[colorFrom];
std::size_t r1 = (c1 & 0xff0000) >> 16;
@@ -85,6 +76,7 @@
}
}
+ colorFrom = colorIdx;
colorIdx++;
if (colorIdx >= NUM_COLORS)
@@ -92,6 +84,6 @@
colorIdx = 0;
}
- colorFrom = colorIdx;
+ colorTo = colorIdx;
}
}