diff --git a/Devices/m5stack-cardputer-adv/m5stack,cardputer-adv.dts b/Devices/m5stack-cardputer-adv/m5stack,cardputer-adv.dts index 1a3ba58d..fefd953f 100644 --- a/Devices/m5stack-cardputer-adv/m5stack,cardputer-adv.dts +++ b/Devices/m5stack-cardputer-adv/m5stack,cardputer-adv.dts @@ -40,8 +40,8 @@ port_a: grove0 { compatible = "espressif,esp32-grove"; defaultMode = ; - pinSdaRx = <&gpio0 2 GPIO_FLAG_NONE>; - pinSclTx = <&gpio0 1 GPIO_FLAG_NONE>; + pinSdaTx = <&gpio0 2 GPIO_FLAG_NONE>; + pinSclRx = <&gpio0 1 GPIO_FLAG_NONE>; uartPort = ; i2cPort = ; i2cClockFrequency = <400000>; diff --git a/Devices/m5stack-cardputer/m5stack,cardputer.dts b/Devices/m5stack-cardputer/m5stack,cardputer.dts index bb169c2d..dde6df8c 100644 --- a/Devices/m5stack-cardputer/m5stack,cardputer.dts +++ b/Devices/m5stack-cardputer/m5stack,cardputer.dts @@ -26,8 +26,8 @@ port_a: grove0 { compatible = "espressif,esp32-grove"; defaultMode = ; - pinSdaRx = <&gpio0 2 GPIO_FLAG_NONE>; - pinSclTx = <&gpio0 1 GPIO_FLAG_NONE>; + pinSdaTx = <&gpio0 2 GPIO_FLAG_NONE>; + pinSclRx = <&gpio0 1 GPIO_FLAG_NONE>; uartPort = ; i2cPort = ; i2cClockFrequency = <400000>; diff --git a/Devices/m5stack-core2/m5stack,core2.dts b/Devices/m5stack-core2/m5stack,core2.dts index 28ecb146..06aedc7d 100644 --- a/Devices/m5stack-core2/m5stack,core2.dts +++ b/Devices/m5stack-core2/m5stack,core2.dts @@ -41,8 +41,8 @@ port_a: grove0 { compatible = "espressif,esp32-grove"; defaultMode = ; - pinSdaRx = <&gpio0 32 GPIO_FLAG_NONE>; - pinSclTx = <&gpio0 33 GPIO_FLAG_NONE>; + pinSdaTx = <&gpio0 32 GPIO_FLAG_NONE>; + pinSclRx = <&gpio0 33 GPIO_FLAG_NONE>; uartPort = ; i2cPort = ; i2cClockFrequency = <400000>; diff --git a/Devices/m5stack-cores3/m5stack,cores3.dts b/Devices/m5stack-cores3/m5stack,cores3.dts index 1f231190..60b54a24 100644 --- a/Devices/m5stack-cores3/m5stack,cores3.dts +++ b/Devices/m5stack-cores3/m5stack,cores3.dts @@ -46,8 +46,8 @@ port_a: grove0 { compatible = "espressif,esp32-grove"; defaultMode = ; - pinSdaRx = <&gpio0 2 GPIO_FLAG_NONE>; - pinSclTx = <&gpio0 1 GPIO_FLAG_NONE>; + pinSdaTx = <&gpio0 2 GPIO_FLAG_NONE>; + pinSclRx = <&gpio0 1 GPIO_FLAG_NONE>; uartPort = ; i2cPort = ; i2cClockFrequency = <400000>; @@ -56,8 +56,8 @@ port_b: grove1 { compatible = "espressif,esp32-grove"; defaultMode = ; - pinSdaRx = <&gpio0 9 GPIO_FLAG_NONE>; - pinSclTx = <&gpio0 8 GPIO_FLAG_NONE>; + pinSdaTx = <&gpio0 9 GPIO_FLAG_NONE>; + pinSclRx = <&gpio0 8 GPIO_FLAG_NONE>; uartPort = ; i2cPort = ; i2cClockFrequency = <400000>; @@ -66,8 +66,8 @@ port_c: grove2 { compatible = "espressif,esp32-grove"; defaultMode = ; - pinSdaRx = <&gpio0 17 GPIO_FLAG_NONE>; - pinSclTx = <&gpio0 18 GPIO_FLAG_NONE>; + pinSdaTx = <&gpio0 17 GPIO_FLAG_NONE>; + pinSclRx = <&gpio0 18 GPIO_FLAG_NONE>; uartPort = ; i2cPort = ; i2cClockFrequency = <400000>; diff --git a/Devices/m5stack-stackchan/m5stack,stackchan.dts b/Devices/m5stack-stackchan/m5stack,stackchan.dts index 00b4729b..5440b6c1 100644 --- a/Devices/m5stack-stackchan/m5stack,stackchan.dts +++ b/Devices/m5stack-stackchan/m5stack,stackchan.dts @@ -80,8 +80,8 @@ port_a: grove0 { compatible = "espressif,esp32-grove"; defaultMode = ; - pinSdaRx = <&gpio0 2 GPIO_FLAG_NONE>; - pinSclTx = <&gpio0 1 GPIO_FLAG_NONE>; + pinSdaTx = <&gpio0 2 GPIO_FLAG_NONE>; + pinSclRx = <&gpio0 1 GPIO_FLAG_NONE>; uartPort = ; i2cPort = ; i2cClockFrequency = <400000>; @@ -90,8 +90,8 @@ port_b: grove1 { compatible = "espressif,esp32-grove"; defaultMode = ; - pinSdaRx = <&gpio0 9 GPIO_FLAG_NONE>; - pinSclTx = <&gpio0 8 GPIO_FLAG_NONE>; + pinSdaTx = <&gpio0 9 GPIO_FLAG_NONE>; + pinSclRx = <&gpio0 8 GPIO_FLAG_NONE>; uartPort = ; i2cPort = ; i2cClockFrequency = <400000>; @@ -100,8 +100,8 @@ port_c: grove2 { compatible = "espressif,esp32-grove"; defaultMode = ; - pinSdaRx = <&gpio0 17 GPIO_FLAG_NONE>; - pinSclTx = <&gpio0 18 GPIO_FLAG_NONE>; + pinSdaTx = <&gpio0 17 GPIO_FLAG_NONE>; + pinSclRx = <&gpio0 18 GPIO_FLAG_NONE>; uartPort = ; i2cPort = ; i2cClockFrequency = <400000>; diff --git a/Documentation/gps.md b/Documentation/gps.md index 8372045b..2d9e240d 100644 --- a/Documentation/gps.md +++ b/Documentation/gps.md @@ -4,12 +4,16 @@ ### Beitian BH-222Q +Currently not working. + 115200 baud, U-Blox 10 clone, defaults to binary messages https://www.beitian.com/en/pd.jsp?id=1677 ### Beitian BN-357ZF +Configure as MTK L76B in GPS settings, or auto-detect as MTK L76K. + 9600 baud, L76K clone https://www.beitian.com/en/sys-pd/879.html @@ -20,7 +24,9 @@ https://www.beitian.com/en/sys-pd/879.html https://www.datasheethub.com/gy-neo6mv2-flight-control-gps-module/ -### M5Stack GPS +### M5Stack Mini GPS (AT6558) + +Configure as ATGM336H. 9600 baud, AT6558 + MAX2659 (LNA) diff --git a/Documentation/ideas.md b/Documentation/ideas.md index 664221e0..8c09f957 100644 --- a/Documentation/ideas.md +++ b/Documentation/ideas.md @@ -12,8 +12,8 @@ ## Higher Priority -- Make a root device type so it can be discovered more easily. -- When device.py selects a new device, it should automatically delete the build dirs (build/, cmake-*/) when it detects that the platform has changed. +- Require either SD card present or at least 8MB of flash. This way we can increase firmware size, ensure performance, and have a single location for storing data. +- Consider storing data on SD card in `/tactility` folder (for usage with Launcher) - Add font design tokens such as "regular", "title" and "smaller". Perhaps via the LVGL kernel module. - Add kernel listening mechanism so that the root device init can be notified when a device becomes available: Callback for device/start stop with filtering on device type: @@ -24,13 +24,11 @@ - DTS: support for #defines - DTS: support for aliases - SPI kernel driver -- iomux kernel driver - Kernel concepts for ELF loading (generic approach for GUI apps, console apps, libraries). - Fix glitches when installing app via App Hub with 4.3" Waveshare - TCA9534 keyboards should use interrupts - GT911 drivers should use interrupts if it's stable - Fix Cardputer (original): use LV_KEY_NEXT and _PREV in keyboard mapping instead of encoder driver hack (and check GPIO app if it then hangs too) -- Logging with a function that uses std::format - Expose http::download() and main dispatcher to TactiltyC. - External app loading: Check the version of Tactility and check ESP target hardware to check for compatibility Check during installation process, but also when starting (SD card might have old app install from before Tactility OS update) @@ -59,15 +57,11 @@ - Make WiFi setup app that starts an access point and hosts a webpage to set up the device. This will be useful for devices without a screen, a small screen or a non-touch screen. - Unify the way displays are dimmed. Some implementations turn off the display when it's fully dimmed. Make this a separate functionality. -- Try out ILI9342 https://github.com/jbrilha/esp_lcd_ili9342 -- All drivers (e.g. display, touch, etc.) should call stop() in their destructor, or at least assert that they should not be running. - Bug: Turn on WiFi (when testing it wasn't connected/connecting - just active). Open chat. Observe crash. - Bug: Crash handling app cannot be exited with an EncoderDevice. (current work-around is to manually reset the device) -- I2C app should show error when I2C port is disabled when the scan button was manually pressed ## Lower Priority -- The boot button on some devices can be used as GPIO_NUM_0 at runtime - Localize all apps - Support hot-plugging SD card (note: this is not possible if they require the CS pin hack) - Explore LVGL9's FreeRTOS functionality @@ -97,7 +91,6 @@ - Audio recording app - OTA updates - T-Deck Plus: Create separate device config? -- Support for displays with different DPI. Consider the layer-based system like on Android. - If present, use LED to show boot/wifi status - Capacity based on voltage: estimation for various devices uses a linear voltage curve, but it should use a battery discharge curve. - Wrapper for lvgl slider widget that shows "+" and "-" buttons, and also the value in a label. @@ -121,14 +114,5 @@ - IR transceiver app - GPS app - Investigate CSI https://stevenmhernandez.github.io/ESP32-CSI-Tool/ -- Compile unix tools to ELF apps? -- Todo list - Calendar -- Display touch calibration - RSS reader -- Static file web server (with option to specify path and port) -- Port TamaFi https://github.com/cifertech/TamaFi - -# Notes on firmware size - -- adding esp_http_client (with esp_event) added about 100kB \ No newline at end of file diff --git a/Platforms/platform-esp32/bindings/espressif,esp32-grove.yaml b/Platforms/platform-esp32/bindings/espressif,esp32-grove.yaml index 11805e03..7c660873 100644 --- a/Platforms/platform-esp32/bindings/espressif,esp32-grove.yaml +++ b/Platforms/platform-esp32/bindings/espressif,esp32-grove.yaml @@ -7,14 +7,14 @@ properties: type: int required: true description: "One of enum Esp32GroveMode" - pinSdaRx: + pinSdaTx: type: phandle-array required: true - description: SDA (I2C) or RX (UART) pin - pinSclTx: + description: SDA (I2C) or TX (UART) pin + pinSclRx: type: phandle-array required: true - description: SCL (I2C) or TX (UART) pin + description: SCL (I2C) or RX (UART) pin uartPort: type: int required: true diff --git a/Platforms/platform-esp32/include/tactility/drivers/esp32_grove.h b/Platforms/platform-esp32/include/tactility/drivers/esp32_grove.h index 01a18451..825305cf 100644 --- a/Platforms/platform-esp32/include/tactility/drivers/esp32_grove.h +++ b/Platforms/platform-esp32/include/tactility/drivers/esp32_grove.h @@ -12,8 +12,8 @@ extern "C" { struct Esp32GroveConfig { enum GroveMode defaultMode; - struct GpioPinSpec pinSdaRx; - struct GpioPinSpec pinSclTx; + struct GpioPinSpec pinSdaTx; + struct GpioPinSpec pinSclRx; uart_port_t uartPort; i2c_port_t i2cPort; uint32_t i2cClockFrequency; diff --git a/Platforms/platform-esp32/source/drivers/esp32_grove.cpp b/Platforms/platform-esp32/source/drivers/esp32_grove.cpp index fad1400e..51529678 100644 --- a/Platforms/platform-esp32/source/drivers/esp32_grove.cpp +++ b/Platforms/platform-esp32/source/drivers/esp32_grove.cpp @@ -108,8 +108,8 @@ static error_t start_child(Device* device, GroveMode mode) { } std::memset(uart_cfg, 0, sizeof(Esp32UartConfig)); uart_cfg->port = config->uartPort; - uart_cfg->pin_tx = config->pinSclTx; - uart_cfg->pin_rx = config->pinSdaRx; + uart_cfg->pin_rx = config->pinSclRx; + uart_cfg->pin_tx = config->pinSdaTx; uart_cfg->pin_cts = GPIO_PIN_SPEC_NONE; uart_cfg->pin_rts = GPIO_PIN_SPEC_NONE; data->child_config = uart_cfg; @@ -131,8 +131,8 @@ static error_t start_child(Device* device, GroveMode mode) { std::memset(i2c_cfg, 0, sizeof(Esp32I2cMasterConfig)); i2c_cfg->port = static_cast(config->i2cPort); i2c_cfg->clockFrequency = config->i2cClockFrequency; - i2c_cfg->pinSda = config->pinSdaRx; - i2c_cfg->pinScl = config->pinSclTx; + i2c_cfg->pinSda = config->pinSdaTx; + i2c_cfg->pinScl = config->pinSclRx; // New driver seems to require pull-up setting i2c_cfg->pinSda.flags |= GPIO_FLAG_PULL_UP; i2c_cfg->pinScl.flags |= GPIO_FLAG_PULL_UP; diff --git a/Tactility/Source/Tactility.cpp b/Tactility/Source/Tactility.cpp index adb615bd..5f83d446 100644 --- a/Tactility/Source/Tactility.cpp +++ b/Tactility/Source/Tactility.cpp @@ -34,7 +34,6 @@ #include #ifdef ESP_PLATFORM -#include #include #endif diff --git a/device.py b/device.py index f9b37e07..1bd0bac2 100644 --- a/device.py +++ b/device.py @@ -1,5 +1,7 @@ import configparser +import glob import os +import shutil import sys from configparser import ConfigParser @@ -392,14 +394,42 @@ def write_properties(output_file, device_properties: ConfigParser, device_id: st write_custom_sdkconfig(output_file, device_properties) write_lvgl_variables(output_file, device_properties) +def get_current_sdkconfig_target(sdkconfig_path: str): + if not os.path.isfile(sdkconfig_path): + return None + with open(sdkconfig_path, "r") as f: + for line in f: + if line.startswith("CONFIG_IDF_TARGET="): + return line.split("=", 1)[1].strip().strip('"') + return None + +def clean_build_dirs_on_platform_change(previous_target: str, new_target: str): + if previous_target is None or previous_target == new_target: + return + dirs_to_remove = [] + if os.path.isdir("build"): + dirs_to_remove.append("build") + for d in glob.glob("cmake-build-*/"): + dirs_to_remove.append(d.rstrip("/")) + if not dirs_to_remove: + return + print(f"Platform changed ({previous_target} -> {new_target}), removing build dirs:") + for d in dirs_to_remove: + print(f" {d}") + shutil.rmtree(d) + def main(device_id: str, is_dev: bool): device_properties_path = get_properties_file_path(device_id) if not os.path.isfile(device_properties_path): exit_with_error(f"{device_id} is not a valid device identifier (could not found {device_properties_path})") output_file_path = "sdkconfig" + # Clean build dirs if target changes + device_properties = read_device_properties(device_id) + new_target = get_property_or_exit(device_properties, "hardware", "target").lower() + sdkconfig_target = get_current_sdkconfig_target(output_file_path) + clean_build_dirs_on_platform_change(sdkconfig_target, new_target) if os.path.isfile(output_file_path): os.remove(output_file_path) - device_properties = read_device_properties(device_id) with open(output_file_path, "w") as output_file: write_properties(output_file, device_properties, device_id, is_dev) if is_dev: