cy liang
/
blip_rainbow_mbed-os
blip_rainbow for Mbed OS 5.x
main.cpp
- Committer:
- JacobBramley
- Date:
- 2014-08-01
- Revision:
- 1:ca76237d2965
- Parent:
- 0:60499ad28ea9
- Child:
- 3:2d84c8262139
File content as of revision 1:ca76237d2965:
#include "mbed.h" #include "neopixel.h" // This must be an SPI MOSI pin. #define DATA_PIN p5 void generate(neopixel::Pixel * out, uint32_t index, uintptr_t extra) { uint32_t brightness = (index + extra) >> 3; out->red = ((index + extra) & 0x1) ? brightness : 0; out->green = ((index + extra) & 0x2) ? brightness : 0; out->blue = ((index + extra) & 0x4) ? brightness : 0; } int main() { // Create a temporary DigitalIn so we can configure the pull-down resistor. // (The mbed API doesn't provide any other way to do this.) // An alternative is to connect an external pull-down resistor. DigitalIn(DATA_PIN, PullDown); // The pixel array control class. neopixel::PixelArray array(DATA_PIN); uint32_t offset = 0; while (1) { array.update(generate, 100, offset++); wait_ms(250); } }