jason berry
/
NeoPixels
neopixels
Diff: main.cpp
- Revision:
- 1:a9f32c0c835d
- Parent:
- 0:f38492690f0e
diff -r f38492690f0e -r a9f32c0c835d main.cpp --- a/main.cpp Wed Mar 12 18:41:42 2014 +0000 +++ b/main.cpp Thu Feb 04 14:03:17 2021 +0000 @@ -1,54 +1,113 @@ /* - * Adafruit NeoPixel 8x8 matrix example + * Adafruit NeoPixel example * * This program displays a couple simple patterns on an 8x8 NeoPixel matrix. * - * 3 buttons are used for DigitalIns, 2 control the brightness up and down, - * and the third switches patterns */ #include "mbed.h" #include "NeoStrip.h" #include "gt.h" -#define N 64 +#define N 5 //number of leds + + #define PATTERNS 3 -int hueToRGB(float h); -void pattern0(); -void pattern1(); -void pattern2(); +//int hueToRGB(float h); +//void pattern0(); +//oid pattern1(); +//void pattern2(); // array of function pointers to the various patterns -void (*patterns[])(void) = {&pattern0, &pattern1, &pattern2}; +//void (*patterns[])(void) = {&pattern0, &pattern1, &pattern2}; -NeoStrip strip(p18, N); -DigitalIn b1(p20); // brightness up -DigitalIn b2(p19); // brightness down -DigitalIn b3(p21); // next pattern +NeoStrip strip(p25, N); +//DigitalIn b1(p20); // brightness up +//DigitalIn b2(p19); // brightness down +//DigitalIn b3(p22); // next pattern // timer used for debugging Timer timer; int main() { - b1.mode(PullDown); - b2.mode(PullDown); - b3.mode(PullDown); +// b1.mode(PullDown); +// b2.mode(PullDown); +// b3.mode(PullDown); - int pattern = 0; - float bright = 0.2; // 20% is plenty for indoor use - bool b3o = b3; // old copy of button 3 to poll for changes + //int pattern = 0; + //bool b3o = b3; // old copy of button 3 to poll for changes + //int p = 0; + + + float bright = 0.2; // 20% is plenty for indoor use + int color = 0x122446; //0xFF0000; //red + strip.setBrightness(bright); // set default brightness - while (true) + while(true) + { + //strip.setPixels(0, N, test_img); + strip.clear(); + strip.write(); + wait_ms(1000); + strip.setPixel(0,color); + strip.write(); + wait_ms(1000); + + strip.setPixel(1,color); + strip.write(); + wait_ms(1000); + + strip.setPixel(2,color); + strip.write(); + wait_ms(1000); + + strip.setPixel(3,color); + strip.write(); + wait_ms(1000); + + strip.setPixel(4,color); + strip.write(); + wait_ms(1000); + + } +} + + + + + + + + + + + + + + + + + + + + + + + + + + + /*while (true) { timer.reset(); // use a timer to measure loop execution time for debugging purposes timer.start(); // for this application, the main loop takes approximately 3ms to run // button 1 increases brightness - if (b1 && bright < 1) + if(0) //(b1 && bright < 1) { bright += 0.01; if (bright > 1) @@ -57,7 +116,7 @@ } // button 2 decreases brightness - if (b2 && bright > 0) + if (0)//(b2 && bright > 0) { bright -= 0.01; if (bright < 0) @@ -66,7 +125,7 @@ } // button 3 changes the pattern, only do stuff when its state has changed - if (b3 != b3o) + if (0)//(b3 != b3o) { if (b3 && ++pattern == PATTERNS) pattern = 0; @@ -84,10 +143,10 @@ wait_ms(10); } -} +}*/ // pattern0 displays a static image -void pattern0() +/*void pattern0() { strip.setPixels(0, N, gt_img); } @@ -177,4 +236,4 @@ return (R << 16) | (G << 8) | B; } - +*/