Skip to content

Commit 401ef42

Browse files
committed
[Painter] Remove surface support for st7789 170x320
At least until I can figure out why it's not working
1 parent 7c44878 commit 401ef42

File tree

1 file changed

+33
-38
lines changed

1 file changed

+33
-38
lines changed

users/drashna/display/painter/st7789_170x320.c

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,7 @@
4444
#endif // ST7789_SPI_MODE
4545

4646
static painter_device_t st7789_display;
47-
#ifdef QUANTUM_PAINTER_DRIVERS_ST7789_170X320_SURFACE
48-
static painter_device_t st7789_170x320_surface_display;
49-
static uint8_t display_buffer[SURFACE_REQUIRED_BUFFER_BYTE_SIZE(240, 320, 16)];
50-
#else
51-
# define st7789_170x320_surface_display st7789_display
52-
#endif // QUANTUM_PAINTER_DRIVERS_ST7789_170X320_SURFACE
47+
painter_image_handle_t screen_saver;
5348

5449
static bool has_run = false, forced_reinit = false;
5550

@@ -87,21 +82,9 @@ void init_display_st7789_170x320_rotation(void) {
8782
void init_display_st7789_170x320(void) {
8883
st7789_display = qp_st7789_make_spi_device(240, 320, ST7789_CS_PIN, ST7789_DC_PIN, ST7789_RST_PIN,
8984
ST7789_SPI_DIVIDER, ST7789_SPI_MODE);
90-
91-
#ifdef QUANTUM_PAINTER_DRIVERS_ST7789_170X320_SURFACE
92-
st7789_170x320_surface_display = qp_make_rgb565_surface(240, 320, display_buffer);
93-
#endif // QUANTUM_PAINTER_DRIVERS_ST7789_170X320_SURFACE
94-
9585
init_display_st7789_170x320_rotation();
9686

97-
#ifdef QUANTUM_PAINTER_DRIVERS_ST7789_170X320_SURFACE
98-
qp_init(st7789_170x320_surface_display, QP_ROTATION_0);
99-
100-
qp_rect(st7789_170x320_surface_display, 0, 0, 240 - 1, 320 - 1, HSV_BLACK, true);
101-
qp_surface_draw(st7789_170x320_surface_display, st7789_display, 0, 0, 0);
102-
#else
10387
qp_rect(st7789_display, 0, 0, 240 - 1, 320 - 1, 0, 0, 0, true);
104-
#endif
10588

10689
st7789_170x320_draw_user();
10790
}
@@ -117,40 +100,52 @@ __attribute__((weak)) void st7789_170x320_draw_user(void) {
117100

118101
static bool force_redraw = false;
119102
#ifdef COMMUNITY_MODULE_DISPLAY_MENU_ENABLE
120-
if (painter_render_menu(st7789_170x320_surface_display, font_oled, 0, 0, width, height, false,
103+
if (painter_render_menu(st7789_display, font_oled, 0, 0, width, height, false,
121104
userspace_config.display.painter.hsv.primary,
122105
userspace_config.display.painter.hsv.secondary)) {
123106
force_redraw = true;
124107
} else
125108
#endif // COMMUNITY_MODULE_DISPLAY_MENU_ENABLE
126109
{
127-
static uint8_t display_logo = 0xFF;
128-
const uint8_t display_logo_ref = is_keyboard_left() ? userspace_config.display.painter.left.display_logo
129-
: userspace_config.display.painter.right.display_logo;
130-
131-
if (display_logo != display_logo_ref) {
132-
display_logo = display_logo_ref;
133-
force_redraw = true;
110+
static uint16_t screen_saver_timer = 0;
111+
static bool screen_saver_redraw = true;
112+
static uint8_t display_mode_ref = 0;
113+
uint8_t display_logo_index = 0;
114+
bool display_logo_cycle = false;
115+
if (is_keyboard_left()) {
116+
display_logo_index = userspace_config.display.painter.left.display_logo;
117+
display_logo_cycle = userspace_config.display.painter.left.display_logo_cycle;
118+
} else {
119+
display_logo_index = userspace_config.display.painter.right.display_logo;
120+
display_logo_cycle = userspace_config.display.painter.right.display_logo_cycle;
134121
}
135-
if (force_redraw) {
136-
painter_image_handle_t screen_saver = qp_load_image_mem(screen_saver_image[display_logo].data);
137122

123+
if (display_logo_cycle && timer_elapsed(screen_saver_timer) > 5000) {
124+
static uint8_t last_display_mode = 0;
125+
if (last_display_mode != display_logo_index) {
126+
last_display_mode = display_logo_index;
127+
display_mode_ref = 0; // reset the reference
128+
} else {
129+
display_mode_ref++;
130+
}
131+
screen_saver_redraw = true;
132+
screen_saver_timer = timer_read();
133+
} else if (!display_logo_cycle) {
134+
display_mode_ref = 0; // reset the reference
135+
// xprintf("Screen saver: %d, reset at %u\n", display_mode_ref, screen_saver_timer);
136+
}
137+
if (force_redraw || screen_saver_redraw) {
138+
screen_saver_redraw = force_redraw = false;
139+
screen_saver = qp_load_image_mem(
140+
screen_saver_image[(display_logo_index + display_mode_ref) % screensaver_image_size].data);
138141
if (screen_saver != NULL) {
139-
#ifdef QUANTUM_PAINTER_DRIVERS_ST7789_170X320_SURFACE
140-
qp_drawimage(st7789_170x320_surface_display, 0, 0, screen_saver);
141-
#else // QUANTUM_PAINTER_DRIVERS_ST7789_170X320_SURFACE
142142
qp_drawimage(st7789_display, 0, 0, screen_saver);
143-
#endif // QUANTUM_PAINTER_DRIVERS_ST7789_170X320_SURFACE
144143
qp_close_image(screen_saver);
144+
} else {
145+
qp_rect(st7789_display, 0, 0, width - 1, height - 1, 0, 0, 0, true);
145146
}
146-
force_redraw = false;
147-
} else {
148-
return;
149147
}
150148
}
151-
#ifdef QUANTUM_PAINTER_DRIVERS_ST7789_170X320_SURFACE
152-
qp_surface_draw(st7789_170x320_surface_display, st7789_display, 0, 0, 0);
153-
#endif // QUANTUM_PAINTER_DRIVERS_ST7789_170X320_SURFACE
154149

155150
qp_flush(st7789_display);
156151
}

0 commit comments

Comments
 (0)