| MD_MAXPanel LED Matrix Panel Arduino Library 1.4 Library to control a panel of connected MAX72XX devices

Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
MD_MAXPanel Class Reference

`#include <MD_MAXPanel.h>`

## Public Types
enum | rotation_t { ROT_0 , ROT_90 , ROT_180 , ROT_270 }

## Public Member Functions
| MD_MAXPanel (MD_MAX72XX::moduleType_t mod, uint8_t dataPin, uint8_t clkPin, uint8_t csPin, uint8_t xDevices, uint8_t yDevices)
| MD_MAXPanel (MD_MAX72XX::moduleType_t mod, uint8_t csPin, uint8_t xDevices, uint8_t yDevices)
| MD_MAXPanel (MD_MAX72XX *D, uint8_t xDevices, uint8_t yDevices)
| MD_MAXPanel (MD_MAX72XX::moduleType_t mod, SPIClass &spi, uint8_t csPin, uint8_t xDevices, uint8_t yDevices)
bool | begin (void)
| ~MD_MAXPanel ()
Methods for object management.
void | clear (void)
void | clear (uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, bool state=false)
MD_MAX72XX * | getGraphicObject (void)
uint16_t | getXMax (void)
uint16_t | getYMax (void)
rotation_t | getRotation (void)
void | setRotation (rotation_t r)
void | update (bool state)
void | update ()
void | setIntensity (uint8_t intensity)
Methods for drawing graphics.
bool | drawHLine (uint16_t y, uint16_t x1, uint16_t x2, bool state=true)
bool | drawLine (uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, bool state=true)
bool | drawVLine (uint16_t x, uint16_t y1, uint16_t y2, bool state=true)
bool | drawRectangle (uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, bool state=true)
bool | drawFillRectangle (uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, bool state=true)
bool | drawTriangle (uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3, bool state=true)
bool | drawFillTriangle (uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3, bool state=true)
bool | drawQuadrilateral (uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3, uint16_t x4, uint16_t y4, bool state=true)
bool | drawCircle (uint16_t xc, uint16_t yc, uint16_t r, bool state=true)
bool | drawFillCircle (uint16_t xc, uint16_t yc, uint16_t r, bool state=true)
bool | getPoint (uint16_t x, uint16_t y)
bool | setPoint (uint16_t x, uint16_t y, bool state=true)
Methods for Fonts and text.
void | setFont (MD_MAX72XX::fontType_t *fontDef)
void | setCharSpacing (uint8_t spacing)
uint8_t | getCharSpacing (void)
uint16_t | getTextWidth (const char *psz)
uint16_t | getFontHeight (void)
uint16_t | drawText (uint16_t x, uint16_t y, const char *psz, rotation_t rot=ROT_0, bool state=true)

## Detailed Description

Core object for the MD_MAXPanel library

## Member Enumeration Documentation

## ◆ rotation_t

enum MD_MAXPanel::rotation_t

Rotation enumerated type specification.

Used to define rotation orientation (eg, text or display). For text the normal rotation is the standard Latin language left to right orientation. Rotation is specified anchored to the first character of the string - 0 points >, 90 ^, 180 < and 270 v. For the display rotation 0 and 180 and are identical and 90 and 270 are identical. The rotation will shift the display between landscape and portrait mode.

Enumerator
ROT_0 | Rotation 0 degrees.
ROT_90 | Rotation 90 degrees.
ROT_180 | Rotation 180 degrees.
ROT_270 | Rotation 270 degrees.

## Constructor & Destructor Documentation

## ◆ MD_MAXPanel() [1/4]

MD_MAXPanel::MD_MAXPanel | ( | MD_MAX72XX::moduleType_t | mod,
|  | uint8_t | dataPin,
|  | uint8_t | clkPin,
|  | uint8_t | csPin,
|  | uint8_t | xDevices,
|  | uint8_t | yDevices
| ) |  |

Class Constructor - arbitrary digital interface.

Instantiate a new instance of the class. The parameters passed are used to connect the software to the hardware. Multiple instances may co-exist but they should not share the same hardware CS pin (SPI interface).

Parameters

  mod | the hardware module being used, one of the MD_MAX72XX::moduleType_t values
  dataPin | output on the Arduino where data gets shifted out.
  clkPin | output for the clock signal.
  csPin | output for selecting the device.
  xDevices | number of LED matrix modules for the width of the panel.
  yDevices | number of LED matrix modules for the height of the panel.

## ◆ MD_MAXPanel() [2/4]

