diff --git a/docs/environment.rst b/docs/environment.rst index ccfa9ff48634..39e33f7f8252 100644 --- a/docs/environment.rst +++ b/docs/environment.rst @@ -119,3 +119,13 @@ If the CIRCUITPY_DISPLAY_ROTATION parameter is set the display will be initializ during power up with the selected rotation, otherwise the display will be initialized with a rotation of 0. Attempting to initialize the screen with a rotation other than 0, 90, 180 or 270 is not supported and will result in an unexpected screen rotation. + +`Sunton ESP32-8048S050 `_ + +CIRCUITPY_DISPLAY_FREQUENCY +~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Allows the entry of a display frequency used during the "dotclock" framebuffer construction. +If a valid frequency is not defined the board will initialize the framebuffer with a +frequency of 12500000hz (12.5Mhz). The value should be entered as an integer in hertz +i.e. CIRCUITPY_DISPLAY_FREQUENCY=16000000 will override the default value with a 16Mhz +display frequency. diff --git a/ports/espressif/boards/sunton_esp32_8048S050/board.c b/ports/espressif/boards/sunton_esp32_8048S050/board.c index fa2b03754ecc..e01f857bfd98 100644 --- a/ports/espressif/boards/sunton_esp32_8048S050/board.c +++ b/ports/espressif/boards/sunton_esp32_8048S050/board.c @@ -12,6 +12,7 @@ #include "shared-bindings/framebufferio/FramebufferDisplay.h" #include "shared-bindings/microcontroller/Pin.h" #include "shared-module/displayio/__init__.h" +#include "shared-module/os/__init__.h" static const mcu_pin_obj_t *blue_pins[] = { &pin_GPIO8, @@ -37,6 +38,7 @@ static const mcu_pin_obj_t *red_pins[] = { }; static void display_init(void) { + mp_int_t frequency; // Turn on backlight gpio_set_direction(2, GPIO_MODE_DEF_OUTPUT); @@ -45,6 +47,10 @@ static void display_init(void) { dotclockframebuffer_framebuffer_obj_t *framebuffer = &allocate_display_bus_or_raise()->dotclock; framebuffer->base.type = &dotclockframebuffer_framebuffer_type; + os_getenv_err_t result = common_hal_os_getenv_int("CIRCUITPY_DISPLAY_FREQUENCY", &frequency); + if (result != GETENV_OK) { + frequency = 12500000; + } common_hal_dotclockframebuffer_framebuffer_construct( framebuffer, @@ -55,7 +61,7 @@ static void display_init(void) { red_pins, MP_ARRAY_SIZE(red_pins), green_pins, MP_ARRAY_SIZE(green_pins), blue_pins, MP_ARRAY_SIZE(blue_pins), - 12500000, // Frequency + frequency, // Frequency 800, // width 480, // height 4, 8, 8, true, // horiz: pulse, back porch, front porch, idle low