8000 Merge pull request #9480 from bill88t/tws3 · codetiger/circuitpython@f064354 · GitHub
[go: up one dir, main page]

Skip to content

Commit f064354

Browse files
authored
Merge pull request adafruit#9480 from bill88t/tws3
LILYGO T-Watch-S3
2 parents 69ae421 + 9b98039 commit f064354

File tree

9 files changed

+259
-0
lines changed

9 files changed

+259
-0
lines changed

.gitmodules

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,15 @@
395395
[submodule "frozen/Adafruit_CircuitPython_LED_Animation"]
396396
path = frozen/Adafruit_CircuitPython_LED_Animation
397397
url = https://github.com/adafruit/Adafruit_CircuitPython_LED_Animation
398+
[submodule "frozen/CircuitPython_AXP2101"]
399+
path = frozen/CircuitPython_AXP2101
400+
url = https://github.com/CDarius/CircuitPython_AXP2101
401+
[submodule "frozen/CircuitPython_BMA423"]
402+
path = frozen/CircuitPython_BMA423
403+
url = https://github.com/jposada202020/CircuitPython_BMA423
404+
[submodule "frozen/Adafruit_CircuitPython_PCF8563"]
405+
path = frozen/Adafruit_CircuitPython_PCF8563
406+
url = https://github.com/adafruit/Adafruit_CircuitPython_PCF8563
398407
[submodule "frozen/Adafruit_CircuitPython_Wiznet5k"]
399408
path = frozen/Adafruit_CircuitPython_Wiznet5k
400409
url = https://github.com/adafruit/Adafruit_CircuitPython_Wiznet5k

frozen/CircuitPython_AXP2101

Submodule CircuitPython_AXP2101 added at f89fc3d

frozen/CircuitPython_BMA423

