Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sunton 8048S050: Configure display frequency in settings.toml #9911

Merged
merged 2 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/environment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://circuitpython.org/board/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.
8 changes: 7 additions & 1 deletion ports/espressif/boards/sunton_esp32_8048S050/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand All @@ -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,
Expand All @@ -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
Expand Down