mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-08-19 05:13:04 +08:00
bsp: renesas: Fix LCD framebuffer bounds
The Renesas LCD helper treats LCD_WIDTH and LCD_HEIGHT as pixel counts. The framebuffer clear loop and lcd_draw_pixel() accepted those count values as valid indexes, which can write one pixel past the framebuffer. Use strict bounds for the 0-based framebuffer indexes and adjust the 180-degree rotation mapping to target the last valid row and column. Generated-by: OpenAI Codex Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com>
This commit is contained in:
@@ -88,7 +88,7 @@ static void turn_on_lcd_backlight(void)
|
||||
|
||||
static void ra_bsp_lcd_clear(uint16_t color)
|
||||
{
|
||||
for (uint32_t i = 0; i <= LCD_BUF_SIZE / sizeof(uint16_t); i++)
|
||||
for (uint32_t i = 0; i < LCD_BUF_SIZE / sizeof(uint16_t); i++)
|
||||
{
|
||||
lcd_current_working_buffer[i] = color;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ static void ra_bsp_lcd_clear(uint16_t color)
|
||||
void lcd_draw_pixel(uint32_t x, uint32_t y, uint16_t color)
|
||||
{
|
||||
// Verify pixel is within LCD range
|
||||
if ((x <= LCD_WIDTH) && (y <= LCD_HEIGHT))
|
||||
if ((x < LCD_WIDTH) && (y < LCD_HEIGHT))
|
||||
{
|
||||
switch (screen_rotation)
|
||||
{
|
||||
@@ -108,7 +108,7 @@ void lcd_draw_pixel(uint32_t x, uint32_t y, uint16_t color)
|
||||
}
|
||||
case ROTATION_180:
|
||||
{
|
||||
lcd_current_working_buffer[((LCD_HEIGHT - y) * LCD_WIDTH) + (LCD_WIDTH - x)] = color;
|
||||
lcd_current_working_buffer[(((LCD_HEIGHT - 1) - y) * LCD_WIDTH) + ((LCD_WIDTH - 1) - x)] = color;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user