Skip to content

Commit 1e36e05

Browse files
committed
Makerfabs tft7:Use settings.toml for screen variant
1 parent 345a829 commit 1e36e05

File tree

1 file changed

+108
-0
lines changed
  • ports/espressif/boards/makerfabs_tft7

1 file changed

+108
-0
lines changed

ports/espressif/boards/makerfabs_tft7/board.c

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,117 @@
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+
// Turn on backlight
46+
// gpio_set_direction(2, GPIO_MODE_DEF_OUTPUT);
47+
// gpio_set_level(2, true);
48+
common_hal_never_reset_pin(&pin_GPIO39);
49+
50+
result = common_hal_os_getenv_int("CIRCUITPY_DISPLAY_WIDTH", &width);
51+
if (result == GETENV_OK && width == 800) {
52+
width = 800;
53+
height = 480;
54+
frequency = 6500000;
55+
} else if (result == GETENV_OK) {
56+
width = 1024;
57+
height = 600;
58+
frequency = 10000000;
59+
}
60+
61+
if (height == 0) {
62+
result = common_hal_os_getenv_int("CIRCUITPY_DISPLAY_HEIGHT", &height);
63+
if (result == GETENV_OK && height == 480) {
64+
width = 800;
65+
height = 480;
66+
frequency = 6500000;
67+
} else if (result == GETENV_OK) {
68+
width = 1024;
69+
height = 600;
70+
frequency = 10000000;
71+
}
72+
}
73+
74+
if (width == 0) {
75+
width = 800;
76+
height = 480;
77+
frequency = 6500000;
78+
}
79+
80+
dotclockframebuffer_framebuffer_obj_t *framebuffer = &allocate_display_bus_or_raise()->dotclock;
81+
framebuffer->base.type = &dotclockframebuffer_framebuffer_type;
82+
83+
common_hal_dotclockframebuffer_framebuffer_construct(
84+
framebuffer,
85+
&pin_GPIO40, // de
86+
&pin_GPIO41, // vsync
87+
&pin_GPIO39, // hsync
88+
&pin_GPIO42, // pclk
89+
red_pins, MP_ARRAY_SIZE(red_pins),
90+
green_pins, MP_ARRAY_SIZE(green_pins),
91+
blue_pins, MP_ARRAY_SIZE(blue_pins),
92+
frequency, // Frequency
93+
width, // width
94+
height, // height
95+
30, 16, 210, false, // horiz: pulse, back porch, front porch, idle low
96+
13, 10, 22, false, // vert: pulse, back porch, front porch, idle low
97+
false, // DE idle high
98+
false, // pclk active high
99+
false, // pclk idle high
100+
0 // overscan left
101+
);
102+
103+
framebufferio_framebufferdisplay_obj_t *display = &allocate_display_or_raise()->framebuffer_display;
104+
display->base.type = &framebufferio_framebufferdisplay_type;
105+
common_hal_framebufferio_framebufferdisplay_construct(
106+
display,
107+
framebuffer,
108+
0, // rotation
109+
true // auto-refresh
110+
);
111+
}
10112

11113
void board_init(void) {
114+
// Debug UART
115+
#ifdef DEBUG
116+
common_hal_never_reset_pin(&pin_GPIO43);
117+
common_hal_never_reset_pin(&pin_GPIO44);
118+
#endif
119+
display_init();
12120
}
13121

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

0 commit comments

Comments
 (0)