21template <class SPIDriver = decltype(SPI) &>
36 chainlength(chainlength) {}
42 static constexpr uint8_t DISPLAYTEST = 15;
48 ExtIO::digitalWrite(loadPin,
HIGH);
49 ExtIO::pinMode(loadPin,
OUTPUT);
51 sendRawAll(DISPLAYTEST, 0);
52 sendRawAll(SCANLIMIT, 7);
53 sendRawAll(DECODEMODE, 0);
54 sendRawAll(INTENSITY, 0xF);
56 sendRawAll(SHUTDOWN, 1);
115 ExtIO::digitalWrite(loadPin,
LOW);
116 spi.beginTransaction(settings);
121 ExtIO::digitalWrite(loadPin,
HIGH);
122 spi.endTransaction();
144 for (
uint8_t row = 0; row < 8; ++row)
145 sendRowAll(row, values + row, 8);
157 ExtIO::digitalWrite(loadPin,
LOW);
158 spi.beginTransaction(settings);
163 ExtIO::digitalWrite(loadPin,
HIGH);
164 spi.endTransaction();
178 if (
chip >= chainlength)
180 ExtIO::digitalWrite(loadPin,
LOW);
181 spi.beginTransaction(settings);
189 for (
c++;
c < chainlength;
c++) {
193 ExtIO::digitalWrite(loadPin,
HIGH);
194 spi.endTransaction();
#define BEGIN_AH_NAMESPACE
constexpr PinStatus_t LOW
constexpr PinStatus_t HIGH
constexpr PinMode_t OUTPUT
#define AH_DIAGNOSTIC_EXTERNAL_HEADER()
#define AH_DIAGNOSTIC_POP()
A base class for classes that control MAX7219 LED drivers.
void sendRawAll(uint8_t opcode, uint8_t value)
Send the same raw opcode and value to all chips in the chain.
uint8_t getChainLength() const
Get the number of daisy-chained chips.
void sendRaw(uint8_t opcode, uint8_t value, uint8_t chip=0)
Send a raw opcode and value to the given MAX7219.
void sendAll(const uint8_t *values)
Send different values to all digits/rows of all chips.
void begin()
Initialize the Arduino pins, SPI, and the MAX7219.
void clear()
Turn off all LEDs.
void sendRowAll(uint8_t digit, const uint8_t *values, uint8_t leading_dim=1)
Send values to the given digit or row, sending a different value for each chip.
void setIntensity(uint8_t intensity, uint8_t chip)
Set the intensity of the LEDs of a specific chip.
void setIntensity(uint8_t intensity)
Set the intensity of the LEDs of all chips.
void send(uint8_t digit, uint8_t value, uint8_t chip=0)
Send the value to the given digit or row.
MAX7219_Base(SPIDriver spi, pin_t loadPin, uint8_t chainlength=1)
Create a MAX7219_Base object.
A class for serial-in/parallel-out shift registers, like the 74HC595 that are connected to the SPI bu...
Type for storing pin numbers of Extended Input/Output elements.