Skip to content

Conversation

@artemy
Copy link
Contributor

@artemy artemy commented Dec 16, 2025

As discussed here, I'm submitting the fixes I made to make the DSI driver work.

Boards tested

The only ESP32P4 board that I have is WHY2025 badge (https://gitlab.com/why2025/team-badge/Hardware) with st7703-based screen (exact model is W395HDC001-A).
One thing to note is that on this board the screen is powered via one of the channels of ESP32P4 LDO, which is not currently supported by micropython, however I opened a PR there

Code exampled used to test the display

import lcd_bus, st7703, display_driver_framework, lvgl as lv  # NOQA

from esp32 import LDO # LDO support is not yet merged in micropython
ldo = LDO(3, voltage_mv=2500, adjustable=False)

display_bus = lcd_bus.DSIBus(bus_id=0,
                             data_lanes=2,
                             lane_bitrate=1000,
                             clock_freq=47,
                             virtual_channel=0,
                             hsync_back_porch=120,
                             hsync_pulse_width=60,
                             hsync_front_porch=106,
                             vsync_back_porch=20,
                             vsync_pulse_width=4,
                             vsync_front_porch=20
                             )

buf1 = display_bus.allocate_framebuffer(720 * 720 * 2, lcd_bus.MEMORY_SPIRAM)
buf2 = display_bus.allocate_framebuffer(720 * 720 * 2, lcd_bus.MEMORY_SPIRAM)

display = st7703.ST7703(data_bus=display_bus,
                        display_width=720,
                        display_height=720,
                        frame_buffer1=buf1,
                        frame_buffer2=buf2,
                        reset_pin=17,
                        reset_state=st7703.STATE_HIGH,
                        color_space=lv.COLOR_FORMAT.RGB565
                        )
display.init()

scrn = lv.screen_active()

scrn.set_style_bg_color(lv.color_hex(0x00FF00), 0)

label = lv.label(scrn)
label.set_text("HELLO LVGL!")
label.align(lv.ALIGN.CENTER, 0, 0)
label.set_style_text_font(lv.font_montserrat_42, 0)

import task_handler

th = task_handler.TaskHandler()

IMG_3517 Large

I can submit another PR with the ST7703 driver, but there's nothing I've implemented except for the custom initialization commands specific to my particular display. Rotation also doesn't work for this display for some reason (I've tried a bunch of different MADCTL commands but it only ever flips at either 90 or 270 degrees).

self->panel_config.dpi_clk_src = MIPI_DSI_DPI_CLK_SRC_DEFAULT;

self->panel_config.dpi_clock_freq_mhz = (uint32_t)args[ARG_freq].u_int;
self->panel_config.dpi_clock_freq_mhz = (uint8_t)args[ARG_clock_freq].u_int;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these new parameter names (also ARG_lane_bitrate) are up for discussion of course

#include "esp_lcd_panel_io.h"
#include "esp_lcd_mipi_dsi.h"

#define DPI_PANEL_MAX_FB_NUM 3 // from "mipi_dsi_priv.h"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DPI_PANEL_MAX_FB_NUM is in a private header file in the current ESP-IDF version so that's one way to define it for this driver

void *buf = heap_caps_calloc(1, size, caps);

mp_obj_array_t *view = MP_OBJ_TO_PTR(mp_obj_new_memoryview(BYTEARRAY_TYPECODE, 1, buf));
mp_obj_array_t *view = MP_OBJ_TO_PTR(mp_obj_new_memoryview(BYTEARRAY_TYPECODE, size, buf));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't entirely sure about these allocations. One thing I found out is that the current allocation mechanism defined in the DisplayDriver didn't work very well. To make my display work I had to explicitly create buffers in SPIRAM (see code example I included in the PR description)

@kdschlosser
Copy link
Collaborator

we are going to have to "roll our own" LDO handling. This is not a big deal to do and a separate user module should be used to do it or we can extend the built in MicroPython Pin class to handle it. After all the LDO is simply a GPIO that has a loop to an input. It would function only as an output pin and the voltage would be set by the user. It shouldn't be that difficult to extend the Pin class but for the sake of clarity I think I may be better to create a new class specifically to handle the LDO. It should be located in the machine module. I can handle taking care of that.

@kdschlosser
Copy link
Collaborator

I have been looking at the code changes you made and I am thinking it might be best to do the modifications needed to get the software rotation working across all of the drivers at the same time. I am going to dig into what that is going to look like in a few hours.

@artemy
Copy link
Contributor Author

artemy commented Dec 16, 2025

After all the LDO is simply a GPIO that has a loop to an input. It would function only as an output pin and the voltage would be set by the user.

the LDO in question is a feature of ESP32P4 chip. There's a built-in 4-channel (2 channels for Flash/PSRAM + 2 extra channels) LDO that's controlled via a separate driver: https://docs.espressif.com/projects/esp-idf/en/stable/esp32p4/api-reference/peripherals/ldo_regulator.html and it's not intersecting with any of the GPIO registers as far as I understand

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants