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

Makerfab TFT7" settings.toml parameter to set screen variant #9634

Merged
merged 6 commits into from
Sep 18, 2024
Merged
Changes from 2 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
95 changes: 95 additions & 0 deletions ports/espressif/boards/makerfabs_tft7/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,104 @@

#include "supervisor/board.h"
#include "mpconfigboard.h"
#include "shared-bindings/board/__init__.h"
#include "shared-bindings/dotclockframebuffer/DotClockFramebuffer.h"
#include "shared-bindings/dotclockframebuffer/__init__.h"
#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,
&pin_GPIO3,
&pin_GPIO46,
&pin_GPIO9,
&pin_GPIO1
};
static const mcu_pin_obj_t *green_pins[] = {
&pin_GPIO5,
&pin_GPIO6,
&pin_GPIO7,
&pin_GPIO15,
&pin_GPIO16,
&pin_GPIO4
};
static const mcu_pin_obj_t *red_pins[] = {
&pin_GPIO45,
&pin_GPIO48,
&pin_GPIO47,
&pin_GPIO21,
&pin_GPIO14
};

static void display_init(void) {

mp_int_t height=0, width=0, frequency=0;
os_getenv_err_t result;

// Turn on backlight
// gpio_set_direction(2, GPIO_MODE_DEF_OUTPUT);
// gpio_set_level(2, true);
common_hal_never_reset_pin(&pin_GPIO39);

result = common_hal_os_getenv_int("CIRCUITPY_DISPLAY_WIDTH", &width);
if (result == GETENV_OK && width == 800) {
width = 800;
height = 480;
frequency = 6500000;
} else if (result == GETENV_OK && width == 1024) {
width = 1024;
height = 600;
frequency = 10000000;
}

if (height == 0) {
width = 800;
height = 480;
frequency = 6500000;
}

dotclockframebuffer_framebuffer_obj_t *framebuffer = &allocate_display_bus_or_raise()->dotclock;
framebuffer->base.type = &dotclockframebuffer_framebuffer_type;

common_hal_dotclockframebuffer_framebuffer_construct(
framebuffer,
&pin_GPIO40, // de
&pin_GPIO41, // vsync
&pin_GPIO39, // hsync
&pin_GPIO42, // pclk
red_pins, MP_ARRAY_SIZE(red_pins),
green_pins, MP_ARRAY_SIZE(green_pins),
blue_pins, MP_ARRAY_SIZE(blue_pins),
frequency, // Frequency
width, // width
height, // height
30, 16, 210, false, // horiz: pulse, back porch, front porch, idle low
13, 10, 22, false, // vert: pulse, back porch, front porch, idle low
false, // DE idle high
false, // pclk active high
false, // pclk idle high
0 // overscan left
);

framebufferio_framebufferdisplay_obj_t *display = &allocate_display_or_raise()->framebuffer_display;
display->base.type = &framebufferio_framebufferdisplay_type;
common_hal_framebufferio_framebufferdisplay_construct(
display,
framebuffer,
0, // rotation
true // auto-refresh
);
}

void board_init(void) {
// Debug UART
#ifdef DEBUG
common_hal_never_reset_pin(&pin_GPIO43);
common_hal_never_reset_pin(&pin_GPIO44);
#endif
RetiredWizard marked this conversation as resolved.
Show resolved Hide resolved
display_init();
}

// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
Loading