Robert Bui / Mbed 2 deprecated CubicHand

Dependencies:   MMA8451Q Multi_WS2811 NVIC_set_all_priorities TSI cc3000_hostdriver_mbedsocket mbed

Fork of CubicHand by Model-Based Team

Files at this revision

API Documentation at this revision

Comitter:
joseoyola
Date:
Wed Dec 10 22:45:49 2014 +0000
Parent:
17:c2e59ada97ee
Child:
21:5b987194387d
Commit message:
Changed Neopixel library to support 240 leds/strip.

Changed in this revision

Multi_WS2811.lib Show annotated file Show diff for this revision Revisions of this file
ledCube.cpp Show annotated file Show diff for this revision Revisions of this file
ledCube.h Show annotated file Show diff for this revision Revisions of this file
--- a/Multi_WS2811.lib	Mon Dec 08 03:29:39 2014 +0000
+++ b/Multi_WS2811.lib	Wed Dec 10 22:45:49 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/bikeNomad/code/Multi_WS2811/#a8535703f23b
+http://developer.mbed.org/users/Tomo2k/code/Multi_WS2811/#58623ad7f310
--- a/ledCube.cpp	Mon Dec 08 03:29:39 2014 +0000
+++ b/ledCube.cpp	Wed Dec 10 22:45:49 2014 +0000
@@ -18,15 +18,14 @@
 #define PANEL1             0
 #define PANEL2             1
 #define PANEL3             2
-#define nLEDs              60//MAX_LEDS_PER_STRIP;
+#define nLEDs              200//MAX_LEDS_PER_STRIP;
 #define nROWs              10
 #define nCOLs              10  
 #define DATA_OUT_PIN1      2 // PTD2
-#define DATA_OUT_PIN2      3 // PTD3
-#define DATA_OUT_PIN3      4 // PTD3  
+#define DATA_OUT_PIN2      3 // PTD3 
 
 
-LedCube::LedCube():X(0),Y(1),Z(2),ledStrip1(nLEDs, DATA_OUT_PIN1),ledStrip2(nLEDs, DATA_OUT_PIN2),ledStrip3(nLEDs, DATA_OUT_PIN3)
+LedCube::LedCube():X(0),Y(1),Z(2),ledStrip1(nLEDs, DATA_OUT_PIN1),ledStrip2(nLEDs, DATA_OUT_PIN2)
 {
 }
 
@@ -50,7 +49,6 @@
     
     ledStrip1.begin();
     ledStrip2.begin();
-    ledStrip3.begin();
 }
 
 int LedCube::getLedIndex(int panel, int x, int y) {
@@ -105,11 +103,9 @@
             for(int j = z; j < z + size; j++) {
                 int led = getLedIndex(PANEL2, i, j);
                 if(on) {
-                    if(z < 3) ledStrip1.setPixelColor(led, r, g, b);
-                    else ledStrip2.setPixelColor(led, r, g, b);
+                    ledStrip1.setPixelColor(led, r, g, b);
                 } else {
-                    if (z < 3) ledStrip1.setPixelColor(led, 0, 0, 0);
-                    ledStrip2.setPixelColor(led, 0, 0, 0);
+                    ledStrip1.setPixelColor(led, 0, 0, 0);
                 }
             }
         }
@@ -121,9 +117,9 @@
             for(int j = y; j < y + size; j++) {
                 int led = getLedIndex(PANEL3, i, j);
                 if(on) {
-                    ledStrip3.setPixelColor(led, r, g, b);
+                    ledStrip2.setPixelColor(led, r, g, b);
                 } else {
-                    ledStrip3.setPixelColor(led, 0, 0, 0);
+                    ledStrip2.setPixelColor(led, 0, 0, 0);
                 }
             }
         }
@@ -140,10 +136,8 @@
     prevPos[Z] = pos[Z];
     ledStrip1.show();
     ledStrip2.show();
-    ledStrip3.show();
     ledStrip1.startDMA();
     ledStrip2.startDMA();
