change to enable to use new type of WS2812.

Dependencies:   mbed

Fork of LEDTape_WS2812 by Suga koubou

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

Files at this revision

API Documentation at this revision

Comitter:
tkasa
Date:
Sun Dec 29 03:15:33 2013 +0000
Parent:
0:d067ddfe3df9
Commit message:
change to enable to use new type of WS2812.

Changed in this revision

LEDStrip_WS2812.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/LEDStrip_WS2812.cpp	Mon Jul 08 01:34:51 2013 +0000
+++ b/LEDStrip_WS2812.cpp	Sun Dec 29 03:15:33 2013 +0000
@@ -39,10 +39,12 @@
       while (_ssp->SR & (1<<1)) { // TNF
         if (data[addr] & bit) {
             // 1
+            //_ssp->DR = 0x01f;
             _ssp->DR = 0x01f;
         } else {
             // 0
-            _ssp->DR = 0x07f;
+            //_ssp->DR = 0x007;
+            _ssp->DR = 0x00F;
         }
         bit = bit >> 1;
         if (bit == 0) {
@@ -58,7 +60,8 @@
     } else {
         // blank
         while (_ssp->SR & (1<<1)) { // TNF
-            _ssp->DR = 0xfff;
+            _ssp->DR = 0x000;
+            //_ssp->DR = 0xfff;
             if (addr < 50) {
                 addr ++;
             } else {
--- a/main.cpp	Mon Jul 08 01:34:51 2013 +0000
+++ b/main.cpp	Sun Dec 29 03:15:33 2013 +0000
@@ -14,7 +14,7 @@
 }
 
 int main() {
-    int i, j, k = 0;
+    int j, k = 0;
 
     pc.baud(115200);
     tapeInit(0, 16);
@@ -23,22 +23,43 @@
     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);
+        for (long int i = 0; i < 256; i++) {
+            int val = i;
+            for(int j=0;j<16;j++){
+              tapeSet(j, val);
+            }
+            tapeSend();
+            wait_ms(2);
+        }
+    }
+    for (;;) {
+        for (long int i = 0; i < 256; i++) {
+            int val = (i << 8)|(255-i);
+            for(int j=0;j<16;j++){
+              tapeSet(j, val);
+            }
             tapeSend();
-            led2 = 0;
-            wait_ms(20);
+            wait_ms(2);
+        }
+        for (long int i = 0; i < 256; i++) {
+            int val = (i << 16)|((255-i)<<8);
+            for(int j=0;j<16;j++){
+              tapeSet(j, val);
+            }
+            tapeSend();
+            wait_ms(2);
         }
-        for (i = 0; i < 160; i ++) {
-            tapeSet(i, 0);
+        for (long int i = 0; i < 256; i++) {
+            int val = ((255-i)<<16)|i;
+            for(int j=0;j<16;j++){
+              tapeSet(j, val);
+            }
+            tapeSend();
+            wait_ms(2);
         }
-        tapeSend();
+        //for (i = 0; i < 160; i ++) {
+        //    tapeSet(i, 0);
+        //}
+        //tapeSend();
     }
 }