
NeoStrip
Fork of NeoPixels by
Revision 1:a0c08e317195, committed 2017-07-02
- Comitter:
- gert_lauritsen
- Date:
- Sun Jul 02 08:47:49 2017 +0000
- Parent:
- 0:f38492690f0e
- Commit message:
- NeoStrip
Changed in this revision
--- a/NeoStrip.lib Wed Mar 12 18:41:42 2014 +0000 +++ b/NeoStrip.lib Sun Jul 02 08:47:49 2017 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/aswild/code/NeoStrip/#9f237b11f0a8 +http://mbed.org/users/aswild/code/NeoStrip/#f531a2be180d
--- a/main.cpp Wed Mar 12 18:41:42 2014 +0000 +++ b/main.cpp Sun Jul 02 08:47:49 2017 +0000 @@ -14,6 +14,7 @@ #define N 64 #define PATTERNS 3 +Serial pc(USBTX, USBRX); int hueToRGB(float h); void pattern0(); void pattern1(); @@ -22,23 +23,23 @@ // array of function pointers to the various patterns void (*patterns[])(void) = {&pattern0, &pattern1, &pattern2}; -NeoStrip strip(p18, N); -DigitalIn b1(p20); // brightness up +NeoStrip strip(p21, N); +int selekt=0; +/*DigitalIn b1(p20); // brightness up DigitalIn b2(p19); // brightness down -DigitalIn b3(p21); // next pattern +DigitalIn b3(p21); // next pattern*/ // timer used for debugging Timer timer; int main() { - b1.mode(PullDown); - b2.mode(PullDown); - b3.mode(PullDown); + pc.baud(115200); + printf("Test af LED\r\n"); 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 b3o = selekt; // old copy of button 3 to poll for changes strip.setBrightness(bright); // set default brightness @@ -48,7 +49,7 @@ timer.start(); // for this application, the main loop takes approximately 3ms to run // button 1 increases brightness - if (b1 && bright < 1) + if ((selekt==1) && bright < 1) { bright += 0.01; if (bright > 1) @@ -57,7 +58,7 @@ } // button 2 decreases brightness - if (b2 && bright > 0) + if ((selekt==2) && bright > 0) { bright -= 0.01; if (bright < 0) @@ -66,22 +67,25 @@ } // button 3 changes the pattern, only do stuff when its state has changed - if (b3 != b3o) + if ((selekt==3) != b3o) { - if (b3 && ++pattern == PATTERNS) - pattern = 0; - b3o = b3; + if (++pattern == PATTERNS) pattern = 0; + } - + selekt=0; // run the pattern update function which sets the strip's pixels patterns[pattern](); strip.write(); timer.stop(); // print loop time if b3 is pressed - if (b3) - printf("Loop Time: %dus\n", timer.read_us()); - + if (pc.readable()) { + switch(pc.getc()) { + case '1': selekt=1; break; + case '2': selekt=2; break; + case '3': selekt=3; break; + } + } wait_ms(10); } }
--- a/mbed.bld Wed Mar 12 18:41:42 2014 +0000 +++ b/mbed.bld Sun Jul 02 08:47:49 2017 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/8e73be2a2ac1 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/cbbeb26dbd92 \ No newline at end of file