Zephyr ILI9341 driver unable to update display area after set orientation

I’ve resolved the of issue of changing the ILI9XXX display orientation.

On initialization LVGL (Light & Versatile Graphics Library) configures its resolution but if you later change it via the ILI9XXX display API, a manual call to lv_disp_drv_update i required with the new settings.

I’ve written a new local function disp_update_orientation to enable the display orientation to be set.

After the invoking ILI9XXX display_set_orientation, the current display orientation is retrieved using display_get_capabilities. Depending on the orientation requested, lv_disp_drv->rotated is updated and lv_disp_drv_update invoked to update the display driver to the new orientation.

static void disp_update_orientation(enum display_orientation orientation) {
	lv_disp_t *lv_disp;
	const struct device *disp_dev;
	lv_disp_drv_t *lv_disp_drv;
    struct display_capabilities cap; 

	lv_disp = lv_disp_get_default();
	disp_dev = lv_disp->driver.user_data;
	lv_disp_drv = &lv_disp->driver;

    display_set_orientation(disp_dev,orientation);
    display_get_capabilities(disp_dev, &cap); 

	if (cap.current_orientation == DISPLAY_ORIENTATION_ROTATED_90 ||
	     cap.current_orientation == DISPLAY_ORIENTATION_ROTATED_270) {
            lv_disp_drv->rotated = 1;
	} else 
		lv_disp_drv->rotated = 0;

    // update display driver
	lv_disp_drv_update(lv_disp, lv_disp_drv);
	lv_obj_invalidate(lv_scr_act());
}
1 Like