I try to control a GC9A01 display with a custom esp32-s3 board and LVGL, together with IDF version 5.1.1. For this purpose I use this display driver with the modification of replacing gpio_pad_select_gpio() with gpio_reset_pin().
My code compiles and doesn't throw errors, but the displayed image is shifted to the right and everything that is pushed out is displayed on the left side of the display, overlapping with some parts of the UI there. Below I added the Code I use for initializing the display and the screen, I only removed the objects I created on the screen in the image.
I've already tried to google this problem but didn't found a solution for this.
Has anyone else encountered this problem or has an idea how to solve this?
- SemaphoreHandle_t xGuiSemaphore;
- void displayTask(void *pvParameter) {
- (void) pvParameter;
- xGuiSemaphore = xSemaphoreCreateMutex();
- lv_init();
- /* Initialize SPI or I2C bus used by the drivers */
- lvgl_driver_init();
- lv_color_t* buf1 = heap_caps_malloc(DISP_BUF_SIZE * sizeof(lv_color_t), MALLOC_CAP_DMA);
- assert(buf1 != NULL);
- //lv_color_t* buf2 = heap_caps_malloc(DISP_BUF_SIZE * sizeof(lv_color_t), MALLOC_CAP_DMA);
- //assert(buf2 != NULL);
- lv_color_t* buf2 = NULL;
- static lv_disp_draw_buf_t disp_buf;
- uint32_t size_in_px = DISP_BUF_SIZE;
- lv_disp_draw_buf_init(&disp_buf, buf1, buf2, size_in_px);
- lv_disp_drv_t disp_drv;
- lv_disp_drv_init(&disp_drv);
- disp_drv.flush_cb = disp_driver_flush;
- #if defined CONFIG_DISPLAY_ORIENTATION_PORTRAIT || defined CONFIG_DISPLAY_ORIENTATION_PORTRAIT_INVERTED
- disp_drv.rotated = 1;
- #endif
- disp_drv.draw_buf = &disp_buf;
- lv_disp_drv_register(&disp_drv);
- /* Create and start a periodic timer interrupt to call lv_tick_inc */
- const esp_timer_create_args_t periodic_timer_args = {
- .callback = &lv_tick_task,
- .name = "periodic_gui"
- };
- esp_timer_handle_t periodic_timer;
- ESP_ERROR_CHECK(esp_timer_create(&periodic_timer_args, &periodic_timer));
- ESP_ERROR_CHECK(esp_timer_start_periodic(periodic_timer, LV_TICK_PERIOD_MS * 1000));
- ui_init();
- while (1) {
- /* Delay 1 tick (assumes FreeRTOS tick is 10ms */
- vTaskDelay(pdMS_TO_TICKS(10));
- /* Try to take the semaphore, call lvgl related function on success */
- if (pdTRUE == xSemaphoreTake(xGuiSemaphore, portMAX_DELAY)) {
- lv_task_handler();
- xSemaphoreGive(xGuiSemaphore);
- }
- }
- /* A task should NEVER return */
- free(buf1);
- free(buf2);
- vTaskDelete(NULL);
- }
- void app_main() {
- // Create task for display
- xTaskCreate(displayTask, "display_task", 4096*4, NULL, 5, NULL);
- }
- void ui_Screen1_screen_init(void)
- {
- ui_Screen1 = lv_obj_create(NULL);
- lv_obj_clear_flag( ui_Screen1, LV_OBJ_FLAG_SCROLLABLE ); /// Flags
- lv_obj_set_style_bg_color(ui_Screen1, lv_color_hex(0x480941), LV_PART_MAIN | LV_STATE_DEFAULT );
- lv_obj_set_style_bg_opa(ui_Screen1, 255, LV_PART_MAIN| LV_STATE_DEFAULT);
- lv_obj_set_style_bg_img_src( ui_Screen1, &ui_img_watchface_png, LV_PART_MAIN | LV_STATE_DEFAULT );
- lv_obj_set_style_bg_img_recolor(ui_Screen1, lv_color_hex(0x3911E4), LV_PART_MAIN| LV_STATE_DEFAULT);
- lv_obj_set_style_bg_img_recolor_opa(ui_Screen1, 255, LV_PART_MAIN| LV_STATE_DEFAULT);
- }