Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: WS2812_LED mbed
Fork of WS2812-Example by
Revision 0:52571581ff7e, committed 2015-11-18
- Comitter:
- fastestoffer
- Date:
- Wed Nov 18 18:11:40 2015 +0000
- Commit message:
- Initial commit of example;
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WS2812_LED.lib Wed Nov 18 18:11:40 2015 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/silabs-abakurs/code/WS2812_LED/#f1e39d76fbca
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Nov 18 18:11:40 2015 +0000
@@ -0,0 +1,59 @@
+#include "mbed.h"
+#include "WS2812.h"
+
+LowPowerTicker toggleTicker;
+
+Color color_red = {255, 0, 0};
+Color color_green = {0, 255, 0};
+Color color_blue = {0, 0, 255};
+Color color_black = {0,0,0};
+
+bool update_led_flag;
+bool ledstrip_busy;
+int state = 0;
+
+void update(void) {
+ update_led_flag = true;
+}
+
+void send_complete(int event) {
+ (void)event;
+ ledstrip_busy = false;
+}
+
+event_callback_t callback;
+
+int main(void) {
+
+ SPI spi(PE10, NC, PE12);
+
+ callback.attach(send_complete);
+
+ WS2812 ledstrip(spi, callback);
+
+ toggleTicker.attach(&update, 1.0f);
+
+ while(1) {
+ sleep();
+ if(update_led_flag)
+ {
+ update_led_flag=false;
+ switch(state){
+ case 0:
+ ledstrip.set_all(&color_green);
+ state++;
+ break;
+ case 1:
+ ledstrip.set_all(&color_blue);
+ state++;
+ break;
+ case 2:
+ ledstrip.set_all(&color_red);
+ state=0;
+ break;
+ }
+ ledstrip_busy = true;
+ ledstrip.update_strip();
+ }
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Nov 18 18:11:40 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11 \ No newline at end of file
