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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
// Example sketch which shows how to display some patterns
// on a 64x64 LED matrix
//
#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
#include <Fonts/Picopixel.h>
#define PANEL_RES_X 64 // Number of pixels wide of each INDIVIDUAL panel module.
#define PANEL_RES_Y 64 // Number of pixels tall of each INDIVIDUAL panel module.
#define PANEL_CHAIN 1 // Total number of panels chained one to another
#include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
/*--------------------- HUB75 MATRIX GPIO CONFIG ---------------------*/
#define R1 1
#define G1 40
#define BL1 2
#define R2 4
#define G2 36
#define BL2 6
#define CH_A 8
#define CH_B 21
#define CH_C 10
#define CH_D 17
#define CH_E 34 // required for 1/32 scan panels, like 64x64px. Any available pin would do, i.e. IO32
#define LAT 15
#define OE 14
#define CLK 13
//MatrixPanel_I2S_DMA dma_display;
MatrixPanel_I2S_DMA *dma_display = nullptr;
uint16_t myBLACK = dma_display->color565(0, 0, 0);
uint16_t myWHITE = dma_display->color565(255, 255, 255);
uint16_t myRED = dma_display->color565(255, 0, 0);
uint16_t myGREEN = dma_display->color565(0, 255, 0);
uint16_t myBLUE = dma_display->color565(0, 0, 255);
uint16_t get_color(char name[4]) {
if (name == "1A") {
return dma_display->color565(255, 0, 0); // Red
} else if (name == "A") {
return dma_display->color565(75, 75, 255); // Light blue
} else if (name == "B") {
return dma_display->color565(50, 150, 16); // Green
} else if (name == "350S" or name == "150S") {
return dma_display->color565(0, 101, 170); // Dark blue
}else {
return dma_display->color565(200, 100, 0); // Yellow
}
}
void draw_line(int index, char* name, char* direction, int time, int time_offset) {
const int vertical_offset = 9 * index;
const uint16_t color = get_color(name);
dma_display->fillRect(0, vertical_offset, 19, 9, color);
if(strlen(name) == 4){
// The name is 4 characters wide, use a condensed font
dma_display->setFont(&Picopixel);
dma_display->setCursor(2, 6 + vertical_offset); // start at top left, with 8 pixel of spacing
}else{
dma_display->setCursor(8 + (4 - (strlen(name) * 6)) / 2, 1 + vertical_offset); // start at top left, with 8 pixel of spacing
}
dma_display->setTextColor(dma_display->color565(255, 255, 255));
dma_display->println(name);
dma_display->setFont();
dma_display->setCursor(21, 1 + vertical_offset); // start at top left, with 8 pixel of spacing
dma_display->print(direction);
dma_display->print(" ");
if (time < 10) {
dma_display->print(" ");
}
if(time_offset > 0){
dma_display->setTextColor(dma_display->color565(255, 0, 0));
} else if(time_offset < 0){
dma_display->setTextColor(dma_display->color565(0, 255, 0));
}
dma_display->print(time);
dma_display->setFont(&Picopixel);
dma_display->setCursor(52, 6 + vertical_offset); // start at top left, with 8 pixel of spacing
if(time_offset == 0){
dma_display->print("min");
} else {
if(time_offset > 0){
dma_display->print("+");
}
dma_display->print(time_offset);
}
dma_display->setFont();
}
void setup() {
// Module configuration
HUB75_I2S_CFG::i2s_pins _pins={R1, G1, BL1, R2, G2, BL2, CH_A, CH_B, CH_C, CH_D, CH_E, LAT, OE, CLK};
HUB75_I2S_CFG mxconfig(
PANEL_RES_X, // module width
PANEL_RES_Y, // module height
PANEL_CHAIN, // Chain length
_pins // pin mapping
);
mxconfig.gpio.e = 34;
mxconfig.clkphase = false;
mxconfig.driver = HUB75_I2S_CFG::MBI5124;
mxconfig.latch_blanking = 4;
mxconfig.i2sspeed = HUB75_I2S_CFG::HZ_8M;
// Display Setup
dma_display = new MatrixPanel_I2S_DMA(mxconfig);
dma_display->begin();
dma_display->setBrightness8(28); //0-255
dma_display->clearScreen();
dma_display->setTextSize(1); // size 1 == 8 pixels high
dma_display->setTextWrap(false); // Don't wrap at end of line - will do ourselves
draw_line(0, "1A", "Av", 0, 0);
draw_line(1, "C", "Kl", 6, 7);
draw_line(2, "B", "Fa", 7, 0);
draw_line(3, "A", "Av", 9, 0);
draw_line(4, "A", "Vi", 10, 0);
draw_line(5, "350S", "Ba", 16, -2);
draw_line(6, "184", "Av", 19, 0);
/*
// draw a box
dma_display->fillRect(0, 12, 13, 11, dma_display->color565(200, 100, 0));
dma_display->setCursor(4, 14); // start at top left, with 8 pixel of spacing
dma_display->setTextColor(dma_display->color565(255,255,255));
dma_display->print("C FR 15min");
// draw a box
dma_display->fillRect(0, 24, 13, 11, dma_display->color565(0, 125, 190));
dma_display->setCursor(4, 26); // start at top left, with 8 pixel of spacing
dma_display->setTextColor(dma_display->color565(255,255,255));
dma_display->print("A HI 22min");
// draw a box
dma_display->fillRect(0, 36, 13, 11, dma_display->color565(0, 175, 0));
dma_display->setCursor(4, 38); // start at top left, with 8 pixel of spacing
dma_display->setTextColor(dma_display->color565(255,255,255));
dma_display->print("B FA 25min");
// draw a box
dma_display->fillRect(0, 48, 13, 11, dma_display->color565(0, 125, 190));
dma_display->setCursor(4, 50); // start at top left, with 8 pixel of spacing
dma_display->setTextColor(dma_display->color565(255,255,255));
dma_display->print("A KO 29min");
*/
delay(500);
}
void loop() {
delay(1000);
}
|