Skip to content
This repository was archived by the owner on Jan 18, 2024. It is now read-only.

Commit 6d7dc78

Browse files
committed
- Added LCD_MIRROR_HORIZONTALLY and LCD_MIRROR_VERTICALLY defines for flipped screens
1 parent e37f619 commit 6d7dc78

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

src/User/features.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,18 @@
77
// Enable fullscreen mode
88
#define LCD_FULLSCREEN
99

10+
// Mirror screen horizontally
11+
//#define LCD_MIRROR_HORIZONTALLY
12+
13+
// Mirror screen vertically
14+
//#define LCD_MIRROR_VERTICALLY
15+
1016
// Rotate screen by 180°
1117
//#define LCD_ROTATE_180
18+
#if defined(LCD_ROTATE_180)
19+
#define LCD_MIRROR_HORIZONTALLY
20+
#define LCD_MIRROR_VERTICALLY
21+
#endif
1222

1323
// Enable LCD backlight idle off
1424
//#define LCD_IDLE_OFF

src/User/main.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,18 @@ static inline lcd_pixel_type min(lcd_pixel_type a, lcd_pixel_type b) {
2424
return b;
2525
}
2626

27-
#if defined(LCD_ROTATE_180)
28-
#define FILLRECT(X,Y,W,H,C) \
29-
{ \
30-
lcd_pixel_type x0 = LCD_WIDTH - (X) - (W) - 1; \
31-
lcd_pixel_type y0 = LCD_HEIGHT - (Y) - (H) - 1; \
32-
GUI_FillRectColor(x0, y0, x0 + W, y0 + H, C); \
33-
}
27+
#if defined(LCD_MIRROR_HORIZONTALLY)
28+
#define _X(X,W) (LCD_WIDTH - (X) - (W) - 1)
29+
#else
30+
#define _X(X,W) (X)
31+
#endif
32+
#if defined(LCD_MIRROR_VERTICALLY)
33+
#define _Y(Y,H) (LCD_HEIGHT - (Y) - (H) - 1)
3434
#else
35-
#define FILLRECT(X,Y,W,H,C) \
36-
GUI_FillRectColor(X, Y, X + W, Y + H, C);
35+
#define _Y(Y,H) (Y)
3736
#endif
37+
#define FILLRECT(X,Y,W,H,C) \
38+
GUI_FillRectColor(_X(X,W), _Y(Y,H), _X(X,W) + W, _Y(Y,H) + H, C);
3839

3940
void clearDisplay() {
4041
// Clear ST7920 gui rect
@@ -141,7 +142,7 @@ int main(void)
141142
st7920Emulator.reset(false);
142143

143144
// Add first part of header line
144-
FILLRECT(0, 7, (LCD_WIDTH - sizeof(pTitle) / 5 * 6) / 2 - 1, 1, LCD_COLOR_FOREGROUND);
145+
FILLRECT(0, 7, LCD_WIDTH / 2 - sizeof(pTitle) / 5 * 3 - 1, 1, LCD_COLOR_FOREGROUND);
145146

146147
// Init slave SPI
147148
ui32SpiActivated = 0;
@@ -172,7 +173,7 @@ int main(void)
172173
#endif
173174

174175
// Add second part of header line
175-
FILLRECT((LCD_WIDTH + sizeof(pTitle) / 5 * 6) / 2, 7, (LCD_WIDTH - sizeof(pTitle) / 5 * 6) / 2, 1, LCD_COLOR_FOREGROUND);
176+
FILLRECT(LCD_WIDTH / 2 + sizeof(pTitle) / 5 * 3, 7, LCD_WIDTH / 2 - sizeof(pTitle) / 5 * 3, 1, LCD_COLOR_FOREGROUND);
176177

177178
// Variables for SPI data received indicator
178179
#if defined(SPI_DATA_RECEIVED_INDICATOR)

0 commit comments

Comments
 (0)