mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
lcd: fix wrong bpp size of rgb666 format
Closes https://github.com/espressif/esp-idf/issues/9729
This commit is contained in:
parent
15e0606ca0
commit
8e2d307c52
@ -42,7 +42,7 @@ typedef struct {
|
|||||||
bool reset_level;
|
bool reset_level;
|
||||||
int x_gap;
|
int x_gap;
|
||||||
int y_gap;
|
int y_gap;
|
||||||
unsigned int bits_per_pixel;
|
uint8_t fb_bits_per_pixel;
|
||||||
uint8_t madctl_val; // save current value of LCD_CMD_MADCTL register
|
uint8_t madctl_val; // save current value of LCD_CMD_MADCTL register
|
||||||
uint8_t colmod_cal; // save surrent value of LCD_CMD_COLMOD register
|
uint8_t colmod_cal; // save surrent value of LCD_CMD_COLMOD register
|
||||||
} nt35510_panel_t;
|
} nt35510_panel_t;
|
||||||
@ -78,15 +78,20 @@ esp_err_t esp_lcd_new_panel_nt35510(const esp_lcd_panel_io_handle_t io, const es
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t fb_bits_per_pixel = 0;
|
||||||
switch (panel_dev_config->bits_per_pixel) {
|
switch (panel_dev_config->bits_per_pixel) {
|
||||||
case 16:
|
case 16: // RGB565
|
||||||
nt35510->colmod_cal = 0x55;
|
nt35510->colmod_cal = 0x55;
|
||||||
|
fb_bits_per_pixel = 16;
|
||||||
break;
|
break;
|
||||||
case 18:
|
case 18: // RGB666
|
||||||
nt35510->colmod_cal = 0x66;
|
nt35510->colmod_cal = 0x66;
|
||||||
|
// each color component (R/G/B) should occupy the 6 high bits of a byte, which means 3 full bytes are required for a pixel
|
||||||
|
fb_bits_per_pixel = 24;
|
||||||
break;
|
break;
|
||||||
case 24:
|
case 24: // RGB888
|
||||||
nt35510->colmod_cal = 0x77;
|
nt35510->colmod_cal = 0x77;
|
||||||
|
fb_bits_per_pixel = 24;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported pixel width");
|
ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported pixel width");
|
||||||
@ -94,7 +99,7 @@ esp_err_t esp_lcd_new_panel_nt35510(const esp_lcd_panel_io_handle_t io, const es
|
|||||||
}
|
}
|
||||||
|
|
||||||
nt35510->io = io;
|
nt35510->io = io;
|
||||||
nt35510->bits_per_pixel = panel_dev_config->bits_per_pixel;
|
nt35510->fb_bits_per_pixel = fb_bits_per_pixel;
|
||||||
nt35510->reset_gpio_num = panel_dev_config->reset_gpio_num;
|
nt35510->reset_gpio_num = panel_dev_config->reset_gpio_num;
|
||||||
nt35510->reset_level = panel_dev_config->flags.reset_active_high;
|
nt35510->reset_level = panel_dev_config->flags.reset_active_high;
|
||||||
nt35510->base.del = panel_nt35510_del;
|
nt35510->base.del = panel_nt35510_del;
|
||||||
@ -207,7 +212,7 @@ static esp_err_t panel_nt35510_draw_bitmap(esp_lcd_panel_t *panel, int x_start,
|
|||||||
(y_end - 1) & 0xFF,
|
(y_end - 1) & 0xFF,
|
||||||
}, 2);
|
}, 2);
|
||||||
// transfer frame buffer
|
// transfer frame buffer
|
||||||
size_t len = (x_end - x_start) * (y_end - y_start) * nt35510->bits_per_pixel / 8;
|
size_t len = (x_end - x_start) * (y_end - y_start) * nt35510->fb_bits_per_pixel / 8;
|
||||||
esp_lcd_panel_io_tx_color(io, LCD_CMD_RAMWR << 8, color_data, len);
|
esp_lcd_panel_io_tx_color(io, LCD_CMD_RAMWR << 8, color_data, len);
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
|
@ -42,7 +42,7 @@ typedef struct {
|
|||||||
bool reset_level;
|
bool reset_level;
|
||||||
int x_gap;
|
int x_gap;
|
||||||
int y_gap;
|
int y_gap;
|
||||||
unsigned int bits_per_pixel;
|
uint8_t fb_bits_per_pixel;
|
||||||
uint8_t madctl_val; // save current value of LCD_CMD_MADCTL register
|
uint8_t madctl_val; // save current value of LCD_CMD_MADCTL register
|
||||||
uint8_t colmod_cal; // save surrent value of LCD_CMD_COLMOD register
|
uint8_t colmod_cal; // save surrent value of LCD_CMD_COLMOD register
|
||||||
} st7789_panel_t;
|
} st7789_panel_t;
|
||||||
@ -78,12 +78,16 @@ esp_err_t esp_lcd_new_panel_st7789(const esp_lcd_panel_io_handle_t io, const esp
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t fb_bits_per_pixel = 0;
|
||||||
switch (panel_dev_config->bits_per_pixel) {
|
switch (panel_dev_config->bits_per_pixel) {
|
||||||
case 16:
|
case 16: // RGB565
|
||||||
st7789->colmod_cal = 0x55;
|
st7789->colmod_cal = 0x55;
|
||||||
|
fb_bits_per_pixel = 16;
|
||||||
break;
|
break;
|
||||||
case 18:
|
case 18: // RGB666
|
||||||
st7789->colmod_cal = 0x66;
|
st7789->colmod_cal = 0x66;
|
||||||
|
// each color component (R/G/B) should occupy the 6 high bits of a byte, which means 3 full bytes are required for a pixel
|
||||||
|
fb_bits_per_pixel = 24;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported pixel width");
|
ESP_GOTO_ON_FALSE(false, ESP_ERR_NOT_SUPPORTED, err, TAG, "unsupported pixel width");
|
||||||
@ -91,7 +95,7 @@ esp_err_t esp_lcd_new_panel_st7789(const esp_lcd_panel_io_handle_t io, const esp
|
|||||||
}
|
}
|
||||||
|
|
||||||
st7789->io = io;
|
st7789->io = io;
|
||||||
st7789->bits_per_pixel = panel_dev_config->bits_per_pixel;
|
st7789->fb_bits_per_pixel = fb_bits_per_pixel;
|
||||||
st7789->reset_gpio_num = panel_dev_config->reset_gpio_num;
|
st7789->reset_gpio_num = panel_dev_config->reset_gpio_num;
|
||||||
st7789->reset_level = panel_dev_config->flags.reset_active_high;
|
st7789->reset_level = panel_dev_config->flags.reset_active_high;
|
||||||
st7789->base.del = panel_st7789_del;
|
st7789->base.del = panel_st7789_del;
|
||||||
@ -191,7 +195,7 @@ static esp_err_t panel_st7789_draw_bitmap(esp_lcd_panel_t *panel, int x_start, i
|
|||||||
(y_end - 1) & 0xFF,
|
(y_end - 1) & 0xFF,
|
||||||
}, 4);
|
}, 4);
|
||||||
// transfer frame buffer
|
// transfer frame buffer
|
||||||
size_t len = (x_end - x_start) * (y_end - y_start) * st7789->bits_per_pixel / 8;
|
size_t len = (x_end - x_start) * (y_end - y_start) * st7789->fb_bits_per_pixel / 8;
|
||||||
esp_lcd_panel_io_tx_color(io, LCD_CMD_RAMWR, color_data, len);
|
esp_lcd_panel_io_tx_color(io, LCD_CMD_RAMWR, color_data, len);
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
|
Loading…
Reference in New Issue
Block a user