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.
SimpleWS2811.cpp
00001 #include "ws2811BitBang.h" 00002 00003 static inline void send0(DigitalOut& ws2811Data){ 00004 ws2811Data=1; 00005 WAIT0H(); 00006 ws2811Data=0; 00007 WAIT0L(); 00008 } 00009 static inline void send1(DigitalOut& ws2811Data){ 00010 ws2811Data=1; 00011 WAIT1H(); 00012 ws2811Data=0; 00013 WAIT1L(); 00014 } 00015 00016 static inline void sendByte(uint8_t b, DigitalOut& ws2811Data){ 00017 for(int i=0;i<8;i++){ 00018 if(b & (uint8_t)0x80){ 00019 send1(ws2811Data); 00020 }else{ 00021 send0(ws2811Data); 00022 } 00023 b = b << 1; 00024 } 00025 } 00026 00027 static inline void sendLED(uint8_t red, uint8_t green, uint8_t blue,DigitalOut& ws2811Data){ 00028 sendByte(red,ws2811Data); 00029 sendByte(green,ws2811Data); 00030 sendByte(blue,ws2811Data); 00031 } 00032 00033 static inline void sendLED(uint8_t *p,DigitalOut& ws2811Data){ 00034 sendLED(*p,*(p+1), *(p+2),ws2811Data); 00035 } 00036 00037 void sendBuffer(uint8_t* rgbBuf,size_t len,DigitalOut& ws2812Data){ 00038 __disable_irq(); 00039 for(size_t i=0;i<len;i++){ 00040 sendLED(rgbBuf+3*i,ws2812Data); 00041 } 00042 __enable_irq(); 00043 }
Generated on Mon Jul 25 2022 05:08:35 by
1.7.2