Skip to content

Commit

Permalink
Merge branch 'main' into setting_up_ci
Browse files Browse the repository at this point in the history
  • Loading branch information
kdschlosser authored May 9, 2024
2 parents 101fdaf + 32987f1 commit 794cb04
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 450 deletions.
12 changes: 8 additions & 4 deletions api_drivers/common_api_drivers/display/st7796.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import lcd_bus # NOQA
import display_driver_framework


_SWRESET = const(0x01)
_SLPOUT = const(0x11)
_CSCON = const(0xF0)
Expand All @@ -22,6 +21,8 @@
_NGC = const(0xE1)
_DISPON = const(0x29)

_EM = const(0xB7)

STATE_HIGH = display_driver_framework.STATE_HIGH
STATE_LOW = display_driver_framework.STATE_LOW
STATE_PWM = display_driver_framework.STATE_PWM
Expand Down Expand Up @@ -83,9 +84,9 @@ def init(self):

color_size = lv.color_format_get_size(self._color_space)
if color_size == 2: # NOQA
pixel_format = 0x55
pixel_format = 0x05
elif color_size == 3:
pixel_format = 0x77
pixel_format = 0x07
else:
raise RuntimeError(
'ST7796 IC only supports '
Expand All @@ -95,6 +96,9 @@ def init(self):
param_buf[0] = pixel_format
self.set_params(_COLMOD, param_mv[:1])

param_buf[0] = 0xC6
self.set_params(_EM, param_mv[:1])

param_buf[0] = 0x01
self.set_params(_DIC, param_mv[:1])

Expand Down Expand Up @@ -126,7 +130,7 @@ def init(self):
self.set_params(_PGC, param_mv[:14])

param_buf[:14] = bytearray([
0xE0, 0x09, 0x0B, 0x06, 0x04, 0x03, 0x2B,
0xF0, 0x09, 0x0B, 0x06, 0x04, 0x03, 0x2D,
0x43, 0x42, 0x3B, 0x16, 0x14, 0x17, 0x1B
])
self.set_params(_NGC, param_mv[:14])
Expand Down
85 changes: 85 additions & 0 deletions builder/esp32.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,17 @@ def get_espidf():
board = None
skip_partition_resize = False
partition_size = None
flash_size = 8
oct_flash = False


def parse_args(extra_args, lv_cflags, brd):
global board
global board_variant
global skip_partition_resize
global partition_size
global flash_size
global oct_flash

board = brd

Expand All @@ -253,6 +257,28 @@ def parse_args(extra_args, lv_cflags, brd):
if arg.startswith('BOARD_VARIANT'):
raise RuntimeError(f'BOARD_VARIANT not supported by "{board}"')

if board == 'ESP32_GENERIC_S3':
esp_argParser = ArgumentParser(prefix_chars='-')

esp_argParser.add_argument(
'--octal-flash',
help='octal spi flash',
dest='oct_flash',
action='store_true'
)

esp_argParser.add_argument(
'--flash-size',
dest='flash_size',
help='flash size',
default=8,
type=int,
action='store'
)
esp_args, extra_args = esp_argParser.parse_known_args(extra_args)
flash_size = esp_args.flash_size
oct_flash = esp_args.oct_flash

esp_argParser = ArgumentParser(prefix_chars='-')

esp_argParser.add_argument(
Expand Down Expand Up @@ -505,6 +531,65 @@ def submodules():
def compile(): # NOQA
env = setup_idf_environ()

if board == 'ESP32_GENERIC_S3':
base_config = [
'CONFIG_ESPTOOLPY_FLASHMODE_QIO=y',
'CONFIG_ESPTOOLPY_FLASHFREQ_80M=y',
'CONFIG_ESPTOOLPY_AFTER_NORESET=y',
'CONFIG_PARTITION_TABLE_CUSTOM=y',
]

if flash_size == 4:
base_config.extend([
'CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y',
'CONFIG_ESPTOOLPY_FLASHSIZE_8MB=n',
'CONFIG_ESPTOOLPY_FLASHSIZE_16MB=n',
'CONFIG_ESPTOOLPY_FLASHSIZE_32MB=n',
'CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-4MiB.csv"'
])
elif flash_size == 8:
base_config.extend([
'CONFIG_ESPTOOLPY_FLASHSIZE_4MB=n',
'CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y',
'CONFIG_ESPTOOLPY_FLASHSIZE_16MB=n',
'CONFIG_ESPTOOLPY_FLASHSIZE_32MB=n',
'CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-8MiB.csv"'
])

elif flash_size == 16:
base_config.extend([
'CONFIG_ESPTOOLPY_FLASHSIZE_4MB=n',
'CONFIG_ESPTOOLPY_FLASHSIZE_8MB=n',
'CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y',
'CONFIG_ESPTOOLPY_FLASHSIZE_32MB=n',
'CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-16MiB.csv"'
])
if flash_size == 32:
base_config.extend([
'CONFIG_ESPTOOLPY_FLASHSIZE_4MB=n',
'CONFIG_ESPTOOLPY_FLASHSIZE_8MB=n',
'CONFIG_ESPTOOLPY_FLASHSIZE_16MB=n',
'CONFIG_ESPTOOLPY_FLASHSIZE_32MB=y',
'CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-32MiB.csv"'
])
else:
base_config = [
'CONFIG_ESPTOOLPY_FLASHSIZE_4MB=n',
'CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y',
'CONFIG_ESPTOOLPY_FLASHSIZE_16MB=n',
'CONFIG_ESPTOOLPY_FLASHSIZE_32MB=n',
'CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-8MiB.csv"'
]

if oct_flash:
base_config[0] = 'CONFIG_ESPTOOLPY_FLASHMODE_DOUT=y'
base_config.append('CONFIG_ESPTOOLPY_OCT_FLASH=y')

base_config = '\n'.join(base_config)

with open('lib/micropython/ports/esp32/boards/ESP32_GENERIC_S3/sdkconfig.board', 'w') as f:
f.write(base_config + '\n')

if board in ('ESP32_GENERIC_S2', 'ESP32_GENERIC_S3'):

mphalport_path = 'lib/micropython/ports/esp32/mphalport.c'
Expand Down
5 changes: 2 additions & 3 deletions ext_mod/lcd_bus/esp32_src/spi_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "lcd_types.h"
#include "modlcd_bus.h"
#include "spi_bus.h"
#include "spi_panel_bus.h"

// esp-idf includes
#include "driver/spi_common.h"
Expand Down Expand Up @@ -366,15 +365,15 @@ mp_lcd_err_t spi_init(mp_obj_t obj, uint16_t width, uint16_t height, uint8_t bpp
self->panel_io_config.trans_queue_depth++;
}
} else {
self->panel_io_config.trans_queue_depth = 1;
self->panel_io_config.trans_queue_depth = 10;
}

mp_lcd_err_t ret = spi_bus_initialize(self->host, &self->bus_config, SPI_DMA_CH_AUTO);
if (ret != 0) {
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("%d(spi_bus_initialize)"), ret);
}

ret = lcdbus_new_panel_io_spi(self->bus_handle, &self->panel_io_config, &self->panel_io_handle.panel_io, double_buffer);
ret = esp_lcd_new_panel_io_spi(self->bus_handle, &self->panel_io_config, &self->panel_io_handle.panel_io);
if (ret != 0) {
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("%d(esp_lcd_new_panel_io_spi)"), ret);
}
Expand Down
Loading

0 comments on commit 794cb04

Please sign in to comment.