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

Commit

Permalink
- Added LCD_MIRROR_HORIZONTALLY and LCD_MIRROR_VERTICALLY defines for…
Browse files Browse the repository at this point in the history
… flipped screens
  • Loading branch information
teeminus committed Nov 3, 2021
1 parent e37f619 commit 6d7dc78
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
10 changes: 10 additions & 0 deletions src/User/features.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,18 @@
// Enable fullscreen mode
#define LCD_FULLSCREEN

// Mirror screen horizontally
//#define LCD_MIRROR_HORIZONTALLY

// Mirror screen vertically
//#define LCD_MIRROR_VERTICALLY

// Rotate screen by 180°
//#define LCD_ROTATE_180
#if defined(LCD_ROTATE_180)
#define LCD_MIRROR_HORIZONTALLY
#define LCD_MIRROR_VERTICALLY
#endif

// Enable LCD backlight idle off
//#define LCD_IDLE_OFF
Expand Down
23 changes: 12 additions & 11 deletions src/User/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@ static inline lcd_pixel_type min(lcd_pixel_type a, lcd_pixel_type b) {
return b;
}

#if defined(LCD_ROTATE_180)
#define FILLRECT(X,Y,W,H,C) \
{ \
lcd_pixel_type x0 = LCD_WIDTH - (X) - (W) - 1; \
lcd_pixel_type y0 = LCD_HEIGHT - (Y) - (H) - 1; \
GUI_FillRectColor(x0, y0, x0 + W, y0 + H, C); \
}
#if defined(LCD_MIRROR_HORIZONTALLY)
#define _X(X,W) (LCD_WIDTH - (X) - (W) - 1)
#else
#define _X(X,W) (X)
#endif
#if defined(LCD_MIRROR_VERTICALLY)
#define _Y(Y,H) (LCD_HEIGHT - (Y) - (H) - 1)
#else
#define FILLRECT(X,Y,W,H,C) \
GUI_FillRectColor(X, Y, X + W, Y + H, C);
#define _Y(Y,H) (Y)
#endif
#define FILLRECT(X,Y,W,H,C) \
GUI_FillRectColor(_X(X,W), _Y(Y,H), _X(X,W) + W, _Y(Y,H) + H, C);

void clearDisplay() {
// Clear ST7920 gui rect
Expand Down Expand Up @@ -141,7 +142,7 @@ int main(void)
st7920Emulator.reset(false);

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

// Init slave SPI
ui32SpiActivated = 0;
Expand Down Expand Up @@ -172,7 +173,7 @@ int main(void)
#endif

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

// Variables for SPI data received indicator
#if defined(SPI_DATA_RECEIVED_INDICATOR)
Expand Down

0 comments on commit 6d7dc78

Please sign in to comment.