updated

Fork of neopixels_spi by Ivan Yohuno

Revision:
1:2023e348c15f
Parent:
0:22b6f7132818
diff -r 22b6f7132818 -r 2023e348c15f neopixels_spi.cpp
--- a/neopixels_spi.cpp	Tue May 12 14:32:12 2015 +0000
+++ b/neopixels_spi.cpp	Wed May 13 17:52:07 2015 +0000
@@ -33,20 +33,10 @@
      {8th pixel red, 8th pixel blue, 8th pixel green}
      } 
 
-//function declarations 
-//void setRGBPixel(int r, int g, int b); //sets colour of one RGB Pixel
-void setRGBStrip1(int r, int g, int b); //sets colour of a strip of 8 RGB Pixels on pin 5
-void setRGBStrip2(int r, int g, int b); //sets colour of a strip of 8 RGB Pixels on pin 11
-void setRGBPixels1(int colours[8][3]); //sets sequence of colours for a strip of 8 RGB Pixels on pin 5
-void setRGBPixels2(int colours[8][3]); //sets sequence of colours for a strip of 8 RGB Pixels on pin 11
-void spi_init(); //initializes SPI pin at correct bit length and bit rate
-int * decimalToBinary(int n); //converts a decimal value between 0 and 255 to an 8 bit binary array of 0xF00 (0) and 0xFF0 (1)
 */
-//initialize pins 
-//DigitalOut volt(p16); //pin for LV voltage
 SPI spi(p5, p6, p7);//pin for SPI communication - p5 MOSI p5 MISO p6 SCLK
 SPI spi2(p11, p12, p13);//pin for SPI communication - p5 MOSI p5 MISO p6 SCLK
-//NeoStrip strip(p5,8);
+
 
 
 void neopixels_spi::setRGBStrip1(int r, int g, int b){
@@ -60,7 +50,8 @@
     //send commands to LED Driver
      //initialize SPI
      spi_init();
-    //LED0
+    for(int x=0; x<4; x++){
+        //LED0
      //set green bits
     spi.write(g_array[7]); //set g7 bit
     spi.write(g_array[6]); //set g6 bit
@@ -287,7 +278,9 @@
     spi.write(b_array[0]); //set b0 bit
     
     //wait for latch 
-    wait_us(60);
+    wait_us(50);        
+        }
+    
 }
 
 void neopixels_spi::setRGBStrip2(int r, int g, int b){
@@ -301,7 +294,8 @@
     //send commands to LED Driver
      //initialize spi
      spi_init();
-    //LED0
+    for(int i = 0; i<4; i++){
+        //LED0
      //set green bits
     spi2.write(g_array[7]); //set g7 bit
     spi2.write(g_array[6]); //set g6 bit
@@ -528,7 +522,9 @@
     spi2.write(b_array[0]); //set b0 bit
     
     //wait for latch 
-    wait_us(60);
+    wait_us(50);
+        }
+    
 }
     
 void neopixels_spi::setRGBPixels1(int colours[8][3]){
@@ -585,7 +581,8 @@
     //send commands to LED Driver
      //initialize SPI
      spi_init();
-    //LED0
+     for(int v = 0; v<4; v++){
+         //LED0
     //set green bits
     spi.write(g0_array[7]); //set g7 bit
     spi.write(g0_array[6]); //set g6 bit
@@ -810,7 +807,9 @@
     spi.write(b7_array[1]); //set b1 bit 
     spi.write(b7_array[0]); //set b0 bit
     //wait for latch
-    wait_us(60);   
+    wait_us(50);   
+         }
+    
 }
 
 void neopixels_spi::setRGBPixels2(int colours[8][3]){
@@ -867,7 +866,8 @@
     //send commands to LED Driver
      //initialize SPI
      spi_init();
-    //LED0
+     for(int b = 0; b<4; b++){
+         //LED0
     //set green bits
     spi2.write(g0_array[7]); //set g7 bit
     spi2.write(g0_array[6]); //set g6 bit
@@ -1092,7 +1092,9 @@
     spi2.write(b7_array[1]); //set b1 bit 
     spi2.write(b7_array[0]); //set b0 bit
     //wait for latch
-    wait_us(60);   
+    wait_us(50);   
+         }
+    
 }
 int * neopixels_spi ::decimalToBinary(int n)  // converts decimal value to 8 bit array of 1's (0xFF0) and 0's (0xF00)
 {