|
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
|
#include <stdint.h>
#include <esp_log.h>
#include "display.h"
MatrixPanel_I2S_DMA *dma_display = nullptr;
esp_err_t init_display() {
HUB75_I2S_CFG mxconfig(
PANEL_RES_X, // module width
PANEL_RES_Y, // module height
PANEL_CHAIN // Chain length
);
mxconfig.gpio.r1 = R1_PIN;
mxconfig.gpio.g1 = G1_PIN;
mxconfig.gpio.b1 = B1_PIN;
mxconfig.gpio.r2 = R2_PIN;
mxconfig.gpio.g2 = G2_PIN;
mxconfig.gpio.b2 = B2_PIN;
mxconfig.gpio.a = A_PIN;
mxconfig.gpio.b = B_PIN;
mxconfig.gpio.c = C_PIN;
mxconfig.gpio.d = D_PIN;
mxconfig.gpio.lat = LAT_PIN;
mxconfig.gpio.oe = OE_PIN;
mxconfig.gpio.clk = CLK_PIN;
mxconfig.clkphase = false;
// Display Setup
dma_display = new MatrixPanel_I2S_DMA(mxconfig);
dma_display->begin();
dma_display->setBrightness8(80);
dma_display->clearScreen();
return ESP_OK;
}
void drawChar(uint8_t x, uint8_t y, unsigned char c, uint8_t r, uint8_t g, uint8_t b) {
for(unsigned int j = 0; j < 8; ++j) {
uint8_t row_data = font[8*c + j];
for(unsigned int i = 0; i < 6; ++i) {
if (row_data & (0x01 << (7-i))) {
dma_display->drawPixelRGB888(x+i, y+j, r, g, b);
}
}
}
}
void drawText(uint8_t x, uint8_t y, const char* text, unsigned int length, uint8_t r, uint8_t g, uint8_t b) {
for(unsigned int i = 0; i < length; ++i) {
drawChar(x + 6*i, y, text[i], r, g, b);
}
}
|