Skip to content

Commit 96c9106

Browse files
authored
Merge pull request #9634 from RetiredWizard/tft7width
Makerfab TFT7" settings.toml parameter to set screen variant
2 parents dee71a9 + 9f1ccbc commit 96c9106

File tree

3 files changed

+88
-5
lines changed

3 files changed

+88
-5
lines changed

ports/espressif/boards/espressif_esp32s3_devkitc_1_n8r8_hacktablet/board.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ static void display_init(void) {
7777
}
7878

7979
void board_init(void) {
80-
// Debug UART
81-
#ifdef DEBUG
82-
common_hal_never_reset_pin(&pin_GPIO43);
83-
common_hal_never_reset_pin(&pin_GPIO44);
84-
#endif
8580
display_init();
8681
}
8782

ports/espressif/boards/makerfabs_tft7/board.c

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,94 @@
66

77
#include "supervisor/board.h"
88
#include "mpconfigboard.h"
9+
#include "shared-bindings/board/__init__.h"
10+
#include "shared-bindings/dotclockframebuffer/DotClockFramebuffer.h"
11+
#include "shared-bindings/dotclockframebuffer/__init__.h"
12+
#include "shared-bindings/framebufferio/FramebufferDisplay.h"
913
#include "shared-bindings/microcontroller/Pin.h"
14+
#include "shared-module/displayio/__init__.h"
15+
#include "shared-module/os/__init__.h"
16+
17+
static const mcu_pin_obj_t *blue_pins[] = {
18+
&pin_GPIO8,
19+
&pin_GPIO3,
20+
&pin_GPIO46,
21+
&pin_GPIO9,
22+
&pin_GPIO1
23+
};
24+
static const mcu_pin_obj_t *green_pins[] = {
25+
&pin_GPIO5,
26+
&pin_GPIO6,
27+
&pin_GPIO7,
28+
&pin_GPIO15,
29+
&pin_GPIO16,
30+
&pin_GPIO4
31+
};
32+
static const mcu_pin_obj_t *red_pins[] = {
33+
&pin_GPIO45,
34+
&pin_GPIO48,
35+
&pin_GPIO47,
36+
&pin_GPIO21,
37+
&pin_GPIO14
38+
};
39+
40+
static void display_init(void) {
41+
42+
mp_int_t height = 0, width = 0, frequency = 0;
43+
os_getenv_err_t result;
44+
45+
result = common_hal_os_getenv_int("CIRCUITPY_DISPLAY_WIDTH", &width);
46+
if (result == GETENV_OK && width == 800) {
47+
width = 800;
48+
height = 480;
49+
frequency = 6500000;
50+
} else if (result == GETENV_OK && width == 1024) {
51+
width = 1024;
52+
height = 600;
53+
frequency = 10000000;
54+
}
55+
56+
if (height == 0) {
57+
width = 800;
58+
height = 480;
59+
frequency = 6500000;
60+
}
61+
62+
dotclockframebuffer_framebuffer_obj_t *framebuffer = &allocate_display_bus_or_raise()->dotclock;
63+
framebuffer->base.type = &dotclockframebuffer_framebuffer_type;
64+
65+
common_hal_dotclockframebuffer_framebuffer_construct(
66+
framebuffer,
67+
&pin_GPIO40, // de
68+
&pin_GPIO41, // vsync
69+
&pin_GPIO39, // hsync
70+
&pin_GPIO42, // pclk
71+
red_pins, MP_ARRAY_SIZE(red_pins),
72+
green_pins, MP_ARRAY_SIZE(green_pins),
73+
blue_pins, MP_ARRAY_SIZE(blue_pins),
74+
frequency, // Frequency
75+
width, // width
76+
height, // height
77+
30, 16, 210, false, // horiz: pulse, back porch, front porch, idle low
78+
13, 10, 22, false, // vert: pulse, back porch, front porch, idle low
79+
false, // DE idle high
80+
false, // pclk active high
81+
false, // pclk idle high
82+
0 // overscan left
83+
);
84+
85+
framebufferio_framebufferdisplay_obj_t *display = &allocate_display_or_raise()->framebuffer_display;
86+
display->base.type = &framebufferio_framebufferdisplay_type;
87+
common_hal_framebufferio_framebufferdisplay_construct(
88+
display,
89+
framebuffer,
90+
0, // rotation
91+
true // auto-refresh
92+
);
93+
}
1094

1195
void board_init(void) {
96+
display_init();
1297
}
1398

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

ports/espressif/boards/makerfabs_tft7/pins.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "py/objtuple.h"
88
#include "shared-bindings/board/__init__.h"
9+
#include "shared-module/displayio/__init__.h"
910

1011
static const mp_rom_obj_tuple_t tft_r_pins = {
1112
{&mp_type_tuple},
@@ -125,6 +126,8 @@ static const mp_rom_map_elem_t board_module_globals_table[] = {
125126
// { MP_ROM_QSTR(MP_QSTR_SDIO_D0), MP_ROM_PTR(&pin_GPIO13) },
126127
// { MP_ROM_QSTR(MP_QSTR_SDIO_CLK), MP_ROM_PTR(&pin_GPIO12) },
127128

129+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display) },
130+
128131
// boot mode button can be used in SW as well
129132
{ MP_ROM_QSTR(MP_QSTR_BUTTON), MP_ROM_PTR(&pin_GPIO1) },
130133

0 commit comments

Comments
 (0)