Temp Fork

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:
robertbui
Date:
Thu Dec 11 05:40:39 2014 +0000
Parent:
25:7a866b3d79bb
Child:
27:0e341d81ea00
Commit message:
Added updateCube function.

Changed in this revision

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/ledCube.cpp	Thu Dec 11 04:24:28 2014 +0000
+++ b/ledCube.cpp	Thu Dec 11 05:40:39 2014 +0000
@@ -18,11 +18,11 @@
 #define PANEL1             0
 #define PANEL2             1
 #define PANEL3             2
-#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 nLEDs              200 //MAX_LEDS_PER_STRIP;
+#define nROWs              10  //number of rows per cube panel 
+#define nCOLs              10  //number of columns per cube panel
+#define DATA_OUT_PIN1      2   // PTD2
+#define DATA_OUT_PIN2      3   // PTD3 
 
 
 LedCube::LedCube():X(0),Y(1),Z(2),ledStrip1(nLEDs, DATA_OUT_PIN1),ledStrip2(nLEDs, DATA_OUT_PIN2)
@@ -33,6 +33,7 @@
 {
 }
 
+/*Sets the initial size and position of the lighted cube*/ 
 void LedCube::Init(int x, int y, int z)
 {
     size = 2;
@@ -51,6 +52,10 @@
     ledStrip2.begin();
 }
 
+/*Determines which LED should be lit based on its 
+cartesian coordinate. The origin is the led at
+bottom left of panel 0 when using a three cube panel.  */
+
 int LedCube::getLedIndex(int panel, int x, int y) {
     if (panel == PANEL1) {
         if (y % 2 == 0) {
@@ -222,4 +227,14 @@
     if((pos[X] + newSize) < nCOLs && (pos[Y] + newSize) < nCOLs && (pos[Z] + newSize) < nCOLs) {
         size = newSize;
     }
-}
\ No newline at end of file
+}
+
+void LedCube::UpdateCube(int size, int deltaX, int deltaY, int deltaZ, float hue) {
+     changeSize(size);
+     move(deltaX, deltaY, deltaZ); 
+     changeColor(hue); 
+     cubeUpdate(); 
+}
+
+
+
--- a/ledCube.h	Thu Dec 11 04:24:28 2014 +0000
+++ b/ledCube.h	Thu Dec 11 05:40:39 2014 +0000
@@ -13,6 +13,7 @@
         void updateLEDs(bool on, int size, int x, int y, int z);
         void updateLEDsOld(bool on, int size, int x, int y, int z);
         void cubeUpdate();
+        void UpdateCube(int size, int deltaX, int deltaY, int deltaZ, float hue); 
         int move(int deltaX, int deltaY, int deltaZ);
         void changeColor(float hue);
         void changeSize(int newSize);