|
4 | 4 | #include <stdlib.h> |
5 | 5 | #include <string.h> |
6 | 6 |
|
7 | | -// #define LCD_SCREEN_BUFFER 0 |
| 7 | +// #define LCD_ACCESS_MODE 0 // 0=Windowed transactions, 1=Direct full framebuffer |
| 8 | +// #define LCD_PIXEL_FORMAT RG_SCREEN_PIXEL_FORMAT |
8 | 9 | // #define LCD_BUFFER_LENGTH (RG_SCREEN_WIDTH * 4) // In pixels |
9 | 10 |
|
10 | 11 | // static rg_display_driver_t driver; |
@@ -34,11 +35,11 @@ static void lcd_sync(void); |
34 | 35 | static void lcd_flip(void); |
35 | 36 | static void lcd_set_rotation(int rotation); |
36 | 37 | static void lcd_set_backlight(float percent); |
37 | | -// When LCD_SCREEN_BUFFER == 0: |
| 38 | +// When LCD_ACCESS_MODE == 0: |
38 | 39 | static void lcd_set_window(int left, int top, int width, int height); |
39 | 40 | static inline uint16_t *lcd_get_buffer(size_t length); |
40 | 41 | static inline void lcd_send_buffer(uint16_t *buffer, size_t length); |
41 | | -// When LCD_SCREEN_BUFFER == 1: |
| 42 | +// When LCD_ACCESS_MODE == 1: |
42 | 43 | static inline uint16_t *lcd_get_buffer_ptr(int left, int top); |
43 | 44 |
|
44 | 45 | #if RG_SCREEN_DRIVER == 0 || RG_SCREEN_DRIVER == 1 /* ILI9341/ST7789 */ |
@@ -142,7 +143,7 @@ static inline void write_update(const rg_surface_t *update) |
142 | 143 |
|
143 | 144 | const int screen_left = display.screen.margins.left + draw_left; |
144 | 145 | const int screen_top = display.screen.margins.top + draw_top; |
145 | | - const bool partial_update = RG_SCREEN_PARTIAL_UPDATES && !LCD_SCREEN_BUFFER; |
| 146 | + const bool partial_update = RG_SCREEN_PARTIAL_UPDATES && LCD_ACCESS_MODE == 0; |
146 | 147 | // const bool interlace = false; |
147 | 148 |
|
148 | 149 | int lines_per_buffer = LCD_BUFFER_LENGTH / draw_width; |
@@ -171,10 +172,10 @@ static inline void write_update(const rg_surface_t *update) |
171 | 172 | LINE_IS_REPEATED(y + lines_to_copy))) |
172 | 173 | --lines_to_copy; |
173 | 174 | } |
174 | | -#if LCD_SCREEN_BUFFER |
175 | | - uint16_t *line_buffer = lcd_get_buffer_ptr(screen_left, screen_top + y); |
176 | | -#else |
| 175 | +#if LCD_ACCESS_MODE == 0 |
177 | 176 | uint16_t *line_buffer = lcd_get_buffer(LCD_BUFFER_LENGTH); |
| 177 | +#else |
| 178 | + uint16_t *line_buffer = lcd_get_buffer_ptr(screen_left, screen_top + y); |
178 | 179 | #endif |
179 | 180 | uint16_t *line_buffer_ptr = line_buffer; |
180 | 181 |
|
@@ -262,7 +263,7 @@ static inline void write_update(const rg_surface_t *update) |
262 | 263 | } |
263 | 264 | } |
264 | 265 |
|
265 | | -#if !LCD_SCREEN_BUFFER |
| 266 | +#if LCD_ACCESS_MODE == 0 |
266 | 267 | size_t lines_to_send = 0; |
267 | 268 | if (need_update) |
268 | 269 | { |
@@ -593,7 +594,7 @@ void rg_display_write_rect(int left, int top, int width, int height, int stride, |
593 | 594 | const int screen_left = display.screen.margins.left + left; |
594 | 595 | const int screen_top = display.screen.margins.top + top; |
595 | 596 |
|
596 | | -#if !LCD_SCREEN_BUFFER |
| 597 | +#if LCD_ACCESS_MODE == 0 |
597 | 598 | lcd_set_window(screen_left, screen_top, width, height); |
598 | 599 |
|
599 | 600 | for (size_t y = 0; y < height;) |
@@ -645,7 +646,7 @@ void rg_display_clear_rect(int left, int top, int width, int height, uint16_t co |
645 | 646 | #else /* 565_LE */ |
646 | 647 | const uint16_t color = color_le; |
647 | 648 | #endif |
648 | | -#if !LCD_SCREEN_BUFFER |
| 649 | +#if LCD_ACCESS_MODE == 0 |
649 | 650 | int pixels_remaining = width * height; |
650 | 651 | if (pixels_remaining <= 0) |
651 | 652 | return; |
|
0 commit comments