-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLEDArrayVisualizer.h
More file actions
40 lines (32 loc) · 884 Bytes
/
LEDArrayVisualizer.h
File metadata and controls
40 lines (32 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef LED_ARRAY_VISUALIZER_H
#define LED_ARRAY_VISUALIZER_H
#include <MD_MAX72xx.h>
class LEDArrayVisualizer {
public:
LEDArrayVisualizer(uint8_t dataPin, uint8_t clkPin, uint8_t csPin, uint8_t numDevices);
void begin();
void displayArray(int arr[8][8]);
void clear();
private:
MD_MAX72XX mx;
};
LEDArrayVisualizer::LEDArrayVisualizer(uint8_t dataPin, uint8_t clkPin, uint8_t csPin, uint8_t numDevices)
: mx(MD_MAX72XX::FC16_HW, dataPin, clkPin, csPin, numDevices) {}
void LEDArrayVisualizer::begin() {
mx.begin();
mx.control(MD_MAX72XX::INTENSITY, 0);
mx.clear();
}
void LEDArrayVisualizer::displayArray(int arr[8][8]) {
for (uint8_t row = 0; row < 8; row++) {
for (uint8_t col = 0; col < 8; col++) {
mx.setPoint(row, col, arr[row][col] != 0);
}
}
mx.update();
}
void LEDArrayVisualizer::clear() {
mx.clear();
mx.update();
}
#endif