Skip to content

Commit b903a02

Browse files
committed
Enable display on esp32-s3-eye
1 parent 8d673bd commit b903a02

File tree

2 files changed

+100
-4
lines changed

2 files changed

+100
-4
lines changed

ports/espressif/boards/espressif_esp32s3_eye/board.c

Lines changed: 94 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,104 @@
2626

2727
#include "supervisor/board.h"
2828
#include "mpconfigboard.h"
29+
#include "shared-bindings/busio/SPI.h"
30+
#include "shared-bindings/displayio/FourWire.h"
2931
#include "shared-bindings/microcontroller/Pin.h"
32+
#include "shared-module/displayio/__init__.h"
33+
#include "shared-module/displayio/mipi_constants.h"
34+
#include "shared-bindings/board/__init__.h"
35+
36+
displayio_fourwire_obj_t board_display_obj;
37+
38+
#define DELAY 0x80
39+
40+
// display init sequence according to LilyGO example app
41+
uint8_t display_init_sequence[] = {
42+
// sw reset
43+
0x01, 0 | DELAY, 150,
44+
// sleep out
45+
0x11, 0 | DELAY, 255,
46+
// normal display mode on
47+
0x13, 0,
48+
// display and color format settings
49+
0x36, 1, 0x08,
50+
0xB6, 2, 0x0A, 0x82,
51+
0x3A, 1 | DELAY, 0x55, 10,
52+
// ST7789V frame rate setting
53+
0xB2, 5, 0x0C, 0x0C, 0x00, 0x33, 0x33,
54+
// voltages: VGH / VGL
55+
0xB7, 1, 0x35,
56+
// ST7789V power setting
57+
0xBB, 1, 0x28,
58+
0xC0, 1, 0x0C,
59+
0xC2, 2, 0x01, 0xFF,
60+
0xC3, 1, 0x10,
61+
0xC4, 1, 0x20,
62+
0xC6, 1, 0x0F,
63+
0xD0, 2, 0xA4, 0xA1,
64+
// ST7789V gamma setting
65+
0xE0, 14, 0xD0, 0x00, 0x02, 0x07, 0x0A, 0x28, 0x32, 0x44, 0x42, 0x06, 0x0E, 0x12, 0x14, 0x17,
66+
0xE1, 14, 0xD0, 0x00, 0x02, 0x07, 0x0A, 0x28, 0x31, 0x54, 0x47, 0x0E, 0x1C, 0x17, 0x1B, 0x1E,
67+
0x21, 0,
68+
// display on
69+
0x29, 0 | DELAY, 255,
70+
};
3071

3172
void board_init(void) {
73+
busio_spi_obj_t *spi = common_hal_board_create_spi(1);
74+
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
75+
bus->base.type = &displayio_fourwire_type;
76+
77+
common_hal_displayio_fourwire_construct(
78+
bus,
79+
spi,
80+
&pin_GPIO43, // DC
81+
&pin_GPIO44, // CS
82+
NULL, // no reset pin
83+
40000000, // baudrate
84+
0, // polarity
85+
0 // phase
86+
);
87+
displayio_display_obj_t *display = &displays[0].display;
88+
display->base.type = &displayio_display_type;
89+
90+
// workaround as board_init() is called before reset_port() in main.c
91+
pwmout_reset();
92+
93+
common_hal_displayio_display_construct(
94+
display,
95+
bus,
96+
240, // width (after rotation)
97+
240, // height (after rotation)
98+
0, // column start
99+
0, // row start
100+
0, // rotation
101+
16, // color depth
102+
false, // grayscale
103+
false, // pixels in a byte share a row. Only valid for depths < 8
104+
1, // bytes per cell. Only valid for depths < 8
105+
false, // reverse_pixels_in_byte. Only valid for depths < 8
106+
true, // reverse_pixels_in_word
107+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command
108+
MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command
109+
MIPI_COMMAND_WRITE_MEMORY_START, // write memory command
110+
display_init_sequence,
111+
sizeof(display_init_sequence),
112+
&pin_GPIO48, // backlight pin
113+
NO_BRIGHTNESS_COMMAND,
114+
1.0f, // brightness (ignored)
115+
false, // auto_brightness
116+
false, // single_byte_bounds
117+
false, // data_as_commands
118+
true, // auto_refresh
119+
60, // native_frames_per_second
120+
false, // backlight_on_high
121+
false, // SH1107_addressing
122+
50000 // backlight pwm frequency
123+
);
124+
125+
common_hal_never_reset_pin(&pin_GPIO48); // backlight pin
32126
// Debug UART
33-
#ifdef DEBUG
34-
common_hal_never_reset_pin(&pin_GPIO43);
35-
common_hal_never_reset_pin(&pin_GPIO44);
36-
#endif
37127
}
38128

39129
bool board_requests_safe_mode(void) {

ports/espressif/boards/espressif_esp32s3_eye/mpconfigboard.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,10 @@
3838
#define DEFAULT_SPI_BUS_MISO (&pin_GPIO40)
3939
#define DEFAULT_SPI_BUS_MOSI (&pin_GPIO38)
4040

41+
#define CIRCUITPY_BOARD_SPI (2)
42+
#define CIRCUITPY_BOARD_SPI_PIN { \
43+
{.clock = &pin_GPIO39, .mosi = &pin_GPIO40, .miso = &pin_GPIO38}, \
44+
{.clock = &pin_GPIO21, .mosi = &pin_GPIO47, .miso = NULL}, \
45+
}
46+
4147
#define DEFAULT_RESERVED_PSRAM (1048576)

0 commit comments

Comments
 (0)