Driver for the GE Color Effects LED lights. Currently it is blocking, but it could be made to be nonblocking.
Dependents: GEColorEffects_Example GEColorEffects_Example
This library's code is based on Clark Jarvis's program here: http://developer.mbed.org/users/clarkjarvis/code/FRDM_GE_ColorEffects/
Revision 1:e56bc0a8c273, committed 2015-07-15
- Comitter:
- bridadan
- Date:
- Wed Jul 15 20:04:49 2015 +0000
- Parent:
- 0:3f51641c4e69
- Commit message:
- Disabling irq around time sensitive parts. Added setBrightness function.
Changed in this revision
GEColorEffects.cpp | Show annotated file Show diff for this revision Revisions of this file |
GEColorEffects.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 3f51641c4e69 -r e56bc0a8c273 GEColorEffects.cpp --- a/GEColorEffects.cpp Mon Feb 16 20:27:53 2015 +0000 +++ b/GEColorEffects.cpp Wed Jul 15 20:04:49 2015 +0000 @@ -7,6 +7,8 @@ void GEColorEffects::write(int buf[], bool eightBit) { int l, r, g, b; + + __disable_irq(); for (int i = 0; i < size; i++) { l = (buf[i] >> 24) & 0xFF; r = (buf[i] >> 16) & 0xFF; @@ -19,6 +21,7 @@ sendFrame(i, l, r, g, b); } } + __enable_irq(); } // GPIO output to send a logical 0 @@ -50,7 +53,13 @@ } } } - + +void GEColorEffects::setBrightness(unsigned char brightness) { + __disable_irq(); + sendFrame(63, brightness, 0, 0, 0); + __enable_irq(); +} + // Send frame of data to control a single pixel void GEColorEffects::sendFrame(unsigned char address, unsigned char lumm, unsigned char R, unsigned char G, unsigned char B) { // Send "1" value to start Frame
diff -r 3f51641c4e69 -r e56bc0a8c273 GEColorEffects.h --- a/GEColorEffects.h Mon Feb 16 20:27:53 2015 +0000 +++ b/GEColorEffects.h Wed Jul 15 20:04:49 2015 +0000 @@ -7,6 +7,7 @@ public: GEColorEffects(PinName pin, int size); + void setBrightness(unsigned char brightness); void write(int buf[], bool eightBit); private: