MAX7219_CH32 Library 1.0.0 A lightweight library for controlling MAX7219 7-segment displays

Loading...
Searching...
No Matches
MAX7219_CH32.cpp
Go to the documentation of this file.
1/*
2 * MAX7219_CH32.cpp - MAX7219 7-Segment Display Library Implementation
3 *
4 * Implementation file for MAX7219_CH32 library
5 *
6 * Author: Rithik Krisna M
7 * License: MIT License
8 * Version: 1.0.0
9 * Created: 2025
10 */
11
12#include <Arduino.h>
13#include <string.h>
14#include <stdlib.h>
15#include "MAX7219_CH32.h"
16
17// ========================================
18// Segment Pattern Tables
19// ========================================
20// 7-segment bit pattern: DP-A-B-C-D-E-F-G
21// A
22// ---
23// F| G |B
24// ---
25// E| |C
26// --- DP
27// D
28
29// Digit patterns for no-decode mode
30 const uint8_t SEGMENT_DIGITS[10] = {
31 0b01111110, // 0
32 0b00110000, // 1
33 0b01101101, // 2
34 0b01111001, // 3
35 0b00110011, // 4
36 0b01011011, // 5
37 0b01011111, // 6
38 0b01110000, // 7
39 0b01111111, // 8
40 0b01111011 // 9
41};
42
43// Letter patterns (A-Z)
44 const uint8_t SEGMENT_LETTERS[26] = {
45 0b01110111, // A
46 0b00011111, // b
47 0b01001110, // C
48 0b00111101, // d
49 0b01001111, // E
50 0b01000111, // F
51 0b01011110, // G
52 0b00110111, // H
53 0b00000110, // I
54 0b00111100, // J
55 0b01010111, // K
56 0b00001110, // L
57 0b01010100, // M
58 0b00010101, // n
59 0b01111110, // O
60 0b01100111, // P
61 0b01110011, // q
62 0b00000101, // r
63 0b01011011, // S
64 0b00001111, // t
65 0b00111110, // U
66 0b00011100, // v
67 0b00101010, // W
68 0b00110111, // X
69 0b00111011, // y
70 0b01101101 // Z
71};
72
73// Hex digits (A-F)
74 const uint8_t SEGMENT_HEX[6] = {
75 0b01110111, // A
76 0b00011111, // b
77 0b01001110, // C
78 0b00111101, // d
79 0b01001111, // E
80 0b01000111 // F
81};
82
83// Special characters
84#define SEGMENT_BLANK 0b00000000
85#define SEGMENT_MINUS 0b00000001
86#define SEGMENT_DOT 0b10000000
87
88// ========================================
89// Constructor
90// ========================================
91 MAX7219::MAX7219(uint8_t dinPin, uint8_t clkPin, uint8_t csPin, uint8_t numDigits) {
92 _dinPin = dinPin;
93 _clkPin = clkPin;
94 _csPin = csPin;
95 _numDigits = constrain(numDigits, 1, 8);
96 _mode = MAX7219_MODE_DECODE;
97 _alignment = MAX7219_ALIGN_RIGHT;
98 _brightness = 8;
99}
100
101// ========================================
102// Initialization
103// ========================================
104 void MAX7219::begin() {
105 begin(_mode);
106}
107
108 void MAX7219::begin(uint8_t mode) {
109 pinMode(_dinPin, OUTPUT);
110 pinMode(_clkPin, OUTPUT);
111 pinMode(_csPin, OUTPUT);
112
113 digitalWrite(_csPin, HIGH);
114 digitalWrite(_clkPin, LOW);
115 digitalWrite(_dinPin, LOW);
116
117 delay(10);
118
119 _mode = mode;
120
121 sendCommand(MAX7219_REG_SHUTDOWN, 0x01); // Normal operation
122 sendCommand(MAX7219_REG_SCANLIMIT, _numDigits - 1); // Set digit count
123 sendCommand(MAX7219_REG_DECODE, _mode); // Set decode mode
124 sendCommand(MAX7219_REG_INTENSITY, _brightness); // Set brightness
125 sendCommand(MAX7219_REG_DISPLAYTEST, 0x00); // Normal mode
126
127 clear();
128}
129
130// ========================================
131// Configuration Functions
132// ========================================
133 void MAX7219::setMode(uint8_t mode) {
134 _mode = mode;
135 sendCommand(MAX7219_REG_DECODE, mode);
136 clear();
137}
138
139uint8_t MAX7219::getMode() {
140 return _mode;
141}
142
143 void MAX7219::setAlignment(uint8_t alignment) {
144 _alignment = alignment;
145}
146
147uint8_t MAX7219::getAlignment() {
148 return _alignment;
149}
150
151 void MAX7219::setBrightness(uint8_t level) {
152 _brightness = constrain(level, 0, 15);
153 sendCommand(MAX7219_REG_INTENSITY, _brightness);
154}
155
156 void MAX7219::setPower(bool on) {
157 sendCommand(MAX7219_REG_SHUTDOWN, on ? 0x01 : 0x00);
158}
159
160 void MAX7219::clear() {
161 for (uint8_t i = 0; i < _numDigits; i++) {
162 if (_mode == MAX7219_MODE_DECODE) {
163 sendCommand(MAX7219_REG_DIGIT0 + i, 0x0F); // Blank in decode mode
164 } else {
165 sendCommand(MAX7219_REG_DIGIT0 + i, 0x00); // All segments off
166 }
167 }
168}
169
170// ========================================
171// Display Functions (Mode-Aware)
172// ========================================
173 void MAX7219::display(const char* text) {
174 if (_mode == MAX7219_MODE_DECODE) {
175 // In decode mode, try to parse as number
176 long num = atol(text);
177 displayNumberInternal(num, false);
178 } else {
179 // In no-decode mode, display as text
180 displayTextInternal(text);
181 }
182}
183
184 void MAX7219::display(int number) {
185 displayNumberInternal((long)number, false);
186}
187
188 void MAX7219::display(long number) {
189 displayNumberInternal(number, false);
190}
191
192 void MAX7219::display(double number, uint8_t decimals) {
193 displayFloatInternal((float)number, decimals);
194}
195
196 void MAX7219::displayAt(uint8_t position, uint8_t value, bool dp) {
197 if (position >= _numDigits) return;
198
199 uint8_t physPos = getPhysicalPosition(position);
200
201 if (_mode == MAX7219_MODE_DECODE) {
202 // BCD mode: hardware handles display
203 uint8_t data = constrain(value, 0, 9);
204 if (dp) data |= 0x80;
205 sendCommand(MAX7219_REG_DIGIT0 + physPos, data);
206 } else {
207 // No-decode mode: use segment patterns
208 uint8_t segments = (value <= 9) ? digitToSegments(value) : SEGMENT_BLANK;
209 if (dp) segments |= SEGMENT_DOT;
210 sendCommand(MAX7219_REG_DIGIT0 + physPos, segments);
211 }
212}
213
214 void MAX7219::displayAt(uint8_t position, char character, bool dp) {
215 if (position >= _numDigits) return;
216
217 uint8_t physPos = getPhysicalPosition(position);
218
219 if (_mode == MAX7219_MODE_DECODE) {
220 // BCD mode: only supports digits
221 if (character >= '0' && character <= '9') {
222 uint8_t data = character - '0';
223 if (dp) data |= 0x80;
224 sendCommand(MAX7219_REG_DIGIT0 + physPos, data);
225 } else if (character == '-') {
226 sendCommand(MAX7219_REG_DIGIT0 + physPos, 0x0A);
227 } else {
228 sendCommand(MAX7219_REG_DIGIT0 + physPos, 0x0F); // Blank
229 }
230 } else {
231 // No-decode mode: supports all characters
232 uint8_t segments = charToSegments(character);
233 if (dp) segments |= SEGMENT_DOT;
234 sendCommand(MAX7219_REG_DIGIT0 + physPos, segments);
235 }
236}
237
238// ========================================
239// Special Format Functions
240// ========================================
241 void MAX7219::displayTime(uint8_t hours, uint8_t minutes) {
242 if (_numDigits < 4) return;
243
244 hours = constrain(hours, 0, 99);
245 minutes = constrain(minutes, 0, 59);
246
247 uint8_t startPos;
248 if (_alignment == MAX7219_ALIGN_LEFT) {
249 startPos = 0;
250 } else if (_alignment == MAX7219_ALIGN_CENTER) {
251 startPos = (_numDigits - 4) / 2;
252 } else { // RIGHT
253 startPos = _numDigits - 4;
254 }
255
256 displayAt(startPos + 0, (uint8_t)(hours / 10));
257 displayAt(startPos + 1, (uint8_t)(hours % 10), true); // DP as colon
258 displayAt(startPos + 2, (uint8_t)(minutes / 10));
259 displayAt(startPos + 3, (uint8_t)(minutes % 10));
260}
261
262 void MAX7219::displayTime(uint8_t hours, uint8_t minutes, uint8_t seconds) {
263 if (_numDigits < 6) return;
264
265 hours = constrain(hours, 0, 99);
266 minutes = constrain(minutes, 0, 59);
267 seconds = constrain(seconds, 0, 59);
268
269 uint8_t startPos;
270 if (_alignment == MAX7219_ALIGN_LEFT) {
271 startPos = 0;
272 } else if (_alignment == MAX7219_ALIGN_CENTER) {
273 startPos = (_numDigits - 6) / 2;
274 } else { // RIGHT
275 startPos = _numDigits - 6;
276 }
277
278 displayAt(startPos + 0, (uint8_t)(hours / 10));
279 displayAt(startPos + 1, (uint8_t)(hours % 10), true);
280 displayAt(startPos + 2, (uint8_t)(minutes / 10));
281 displayAt(startPos + 3, (uint8_t)(minutes % 10), true);
282 displayAt(startPos + 4, (uint8_t)(seconds / 10));
283 displayAt(startPos + 5, (uint8_t)(seconds % 10));
284}
285
286 void MAX7219::displayHex(uint32_t value) {
287 if (_mode == MAX7219_MODE_DECODE) {
288 setMode(MAX7219_MODE_NO_DECODE); // Switch to no-decode for hex
289 }
290
291 for (int i = _numDigits - 1; i >= 0; i--) {
292 uint8_t digit = value & 0xF;
293 uint8_t physPos = getPhysicalPosition(i);
294
295 if (digit < 10) {
296 sendCommand(MAX7219_REG_DIGIT0 + physPos, SEGMENT_DIGITS[digit]);
297 } else {
298 sendCommand(MAX7219_REG_DIGIT0 + physPos, SEGMENT_HEX[digit - 10]);
299 }
300
301 value >>= 4;
302 if (value == 0 && i > 0) {
303 // Clear leading zeros
304 for (int j = i - 1; j >= 0; j--) {
305 uint8_t pos = getPhysicalPosition(j);
306 sendCommand(MAX7219_REG_DIGIT0 + pos, SEGMENT_BLANK);
307 }
308 break;
309 }
310 }
311}
312
313 void MAX7219::displayBinary(uint8_t value) {
314 if (_numDigits < 8) return;
315
316 for (int i = 0; i < 8; i++) {
317 uint8_t bit = (value >> (7 - i)) & 1;
318 displayAt(i, bit);
319 }
320}
321
322// ========================================
323// Animation Functions
324// ========================================
325 void MAX7219::blink(uint8_t times, uint16_t delayMs) {
326 for (uint8_t i = 0; i < times; i++) {
327 setPower(false);
328 delay(delayMs);
329 setPower(true);
330 delay(delayMs);
331 }
332}
333
334 void MAX7219::fadeIn(uint16_t delayMs) {
335 uint8_t oldBrightness = _brightness;
336 for (uint8_t b = 0; b <= 15; b++) {
337 setBrightness(b);
338 delay(delayMs);
339 }
340 setBrightness(oldBrightness);
341}
342
343 void MAX7219::fadeOut(uint16_t delayMs) {
344 uint8_t oldBrightness = _brightness;
345 for (int b = _brightness; b >= 0; b--) {
346 setBrightness(b);
347 delay(delayMs);
348 }
349 setBrightness(oldBrightness);
350}
351
352 void MAX7219::scroll(const char* text, uint16_t delayMs) {
353 int len = strlen(text);
354
355 for (int offset = _numDigits - 1; offset >= -len; offset--) {
356 clear();
357
358 for (int i = 0; i < len; i++) {
359 int pos = offset + i;
360 if (pos >= 0 && pos < _numDigits) {
361 displayAt(pos, text[i]);
362 }
363 }
364
365 delay(delayMs);
366 }
367}
368
369 void MAX7219::scroll(long number, uint16_t delayMs) {
370 char buffer[16];
371 sprintf(buffer, "%ld", number);
372 scroll(buffer, delayMs);
373}
374
375 void MAX7219::chase(uint16_t delayMs) {
376 for (uint8_t i = 0; i < _numDigits; i++) {
377 clear();
378 displayAt(i, (uint8_t)8); // Display "8" to light all segments
379 delay(delayMs);
380 }
381
382 for (int i = _numDigits - 1; i >= 0; i--) {
383 clear();
384 displayAt(i, (uint8_t)8);
385 delay(delayMs);
386 }
387}
388
389 void MAX7219::countUp(long from, long to, uint16_t delayMs) {
390 if (from > to) return;
391
392 for (long i = from; i <= to; i++) {
393 display(i);
394 delay(delayMs);
395 }
396}
397
398 void MAX7219::countDown(long from, long to, uint16_t delayMs) {
399 if (from < to) return;
400
401 for (long i = from; i >= to; i--) {
402 display(i);
403 delay(delayMs);
404 }
405}
406
407// ========================================
408// Low-Level Control
409// ========================================
410 void MAX7219::setSegments(uint8_t position, uint8_t segments) {
411 if (position >= _numDigits) return;
412 uint8_t physPos = getPhysicalPosition(position);
413 sendCommand(MAX7219_REG_DIGIT0 + physPos, segments);
414}
415
416 void MAX7219::setRawDigit(uint8_t position, uint8_t value, bool dp) {
417 if (position >= _numDigits) return;
418 uint8_t physPos = getPhysicalPosition(position);
419 uint8_t data = value;
420 if (dp) data |= 0x80;
421 sendCommand(MAX7219_REG_DIGIT0 + physPos, data);
422}
423
424// ========================================
425// Internal Helper Functions
426// ========================================
427 void MAX7219::sendCommand(uint8_t address, uint8_t data) {
428 digitalWrite(_csPin, LOW);
429 delayMicroseconds(1);
430 sendByte(address);
431 sendByte(data);
432 delayMicroseconds(1);
433 digitalWrite(_csPin, HIGH);
434 delayMicroseconds(1);
435}
436
437 void MAX7219::sendByte(uint8_t data) {
438 for (int i = 7; i >= 0; i--) {
439 sendBit((data >> i) & 0x01);
440 }
441}
442
443 void MAX7219::sendBit(uint8_t bit) {
444 digitalWrite(_dinPin, bit ? HIGH : LOW);
445 delayMicroseconds(1);
446 digitalWrite(_clkPin, HIGH);
447 delayMicroseconds(1);
448 digitalWrite(_clkPin, LOW);
449}
450
451uint8_t MAX7219::getPhysicalPosition(uint8_t logicalPosition) {
452 if (_alignment == MAX7219_ALIGN_LEFT) {
453 return _numDigits - 1 - logicalPosition; // Left-to-right
454 } else if (_alignment == MAX7219_ALIGN_RIGHT) {
455 return logicalPosition; // Right-to-left
456 } else { // CENTER
457 // For center alignment, treat logical positions same as left alignment
458 return _numDigits - 1 - logicalPosition;
459 }
460}
461
462uint8_t MAX7219::charToSegments(char c) {
463 if (c >= '0' && c <= '9') {
464 return SEGMENT_DIGITS[c - '0'];
465 } else if (c >= 'A' && c <= 'Z') {
466 return SEGMENT_LETTERS[c - 'A'];
467 } else if (c >= 'a' && c <= 'z') {
468 return SEGMENT_LETTERS[c - 'a'];
469 } else if (c == '-') {
470 return SEGMENT_MINUS;
471 } else if (c == ' ') {
472 return SEGMENT_BLANK;
473 }
474 return SEGMENT_BLANK;
475}
476
477uint8_t MAX7219::digitToSegments(uint8_t digit) {
478 if (digit <= 9) {
479 return SEGMENT_DIGITS[digit];
480 }
481 return SEGMENT_BLANK;
482}
483
484 void MAX7219::displayNumberInternal(long number, bool leadingZeros) {
485 bool negative = number < 0;
486 if (negative) number = -number;
487
488 // Clear display first
489 clear();
490
491 // Collect digits in reverse order (least significant first)
492 uint8_t digits[8];
493 uint8_t numDigits = 0;
494
495 if (number == 0) {
496 digits[0] = 0;
497 numDigits = 1;
498 } else {
499 while (number > 0 && numDigits < 8) {
500 digits[numDigits++] = number % 10;
501 number /= 10;
502 }
503 }
504
505 // Display digits in correct order
506 uint8_t lastPos = 0;
507 bool hasShownDigit = false;
508
509 // Calculate starting position based on alignment
510 uint8_t startPos;
511 if (_alignment == MAX7219_ALIGN_RIGHT) {
512 // Right align: fill from rightmost positions
513 startPos = 0;
514 } else if (_alignment == MAX7219_ALIGN_CENTER) {
515 // Center align: calculate center position
516 startPos = (_numDigits - numDigits) / 2;
517 } else { // LEFT
518 // Left align: fill from leftmost positions
519 startPos = 0;
520 }
521
522 // Display digits in correct order
523 for (int i = numDigits - 1; i >= 0; i--) {
524 uint8_t pos;
525 if (_alignment == MAX7219_ALIGN_RIGHT) {
526 // Right align: most significant (i=4, digit 1) goes to logical position 4, least (i=0, digit 5) to logical 0
527 pos = i; // i=4→pos=4, i=3→pos=3, ..., i=0→pos=0
528 } else if (_alignment == MAX7219_ALIGN_CENTER) {
529 // Center align: most significant digit at startPos, then increment
530 pos = startPos + (numDigits - 1 - i);
531 } else { // LEFT
532 // Left align: most significant (i=4, digit 1) goes to logical position 0, least (i=0, digit 5) to logical 4
533 pos = numDigits - 1 - i; // i=4→pos=0, i=3→pos=1, ..., i=0→pos=4
534 }
535
536 if (!leadingZeros && !hasShownDigit && digits[i] == 0 && i > 0) {
537 // Skip leading zeros
538 uint8_t physPos = getPhysicalPosition(pos);
539 if (_mode == MAX7219_MODE_DECODE) {
540 sendCommand(MAX7219_REG_DIGIT0 + physPos, 0x0F);
541 } else {
542 sendCommand(MAX7219_REG_DIGIT0 + physPos, SEGMENT_BLANK);
543 }
544 } else {
545 displayAt(pos, digits[i]);
546 hasShownDigit = true;
547 lastPos = pos;
548 }
549 }
550
551 // Display negative sign at the leftmost position if needed
552 if (negative && hasShownDigit) {
553 uint8_t leftmostPos;
554 if (_alignment == MAX7219_ALIGN_LEFT) {
555 leftmostPos = 0;
556 } else if (_alignment == MAX7219_ALIGN_CENTER) {
557 // For center, place negative sign one position before the number
558 leftmostPos = (startPos > 0) ? startPos - 1 : 0;
559 } else { // RIGHT
560 leftmostPos = _numDigits - 1;
561 }
562 if (leftmostPos != lastPos && leftmostPos < _numDigits) {
563 displayAt(leftmostPos, '-');
564 }
565 }
566}
567
568 void MAX7219::displayFloatInternal(double number, uint8_t decimals) {
569 if (decimals >= _numDigits) decimals = _numDigits - 1;
570
571 // Clear display first
572 clear();
573
574 long multiplier = 1;
575 for (uint8_t i = 0; i < decimals; i++) multiplier *= 10;
576
577 long intValue = (long)(number * multiplier);
578 bool negative = intValue < 0;
579 if (negative) intValue = -intValue;
580
581 // Collect digits in reverse order (least significant first)
582 uint8_t digits[8];
583 uint8_t numDigits = 0;
584
585 if (intValue == 0) {
586 digits[0] = 0;
587 numDigits = 1;
588 } else {
589 while (intValue > 0 && numDigits < 8) {
590 digits[numDigits++] = intValue % 10;
591 intValue /= 10;
592 }
593 }
594
595 // Display digits in correct order
596 uint8_t lastPos = 0;
597 bool hasShownDigit = false;
598
599 // Calculate starting position based on alignment
600 uint8_t startPos;
601 if (_alignment == MAX7219_ALIGN_RIGHT) {
602 startPos = 0;
603 } else if (_alignment == MAX7219_ALIGN_CENTER) {
604 startPos = (_numDigits - numDigits) / 2;
605 } else { // LEFT
606 startPos = 0;
607 }
608
609 for (int i = numDigits - 1; i >= 0; i--) {
610 uint8_t pos;
611 if (_alignment == MAX7219_ALIGN_RIGHT) {
612 pos = i;
613 } else if (_alignment == MAX7219_ALIGN_CENTER) {
614 pos = startPos + (numDigits - 1 - i);
615 } else { // LEFT
616 pos = numDigits - 1 - i;
617 }
618 bool showDP = (numDigits - 1 - i == decimals);
619 displayAt(pos, digits[i], showDP);
620 hasShownDigit = true;
621 lastPos = pos;
622 }
623
624 // Display negative sign at the leftmost position if needed
625 if (negative && hasShownDigit) {
626 uint8_t leftmostPos;
627 if (_alignment == MAX7219_ALIGN_LEFT) {
628 leftmostPos = 0;
629 } else if (_alignment == MAX7219_ALIGN_CENTER) {
630 // For center, place negative sign one position before the number
631 leftmostPos = (startPos > 0) ? startPos - 1 : 0;
632 } else { // RIGHT
633 leftmostPos = _numDigits - 1;
634 }
635 if (leftmostPos != lastPos && leftmostPos < _numDigits) {
636 displayAt(leftmostPos, '-');
637 }
638 }
639}
640
641 void MAX7219::displayTextInternal(const char* text) {
642 int len = strlen(text);
643 int textStartIdx = 0;
644 int logicalStartPos = 0;
645
646 clear();
647
648 if (_alignment == MAX7219_ALIGN_RIGHT) {
649 // For right alignment: text starts at logical position 0 (rightmost)
650 if (len <= _numDigits) {
651 // Text fits: display from rightmost positions
652 logicalStartPos = 0;
653 textStartIdx = 0;
654 // Display text in reverse order so first char appears on left, last char on right
655 for (int i = 0; i < len && i < _numDigits; i++) {
656 displayAt(len - 1 - i, text[i]);
657 }
658 } else {
659 // Text is longer: show last _numDigits characters
660 textStartIdx = len - _numDigits;
661 for (int i = 0; i < _numDigits; i++) {
662 displayAt(_numDigits - 1 - i, text[textStartIdx + i]);
663 }
664 }
665 } else if (_alignment == MAX7219_ALIGN_CENTER) {
666 // For center alignment: calculate center position
667 if (len <= _numDigits) {
668 logicalStartPos = (_numDigits - len) / 2;
669 textStartIdx = 0;
670 for (int i = 0; i < len && i < _numDigits; i++) {
671 displayAt(logicalStartPos + i, text[textStartIdx + i]);
672 }
673 } else {
674 // Text is longer: show last _numDigits characters centered
675 logicalStartPos = 0;
676 textStartIdx = len - _numDigits;
677 for (int i = 0; i < _numDigits; i++) {
678 displayAt(logicalStartPos + i, text[textStartIdx + i]);
679 }
680 }
681 } else { // LEFT
682 // For left alignment: text starts at logical position 0 (leftmost)
683 logicalStartPos = 0;
684 textStartIdx = 0;
685 for (int i = 0; i < _numDigits && (textStartIdx + i) < len; i++) {
686 displayAt(logicalStartPos + i, text[textStartIdx + i]);
687 }
688 }
689
690 // For left alignment with short text, remaining positions are already blank (from clear())
691 // For right alignment with short text, clear() already blanked everything, then we display
692 // starting from logicalStartPos which handles the padding
693}
694
SEGMENT_DIGITS
const uint8_t SEGMENT_DIGITS[10]
Definition MAX7219_CH32.cpp:30
SEGMENT_MINUS
#define SEGMENT_MINUS
Definition MAX7219_CH32.cpp:85
SEGMENT_DOT
#define SEGMENT_DOT
Definition MAX7219_CH32.cpp:86
SEGMENT_HEX
const uint8_t SEGMENT_HEX[6]
Definition MAX7219_CH32.cpp:74
SEGMENT_LETTERS
const uint8_t SEGMENT_LETTERS[26]
Definition MAX7219_CH32.cpp:44
SEGMENT_BLANK
#define SEGMENT_BLANK
Definition MAX7219_CH32.cpp:84
MAX7219_CH32.h
MAX7219_REG_INTENSITY
#define MAX7219_REG_INTENSITY
Definition MAX7219_CH32.h:51
MAX7219_ALIGN_CENTER
#define MAX7219_ALIGN_CENTER
Definition MAX7219_CH32.h:36
MAX7219_REG_SCANLIMIT
#define MAX7219_REG_SCANLIMIT
Definition MAX7219_CH32.h:52
MAX7219_ALIGN_LEFT
#define MAX7219_ALIGN_LEFT
Definition MAX7219_CH32.h:34
MAX7219_REG_DECODE
#define MAX7219_REG_DECODE
Definition MAX7219_CH32.h:50
MAX7219_REG_SHUTDOWN
#define MAX7219_REG_SHUTDOWN
Definition MAX7219_CH32.h:53
MAX7219_MODE_DECODE
#define MAX7219_MODE_DECODE
Definition MAX7219_CH32.h:28
MAX7219_ALIGN_RIGHT
#define MAX7219_ALIGN_RIGHT
Definition MAX7219_CH32.h:35
MAX7219_REG_DISPLAYTEST
#define MAX7219_REG_DISPLAYTEST
Definition MAX7219_CH32.h:54
MAX7219_REG_DIGIT0
#define MAX7219_REG_DIGIT0
Definition MAX7219_CH32.h:42
MAX7219_MODE_NO_DECODE
#define MAX7219_MODE_NO_DECODE
Definition MAX7219_CH32.h:29
MAX7219::displayHex
void displayHex(uint32_t value)
Display value in hexadecimal format.
Definition MAX7219_CH32.cpp:286
MAX7219::chase
void chase(uint16_t delayMs=100)
Chase animation (digit-by-digit)
Definition MAX7219_CH32.cpp:375
MAX7219::clear
void clear()
Clear all digits.
Definition MAX7219_CH32.cpp:160
MAX7219::setPower
void setPower(bool on)
Turn display on or off.
Definition MAX7219_CH32.cpp:156
MAX7219::setSegments
void setSegments(uint8_t position, uint8_t segments)
Set raw segment pattern at position.
Definition MAX7219_CH32.cpp:410
MAX7219::begin
void begin()
Initialize the display with default mode.
Definition MAX7219_CH32.cpp:104
MAX7219::blink
void blink(uint8_t times=3, uint16_t delayMs=500)
Blink the display.
Definition MAX7219_CH32.cpp:325
MAX7219::fadeIn
void fadeIn(uint16_t delayMs=50)
Fade in animation.
Definition MAX7219_CH32.cpp:334
MAX7219::setBrightness
void setBrightness(uint8_t level)
Set display brightness.
Definition MAX7219_CH32.cpp:151
MAX7219::getMode
uint8_t getMode()
Get current mode.
Definition MAX7219_CH32.cpp:139
MAX7219::getAlignment
uint8_t getAlignment()
Get current alignment.
Definition MAX7219_CH32.cpp:147
MAX7219::scroll
void scroll(const char *text, uint16_t delayMs=200)
Scroll text across display.
Definition MAX7219_CH32.cpp:352
MAX7219::setMode
void setMode(uint8_t mode)
Set decode mode.
Definition MAX7219_CH32.cpp:133
MAX7219::setRawDigit
void setRawDigit(uint8_t position, uint8_t value, bool dp=false)
Set raw digit value at position.
Definition MAX7219_CH32.cpp:416
MAX7219::displayAt
void displayAt(uint8_t position, uint8_t value, bool dp=false)
Display value at specific position.
Definition MAX7219_CH32.cpp:196
MAX7219::display
void display(const char *text)
Display text string.
Definition MAX7219_CH32.cpp:173
MAX7219::fadeOut
void fadeOut(uint16_t delayMs=50)
Fade out animation.
Definition MAX7219_CH32.cpp:343
MAX7219::displayBinary
void displayBinary(uint8_t value)
Display value in binary format.
Definition MAX7219_CH32.cpp:313
MAX7219::countDown
void countDown(long from, long to, uint16_t delayMs=100)
Count down animation.
Definition MAX7219_CH32.cpp:398
MAX7219::countUp
void countUp(long from, long to, uint16_t delayMs=100)
Count up animation.
Definition MAX7219_CH32.cpp:389
MAX7219::MAX7219
MAX7219(uint8_t dinPin, uint8_t clkPin, uint8_t csPin, uint8_t numDigits=8)
Constructor for MAX7219 display.
Definition MAX7219_CH32.cpp:91
MAX7219::setAlignment
void setAlignment(uint8_t alignment)
Set text alignment.
Definition MAX7219_CH32.cpp:143
MAX7219::displayTime
void displayTime(uint8_t hours, uint8_t minutes)
Display time in HH:MM format.
Definition MAX7219_CH32.cpp:241