Skip to content

Commit e52f434

Browse files
committed
rg_display: Experimenting with on-screen indicators
Such as a low battery icon or a virtual LED
1 parent 06f9f09 commit e52f434

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

components/retro-go/rg_display.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,19 @@ static inline void write_update(const rg_surface_t *update)
199199
{
200200
int left = display.screen.margins.left + draw_left;
201201
int top = display.screen.margins.top + draw_top + y - lines_to_copy;
202+
203+
// // This annoying block is to avoid the on-screen led flickering.
204+
// if (config.on_screen_led && top < ON_SCREEN_LED_SIZE && left < ON_SCREEN_LED_SIZE && led_color > 0)
205+
// {
206+
// uint16_t color = led_color << 8 | led_color >> 8;
207+
// for (int y = 0; y < 8; ++y)
208+
// {
209+
// if (top + y < 8)
210+
// for (int x = 0; x < ON_SCREEN_LED_SIZE; ++x)
211+
// line_buffer[y * draw_width + x] = color;
212+
// }
213+
// }
214+
202215
if (top != window_top)
203216
lcd_set_window(left, top, draw_width, lines_remaining);
204217
lcd_send_buffer(line_buffer, draw_width * lines_to_copy);
@@ -302,6 +315,43 @@ static bool load_border_file(const char *filename)
302315
return false;
303316
}
304317

318+
static void on_screen_indicators(void)
319+
{
320+
// TODO: Respect RG_SCREEN_SAFE_AREA
321+
int left = display.screen.width - 20;
322+
int top = display.screen.height - 12;
323+
static bool cleared = false;
324+
#if 1 // Just low battery icon
325+
if (rg_system_get_indicator(RG_INDICATOR_POWER_LOW))
326+
{
327+
rg_display_clear_rect(left + 2, top, 14, 10, C_RED);
328+
rg_display_clear_rect(left, top + 2, 2, 6, C_RED);
329+
rg_display_clear_rect(left + 4, top + 2, 10, 6, C_BLACK);
330+
cleared = false;
331+
}
332+
else if (!cleared)
333+
{
334+
rg_display_clear_rect(left, top, display.screen.width - left, display.screen.height - top, C_BLACK);
335+
memset(&screen_line_checksum[top], 0, sizeof(uint32_t) * (display.screen.height - top));
336+
cleared = true;
337+
}
338+
#else // Virtual LED
339+
rg_color_t led_color = rg_system_get_led_color();
340+
const int led_size = 10;
341+
if (led_color > 0)
342+
{
343+
rg_display_clear_rect(left, top, led_size, led_size, led_color);
344+
cleared = false;
345+
}
346+
else if (!cleared)
347+
{
348+
rg_display_clear_rect(left, top, led_size, led_size, C_BLACK);
349+
memset(&screen_line_checksum[top], 0, sizeof(uint32_t) * led_size);
350+
cleared = true;
351+
}
352+
#endif
353+
}
354+
305355
IRAM_ATTR
306356
static void display_task(void *arg)
307357
{
@@ -329,6 +379,8 @@ static void display_task(void *arg)
329379

330380
write_update(msg.dataPtr);
331381

382+
on_screen_indicators();
383+
332384
rg_task_receive(&msg);
333385

334386
lcd_sync();

0 commit comments

Comments
 (0)