Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MMA8451Q TSI cc3000_hostdriver_mbedsocket NVIC_set_all_priorities mbed Multi_WS2811
Diff: ledCube.cpp
- Revision:
- 32:bf5f545621aa
- Parent:
- 24:554ea084eddf
- Child:
- 33:ff87df17c55d
diff -r 3261015fdd17 -r bf5f545621aa ledCube.cpp
--- a/ledCube.cpp Thu Dec 11 05:57:54 2014 +0000
+++ b/ledCube.cpp Thu Dec 11 06:08:13 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,19 @@
ledStrip2.begin();
}
+/*Determines which LED should be lit based on its
+cartesian coordinate. The origin is the led at
+bottom left of panel 1 when using a three panel cube
+ ________
+ / /|
+ / 3 / |
+ /_______/ 2|
+ | | |
+ | 1 | /
+ | |
+ --------
+*/
+
int LedCube::getLedIndex(int panel, int x, int y) {
if (panel == PANEL1) {
if (y % 2 == 0) {
@@ -222,4 +236,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();
+}
+
+
+