Submodule CircuitPython_BMA423 added at d6446c4
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2024 Bill Sideris, independently providing these changes
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "supervisor/board.h"
8+
#include "mpconfigboard.h"
9+
#include "shared-bindings/busio/SPI.h"
10+
#include "shared-bindings/fourwire/FourWire.h"
11+
#include "shared-bindings/microcontroller/Pin.h"
12+
#include "shared-module/displayio/__init__.h"
13+
#include "shared-module/displayio/mipi_constants.h"
14+
#include "shared-bindings/board/__init__.h"
15+
16+
17+
#define DELAY 0x80
18+
19+
// Display init sequence according to LILYGO factory firmware
20+
uint8_t display_init_sequence[] = {
21+
// sw reset
22+
0x01, 0 | DELAY, 150,
23+
// sleep out
24+
0x11, 0 | DELAY, 255,
25+
// normal display mode on
26+
0x13, 0,
27+
// display and color format settings
28+
0x36, 1, 0x68,
29+
0xB6, 2, 0x0A, 0x82,
30+
0x3A, 1 | DELAY, 0x55, 10,
31+
// ST7789V frame rate setting
32+
0xB2, 5, 0x0C, 0x0C, 0x00, 0x33, 0x33,
33+
// voltages: VGH / VGL
34+
0xB7, 1, 0x35,
35+
// ST7789V power setting
36+
0xBB, 1, 0x28,
37+
0xC0, 1, 0x0C,
38+
0xC2, 2, 0x01, 0xFF,
39+
0xC3, 1, 0x10,
40+
0xC4, 1, 0x20,
41+
0xC6, 1, 0x0F,
42+
0xD0, 2, 0xA4, 0xA1,
43+
// ST7789V gamma setting
44+
0xE0, 14, 0xD0, 0x00, 0x02, 0x07, 0x0A, 0x28, 0x32, 0x44, 0x42, 0x06, 0x0E, 0x12, 0x14, 0x17,
45+
0xE1, 14, 0xD0, 0x00, 0x02, 0x07, 0x0A, 0x28, 0x31, 0x54, 0x47, 0x0E, 0x1C, 0x17, 0x1B, 0x1E,
46+
0x21, 0,
47+
// display on
48+
0x29, 0 | DELAY, 255,
49+
};
50+
51+
52+
void board_init(void) {
53+
busio_spi_obj_t *spi = common_hal_board_create_spi(0);
54+
fourwire_fourwire_obj_t *bus = &allocate_display_bus()->fourwire_bus;
55+
bus->base.type = &fourwire_fourwire_type;
56+
57+
common_hal_fourwire_fourwire_construct(
58+
bus,
59+
spi,
60+
&pin_GPIO38, // DC
61+
&pin_GPIO12, // CS
62+
NULL, // RST
63+
40000000, // baudrate
64+
0, // polarity
65+
0 // phase
66+
);
67+
busdisplay_busdisplay_obj_t *display = &allocate_display()->display;
68+
display->base.type = &busdisplay_busdisplay_type;
69+
70+
common_hal_busdisplay_busdisplay_construct(
71+
display,
72+
bus,
73+
240, // width (after rotation)
74+
240, // height (after rotation)
75+
0, // column start
76+
0, // row start
77+
90, // rotation
78+
16, // color depth
79+
false, // grayscale
80+
false, // pixels in a byte share a row. Only valid for depths < 8
81+
1, // bytes per cell. Only valid for depths < 8
82+
false, // reverse_pixels_in_byte. Only valid for depths < 8
83+
true, // reverse_pixels_in_word
84+
MIPI_COMMAND_SET_COLUMN_ADDRESS, // set column command
85+
MIPI_COMMAND_SET_PAGE_ADDRESS, // set row command
86+
MIPI_COMMAND_WRITE_MEMORY_START, // write memory command
87+
display_init_sequence,
88+
sizeof(display_init_sequence),
89+
&pin_GPIO45, // backlight pin
90+
NO_BRIGHTNESS_COMMAND,
91+
1.0f, // brightness
92+
false, // single_byte_bounds
93+
false, // data_as_commands
94+
true, // auto_refresh
95+
60, // native_frames_per_second
96+
true, // backlight_on_high
97+
false, // SH1107_addressing
98+
50000 // backlight pwm frequency
99+
);
100+
}
101+
102+
// Use the MP_WEAK supervisor/shared/board.c versions of routines not defined here.
103+
104+
// TODO: Should we turn off the display when asleep, in board_deinit() ?
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2024 Bill Sideris, independently providing these changes
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#pragma once
8+
9+
// Micropython setup
10+
11+
#define MICROPY_HW_BOARD_NAME "LILYGO T-Watch-S3"
12+
#define MICROPY_HW_MCU_NAME "ESP32S3"
13+
14+
#define CIRCUITPY_BOARD_I2C (2)
15+
#define CIRCUITPY_BOARD_I2C_PIN {{.scl = &pin_GPIO11, .sda = &pin_GPIO10}, \
16+
{.scl = &pin_GPIO40, .sda = &pin_GPIO39}}
17+
18+
#define CIRCUITPY_BOARD_SPI (2)
19+
#define CIRCUITPY_BOARD_SPI_PIN {{.clock = &pin_GPIO18, .mosi = &pin_GPIO13}, \
20+
{.clock = &pin_GPIO3, .mosi = &pin_GPIO1, .miso = &pin_GPIO4}}
21+
// LCD then LORA
22+
23+
#define DOUBLE_TAP_PIN (&pin_GPIO21)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
USB_VID = 0x303A
2+
USB_PID = 0x821C
3+
4+
USB_PRODUCT = "T-Watch-S3"
5+
USB_MANUFACTURER = "LILYGO"
6+
7+
IDF_TARGET = esp32s3
8+
9+
CIRCUITPY_ESP_FLASH_MODE = qio
10+
CIRCUITPY_ESP_FLASH_FREQ = 80m
11+
CIRCUITPY_ESP_FLASH_SIZE = 16MB
12+
13+
CIRCUITPY_ESPCAMERA = 0
14+
CIRCUITPY_PARALLELDISPLAYBUS = 0
15+
CIRCUITPY_MAX3421E = 0
16+
CIRCUITPY_CANIO = 0
17+
CIRCUITPY_COUNTIO = 0
18+
CIRCUITPY_PS2IO = 0
19+
CIRCUITPY_RGBMATRIX = 0
20+
CIRCUITPY_ROTARYIO = 0
21+
22+
CIRCUITPY_ESP_PSRAM_SIZE = 8MB
23+
CIRCUITPY_ESP_PSRAM_MODE = opi
24+
CIRCUITPY_ESP_PSRAM_FREQ = 80m
25+
26+
# Include these Python libraries in firmware.
27+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_FocalTouch
28+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_IRRemote
29+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_Register
30+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_DRV2605
31+
FROZEN_MPY_DIRS += $(TOP)/frozen/Adafruit_CircuitPython_PCF8563
32+
FROZEN_MPY_DIRS += $(TOP)/frozen/CircuitPython_AXP2101
33+
FROZEN_MPY_DIRS += $(TOP)/frozen/CircuitPython_BMA423
34+
# FROZEN_MPY_DIRS += $(TOP)/frozen/CircuitPython_SX126X # To be added in the future
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2024 Bill Sideris, independently providing these changes
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include "shared-bindings/board/__init__.h"
8+
#include "shared-module/displayio/__init__.h"
9+
10+
CIRCUITPY_BOARD_BUS_SINGLETON(tft_spi, spi, 0)
11+
CIRCUITPY_BOARD_BUS_SINGLETON(radio_spi, spi, 1)
12+
CIRCUITPY_BOARD_BUS_SINGLETON(touch_i2c, i2c, 1)
13+
14+
static const mp_rom_map_elem_t board_module_globals_table[] = {
15+
CIRCUITPYTHON_BOARD_DICT_STANDARD_ITEMS
16+
17+
// DISPLAY
18+
{ MP_ROM_QSTR(MP_QSTR_TFT_MOSI), MP_ROM_PTR(&pin_GPIO13) },
19+
{ MP_ROM_QSTR(MP_QSTR_TFT_SCLK), MP_ROM_PTR(&pin_GPIO18) },
20+
{ MP_ROM_QSTR(MP_QSTR_TFT_CS), MP_ROM_PTR(&pin_GPIO12) },
21+
{ MP_ROM_QSTR(MP_QSTR_TFT_DC), MP_ROM_PTR(&pin_GPIO38) },
22+
{ MP_ROM_QSTR(MP_QSTR_TFT_BL), MP_ROM_PTR(&pin_GPIO45) },
23+
{ MP_ROM_QSTR(MP_QSTR_TFT_SPI), MP_ROM_PTR(&board_tft_spi_obj) },
24+
{ MP_ROM_QSTR(MP_QSTR_DISPLAY), MP_ROM_PTR(&displays[0].display)},
25+
26+
// TOUCH
27+
{ MP_ROM_QSTR(MP_QSTR_TOUCH_INT), MP_ROM_PTR(&pin_GPIO16) },
28+
{ MP_ROM_QSTR(MP_QSTR_TOUCH_SCL), MP_ROM_PTR(&pin_GPIO40) },
29+
{ MP_ROM_QSTR(MP_QSTR_TOUCH_SDA), MP_ROM_PTR(&pin_GPIO39) },
30+
{ MP_ROM_QSTR(MP_QSTR_TOUCH_I2C), MP_ROM_PTR(&board_touch_i2c_obj) },
31+
32+
// RTC
33+
{ MP_ROM_QSTR(MP_QSTR_RTC_INT), MP_ROM_PTR(&pin_GPIO17) },
34+
35+
// IR
36+
{ MP_ROM_QSTR(MP_QSTR_IR_LED), MP_ROM_PTR(&pin_GPIO2) },
37+
38+
// AXP2101 PMU
39+
{ MP_ROM_QSTR(MP_QSTR_PMU_INT), MP_ROM_PTR(&pin_GPIO21) },
40+
41+
// RADIO
42+
{ MP_ROM_QSTR(MP_QSTR_RADIO_SCK), MP_ROM_PTR(&pin_GPIO3) },
43+
{ MP_ROM_QSTR(MP_QSTR_RADIO_MISO), MP_ROM_PTR(&pin_GPIO4) },
44+
{ MP_ROM_QSTR(MP_QSTR_RADIO_MOSI), MP_ROM_PTR(&pin_GPIO1) },
45+
{ MP_ROM_QSTR(MP_QSTR_RADIO_SS), MP_ROM_PTR(&pin_GPIO5) },
46+
{ MP_ROM_QSTR(MP_QSTR_RADIO_DIO1), MP_ROM_PTR(&pin_GPIO9) },
47+
{ MP_ROM_QSTR(MP_QSTR_RADIO_RST), MP_ROM_PTR(&pin_GPIO8) },
48+
{ MP_ROM_QSTR(MP_QSTR_RADIO_BUSY), MP_ROM_PTR(&pin_GPIO7) },
49+
{ MP_ROM_QSTR(MP_QSTR_RADIO_SPI), MP_ROM_PTR(&board_radio_spi_obj) },
50+
51+
// MIC
52+
{ MP_ROM_QSTR(MP_QSTR_MIC_DATA), MP_ROM_PTR(&pin_GPIO47) },
53+
{ MP_ROM_QSTR(MP_QSTR_MIC_SCLK), MP_ROM_PTR(&pin_GPIO44) },
54+
55+
// MAX98357A SPK
56+
{ MP_ROM_QSTR(MP_QSTR_I2S_BCK), MP_ROM_PTR(&pin_GPIO48) },
57+
{ MP_ROM_QSTR(MP_QSTR_I2S_WS), MP_ROM_PTR(&pin_GPIO15) },
58+
{ MP_ROM_QSTR(MP_QSTR_I2S_DOUT), MP_ROM_PTR(&pin_GPIO46) },
59+
60+
// BMA423 AXIS SENSOR
61+
{ MP_ROM_QSTR(MP_QSTR_AXIS_INT), MP_ROM_PTR(&pin_GPIO14) },
62+
63+
// I2C, AXP2101, BMA423, RTC, DRV2605
64+
{ MP_ROM_QSTR(MP_QSTR_I2C_SCL), MP_ROM_PTR(&pin_GPIO11) },
65+
{ MP_ROM_QSTR(MP_QSTR_I2C_SDA), MP_ROM_PTR(&pin_GPIO10) },
66+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
67+
68+
// MISC
69+
{ MP_ROM_QSTR(MP_QSTR_BOOT), MP_ROM_PTR(&pin_GPIO0) }
70+
};
71+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#
2+
# Espressif IoT Development Framework Configuration
3+
#
4+
#
5+
# Component config
6+
#
7+
#
8+
# LWIP
9+
#
10+
CONFIG_LWIP_LOCAL_HOSTNAME="t-watch-s3"
11+
# end of LWIP
12+
13+
# end of Component config
14+
15+
# end of Espressif IoT Development Framework Configuration

0 commit comments

Comments
 (0)
0