MD_Cubo LED Cube Arduino Library  2.1
Library to control LED Cubes
MD_Cubo Class Reference

#include <MD_Cubo.h>

+ Inheritance diagram for MD_Cubo:

Public Types

enum  axis_t : uint8_t { XAXIS, YAXIS, ZAXIS }
 
enum  plane_t : uint8_t { XYPLANE, XZPLANE, YZPLANE }
 

Public Member Functions

 MD_Cubo (uint8_t sizeCube)
 
 ~MD_Cubo ()
 
Methods for hardware control.
virtual void begin (void)
 
virtual void setVoxel (boolean p, uint8_t x, uint8_t y, uint8_t z)
 
virtual void setVoxel (uint32_t p, uint8_t x, uint8_t y, uint8_t z)
 
virtual uint32_t getVoxel (uint8_t x, uint8_t y, uint8_t z)
 
virtual void setIntensity (uint8_t intensity)
 
uint8_t getIntensity (void)
 
virtual void update ()
 
virtual void clear (uint32_t p=VOX_OFF)
 
virtual void animate (uint32_t wait=0)
 
uint8_t size (axis_t axis)
 
virtual bool isColorCube (void)
 

Methods for device-independent graphics.

uint8_t _sizeXaxis
 the number of LEDs on x axis of the cube. Total number of voxels is x*y*z.
 
uint8_t _sizeYaxis
 the number of LEDs on y axis of the cube. Total number of voxels is x*y*z.
 
uint8_t _sizeZaxis
 the number of LEDs on z axis of the cube. Total number of voxels is x*y*z.
 
uint8_t _intensity
 the default intensity for the cube.
 
void fillPlane (uint32_t p, plane_t plane, uint8_t coord)
 
void copyPlane (plane_t plane, uint8_t cordFrom, uint8_t cordTo)
 
void drawLine (uint32_t p, uint8_t x1, uint8_t y1, uint8_t z1, uint8_t x2, uint8_t y2, uint8_t z2)
 
void drawRPrism (uint32_t p, uint8_t x, uint8_t y, uint8_t z, int8_t dx, int8_t dy, int8_t dz)
 
void drawCube (uint32_t p, uint8_t x, uint8_t y, uint8_t z, int8_t size)
 

Detailed Description

Core object for the MD_Cubo library

Member Enumeration Documentation

◆ axis_t

enum MD_Cubo::axis_t : uint8_t

Axis name enumerated type.

This enumerated type is used to specify a cartesian axis

Enumerator
XAXIS 

X axis.

YAXIS 

Y axis.

ZAXIS 

Z axis (always vertical, starting at the bottom)

◆ plane_t

enum MD_Cubo::plane_t : uint8_t

Plane name enumerated type.

This enumerated type is used to define a specific cartesian plane

Enumerator
XYPLANE 

Cartesian plane bounded by XY axes.

XZPLANE 

Cartesian plane bounded by XZ axes.

YZPLANE 

Cartesian plane bounded by YZ axes.

Constructor & Destructor Documentation

◆ MD_Cubo()

MD_Cubo::MD_Cubo ( uint8_t  sizeCube)

Class Constructor.

Instantiate a new instance of the class. The parameters passed are used to initialize the object. Multiple instances may co-exist provided the virtual cube functions can do so also.

Parameters
sizeCubethe number of LEDs on each side of the cube.

◆ ~MD_Cubo()

MD_Cubo::~MD_Cubo ( )

Class Destructor.

Released any allocated memory and does the necessary to clean up once the object is no longer required.

Member Function Documentation

◆ animate()

virtual void MD_Cubo::animate ( uint32_t  wait = 0)
virtual

Animate the cube display.

Cubes that need to be refreshed/multiplexed in order to show the display should have the multiplexing code inserted here. The code should be written as a non-blocking state machine that should be executing for wait milliseconds. If wait is zero then one step in the refresh should be executed and the method needs to be invoke often enough to ensure animations are seen to be smooth. This is only implementable in the user derived object, as it is heavily reliant on the hardware configuration.

Parameters
waitoptional period for this animation to execute before returning.
Returns
No return value.

Reimplemented in MD_Cubo_DirectIO, MD_Cubo_ICS595, and MD_Cubo_ICS574.

◆ begin()

virtual void MD_Cubo::begin ( void  )
virtual

Initialize the object.

Initialize the object data. This needs to be called during setup() to initialize new data for the class that cannot be done during the object creation.

Hardware interfaces implemented in virtual functions should be initialized here.

