Skip to content

Commit 91e6809

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents b75129e + e8e5ea7 commit 91e6809

File tree

4 files changed

+68
-6
lines changed

4 files changed

+68
-6
lines changed

ports/espressif/boards/espressif_esp32s3_box/board.c

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,68 @@
2828
#include "mpconfigboard.h"
2929
#include "shared-bindings/microcontroller/Pin.h"
3030

31+
#include "shared-bindings/busio/SPI.h"
32+
#include "shared-bindings/displayio/FourWire.h"
33+
#include "shared-module/displayio/__init__.h"
34+
#include "shared-module/displayio/mipi_constants.h"
35+
36+
uint8_t display_init_sequence[] = {
37+
0x01, 0x80, 0x96, // _SWRESET and Delay 150ms
38+
0x11, 0x80, 0xFF, // _SLPOUT and Delay 500ms
39+
0x3A, 0x81, 0x55, 0x0A, // _COLMOD and Delay 10ms
40+
0x36, 0x01, 0x08, // _MADCTL
41+
0x13, 0x80, 0x0A, // _NORON and Delay 10ms
42+
0x36, 0x01, 0xC0, // _MADCTL
43+
0x29, 0x80, 0xFF, // _DISPON and Delay 500ms
44+
};
45+
3146
void board_init(void) {
47+
busio_spi_obj_t *spi = &displays[0].fourwire_bus.inline_bus;
48+
common_hal_busio_spi_construct(spi, &pin_GPIO7, &pin_GPIO6, NULL);
49+
common_hal_busio_spi_never_reset(spi);
50+
51+
displayio_fourwire_obj_t *bus = &displays[0].fourwire_bus;
52+
bus->base.type = &displayio_fourwire_type;
53+
common_hal_displayio_fourwire_construct(bus,
54+
spi,
55+
&pin_GPIO4, // TFT_DC Command or data
56+
&pin_GPIO5, // TFT_CS Chip select
57+
&pin_GPIO48, // TFT_RST Reset
58+
60000000, // Baudrate
59+
0, // Polarity
60+
0); // Phase
61+
62+
displayio_display_obj_t *display = &displays[0].display;
63+
display->base.type = &displayio_display_type;
64+
common_hal_displayio_display_construct(display,
65+
bus,
66+
320, // Width
67+
240, // Height
68+
0, // column start
69+
0, // row start
70+
0, // rotation
71+
16, // Color depth
72+
false, // Grayscale
73+
false, // pixels in a byte share a row. Only valid for depths < 8
74+
1, // bytes per cell. Only valid for depths < 8
75+
false, // reverse_pixels_in_byte. Only valid for depths < 8
76+
true, // reverse_pixels_in_word
77+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // Set column command
78+
MIPI_COMMAND_SET_PAGE_ADDRESS, // Set row command
79+
MIPI_COMMAND_WRITE_MEMORY_START, // Write memory command
80+
display_init_sequence,
81+
sizeof(display_init_sequence),
82+
&pin_GPIO45, // backlight pin
83+
NO_BRIGHTNESS_COMMAND,
84+
1.0f, // brightness (ignored)
85+
true, // auto_brightness
86+
false, // single_byte_bounds
87+
false, // data_as_commands
88+
true, // auto_refresh
89+
60, // native_frames_per_second
90+
true, // backlight_on_high
91+
false); // SH1107_addressing
92+
3293
// USB
3394
common_hal_never_reset_pin(&pin_GPIO19);
3495
common_hal_never_reset_pin(&pin_GPIO20);

ports/espressif/boards/espressif_esp32s3_box/pins.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "shared-bindings/board/__init__.h"
2+
#include "shared-module/displayio/__init__.h"
23

34
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
45
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
@@ -60,5 +61,7 @@ STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
6061

6162
// boot button, also usable as a software button
6263
{ MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO0) },
64+
65+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)}
6366
};
6467
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

ports/espressif/common-hal/microcontroller/Pin.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ void reset_all_pins(void) {
9595
}
9696
floating_gpio_reset(i);
9797
}
98-
in_use[0] = 0;
99-
in_use[1] = 0;
98+
in_use[0] = never_reset_pins[0];
99+
in_use[1] = never_reset_pins[1];
100100
}
101101

102102
void claim_pin_number(gpio_num_t pin_number) {

ports/espressif/common-hal/pwmio/PWMOut.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@
3232

3333
#define INDEX_EMPTY 0xFF
3434

35-
STATIC bool not_first_reset = false;
3635
STATIC uint32_t reserved_timer_freq[LEDC_TIMER_MAX];
3736
STATIC bool varfreq_timers[LEDC_TIMER_MAX];
38-
STATIC uint8_t reserved_channels[LEDC_CHANNEL_MAX];
37+
STATIC uint8_t reserved_channels[LEDC_CHANNEL_MAX] = { [0 ... LEDC_CHANNEL_MAX - 1] = INDEX_EMPTY};
3938
STATIC bool never_reset_tim[LEDC_TIMER_MAX];
4039
STATIC bool never_reset_chan[LEDC_CHANNEL_MAX];
4140

@@ -56,7 +55,7 @@ STATIC uint32_t calculate_duty_cycle(uint32_t frequency) {
5655

5756
void pwmout_reset(void) {
5857
for (size_t i = 0; i < LEDC_CHANNEL_MAX; i++) {
59-
if (reserved_channels[i] != INDEX_EMPTY && not_first_reset) {
58+
if (reserved_channels[i] != INDEX_EMPTY) {
6059
ledc_stop(LEDC_LOW_SPEED_MODE, i, 0);
6160
}
6261
if (!never_reset_chan[i]) {
@@ -72,7 +71,6 @@ void pwmout_reset(void) {
7271
varfreq_timers[i] = false;
7372
}
7473
}
75-
not_first_reset = true;
7674
}
7775

7876
pwmout_result_t common_hal_pwmio_pwmout_construct(pwmio_pwmout_obj_t *self,

0 commit comments

Comments
 (0)