Added degree symbol for MAX7219 7-segment display. (#764)

The ascii char to use it is "~" (0x7E).

Disclaimer: I didn't test this yet.
This commit is contained in:
Luar Roji 2020-01-12 11:18:30 -03:00 committed by Otto Winter
parent e21dbc4b60
commit d33a158585

View file

@ -14,7 +14,7 @@ static const uint8_t MAX7219_REGISTER_SCAN_LIMIT = 0x0B;
static const uint8_t MAX7219_REGISTER_SHUTDOWN = 0x0C; static const uint8_t MAX7219_REGISTER_SHUTDOWN = 0x0C;
static const uint8_t MAX7219_UNKNOWN_CHAR = 0b11111111; static const uint8_t MAX7219_UNKNOWN_CHAR = 0b11111111;
const uint8_t MAX7219_ASCII_TO_RAW[94] PROGMEM = { const uint8_t MAX7219_ASCII_TO_RAW[95] PROGMEM = {
0b00000000, // ' ', ord 0x20 0b00000000, // ' ', ord 0x20
0b10110000, // '!', ord 0x21 0b10110000, // '!', ord 0x21
0b00100010, // '"', ord 0x22 0b00100010, // '"', ord 0x22
@ -109,6 +109,7 @@ const uint8_t MAX7219_ASCII_TO_RAW[94] PROGMEM = {
0b00110001, // '{', ord 0x7B 0b00110001, // '{', ord 0x7B
0b00000110, // '|', ord 0x7C 0b00000110, // '|', ord 0x7C
0b00000111, // '}', ord 0x7D 0b00000111, // '}', ord 0x7D
0b01100011, // '~', ord 0x7E (degree symbol)
}; };
float MAX7219Component::get_setup_priority() const { return setup_priority::PROCESSOR; } float MAX7219Component::get_setup_priority() const { return setup_priority::PROCESSOR; }
@ -166,7 +167,7 @@ uint8_t MAX7219Component::print(uint8_t start_pos, const char *str) {
uint8_t pos = start_pos; uint8_t pos = start_pos;
for (; *str != '\0'; str++) { for (; *str != '\0'; str++) {
uint8_t data = MAX7219_UNKNOWN_CHAR; uint8_t data = MAX7219_UNKNOWN_CHAR;
if (*str >= ' ' && *str <= '}') if (*str >= ' ' && *str <= '~')
data = pgm_read_byte(&MAX7219_ASCII_TO_RAW[*str - ' ']); data = pgm_read_byte(&MAX7219_ASCII_TO_RAW[*str - ' ']);
if (data == MAX7219_UNKNOWN_CHAR) { if (data == MAX7219_UNKNOWN_CHAR) {