Reimplemented in MD_Cubo_DirectIO, MD_Cubo_JC, MD_Cubo_ICS574, MD_Cubo_STC, MD_Cubo_ICS595, and MD_Cubo_72xx.

◆ clear()

void MD_Cubo::clear ( uint32_t  p = VOX_OFF)
virtual

Clear the cube.

Set every voxel in the cube to the specified value (default off). The generic method iterates through all the voxels. A more efficient implementation may be possible by exploiting access to hardware.

Parameters
pset the the RGB value required, RGB(0,0,0) for all black (default).
Returns
No return value.

Reimplemented in MD_Cubo_DirectIO, MD_Cubo_JC, MD_Cubo_STC, MD_Cubo_ICS595, and MD_Cubo_72xx.

◆ copyPlane()

void MD_Cubo::copyPlane ( plane_t  plane,
uint8_t  cordFrom,
uint8_t  cordTo 
)

Copy the specified plane.

One slice of LEDs (a square) is copied from the plane coordinate cordFrom to the plane coordinate cordTo. The coordinate relates to the intersection point between the plane and the axis specified. For example, if plane is XYPLANE, coord is the z value through which the plane passes.

Parameters
planethe plane this applies to. One of the plane_t value.
cordFromthe source coordinate value.
cordTothe destination coordinate value.
Returns
No return value.

◆ drawCube()

void MD_Cubo::drawCube ( uint32_t  p,
uint8_t  x,
uint8_t  y,
uint8_t  z,
int8_t  size 
)

Draw the outline of a cube in 3D space.

The cube is a rectangular prism with same dx, dy, dz, so this is a wrapper for the more generic case.

Parameters
pvoxel RGB value - if VOX_OFF, set the voxel off. Otherwise set the voxel to the color.
xx coordinate for one corner.
yy coordinate for one corner.
zz coordinate for one corner.
sizethe size of one side of the cube in voxels.
Returns
No return value.

◆ drawLine()

void MD_Cubo::drawLine ( uint32_t  p,
uint8_t  x1,
uint8_t  y1,
uint8_t  z1,
uint8_t  x2,
uint8_t  y2,
uint8_t  z2 
)

Draw an arbitrary line in 3D space.

The line is drawn from the start to the end coordinates using Bresenham's line drawing algorithm in 3D. The line can be drawn 'on' or 'off' by specifying the voxel value, p.

Parameters
pvoxel RGB value - if VOX_OFF, set the voxel off. Otherwise, set the voxel to the color.
x1x coordinate for the start point.
y1y coordinate for the start point.
z1z coordinate for the start point.
x2x coordinate for the end point.
y2y coordinate for the end point.
z2z coordinate for the end point.
Returns
No return value.

◆ drawRPrism()

void MD_Cubo::drawRPrism ( uint32_t  p,
uint8_t  x,
uint8_t  y,
uint8_t  z,
int8_t  dx,
int8_t  dy,
int8_t  dz 
)

Draw an arbitrary rectangular prism in 3D space.

The rectangular prism is drawn from the start coordinates to the diagonally opposite corner in 3D space. The line can be drawn in any color by specifying the voxel value, p. A cube is a rectangular prism with the same dx, dy, dz A rectangle (2D) is a rectangular prism with one of dx, dy or dz set to 0

Parameters
pvoxel RGB value - if VOX_OFF set the voxel off. Otherwise set the voxel to the color.
xx coordinate for one corner.
yy coordinate for one corner.
zz coordinate for one corner.
dxx delta for diagonally opposite point.
dyy delta for diagonally opposite point.
dzz delta for diagonally opposite point.
Returns
No return value.

◆ fillPlane()

void MD_Cubo::fillPlane ( uint32_t  p,
plane_t  plane,
uint8_t  coord 
)

Fill the specified plane.

One slice of LEDs (a square) is turned on or off at the specified coordinate value. The coordinate relates to the intersection point between the plane and the axis specified. For example, if plane is XYPLANE, coord is the z value through which the plane passes.

Parameters
pvoxel RGB value - if VOX_OFF set the voxel off. Otherwise set the voxel to the color.
planethe plane this applies to. One of the plane_t value.
coordaxis intersection coordinate value.
Returns
No return value.

◆ getIntensity()

uint8_t MD_Cubo::getIntensity ( void  )

Get the default intensity/brightness of the cube.

Get the default brightness of the cube. This is only implementable in the user derived object, as it is heavily reliant on the hardware configuration.

Returns
The intensity for the cube (0 .. MAX_INTENSITY).

◆ getVoxel()

virtual uint32_t MD_Cubo::getVoxel ( uint8_t  x,
uint8_t  y,
uint8_t  z 
)
virtual