MD_MAXPanel::MD_MAXPanel | ( | MD_MAX72XX::moduleType_t | mod,
|  | uint8_t | csPin,
|  | uint8_t | xDevices,
|  | uint8_t | yDevices
| ) |  |

Class Constructor - default SPI hardware interface.

Instantiate a new instance of the class. The parameters passed are used to connect the software to the hardware. Multiple instances may co-exist but they should not share the same hardware CS pin (SPI interface). The dataPin and the clockPin are defined by the Arduino hardware definition (SPI MOSI and SCK signals).

Parameters

  mod | the hardware module being used, one of the MD_MAX72XX::moduleType_t values
  csPin | output for selecting the device.
  xDevices | number of LED matrix modules for the width of the panel.
  yDevices | number of LED matrix modules for the height of the panel.

## ◆ MD_MAXPanel() [3/4]

MD_MAXPanel::MD_MAXPanel | ( | MD_MAX72XX * | D,
|  | uint8_t | xDevices,
|  | uint8_t | yDevices
| ) |  |

Class Constructor - Existing MD_MAX72XX object.

Instantiate a new instance of the class. The parameters passed are used to connect the software to the hardware. The MD_MAX72X object has been created outside this object and it is up to the programmer to ensure that the correct parameters are used when this object is created.

Parameters

  D | pointer to the existing MD_MAX72XX object.
  xDevices | number of LED matrix modules for the width of the panel.
  yDevices | number of LED matrix modules for the height of the panel.

## ◆ MD_MAXPanel() [4/4]

MD_MAXPanel::MD_MAXPanel | ( | MD_MAX72XX::moduleType_t | mod,
|  | SPIClass & | spi,
|  | uint8_t | csPin,
|  | uint8_t | xDevices,
|  | uint8_t | yDevices
| ) |  |

Class Constructor - specify SPI hardware interface.

Instantiate a new instance of the class with a specified SPI object. This allows a specific SPI interface to be specified for architectures with more than one hardware SPI interface. The parameters passed are used to connect the software to the hardware. Multiple instances may co-exist but they should not share the same hardware CS pin (SPI interface). The dataPin and the clockPin are defined by the Arduino hardware definition for the specified SPI interface (SPI MOSI and SCK signals).

Parameters

  mod | module type used in this application. One of the moduleType_t values.
  spi | reference to the SPI object to use for comms to the device
  csPin | output for selecting the device.
  xDevices | number of LED matrix modules for the width of the panel.
  yDevices | number of LED matrix modules for the height of the panel.

## ◆ ~MD_MAXPanel()

MD_MAXPanel::~MD_MAXPanel | ( | void |  | ) |

Class Destructor.

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

## Member Function Documentation

## ◆ begin()

void MD_MAXPanel::begin | ( | void |  | ) |

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.

Returns
  true if initialized with no error, false otherwise.

## ◆ clear() [1/2]

void MD_MAXPanel::clear | ( | uint16_t | x1,
|  | uint16_t | y1,
|  | uint16_t | x2,
|  | uint16_t | y2,
|  | bool | state = `false`
| ) |  |

Clear the specified display area.

Clear the rectangular area specified by the coordinates by setting the pixels to the state specified (default is off).

Parameters

  x1 | the upper left x coordinate of the window
  y1 | the upper left y coordinate of the window
  x2 | the lower right x coordinate of the window
  y2 | the upper lower right y coordinate of the window
  state | true - switch pixels on; false - switch pixels off. If omitted, default to false.

## ◆ clear() [2/2]

void MD_MAXPanel::clear | ( | void |  | ) |

Clear all the display data on all the display devices.

## ◆ drawCircle()

bool MD_MAXPanel::drawCircle | ( | uint16_t | xc,
|  | uint16_t | yc,
|  | uint16_t | r,
|  | bool | state = `true`
| ) |  |

Draw a circle given center and radius

Draw a circle given center and radius. The LEDs will be turned on or off depending on the value supplied. The coordinates will be dereferenced into the device and column within the device, allowing the LEDs to be treated as a continuous pixel field.

Parameters

  xc | x coordinate for the center point [0..getXMax()].
  yc | y coordinate for the center point [0..getYMax()].
  r | radius of the circle.
  state | true - switch on; false - switch off. If omitted, default to true.

Returns
  false if any point is drawn outside the display, true otherwise.

## ◆ drawFillCircle()

bool MD_MAXPanel::drawFillCircle | ( | uint16_t | xc,
|  | uint16_t | yc,
|  | uint16_t | r,
|  | bool | state = `true`
| ) |  |

Draw a filled circle given center and radius

Draw a circle given center and radius. The LEDs for the border and fill will be turned on or off depending on the value supplied. The coordinates will be dereferenced into the device and column within the device, allowing the LEDs to be treated as a continuous pixel field.

Parameters

  xc | x coordinate for the center point [0..getXMax()].
  yc | y coordinate for the center point [0..getYMax()].
  r | radius of the circle.
  state | true - switch on; false - switch off. If omitted, default to true.

Returns
  false if any point is drawn outside the display, true otherwise.

## ◆ drawFillRectangle()

bool MD_MAXPanel::drawFillRectangle | ( | uint16_t | x1,
|  | uint16_t | y1,
|  | uint16_t | x2,
|  | uint16_t | y2,
|  | bool | state = `true`
| ) |  |

Draw a filled rectangle given two diagonal vertices

Draw a filled rectangle given the points across the diagonal. The LEDs inside and on the border will be turned on or off depending on the value supplied. The coordinates will be dereferenced into the device and column within the device, allowing the LEDs to be treated as a continuous pixel field.

Parameters

  x1 | starting x coordinate for the point [0..getXMax()].
  y1 | starting y coordinate for the point [0..getYMax()].
  x2 | ending x coordinate for the point [0..getXMax()].
  y2 | ending y coordinate for the point [0..getYMax()].
  state | true - switch on; false - switch off. If omitted, default to true.

Returns
  false if any point is drawn outside the display, true otherwise.

## ◆ drawFillTriangle()

bool MD_MAXPanel::drawFillTriangle | ( | uint16_t | x1,
|  | uint16_t | y1,
|  | uint16_t | x2,
|  | uint16_t | y2,
|  | uint16_t | x3,
|  | uint16_t | y3,
|  | bool | state = `true`
| ) |  |

Draw a filled triangle given 3 vertices

Draw a filled triangle given the all the corner points. The LED for the border and fill will be turned on or off depending on the value supplied. The coordinates will be dereferenced into the device and column within the device, allowing the LEDs to be treated as a continuous pixel field.

Parameters

  x1 | first x coordinate for the point [0..getXMax()].
  y1 | first y coordinate for the point [0..getYMax()].
  x2 | second x coordinate for the point [0..getXMax()].
  y2 | second y coordinate for the point [0..getYMax()].
  x3 | third x coordinate for the point [0..getXMax()].
  y3 | third y coordinate for the point [0..getYMax()].
  state | true - switch on; false - switch off. If omitted, default to true.

Returns
  false if any point is drawn outside the display, true otherwise.

## ◆ drawHLine()

bool MD_MAXPanel::drawHLine | ( | uint16_t | y,
|  | uint16_t | x1,
|  | uint16_t | x2,
|  | bool | state = `true`
| ) |  |

Draw a horizontal line between two points on the display

Draw a horizontal line between the specified points. The LED will be turned on or off depending on the value supplied. The column number will be dereferenced into the device and column within the device, allowing the LEDs to be treated as a continuous pixel field.

Parameters

  y | y coordinate for the line [0..getYMax()].
  x1 | starting x coordinate for the point [0..getXMax()].
  x2 | ending x coordinate for the point [0..getXMax()].
  state | true - switch on; false - switch off. If omitted, default to true.

Returns
  false if any point is drawn outside the display, true otherwise.

## ◆ drawLine()

bool MD_MAXPanel::drawLine | ( | uint16_t | x1,
|  | uint16_t | y1,
|  | uint16_t | x2,
|  | uint16_t | y2,
|  | bool | state = `true`
| ) |  |

Draw an arbitrary line between two points on the display

Draw a line between the specified points using Bresenham's algorithm. The LED will be turned on or off depending on the value supplied. The column number will be dereferenced into the device and column within the device, allowing the LEDs to be treated as a continuous pixel field.

Parameters

  x1 | starting x coordinate for the point [0..getXMax()].
  y1 | starting y coordinate for the point [0..getYMax()].
  x2 | ending x coordinate for the point [0..getXMax()].
  y2 | ending y coordinate for the point [0..getYMax()].
  state | true - switch on; false - switch off. If omitted, default to true.

Returns
  false if any point is drawn outside the display, true otherwise.

## ◆ drawQuadrilateral()

bool MD_MAXPanel::drawQuadrilateral | ( | uint16_t | x1,
|  | uint16_t | y1,
|  | uint16_t | x2,
|  | uint16_t | y2,
|  | uint16_t | x3,
|  | uint16_t | y3,
|  | uint16_t | x4,
|  | uint16_t | y4,
|  | bool | state = `true`
| ) |  |

Draw a quadrilateral given 4 vertices

