Model-Based Team / Mbed 2 deprecated CubicHand

Dependencies:   MMA8451Q TSI cc3000_hostdriver_mbedsocket NVIC_set_all_priorities mbed Multi_WS2811

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LedCube.h Source File

LedCube.h

00001 #include "mbed.h"
00002 #include "WS2811.h"
00003 #include "CubeUpdateParameters.h"
00004 
00005 #pragma once
00006 
00007 class LedCube
00008 {
00009     public:
00010         LedCube();
00011         ~LedCube();
00012         
00013         /*Sets the initial size and position of the lighted cube*/ 
00014         void Init(int x, int y, int z);
00015         
00016         /* Returns the index of the LED given the cartesian 
00017          * coordinates of the LED on a given panel. The origin 
00018          * is the led at the bottom left of panel 1 when using 
00019          * a three panel cube.
00020              ________
00021             /       /|
00022            /   3   / |
00023           /_______/ 2|
00024           |       |  | 
00025           |   1   | /
00026           |       |
00027           --------      
00028           
00029           Z    Y
00030           |   /
00031           |  /
00032           | /
00033           |/
00034            -------X   */
00035         int getLedIndex(int panel, int x, int y);
00036         
00037         /* Lights up (if on) or turns off (if !on) the LEDs on the LED cube 
00038          * corresponding to the location of the square. All panels will show 
00039          * the cube, with brightness depending on the distance from the 
00040          * square to the panel.*/
00041         void updateLEDs(bool on, int size, int x, int y, int z);
00042         void updateLEDsOld(bool on, int size, int x, int y, int z);
00043         
00044         /* Updates the LED cube.*/
00045         void cubeUpdate();
00046         
00047         /* Updates the LED cube given the size, hue and offsets in the X, Y and Z axes.*/
00048         void UpdateCube(int size, int deltaX, int deltaY, int deltaZ, float hue); 
00049         
00050         /* Updates the LED cube given parameters in a CubeUpdateParameters struct.*/
00051         void UpdateCube2(CubeUpdateParameters cubeParams);
00052         
00053         /* Moves the square inside the cube by deltaX in the x-axis,
00054          * by deltaY in the y-axis, and deltaZ in the z-axis. Returns
00055          * 1 if movement occured, and -1 if no movement occured.*/
00056         int move(int deltaX, int deltaY, int deltaZ);
00057         
00058         /* Changes the color of the square in the LED cube to the given hue.*/
00059         void changeColor(float hue);
00060         
00061         /* Changes the size of the square in the LED cube to the given size.
00062          * The minimum size is 1, corresponding to a square of a single LED.
00063          * A size of 2 corresponds to a 2x2 LED square, 3 corresponds to 3x3 
00064          * and so forth. If square is on an edge, it moves accordingly in 
00065          * order to be able to increase size.*/
00066         void changeSize(int newSize);
00067         
00068     private:
00069         unsigned const X;
00070         unsigned const Y;
00071         unsigned const Z;
00072         int pos[3];
00073         int prevPos[3];
00074         int size;
00075         int prevSize;
00076 
00077         float saturation;
00078         float brightness;
00079         uint8_t r;
00080         uint8_t g;
00081         uint8_t b;        
00082         WS2811 ledStrip1;
00083         WS2811 ledStrip2;
00084     
00085 };