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

The lines of text a control page or program sends, carried out on a Matrix. More...

#include <Command.h>

Public Member Functions

 Command ()
 Makes a reader at the start of an empty line.
Result< CommandState > Feed (Matrix &matrix, char c, Print &answer)
 Takes the next char of a command line, and carries the line out and answers it at its end.

Detailed Description

The lines of text a control page or program sends, carried out on a Matrix.

One command per line, as the Windows tool in AndreasBur/Led-Matrix sends them:

Line Does
text=TEXT Clears the matrix and shows the text from the left edge, as

one picture. | | textShift=TEXT | Shifts the text in from the right. | | intensity=0..15 | Sets the brightness. | | speed=MILLISECONDS | Sets the shift interval per column. | | space=COLUMNS | Sets the empty columns between the chars of a text. | | setDot=COLUMN,ROW,VALUE | Lights a dot, with 1, or turns it off, with 0. | | clear | Turns every LED off. | | picture | Asks what the matrix shows. |

Every line is answered with one line: ok, error: and the reason, such as error: out of range for intensity=16, or the answer to picture, picture= and two hex digits per column as the viewer sees it, from the left, bit 0 the top row. A program that shows the matrix asks for it over and over; a board cannot be told what it shows otherwise.

void loop() {
while(Serial.available() > 0) command.Feed(matrix, Serial.read(),
Serial); matrix.ShiftTask();
}
The lines of text a control page or program sends, carried out on a Matrix.
Definition Command.h:75
Result< CommandState > Feed(Matrix &matrix, char c, Print &answer)
Takes the next char of a command line, and carries the line out and answers it at its end.

A sketch that does not use it pays nothing. It costs twice MAXMATRIX_COMMAND_LINE_LENGTH bytes of RAM: the line, and the text of textShift=, which Matrix::SetTextWithShift() reads for as long as it shifts while the next line fills the line buffer.

Member Function Documentation

◆ Feed()

Result< CommandState > max_matrix::Command::Feed ( Matrix & matrix,
char c,
Print & answer )

Takes the next char of a command line, and carries the line out and answers it at its end.

The chars are collected up to a line feed. A carriage return is skipped, so that lines may end in \\r\\n as well; an empty line is no command and gets no answer. A line too long for the buffer is dropped whole, rather than carried out cut short.

Parameters
[in,out]matrixThe matrix the command acts on.
[in]cThe next char, as Serial.read() gives it.
[out]answerWhere the answer to a line goes, as a rule Serial.
Returns
CommandState::kPending while the line goes on or after an empty line, CommandState::kDone once it was carried out, or CommandState::kAnswered once the answer to picture is printed. Error::kLineTooLong if the line did not fit and is dropped; Error::kUnknownCommand if no command has its name; or why the command failed: kNoText, kNotANumber, kOutOfRange or kUnknownChar.

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