|
10 | 10 | static rg_task_t *display_task_queue; |
11 | 11 | static rg_display_counters_t counters; |
12 | 12 | static rg_display_config_t config; |
13 | | -// static rg_surface_t *osd; |
14 | 13 | static rg_surface_t *border; |
15 | 14 | static rg_display_t display; |
16 | 15 | static int16_t map_viewport_to_source_x[RG_SCREEN_WIDTH + 1]; |
@@ -45,6 +44,38 @@ static inline void lcd_send_buffer(uint16_t *buffer, size_t length); |
45 | 44 | #include "drivers/display/dummy.h" |
46 | 45 | #endif |
47 | 46 |
|
| 47 | +static inline bool draw_on_screen_display(int y1, int y2) |
| 48 | +{ |
| 49 | + static unsigned area_dirty = 0; |
| 50 | + rg_margins_t margins = rg_gui_get_safe_area(); |
| 51 | + int left = display.screen.width - margins.right - 28; |
| 52 | + int top = margins.top + 4; |
| 53 | + int border = 3; |
| 54 | + int width = 20; |
| 55 | + int height = 14; |
| 56 | + |
| 57 | + // Check if the region contains OSD to draw |
| 58 | + if (y2 < top || y1 > top + height) |
| 59 | + return false; |
| 60 | + |
| 61 | + // Low battery indicator |
| 62 | + if (rg_system_get_indicator(RG_INDICATOR_POWER_LOW) && ((counters.totalFrames / 20) & 1)) |
| 63 | + { |
| 64 | + rg_display_clear_rect(left, top, width, height, C_RED); // Main body |
| 65 | + rg_display_clear_rect(left + width, top + height / 4, border, height / 2, C_RED); // The tab |
| 66 | + rg_display_clear_rect(left + border, top + border, width - border * 2, height - border * 2, C_BLACK); // The fill |
| 67 | + area_dirty |= 1 << RG_INDICATOR_POWER_LOW; |
| 68 | + } |
| 69 | + else if (area_dirty) |
| 70 | + { |
| 71 | + if (display.viewport.left || display.viewport.top) |
| 72 | + rg_display_clear_rect(left, top, width + border, height, C_BLACK); |
| 73 | + memset(&screen_line_checksum[top], 0, sizeof(uint32_t) * height); |
| 74 | + area_dirty = 0; |
| 75 | + } |
| 76 | + return true; |
| 77 | +} |
| 78 | + |
48 | 79 | static inline unsigned blend_pixels(unsigned a, unsigned b) |
49 | 80 | { |
50 | 81 | // Fast path (taken 80-90% of the time) |
@@ -102,6 +133,7 @@ static inline void write_update(const rg_surface_t *update) |
102 | 133 | int lines_remaining = draw_height; |
103 | 134 | int lines_updated = 0; |
104 | 135 | int window_top = -1; |
| 136 | + int osd_threshold = 24; |
105 | 137 |
|
106 | 138 | for (int y = 0; y < draw_height;) |
107 | 139 | { |
@@ -211,6 +243,13 @@ static inline void write_update(const rg_surface_t *update) |
211 | 243 | lcd_send_buffer(line_buffer, 0); |
212 | 244 | } |
213 | 245 |
|
| 246 | + // if (draw_on_screen_display(draw_top + y - lines_to_copy, draw_top + y)) |
| 247 | + if (draw_top + y > osd_threshold && draw_on_screen_display(0, draw_top + y)) |
| 248 | + { |
| 249 | + osd_threshold = 9999; |
| 250 | + window_top = -1; |
| 251 | + } |
| 252 | + |
214 | 253 | lines_remaining -= lines_to_copy; |
215 | 254 | } |
216 | 255 |
|
@@ -328,7 +367,7 @@ static void display_task(void *arg) |
328 | 367 | } |
329 | 368 |
|
330 | 369 | write_update(msg.dataPtr); |
331 | | - |
| 370 | + // draw_on_screen_display(0, display.screen.height); |
332 | 371 | rg_task_receive(&msg); |
333 | 372 |
|
334 | 373 | lcd_sync(); |
|
0 commit comments