Minimal library to work with APA102-based LED strips. Uses code from FastLED library.
Embed:
(wiki syntax)
Show/hide line numbers
APA102.cpp
00001 #include "mbed.h" 00002 #include "APA102.h" 00003 00004 void fill_solid( struct CRGB * leds, int numToFill, const struct CRGB& color) { 00005 for(int i = 0; i < numToFill; i++) { 00006 leds[i] = color; 00007 } 00008 } 00009 00010 void APA102_write(mbed::SPI& mSPI, struct CRGB * leds, int numToFill) { 00011 00012 mSPI.write(0); 00013 mSPI.write(0); 00014 mSPI.write(0); 00015 mSPI.write(0); 00016 00017 for (int i = 0; i < numToFill; ++i) { 00018 mSPI.write(0xE0 | 31); 00019 mSPI.write(leds[i].b); 00020 mSPI.write(leds[i].g); 00021 mSPI.write(leds[i].r); 00022 } 00023 00024 int nDWords = numToFill / 32; 00025 do { 00026 mSPI.write(0xFF); 00027 mSPI.write(0x00); 00028 mSPI.write(0x00); 00029 mSPI.write(0x00); 00030 } while(nDWords--); 00031 00032 }
Generated on Sun Jul 17 2022 02:18:08 by 1.7.2