-    ledStrip3.startDMA();
     printf("Position: %d, %d, %d \t Size: %d\r\n", pos[X], pos[Y], pos[Z], size);
 }
 
@@ -154,7 +148,6 @@
         if((pos[X] + size + deltaX - 1) < nCOLs && (pos[X] + deltaX) >= 0) {
             pos[X] += deltaX;
             if (deltaX != 0) retVal = 1;
-            printf("Here1, %d\r\n",retVal);
         }
     }
     
@@ -163,7 +156,6 @@
         if((pos[Y] + size + deltaY - 1) < nCOLs && (pos[Y] + deltaY) >= 0) {
             pos[Y] += deltaY;
             if (deltaY != 0) retVal = 1;
-            printf("Here2, %d\r\n",retVal);
         }
     }
     
@@ -172,58 +164,17 @@
         if((pos[Z] + size + deltaZ - 1) < nCOLs && (pos[Z] + deltaZ) >= 0) {
             pos[Z] += deltaZ;
             if (deltaZ != 0) retVal = 1;
-            printf("Here3, %d\r\n",retVal);
         }
     }
     return retVal;
-    //cubeUpdate();
 }
 
 void LedCube::changeColor(float hue){
-    HSBtoRGB(hue, saturation, brightness, &r, &g, &b);
+    Colors::HSBtoRGB(hue, saturation, brightness, &r, &g, &b);
 }
 
 void LedCube::changeSize(int newSize) {
     if((pos[X] + newSize) < nCOLs && (pos[Y] + newSize) < nCOLs && (pos[Z] + newSize) < nCOLs) {
         size = newSize;
     }
-}
-
-
-
-
-
-
-
-/*
-static void move( int delta_x, int delta_y, int old_size, int new_size)
-{
-    for( int i = pos_y; i < pos_y + old_size; i++){
-        for( int j= pos_x; j < pos_x + old_size; j++){
-            int pos_off = matrixtolinear(i,j);
-            if( pos_off >= nLEDs){lightStrip2.setPixelColor(pos_off-nLEDs, 0, 0, 0);}
-            else 
-            {lightStrip1.setPixelColor(pos_off, 0, 0, 0);}
-            
-            }
-        }
-        if ( (pos_y + (new_size-1) + delta_y < nROWs) && (pos_y + delta_y ) >= 0 ) {
-        pos_y = pos_y + delta_y;}
-        if ( (pos_x + (new_size-1) + delta_x < nCOLs ) && (pos_x + delta_x ) >= 0) {
-        pos_x = pos_x + delta_x;}
-         
-    for( int i = pos_y; i < pos_y + new_size; i++){
-        for( int j= pos_x; j < pos_x + new_size; j++){
-            int pos_on = matrixtolinear(i,j);
-            if( pos_on >= nLEDs){lightStrip2.setPixelColor(pos_on-nLEDs, 0, g, 0);}
-            else
-            {lightStrip1.setPixelColor(pos_on, 0, g, 0);}
-            }
-        }
-    
-    lightStrip1.show();
-    lightStrip2.show();
-    lightStrip1.startDMA();
-    lightStrip2.startDMA();
-}
-*/
\ No newline at end of file
+}
\ No newline at end of file
--- a/ledCube.h	Mon Dec 08 03:29:39 2014 +0000
+++ b/ledCube.h	Wed Dec 10 22:45:49 2014 +0000
@@ -24,12 +24,7 @@
         int prevPos[3];
         int size;
         int prevSize;
-        //unsigned const nLEDs;//MAX_LEDS_PER_STRIP;
-        //unsigned const nROWs;
-        //unsigned const nCOLs; 
-        //unsigned const DATA_OUT_PIN1; // PTD2
-        //unsigned const DATA_OUT_PIN2; // PTD3
-        //unsigned const DATA_OUT_PIN3; // PTD3
+
         float saturation;
         float brightness;
         uint8_t r;
@@ -37,6 +32,5 @@
         uint8_t b;        
         WS2811 ledStrip1;
         WS2811 ledStrip2;
-        WS2811 ledStrip3;
     
 };
\ No newline at end of file