Get the status of specified point in the cube.

This is the most basic graphic function and is necessarily only implementable in the user derived object, as it is heavily related to the hardware configuration. The (x,y,z) coordinate for the voxel needs to be mapped to a device address and color value of the voxel returned to the calling program.

Parameters
xx coordinate for the voxel.
yy coordinate for the voxel.
zz coordinate for the voxel.
Returns
voxel RGB value - VOX_OFF if the voxel is off. Otherwise the voxel color value.

Reimplemented in MD_Cubo_DirectIO, MD_Cubo_JC, MD_Cubo_ICS574, MD_Cubo_STC, MD_Cubo_ICS595, and MD_Cubo_72xx.

◆ isColorCube()

virtual bool MD_Cubo::isColorCube ( void  )
virtual

Return whether the cube supports RGB color.

Return true if the cube supports RGB colors. This will depend on the hardware implemented, so can be overridden by the user functions.

Returns
True if RGB color supported.

Reimplemented in MD_Cubo_STC.

◆ setIntensity()

virtual void MD_Cubo::setIntensity ( uint8_t  intensity)
virtual

Set the default intensity/brightness of the cube.

Set the default brightness of the cube. This is only implementable in the user derived object, as it is heavily reliant on the hardware configuration.

Brightness is supplied as a number 0 to MAX_INTENSITY (0 is darkest). If the hardware has a different range this will need to be remapped in the user derived object.

Parameters
intensitythe intensity for the cube (0 .. MAX_INTENSITY).
Returns
No return value.

Reimplemented in MD_Cubo_JC, and MD_Cubo_72xx.

◆ setVoxel() [1/2]

virtual void MD_Cubo::setVoxel ( boolean  p,
uint8_t  x,
uint8_t  y,
uint8_t  z 
)
virtual

Set the specified point in the cube (monochrome version).

This method should only be implemented for monochrome cubes and is for backward compatibility only. The preferred implementation is to use the color version for all cubes.

This is the most basic graphic function and is necessarily only implementable in the user derived object, as it is heavily related to the hardware configuration. The (x,y,z) coordinate for the voxel needs to be mapped to a device action to turn the voxel on or off.

Parameters
pvoxel value - if false, set the voxel off. Otherwise, set the voxel on.
xx coordinate for the voxel.
yy coordinate for the voxel.
zz coordinate for the voxel.
Returns
No return value.

Reimplemented in MD_Cubo_STC.

◆ setVoxel() [2/2]

virtual void MD_Cubo::setVoxel ( uint32_t  p,
uint8_t  x,
uint8_t  y,
uint8_t  z 
)
virtual

Set the specified point in the cube.

This is the most basic graphic function and is necessarily only implementable in the user derived object, as it is heavily related to the hardware configuration. The (x,y,z) coordinate for the voxel needs to be mapped to a device action to turn the voxel to the specified color in the specified color and intensity.

By default all cubes are treated as color cubes. User code should recognize if it is operating with a color or monochrome cube by testing isColorCube(). For clarity, monochrome cubes should use the default VOX_ON and VOX_OFF colors for clarity, color cubes are free to choose any RGB color.

Default for this virtual method is to invoke the monochrome method if color is not implemented in user code.

See also
isColorCube()
Parameters
pvoxel RGB value - if VOX_OFF, set the voxel off. Otherwise, set the voxel to the color.
xx coordinate for the voxel.
yy coordinate for the voxel.
zz coordinate for the voxel.
Returns
No return value.

Reimplemented in MD_Cubo_DirectIO, MD_Cubo_JC, MD_Cubo_ICS574, MD_Cubo_STC, MD_Cubo_ICS595, and MD_Cubo_72xx.

◆ size()

uint8_t MD_Cubo::size ( axis_t  axis)

Return the size of the cube.

Return the number of LED on one side of the cube. Allows high level code to be independent of any size definitions, which are known in in the user derived object, as it is reliant on the hardware configuration.

Parameters
axisspecifies the axis required, one of the axis_t enumerations.
Returns
Size of the cube.

◆ update()

virtual void MD_Cubo::update ( )
virtual

Update the cube display.

All cube changes are buffered internally until this method is called, at which time the cube is updated. This is only implementable in the user derived object, as it is heavily reliant on the hardware configuration.

Returns
No return value.

Reimplemented in MD_Cubo_DirectIO, MD_Cubo_JC, MD_Cubo_STC, MD_Cubo_ICS595, and MD_Cubo_72xx.


The documentation for this class was generated from the following files: