MaxMatrix
Drive chained 8x8 LED dot matrix modules with MAX7219.
Loading...
Searching...
No Matches
max_matrix::internal::Panel Class Reference

The matrix as the viewer sees it: columns, rows and dots in the viewer's coordinates. More...

#include <Panel.h>

Public Member Functions

 Panel (uint8_t data_in_pin, uint8_t chip_select_pin, uint8_t clock_pin, span< Byte > buffer)
 Makes the panel of the chain at these pins, of modules ModuleType::kDr0Cr0Rr1 in matrix orientation 0.
MAXMATRIX_NODISCARD uint8_t GetNumberOfModules () const
 Returns the modules of the chain.
MAXMATRIX_NODISCARD uint8_t GetNumberOfColumns () const
 Returns the columns of the panel, eight per module.
Wired & GetWired ()
 Returns the matrix as it is wired, below this one.
MAXMATRIX_NODISCARD Wired const & GetWired () const
 Returns the matrix as it is wired, below this one.
MAXMATRIX_NODISCARD ModuleType GetModuleType () const
 Returns how the LEDs of every module are wired.
MAXMATRIX_NODISCARD MatrixOrientation GetMatrixOrientation () const
 Returns how the whole matrix is turned.
MAXMATRIX_NODISCARD Result< Byte > GetColumn (int16_t column)
 Returns a column of the matrix.
MAXMATRIX_NODISCARD Result< Byte > GetColumn (uint8_t module, uint8_t column)
 Returns a column of a module.
MAXMATRIX_NODISCARD Status GetRow (int16_t row, span< Byte > values)
 Gives a row of the matrix, one byte per module.
MAXMATRIX_NODISCARD Result< Byte > GetRow (uint8_t module, uint8_t row)
 Returns a row of a module.
MAXMATRIX_NODISCARD Result< bool > GetDot (int16_t column, int16_t row)
 Returns whether a dot is lit.
void SetColumn (int16_t column, Byte value)
 Sets a column of the matrix.
void SetColumn (uint8_t module, uint8_t column, Byte value)
 Sets a column of a module.
void SetRow (int16_t row, span< Byte const > values)
 Sets a row of the matrix, one byte per module.
void SetRow (uint8_t module, uint8_t row, Byte value)
 Sets a row of a module.
void SetDot (int16_t column, int16_t row, bool value)
 Lights a dot or turns it off.
void DrawLine (int16_t x0, int16_t y0, int16_t x1, int16_t y1, bool value)
 Draws a straight line from one dot to another, both ends included.
void DrawRect (int16_t x, int16_t y, int16_t width, int16_t height, bool value)
 Draws the outline of a rectangle.
void FillRect (int16_t x, int16_t y, int16_t width, int16_t height, bool value)
 Draws a rectangle with its inside.
void DrawCircle (int16_t x, int16_t y, int16_t radius, bool value)
 Draws the outline of a circle.
void DrawBitmap (int16_t x, int16_t y, uint8_t height, span< uint8_t const > bitmap)
 Draws a picture from flash with its top left corner at x, y.
void DrawColumn (int16_t x, int16_t y, uint8_t height, Byte value)
 Draws one column of a picture, height rows from y on.
void SetModuleType (ModuleType module_type)
 Sets how the LEDs of every module are wired.
void SetMatrixOrientation (MatrixOrientation matrix_orientation)
 Sets how the whole matrix is turned.
void ShiftLeft (ShiftFill fill=ShiftFill::kZero)
 Shifts the whole picture one column to the left.
Byte ShiftLeft (Byte shifted_in)
 Shifts the whole picture one column to the left, with a column of the sketch coming in at the right.
void ShiftRight (ShiftFill fill=ShiftFill::kZero)
 Shifts the whole picture one column to the right.
Byte ShiftRight (Byte shifted_in)
 Shifts the whole picture one column to the right, with a column of the sketch coming in at the left.
void ShiftUp (ShiftFill fill=ShiftFill::kZero)
 Shifts the whole picture one row up.
void ShiftDown (ShiftFill fill=ShiftFill::kZero)
 Shifts the whole picture one row down.

Detailed Description

The matrix as the viewer sees it: columns, rows and dots in the viewer's coordinates.

It turns every coordinate by the matrix orientation and the module type into the buffer of Wired. A sketch reaches it through Matrix, which takes most of its functions over.

Constructor & Destructor Documentation

◆ Panel()

max_matrix::internal::Panel::Panel ( uint8_t data_in_pin,
uint8_t chip_select_pin,
uint8_t clock_pin,
span< Byte > buffer )

Makes the panel of the chain at these pins, of modules ModuleType::kDr0Cr0Rr1 in matrix orientation 0.

Parameters
[in]data_in_pinThe pin DIN of the chain is connected to.
[in]chip_select_pinThe pin CS of the chain is connected to.
[in]clock_pinThe pin CLK of the chain is connected to.
[out]bufferThe buffer, BufferSize() of the modules in the chain, 1 to kMaxNumberOfModules; it has to live as long as the panel.

Member Function Documentation

◆ DrawBitmap()

void max_matrix::internal::Panel::DrawBitmap ( int16_t x,
int16_t y,
uint8_t height,
span< uint8_t const > bitmap )

Draws a picture from flash with its top left corner at x, y.

The picture is a column per byte, bit 0 the top row, as a glyph of a font: a 0 bit turns its dot off. Rows below height are left as they are, and what lies off the panel is left out.

The height goes before the bitmap, so that a width after it, as the columns were once given, does not compile: the bitmap brings its width.

Parameters
[in]xThe column of the left edge; it may lie off the panel.
[in]yThe row of the top edge; it may lie off the panel.
[in]heightThe rows of the picture, 1 to 8.
[in]bitmapThe columns, in PROGMEM; as many as it holds.

◆ DrawCircle()

void max_matrix::internal::Panel::DrawCircle ( int16_t x,
int16_t y,
int16_t radius,
bool value )

Draws the outline of a circle.

What lies off the panel is left out, as for SetDot(). A radius of 0 draws the centre only, a negative one nothing.

Parameters
[in]xThe column of the centre.
[in]yThe row of the centre.
[in]radiusThe dots from the centre to the outline; 3 fills the height of the panel.
[in]valueTrue to light the outline, false to turn it off.

◆ DrawColumn()

void max_matrix::internal::Panel::DrawColumn ( int16_t x,
int16_t y,
uint8_t height,
Byte value )

Draws one column of a picture, height rows from y on.

What lies off the panel is left out; rows below height are left as they are.

Parameters
[in]xThe column; it may lie off the panel.
[in]yThe row of bit 0; it may lie off the panel.
[in]heightThe rows to draw, 1 to 8.
[in]valueThe column, bit 0 at y.

◆ DrawLine()

void max_matrix::internal::Panel::DrawLine ( int16_t x0,
int16_t y0,
int16_t x1,
int16_t y1,
bool value )

Draws a straight line from one dot to another, both ends included.

What lies off the panel is left out, as for SetDot(); the ends may lie off it.

Parameters
[in]x0The column of the first end.
[in]y0The row of the first end.
[in]x1The column of the second end.
[in]y1The row of the second end.
[in]valueTrue to light the line, false to turn it off.

◆ DrawRect()

void max_matrix::internal::Panel::DrawRect ( int16_t x,
int16_t y,
int16_t width,
int16_t height,
bool value )

Draws the outline of a rectangle.

What lies off the panel is left out, as for SetDot(). A width or height of 0 or less draws nothing.

Parameters
[in]xThe column of the left edge.
[in]yThe row of the top edge.
[in]widthThe columns it spans.
[in]heightThe rows it spans.
[in]valueTrue to light the outline, false to turn it off.

◆ FillRect()

void max_matrix::internal::Panel::FillRect ( int16_t x,
int16_t y,
int16_t width,
int16_t height,
bool value )

Draws a rectangle with its inside.

What lies off the panel is left out, as for SetDot(). A width or height of 0 or less draws nothing.

Parameters
[in]xThe column of the left edge.
[in]yThe row of the top edge.
[in]widthThe columns it spans.
[in]heightThe rows it spans.
[in]valueTrue to light it, false to turn it off.

◆ GetColumn() [1/2]

MAXMATRIX_NODISCARD Result< Byte > max_matrix::internal::Panel::GetColumn ( int16_t column)

Returns a column of the matrix.

Parameters
[in]columnThe column, from 0 at the left to eight times the modules.
Returns
The column, bit 0 the top row, or Error::kOutOfRange if it lies off the panel.

◆ GetColumn() [2/2]

MAXMATRIX_NODISCARD Result< Byte > max_matrix::internal::Panel::GetColumn ( uint8_t module,
uint8_t column )

Returns a column of a module.

Parameters
[in]moduleThe module, from 0 at the left.
[in]columnThe column within the module, 0 to 7.
Returns
The column, bit 0 the top row, or Error::kOutOfRange if the module or the column does not exist.

◆ GetDot()

MAXMATRIX_NODISCARD Result< bool > max_matrix::internal::Panel::GetDot ( int16_t column,
int16_t row )

Returns whether a dot is lit.

Parameters
[in]columnThe column, negative to the left of the panel.
[in]rowThe row, negative above the panel.
Returns
Whether the dot is lit, or Error::kOutOfRange if it lies off the panel.

◆ GetRow() [1/2]

MAXMATRIX_NODISCARD Status max_matrix::internal::Panel::GetRow ( int16_t row,
span< Byte > values )

Gives a row of the matrix, one byte per module.

Parameters
[in]rowThe row, from 0 at the top.
[out]valuesThe row, bit 7 of each byte the leftmost column of its module; left as it was on an error.
Returns
Error::kOk, or Error::kOutOfRange if the row lies off the panel or values has room for fewer bytes than there are modules.

◆ GetRow() [2/2]

MAXMATRIX_NODISCARD Result< Byte > max_matrix::internal::Panel::GetRow ( uint8_t module,
uint8_t row )

Returns a row of a module.

The leftmost column is in bit 7, so that a row written as a binary literal looks like the dots it stands for.

