Improve QP code

This commit is contained in:
VeyPatch 2025-01-06 10:41:32 +01:00
commit 3f5bc1227e
2 changed files with 20 additions and 19 deletions

View file

@ -13,7 +13,6 @@
#define LCD_DC_PIN GP16
#define LCD_SPI_DIVISOR 0
#define LCD_SPI_MODE 3
#define LCD_WAIT_TIME 150
#define LCD_WIDTH 135
#define LCD_HEIGHT 240
#define LCD_ROTATION QP_ROTATION_0

View file

@ -32,7 +32,7 @@ static painter_font_handle_t Retron27;
static painter_font_handle_t Retron27_underline;
static painter_image_handle_t layer_number;
static uint16_t lcd_surface_fb[135*240];
static uint8_t lcd_surface_fb[SURFACE_REQUIRED_BUFFER_BYTE_SIZE(135, 240, 16)];
int color_value = 0;
@ -249,26 +249,27 @@ void suspend_wakeup_init_kb(void) {
// Called from halcyon.c
bool module_post_init_kb(void) {
setPinOutput(LCD_RST_PIN);
writePinHigh(LCD_RST_PIN);
// Initialise the LCD
lcd = qp_st7789_make_spi_device(LCD_WIDTH, LCD_HEIGHT, LCD_CS_PIN, LCD_DC_PIN, LCD_RST_PIN, LCD_SPI_DIVISOR, LCD_SPI_MODE);
qp_init(lcd, LCD_ROTATION);
qp_set_viewport_offsets(lcd, LCD_OFFSET_X, LCD_OFFSET_Y);
// Initialise surface
lcd_surface = qp_make_rgb565_surface(LCD_WIDTH, LCD_HEIGHT, lcd_surface_fb);
qp_init(lcd_surface, LCD_ROTATION);
// Turn on the LCD and clear the display
qp_power(lcd, true);
qp_rect(lcd, 0, 0, LCD_WIDTH - 1, LCD_HEIGHT - 1, HSV_BLACK, true);
qp_flush(lcd);
// Turn on backlight
backlight_enable();
// Make the devices
lcd = qp_st7789_make_spi_device(LCD_WIDTH, LCD_HEIGHT, LCD_CS_PIN, LCD_DC_PIN, LCD_RST_PIN, LCD_SPI_DIVISOR, LCD_SPI_MODE);
lcd_surface = qp_make_rgb565_surface(LCD_WIDTH, LCD_HEIGHT, lcd_surface_fb);
// Initialise the LCD
qp_init(lcd, LCD_ROTATION);
qp_set_viewport_offsets(lcd, LCD_OFFSET_X, LCD_OFFSET_Y);
qp_clear(lcd);
qp_rect(lcd, 0, 0, LCD_WIDTH - 1, LCD_HEIGHT - 1, HSV_BLACK, true);
qp_power(lcd, true);
qp_flush(lcd);
// Initialise the LCD surface
qp_init(lcd_surface, LCD_ROTATION);
qp_rect(lcd_surface, 0, 0, LCD_WIDTH - 1, LCD_HEIGHT - 1, HSV_BLACK, true);
qp_surface_draw(lcd_surface, lcd, 0, 0, 0);
qp_flush(lcd);
if(!module_post_init_user()) { return false; }
return true;
@ -311,6 +312,7 @@ bool display_module_housekeeping_task_kb(bool second_display) {
// Move surface to lcd
qp_surface_draw(lcd_surface, lcd, 0, 0, 0);
qp_flush(lcd);
return true;
}