cy liang
/
blip_rainbow_mbed-os
blip_rainbow for Mbed OS 5.x
Diff: main.cpp
- Revision:
- 0:60499ad28ea9
- Child:
- 1:ca76237d2965
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jul 25 15:22:59 2014 +0000 @@ -0,0 +1,28 @@ +#include "mbed.h" +#include "neopixel-spi.h" + +// A backing store for the pixel data. +static size_t const count = 16; +neopixel::Pixel pixels[count]; + +// The pixel array control class. +neopixel::Array array(p30); + +uint8_t IntensityForIndex(size_t index) { + uint32_t c = index % 512; + return (c >= 256) ? (256 - c) : c; +} + +int main() { + size_t offset = 0; + while (1) { + for (size_t i = 0; i < count; i++) { + pixels[i].red = IntensityForIndex((i * 10) + offset); + pixels[i].green = IntensityForIndex((i * 20) + offset); + pixels[i].blue = IntensityForIndex((i * 40) + offset); + } + array.Update(pixels, count); + wait_ms(10); + offset++; + } +}