Draw a quadrilateral given the all the corner points. The LED will be turned on or off depending on the value supplied. The coordinates will be dereferenced into the device and column within the device, allowing the LEDs to be treated as a continuous pixel field.

Parameters

  x1 | first x coordinate for the point [0..getXMax()].
  y1 | first y coordinate for the point [0..getYMax()].
  x2 | second x coordinate for the point [0..getXMax()].
  y2 | second y coordinate for the point [0..getYMax()].
  x3 | third x coordinate for the point [0..getXMax()].
  y3 | third y coordinate for the point [0..getYMax()].
  x4 | fourth x coordinate for the point [0..getXMax()].
  y4 | fourth y coordinate for the point [0..getYMax()].
  state | true - switch on; false - switch off. If omitted, default to true.

Returns
  false if any point is drawn outside the display, true otherwise.

## ◆ drawRectangle()

bool MD_MAXPanel::drawRectangle | ( | uint16_t | x1,
|  | uint16_t | y1,
|  | uint16_t | x2,
|  | uint16_t | y2,
|  | bool | state = `true`
| ) |  |

Draw a rectangle given two diagonal vertices

Draw a rectangle given the points across the diagonal. The LED will be turned on or off depending on the value supplied. The coordinates will be dereferenced into the device and column within the device, allowing the LEDs to be treated as a continuous pixel field.

Parameters

  x1 | starting x coordinate for the point [0..getXMax()].
  y1 | starting y coordinate for the point [0..getYMax()].
  x2 | ending x coordinate for the point [0..getXMax()].
  y2 | ending y coordinate for the point [0..getYMax()].
  state | true - switch on; false - switch off. If omitted, default to true.

Returns
  false if any point is drawn outside the display, true otherwise.

## ◆ drawText()

uint16_t MD_MAXPanel::drawText | ( | uint16_t | x,
|  | uint16_t | y,
|  | const char * | psz,
|  | rotation_t | rot = `ROT_0`,
|  | bool | state = `true`
| ) |  |

Draw text on the display.

Draw the text with top left coordinates (x,y) with specified rotation.

Parameters

  x | the x coordinate for the top left corner of the first character.
  y | the Y coordinate for the top left corner of the first character.
  psz | the text to be displayed as a nul terminated character array.
  rot | the required rotation orientation for the text as described in textRotation_t. Default is ROT_0.
  state | true - switch on; false - switch off. If omitted, default to true.

Returns
  the length of the text in pixels.

## ◆ drawTriangle()

bool MD_MAXPanel::drawTriangle | ( | uint16_t | x1,
|  | uint16_t | y1,
|  | uint16_t | x2,
|  | uint16_t | y2,
|  | uint16_t | x3,
|  | uint16_t | y3,
|  | bool | state = `true`
| ) |  |

Draw a triangle given 3 vertices

Draw a triangle given the all the corner points. The LED will be turned on or off depending on the value supplied. The coordinates will be dereferenced into the device and column within the device, allowing the LEDs to be treated as a continuous pixel field.

Parameters

  x1 | first x coordinate for the point [0..getXMax()].
  y1 | first y coordinate for the point [0..getYMax()].
  x2 | second x coordinate for the point [0..getXMax()].
  y2 | second y coordinate for the point [0..getYMax()].
  x3 | third x coordinate for the point [0..getXMax()].
  y3 | third y coordinate for the point [0..getYMax()].
  state | true - switch on; false - switch off. If omitted, default to true.

Returns
  false if any point is drawn outside the display, true otherwise.

## ◆ drawVLine()

bool MD_MAXPanel::drawVLine | ( | uint16_t | x,
|  | uint16_t | y1,
|  | uint16_t | y2,
|  | bool | state = `true`
| ) |  |

Draw a vertical line between two points on the display

Draw a horizontal line between the specified points. The LED will be turned on or off depending on the value supplied. The column number will be dereferenced into the device and column within the device, allowing the LEDs to be treated as a continuous pixel field.

Parameters

  x | x coordinate for the line [0..getXMax()].
  y1 | starting y coordinate for the point [0..getYMax()].
  y2 | ending y coordinate for the point [0..getYMax()].
  state | true - switch on; false - switch off. If omitted, default to true.

Returns
  false if any point is drawn outside the display, true otherwise.

## ◆ getCharSpacing()

uint8_t MD_MAXPanel::getCharSpacing | ( | void |  | ) |

Get the spacing between characters.

Get number of pixel columns between each character in a displayed text.

Returns
  the spacing between characters.

## ◆ getFontHeight()

uint16_t MD_MAXPanel::getFontHeight | ( | void |  | ) |

Get the height of the current font in pixels.

