6#include "MAX7219_Base.hpp"
23 0b00000000, 0b01110111, 0b00011111, 0b01001110,
24 0b00111101, 0b01001111, 0b01000111, 0b01011110,
25 0b00010111, 0b00110000, 0b00111100, 0b00000111,
26 0b00001110, 0b01110110, 0b00010101, 0b00011101,
27 0b01100111, 0b01110011, 0b00000101, 0b01011011,
28 0b00001111, 0b00011100, 0b00100111, 0b00111110,
29 0b00110111, 0b00111011, 0b01101101, 0b01001110,
30 0b00010011, 0b01111000, 0b01100010, 0b00001000,
31 0b00000000, 0b00000000, 0b00100010, 0b01100011,
32 0b01011011, 0b01100111, 0b01111101, 0b00000010,
33 0b01001110, 0b01111000, 0b01100011, 0b00110001,
34 0b00000100, 0b00000001, 0b00001000, 0b00100101,
35 0b01111110, 0b00110000, 0b01101101, 0b01111001,
36 0b00110011, 0b01011011, 0b01011111, 0b01110000,
37 0b01111111, 0b01111011, 0b00000000, 0b01000100,
38 0b00110001, 0b00001001, 0b00000111, 0b01100101,
52template <
class SPIDriver = decltype(SPI) &>
86 this->
sendRaw((digit % 8) + 1, value, digit / 8);
115 int16_t
display(
long number, int16_t startDigit = 0,
116 int16_t endDigit = -1) {
121 unsigned long anumber = abs(number);
122 int16_t i = startDigit;
126 }
while (anumber && i <= endDigit);
127 if (number < 0 && i <= endDigit) {
131 for (int16_t i = startDigit; i <= endDigit;)
135 while (i <= endDigit)
138 return endDigit - startDigit;
142 int16_t
display(
int number, int16_t startDigit = 0, int16_t endDigit = -1) {
143 return display(
long(number), startDigit, endDigit);
166 int16_t
display(
unsigned long number, int16_t startDigit = 0,
167 int16_t endDigit = -1) {
172 int16_t i = startDigit;
176 }
while (number && i <= endDigit);
178 for (int16_t i = startDigit; i <= endDigit;)
182 while (i <= endDigit)
185 return endDigit - startDigit;
189 int16_t
display(
unsigned int number, int16_t startDigit = 0,
190 int16_t endDigit = -1) {
191 return display((
unsigned long)(number), startDigit, endDigit);
204 int16_t
display(
const char *text, int16_t startPos = 0) {
209 while (*text && (i > 0 || *text ==
'.')) {
221 }
else if (c >=
'@' && c <=
'_')
223 else if (c >=
'!' && c <=
'?')
225 else if (c >=
'a' && c <=
'z')
245 uint8_t c = value >= 0x0A
269 int16_t
displayHex(
unsigned long number, int16_t startDigit = 0,
270 int16_t endDigit = -1) {
275 int16_t i = startDigit;
279 }
while (number && i <= endDigit);
281 for (int16_t i = startDigit; i <= endDigit;)
285 while (i <= endDigit)
288 return endDigit - startDigit;
uint16_t pin_t
The type for Arduino pins (and ExtendedIOElement pins).
static constexpr const uint8_t * NumericChars
static constexpr const uint8_t * AlphaChars
static constexpr uint8_t SevenSegmentCharacters[0x40]
A lookup table for 7-segment characters, as specified by the Logic Control manual.
#define BEGIN_AH_NAMESPACE
#define AH_DIAGNOSTIC_POP()
#define AH_DIAGNOSTIC_WERROR()
A class for 8-digit 7-segment displays with a MAX7219 driver.
uint8_t getNumberOfDigits() const
Get the total number of digits in this chain of displays, i.e.
int16_t display(unsigned int number, int16_t startDigit=0, int16_t endDigit=-1)
Display a long unsigned integer to the display.
int16_t display(long number, int16_t startDigit=0, int16_t endDigit=-1)
Display a long integer to the display.
int16_t display(const char *text, int16_t startPos=0)
Display a string of text to the display.
int16_t displayHex(unsigned long number, int16_t startDigit=0, int16_t endDigit=-1)
Print a number to the display in hexadecimal format.
int16_t display(int number, int16_t startDigit=0, int16_t endDigit=-1)
Display a long integer to the display.
MAX7219SevenSegmentDisplay(SPIDriver spi, pin_t loadPin, uint8_t chainlength=1)
Create a MAX7219SevenSegmentDisplay.
void sendDigit(uint16_t digit, uint8_t value)
Set the value of a single digit.
int16_t display(unsigned long number, int16_t startDigit=0, int16_t endDigit=-1)
Display a long unsigned integer to the display.
void printHexChar(int16_t digit, uint8_t value)
Print a single hexadecimal digit.
A base class for classes that control MAX7219 LED drivers.
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 begin()
Initialize the Arduino pins, SPI, and the MAX7219.