change to enable to use new type of WS2812.
Fork of LEDTape_WS2812 by
this program is forked from following programs. http://mbed.org/users/okini3939/code/LEDTape_WS2812/
differences
diffs from parent source.
- 1. adapted to new type of WS2812.
- 2. change output level to be reversed.
1.adapted to new type of WS2812.
CODE:0
__________ | |________________| 0.4[us] ±150[ns] 0.85[us] ±150[ns] (old module: 0.35[us] 0.8[us])
CODE:1
_______________ | |___________| 0.8[us] ±150[ns] 0.45[us] ±150[ns] (old module: 0.7[us] 0.6[us])
CODE:RET
> 50[us] |______________________|
2. change output level to be reversed
mbed LED module ----------+ +-------- Vcc | ---------- | 5[v] MOSI | ---|>----- | DIO GND | ---------- | GND ----------+ +--------
syntax : https://mbed.org/cookbook/Wiki-Syntax
Diff: main.cpp
- Revision:
- 0:d067ddfe3df9
- Child:
- 1:bbc584b629fa
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Jul 08 01:34:51 2013 +0000 @@ -0,0 +1,44 @@ +/* + * WS2812 tape led IC + */ +#include "mbed.h" +#include "LEDStrip.h" + +Serial pc(USBTX, USBRX); +DigitalOut led1(LED1), led2(LED2), led3(LED3), led4(LED4); + +extern "C" +void HardFault_Handler() { + printf("Hard Fault!\r\n"); + exit(-1); +} + +int main() { + int i, j, k = 0; + + pc.baud(115200); + tapeInit(0, 16); + led1 = 1; + + pc.printf("led\r\n"); + + for (;;) { + for (i = 0; i < 256; i ++) { + led2 = 1; + tapeSet(0, (i << 16)); + tapeSet(2, (i << 8)); + tapeSet(4, i); + tapeSet(6, (i << 8)|i); + tapeSet(7, (i << 16)|i); + tapeSet(8, (i << 16)|(i << 8)); + tapeSet(9, (i << 16)|(i << 8)|i); + tapeSend(); + led2 = 0; + wait_ms(20); + } + for (i = 0; i < 160; i ++) { + tapeSet(i, 0); + } + tapeSend(); + } +}