Get the specified of height of the current font in pixels. All the characters of the font will fit with this height.

Returns
  the height in pixels.

## ◆ getGraphicObject()

MD_MAX72XX * MD_MAXPanel::getGraphicObject | ( | void |  | ) |

Get a pointer to the instantiated graphics object.

Provides a pointer to the MD_MAX72XX object to allow access to the display graphics functions.

Returns
  Pointer to the MD_MAX72xx object used by the library.

## ◆ getPoint()

bool MD_MAXPanel::getPoint | ( | uint16_t | x,
|  | uint16_t | y
| ) |  |

Get the status of a single LED, addressed as a pixel.

The method will get the status of a specific LED element based on its coordinate position. The column number is dereferenced into the device and column within the device, allowing the LEDs to be treated as a planar pixel field.

Parameters

  x | x coordinate [0..getXMax()].
  y | y coordinate [0..getYMax()].

Returns
  true if LED is on, false if off or parameter errors.

## ◆ getRotation()

rotation_t MD_MAXPanel::getRotation | ( | void |  | ) |

Get the rotation status of the display

Returns
  rotation_t value for the current rotation (ROT_0 or ROT_90)

## ◆ getTextWidth()

uint16_t MD_MAXPanel::getTextWidth | ( | const char * | psz | ) |

Get the length of a text string in pixels.

Get the length of a string in pixels. The text is a nul terminated characters array. The returned length will include all inter-character Set number of pixel columns between each character in a displayed text.

Parameters

  psz | the text string as a nul terminated character array.

Returns
  the length in pixels.

## ◆ getXMax()

uint16_t MD_MAXPanel::getXMax | ( | void |  | ) |

Gets the maximum X coordinate.

Depends on the rotation status of the display.

Returns
  uint8_t the maximum X coordinate.

## ◆ getYMax()

uint16_t MD_MAXPanel::getYMax | ( | void |  | ) |

Gets the maximum Y coordinate.

Depends on the rotation status of the display.

Returns
  uint16_t representing the number of columns.

## ◆ setCharSpacing()

void MD_MAXPanel::setCharSpacing | ( | uint8_t | spacing | ) |

Set the spacing between characters.

Set number of pixel columns between each character in a displayed text.

Parameters

  spacing | the spacing between characters.

## ◆ setFont()

void MD_MAXPanel::setFont | ( | MD_MAX72XX::fontType_t * | fontDef | ) |

Set the display font.

Set the display font to a user defined font table. This can be created using the MD_MAX72xx font builder (refer to documentation for the tool and the MD_MAX72xx library). Passing nullptr resets to the library default font.

Parameters

  fontDef | Pointer to the font definition to be used.

## ◆ setIntensity()

void MD_MAXPanel::setIntensity | ( | uint8_t | intensity | ) |

Set the display intensity.

Set the intensity (brightness) of the display.

Parameters

  intensity | the intensity to set the display (0-15).

## ◆ setPoint()

bool MD_MAXPanel::setPoint | ( | uint16_t | x,
|  | uint16_t | y,
|  | bool | state = `true`
| ) |  |

Set the status of a single LED, addressed as a pixel.

The method will set the value of a specific LED element based on its coordinate position. The LED will be turned on or off depending on the value supplied. The column number is dereferenced into the device and column within the device, allowing the LEDs to be treated as a planar pixel field.

Parameters

  x | x coordinate [0..getXMax()].
  y | y coordinate [0..getYMax()].
  state | true - switch on; false - switch off. If omitted, default to true.

Returns
  false if parameter errors, true otherwise.

## ◆ setRotation()

void MD_MAXPanel::setRotation | ( | rotation_t | r | ) |

Set rotation status of the display

Set the display to be rotated or not. ROT_90 and ROT_270 rotate the display by 90 degrees in the same direction. ROT_O and ROT_180 are an unrotated display. The default is ROT_O (unrotated).

Parameters

  r | rotation_t value for the current rotation (ROT_0 or ROT_90);

## ◆ update() [1/2]

void MD_MAXPanel::update | ( |  | ) |

Force a display update.

Force a display update of any changes since the last update. This overrides the current setting for display updates.

## ◆ update() [2/2]

void MD_MAXPanel::update | ( | bool | state | ) |

Turn auto display updates on or off.

Turn auto updates on and off, as required. When auto updates are turned OFF the display will not update after each operation. Display updates can be forced at any time using using a call to update() with no parameters.

Parameters

  state | true to enable update, false to suspend updates.

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

- src/MD_MAXPanel.h
- src/MD_MAXPanel.cpp
- src/MD_MAXPanel_Font.cpp