Skip to content

Commit d6991a3

Browse files
committed
added Y-Offset for 128x64, support 4 buttons with S3, re-added debug mode
1 parent b6d8c9a commit d6991a3

File tree

4 files changed

+223
-103
lines changed

4 files changed

+223
-103
lines changed

src/displayConfig.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#include "displayConfig.h"
22

3-
uint8_t rgbMode = 0;
3+
int8_t rgbMode = 0;
44
uint8_t rgbModeLoaded = 0;
5+
uint8_t yOffset = 0;
56

67
// I needed to change these from RGB to RC (Red Color), BC, GC to prevent
78
// conflicting with the TFT_SPI Library.

src/displayConfig.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
#define BC 2
99

1010
// Global variables
11-
extern uint8_t rgbMode;
11+
extern int8_t rgbMode;
1212
extern uint8_t rgbModeLoaded;
13+
extern uint8_t yOffset;
1314

1415
// Constant array
1516
extern const uint8_t rgbOrder[3 * 6];

src/displays/LEDMatrix.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ void LedMatrix::SetCurrentScalingMode(uint8_t mode) {}
4747

4848
void LedMatrix::DrawPixel(uint16_t x, uint16_t y, uint8_t r, uint8_t g,
4949
uint8_t b) {
50-
dma_display->drawPixelRGB888(x, y, r, g, b);
50+
dma_display->drawPixelRGB888(x, y + yOffset, r, g, b);
5151
}
5252

5353
void LedMatrix::DrawPixel(uint16_t x, uint16_t y, uint16_t color) {
54-
dma_display->drawPixel(x, y, color);
54+
dma_display->drawPixel(x, y + yOffset, color);
5555
}
5656

5757
void LedMatrix::ClearScreen() { dma_display->clearScreen(); }
@@ -78,48 +78,48 @@ void LedMatrix::DisplayText(const char *text, uint16_t x, uint16_t y, uint8_t r,
7878
if (transparent && !p) {
7979
continue;
8080
}
81-
dma_display->drawPixelRGB888(x + pixel + (ti * 4), y + tj, r * p, g * p,
81+
dma_display->drawPixelRGB888(x + pixel + (ti * 4), y + yOffset + tj, r * p, g * p,
8282
b * p);
8383
}
8484
}
8585
}
8686
}
8787

8888
void IRAM_ATTR LedMatrix::FillZoneRaw(uint8_t idx, uint8_t *pBuffer) {
89-
const uint8_t yOffset = (idx / ZONES_PER_ROW) * ZONE_HEIGHT;
90-
const uint8_t xOffset = (idx % ZONES_PER_ROW) * ZONE_WIDTH;
89+
const uint8_t zoneYOffset = (idx / ZONES_PER_ROW) * ZONE_HEIGHT;
90+
const uint8_t zoneXOffset = (idx % ZONES_PER_ROW) * ZONE_WIDTH;
9191

9292
for (uint8_t y = 0; y < ZONE_HEIGHT; y++) {
9393
for (uint8_t x = 0; x < ZONE_WIDTH; x++) {
9494
uint16_t pos = (y * ZONE_WIDTH + x) * 3;
9595

96-
dma_display->drawPixelRGB888(x + xOffset, y + yOffset, pBuffer[pos],
96+
dma_display->drawPixelRGB888(x + zoneXOffset, y + zoneYOffset + yOffset, pBuffer[pos],
9797
pBuffer[pos + 1], pBuffer[pos + 2]);
9898
}
9999
}
100100
}
101101

102102
void IRAM_ATTR LedMatrix::FillZoneRaw565(uint8_t idx, uint8_t *pBuffer) {
103-
const uint8_t yOffset = (idx / ZONES_PER_ROW) * ZONE_HEIGHT;
104-
const uint8_t xOffset = (idx % ZONES_PER_ROW) * ZONE_WIDTH;
103+
const uint8_t zoneYOffset = (idx / ZONES_PER_ROW) * ZONE_HEIGHT;
104+
const uint8_t zoneXOffset = (idx % ZONES_PER_ROW) * ZONE_WIDTH;
105105

106106
for (uint8_t y = 0; y < ZONE_HEIGHT; y++) {
107107
for (uint8_t x = 0; x < ZONE_WIDTH; x++) {
108108
uint16_t pos = (y * ZONE_WIDTH + x) * 2;
109109
dma_display->drawPixel(
110-
x + xOffset, y + yOffset,
110+
x + zoneXOffset, y + zoneYOffset + yOffset,
111111
(((uint16_t)pBuffer[pos + 1]) << 8) + pBuffer[pos]);
112112
}
113113
}
114114
}
115115

116116
void IRAM_ATTR LedMatrix::ClearZone(uint8_t idx) {
117-
const uint8_t yOffset = (idx / ZONES_PER_ROW) * ZONE_HEIGHT;
118-
const uint8_t xOffset = (idx % ZONES_PER_ROW) * ZONE_WIDTH;
117+
const uint8_t zoneYOffset = (idx / ZONES_PER_ROW) * ZONE_HEIGHT;
118+
const uint8_t zoneXOffset = (idx % ZONES_PER_ROW) * ZONE_WIDTH;
119119

120120
for (uint8_t y = 0; y < ZONE_HEIGHT; y++) {
121121
for (uint8_t x = 0; x < ZONE_WIDTH; x++) {
122-
dma_display->drawPixelRGB888(x + xOffset, y + yOffset, 0, 0, 0);
122+
dma_display->drawPixelRGB888(x + zoneXOffset, y + zoneYOffset + yOffset, 0, 0, 0);
123123
}
124124
}
125125
}
@@ -131,7 +131,7 @@ void IRAM_ATTR LedMatrix::FillPanelRaw(uint8_t *pBuffer) {
131131
for (uint16_t x = 0; x < TOTAL_WIDTH; x++) {
132132
pos = (y * TOTAL_WIDTH + x) * 3;
133133

134-
dma_display->drawPixelRGB888(x, y, pBuffer[pos], pBuffer[pos + 1],
134+
dma_display->drawPixelRGB888(x, y + yOffset, pBuffer[pos], pBuffer[pos + 1],
135135
pBuffer[pos + 2]);
136136
}
137137
}

0 commit comments

Comments
 (0)