Parameters
[in]moduleThe module, from 0 at the left.
[in]rowThe row within the module, 0 to 7.
Returns
The row, bit 7 the leftmost column, or Error::kOutOfRange if the module or the row does not exist.

◆ GetWired()

MAXMATRIX_NODISCARD Wired const & max_matrix::internal::Panel::GetWired ( ) const
inline

Returns the matrix as it is wired, below this one.

◆ SetColumn() [1/2]

void max_matrix::internal::Panel::SetColumn ( int16_t column,
Byte value )

Sets a column of the matrix.

A column off the panel is left out, as for SetDot().

Parameters
[in]columnThe column, from 0 at the left to eight times the modules.
[in]valueThe column, bit 0 the top row.

◆ SetColumn() [2/2]

void max_matrix::internal::Panel::SetColumn ( uint8_t module,
uint8_t column,
Byte value )

Sets a column of a module.

A module or a column that does not exist is left out.

Parameters
[in]moduleThe module, from 0 at the left.
[in]columnThe column within the module, 0 to 7.
[in]valueThe column, bit 0 the top row.

◆ SetDot()

void max_matrix::internal::Panel::SetDot ( int16_t column,
int16_t row,
bool value )

Lights a dot or turns it off.

A dot off the panel is left out rather than reported: a sprite, a line or a text that lies partly off the panel is drawn all the time while something moves in or out, and a sketch would only have to clip it itself. Adafruit GFX's drawPixel() and Rust's embedded-graphics do the same.

Parameters
[in]columnThe column, negative to the left of the panel.
[in]rowThe row, negative above the panel.
[in]valueTrue to light it.

◆ SetMatrixOrientation()

void max_matrix::internal::Panel::SetMatrixOrientation ( MatrixOrientation matrix_orientation)

Sets how the whole matrix is turned.

By 180 degrees for a board mounted upside down, with the module at the input then on the left; in addition to the module type. The picture stays as the viewer sees it; the buffer is turned along.

Parameters
[in]matrix_orientation0 or 180 degrees.

◆ SetModuleType()

void max_matrix::internal::Panel::SetModuleType ( ModuleType module_type)

Sets how the LEDs of every module are wired.

The picture stays as the viewer sees it; the buffer is rewritten along.

Parameters
[in]module_typeThe type of the modules, as MD_MAX72XX names it.

◆ SetRow() [1/2]

void max_matrix::internal::Panel::SetRow ( int16_t row,
span< Byte const > values )

Sets a row of the matrix, one byte per module.

A row off the panel is left out, as for SetDot(), and so are the modules beyond the bytes given, or the bytes beyond the modules.

Parameters
[in]rowThe row, from 0 at the top.
[in]valuesThe row, bit 7 of each byte the leftmost column of its module.

◆ SetRow() [2/2]

void max_matrix::internal::Panel::SetRow ( uint8_t module,
uint8_t row,
Byte value )

Sets a row of a module.

A module or a row that does not exist is left out.

Parameters
[in]moduleThe module, from 0 at the left.
[in]rowThe row within the module, 0 to 7.
[in]valueThe row, bit 7 the leftmost column.

◆ ShiftDown()

void max_matrix::internal::Panel::ShiftDown ( ShiftFill fill = ShiftFill::kZero)

Shifts the whole picture one row down.

Parameters
[in]fillWhat comes in at the top: an empty row, the bottom one, or the top one as it was.

◆ ShiftLeft() [1/2]

Byte max_matrix::internal::Panel::ShiftLeft ( Byte shifted_in)

Shifts the whole picture one column to the left, with a column of the sketch coming in at the right.

A sketch that feeds a column on every step gets a band of any length, from flash, a sensor or a calculation, and what falls out at the left, to keep or pass on.

Parameters
[in]shifted_inThe column that comes in, bit 0 the top row.
Returns
The column that fell out at the left, bit 0 the top row.

◆ ShiftLeft() [2/2]

void max_matrix::internal::Panel::ShiftLeft ( ShiftFill fill = ShiftFill::kZero)

Shifts the whole picture one column to the left.

Parameters
[in]fillWhat comes in at the right: an empty column, the leftmost one, or the rightmost one as it was.

◆ ShiftRight() [1/2]

Byte max_matrix::internal::Panel::ShiftRight ( Byte shifted_in)

Shifts the whole picture one column to the right, with a column of the sketch coming in at the left.

Parameters
[in]shifted_inThe column that comes in, bit 0 the top row.
Returns
The column that fell out at the right, bit 0 the top row.

◆ ShiftRight() [2/2]

void max_matrix::internal::Panel::ShiftRight ( ShiftFill fill = ShiftFill::kZero)

Shifts the whole picture one column to the right.

Parameters
[in]fillWhat comes in at the left: an empty column, the rightmost one, or the leftmost one as it was.

◆ ShiftUp()

void max_matrix::internal::Panel::ShiftUp ( ShiftFill fill = ShiftFill::kZero)

Shifts the whole picture one row up.

Parameters
[in]fillWhat comes in at the bottom: an empty row, the top one, or the bottom one as it was.

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