Compare commits

...

322 Commits

Author SHA1 Message Date
Adolfo Reyna 7788415e0e feat(es8311): add digital input gain and restore 42dB HW max for ES3C28P/35P
- Same as firmware: add input-gain-percent, 42dB HW max, digital multiplier
2026-07-31 12:11:13 -04:00
Adolfo Reyna d8c5a55fe8 Add firmware font size setting 2026-07-24 22:01:18 -04:00
Adolfo Reyna 56bbd6a90e Add ES3C35P board support 2026-07-24 22:01:18 -04:00
Adolfo Reyna 642847be41 fix(mcp): implement startMcpScreensaver - missing method caused linker error
- Was declared in DisplayIdleService.h but not defined in clean refactored branch
- Implementation taken from original 8970143f: locks LVGL, checks overlay, ensures backlight, creates McpScreensaver
- Fixes build of feature/local-all-rebased on es3c28p
2026-07-23 22:56:17 -04:00
Adolfo Reyna 0367b95f27 feat(app): allow external apps to hide statusbar via manifest flags
- Add parseAppFlagsString() in AppManifestParsing.cpp to parse comma-separated flags (HideStatusBar, Hidden, None)
- Parse [app]flags in V1 and app.flags in V2 manifests
- Loader already supports HideStatusBar, GuiService hides statusbarWidget when set
- Enables fullscreen for ELF apps (e.g. BibleVerse, BookPlayer) without firmware recompilation of internal manifests
- Add tests for flag parsing (38 tests passing)
- Tested on es3c28p /dev/cu.usbmodem1101 @ 192.168.68.133 with HelloWorld app
2026-07-23 22:56:17 -04:00
Adolfo Reyna 17773825fa fix(audio): ES8311 BOTH complementary open + audio-stream close ref-count + mic unmute
- es8311 driver open() now allows OUTPUT->INPUT complementary (promotes to BOTH) when same native rate 44100
- audio-stream close_stream() ref-counts shared BOTH codec (don't close if other direction still open)
- MCP recordVoice + VoiceRecorder app explicitly unmute and set 100% gain

Fixes mic input not working - was returning ERROR_RESOURCE when output already open
2026-07-23 22:56:17 -04:00
Adolfo Reyna 3115a685e2 fix(files): launch mp3 player from file explorer - audio support
- SupportedFiles: add isSupportedAudioFile (.mp3/.wav/.ogg/.flac)
- Files View::viewFile: if audio file, loader->start one.tactility.mp3player with file bundle
- Tactility.cpp: hide mcpoverride (screensaver internal), keep mcpsettings visible
- Fixes MP3 no longer running from file explorer, plus audio fast playback already fixed via audio-stream (Mp3Player/BookPlayer/VoiceRecorder use audio_stream_open_output not direct i2s_controller_write)
- MCP dev coexistence already fixed: DisplayIdle lock inversion 3629ffef, WebServer serverEnabled=ws||mcp, unauth /api/mcp, video 8081/8083 vs dev 6666
2026-07-23 22:56:17 -04:00
Adolfo Reyna ad4a15dce8 feat(mcp): restore MCP service with display charging toggle
- Restore MCP system (McpSystem 1900+ LOC, McpHandler, McpScreensaver, McpSettings, McpOverride apps)
- Use audio-stream instead of direct I2S for MP3 playback (fixes fast playback, uses native resampler)
- Register McpSettings + McpOverride in Tactility.cpp so Settings shows MCP Screen
- DisplaySettings: add ScreensaverType::McpScreen and disableScreensaverWhenCharging flag
- Display app: add 'Disable on charging' toggle, handles McpScreen screensaver type
- DisplayIdle: skip screensaver while charging, support McpScreen screensaver, isDeviceCharging check via PowerDevice
- WebServer: coexistence with MCP (McpHandler)
- Avoid formatting churn from previous commits

Squashed from range eaa248b0..8970143f (6 commits) into single clean commit
2026-07-23 22:56:17 -04:00
Ken Van Hoeylandt 29e80cfd65 T-Deck Max & Pro support updates (#582)
- Created kernel driver for T-Deck Max & Pro display (needs work, doesn't refresh reliably on T-Deck Pro)
- Created T-Deck Pro device implementation (incubating)
2026-07-24 00:17:48 +02:00
Ken Van Hoeylandt 429125734a Add drivers to module and make start/stop optional (#580) 2026-07-23 23:28:09 +02:00
Shadowtrance 08eac48e64 Fix Tab5 Display Issues (#579)
And add PPA rotation to lvgl_display
2026-07-22 23:58:34 +02:00
Ken Van Hoeylandt 8b92aa8e5a GPIO descriptor fixes (#578) 2026-07-22 22:43:34 +02:00
Ken Van Hoeylandt a3fda9ad8f Device migrations and driver improvements (#576) 2026-07-22 21:11:12 +02:00
Ken Van Hoeylandt 2fbc44466a Device migrations, driver migrations and more (#575) 2026-07-20 23:43:17 +02:00
Shadowtrance 2d768ef3a1 ESP-NOW bridge for P4 (#573) 2026-07-19 09:23:20 +02:00
reyna-b bd30aa046a Add ES3C28P device (#569) 2026-07-19 09:17:19 +02:00
Ken Van Hoeylandt f9453d8956 Migrate devices, create drivers, other improvements & fixes (#574)
Migrated devices to kernel drivers:

- guition-jc3248w535c
- m5stack-core2
- m5stack-cores3
- m5stack-papers3

New drivers:

- axp192-module
- axp2101-module

Fixes:

- Fix SD card LDO for P4 devices
- Updated PowerOff app to work with kernel displays
- Fix for `lvgl_try_lock()` timing
- Fix for touch events with slow updating displays

Improvements:

- `GuiService` now keeps trying to lock to prevent silent failures caused by drivers.
- `GuiService` now uses lvgl-module calls for locking/unlocking
- display driver now has capability `DISPLAY_CAPABILITY_SLOW_REFRESH`
2026-07-19 00:39:26 +02:00
Ken Van Hoeylandt 5f54f7ca3d Fix for SDMMC driver on ESP32-P4 (#572)
The driver was using the incorrect (read: old) if-defs for a capability check.
2026-07-18 15:58:48 +02:00
Ken Van Hoeylandt d896657bf9 Device migrations, drivers and fixes (#571)
Device migrations:

- cyd-4848S040c
- guition-jc1060p470ciwy
- guition-jc2432w328c
- guition-jc3248w535c (known issue with display and touch, Shadowtrance will look into it)
- guition-jc8048w550c
- heltec-wifi-lora-32-v3
- lilygo-tdeck-max (excluding graphics)
- lilygo-tdisplay
- lilygo-tdisplay-s3
- lilygo-tdongle-s3
- lilygo-tlora-pager

Driver migrations:

- Implemented haptic driver interface in kernel
- AXS15231b
- BQ25896
- BQ27220
- CST328
- CST6xx
- DRV2605
- JD9165
- Custom LilyGO driver for T-Lora Pager
- SSD1306
- ST7701
- ST7735
- SY6970
- TCA8418

Fixes/improvements:

- Boot app: support for multiple power devices, improved UI
- lvgl_devices and related code: fixes for mapping
- Support for arrays in dts parser
2026-07-18 15:01:42 +02:00
Ken Van Hoeylandt 3b5a401594 Device migrations, new drivers, cleanup (#567)
* **New Features**
  * Added native display support for ST7796, ILI9341, and ST7789 panels across supported boards.
  * Added FT5x06 and FT6x36 touchscreen support.
  * Generic PWM driver
  * ESP32 PWM driver
  * Generic RGB LED driver
  * RGB PWM LED driver
  * RGB GPIO LED driver
  * Implementation of RGB LED for various boards

* **Improvements**
  * Updated board hardware descriptions to use explicit display/touch/backlight device-tree bindings and disabled deprecated HAL usage.
  * Improved display and touch-driver cleanup to prevent stale resources and improve shutdown reliability.
  * Pinned esp-hosted library to a fixed version
 
* **Deletions**
  * Obsolete placeholder display
  * Legacy ILI9488 support.
  * ESP32-specific LEDC PWM implementation
2026-07-16 22:47:26 +02:00
Ken Van Hoeylandt 6fb2bb736c Drivers, device migrations and other improvements (#566)
- RGB display driver added
- display_driver API:
  - Added software-based display rotation for screens without hardware rotation support.
  - Improved display capability detection across supported display drivers.
- lvgl_display driver:
  - Improved framebuffer handling for smoother, more reliable display updates.
  - Display gap and rotation behavior now adapts more accurately to hardware capabilities.
- Migration Crowpanel 5" basic & advance to kernel drivers
- Improve KernelDisplay app: brightness controls are hidden for displays that only support on/off operation
- device.py now allows for (non-ambiguous) partial device IDs
- TactilityKernel: Implement more tests
2026-07-15 22:56:21 +02:00
Ken Van Hoeylandt bd8fdfd858 Device migrations and driver implementations (#564) 2026-07-15 12:46:24 +02:00
Ken Van Hoeylandt 8af6204ba1 New kernel drivers and device migrations (#563) 2026-07-14 20:26:57 +02:00
Shadowtrance 955416dac8 Audio System + Drivers (#562) 2026-07-14 08:34:29 +02:00
Ken Van Hoeylandt fa4a6e255c New kernel drivers and device implementation updates (#561)
- Added modular device support and devicetree bindings for ILI9341, ILI9488, CST816S, XPT2046, and GPIO button input, updating several board configurations for display/touch/backlight/keyboard/battery.
- Added a setting to control deprecated HAL usage (device property + Kconfig).
2026-07-12 23:54:55 +02:00
Ken Van Hoeylandt 50c0a14a93 New kernel drivers and more (#560)
- Added kernel base drivers for: display, pointer (touch, mouse, etc.), keyboard, adc, power supply and backlight
- Implement new kernel driver modules: `st7789-module` and `gt911-module`
- Implement ESP32 ADC "oneshot" kernel driver
- Implement ESP32  backlight kernel driver with ledc API
- Implemented `battery-sense` driver that allows for voltage measurement and creates a power supply child device
- Updated github actions
- Updated flash scripts
- Fix for esp32 legacy driver conflict with ADC
- Created separate `lilygo-tdeck` and `lilygo-tdeck-plus` devices
- Created `lilygo-module` with LilyGO kernel drivers
- Fix for intermittent errors in build related to code generation of `devicetree.c`
- `lvgl-module` can now map kernel drivers onto LVGL devices
- Created `KernelDisplayApp` as a mirror of `HalDisplayApp` (formerly `DisplayApp`)
- Removed `struct` and `enum` prefix in a lot of kernel driver cpp source files
- `lilygo-tdeck` and `lilygo-tdeck-plus` are now fully relying on kernel drivers and don't use any of the old HAL
2026-07-12 00:29:12 +02:00
Ken Van Hoeylandt c4406b24ba Fixes and improvements (#559)
- **Fixes**
  - Added missing Wi-Fi hardware configuration support for P4 devices.
  - Fixed build warning
  - Fixed build wrt Tab5

- **Changes**
  - M5Stack StickS3: Switched default storage location from SD to Internal
  - M5Stack StickS3: Removed DIY SD card support over SPI
  - M5Stack StickC Plus2: Removed the automatic startup of the web server
2026-07-10 18:19:11 +02:00
Crazypedia 0922c4d55b Show a confirmed shutdown screen before cutting power (#555) 2026-07-10 08:49:46 +02:00
Shadowtrance 7a7f09be35 Tab5 camera + other stuff (#558)
* Tab5 camera + other stuff

Tab5 camera driver - SC2356
Custom SliderBox widget - slider with plus and minus buttons + value label and snapping
Rtc Time service + rtc api
Sdk release - only include drivers built for that specific target, eg: sc2356 driver is mipi / p4 only.
No more hardcoded manual sdk cmakelists
New function to find device by compatible string match. no more static cast bool wildness when trying to match a single device (like M5Stack PaperS3 for example)

* feedback + fixes

Fixed external app user data path.
fix(gui): block app teardown until onHide() completes, preventing ELF unload racing a still-running app
added camera device type and api

* drain the snake sssem

---------

Co-authored-by: Ken Van Hoeylandt <git@kenvanhoeylandt.net>
2026-07-10 08:45:03 +02:00
Crazypedia 16a61a087c Add power device (battery + power-off) to lilygo-tdeck-max (#553) 2026-07-09 22:55:14 +02:00
Ken Van Hoeylandt 1c2806bddf Added WiFi kernel drivers and refactored Wifi service (#557)
+ other improvements
2026-07-09 21:03:38 +02:00
Ken Van Hoeylandt dbb96a891c Generate device matrix and add missing symbol (#556) 2026-07-08 08:58:45 +02:00
Crazypedia d6ac070e30 Add LilyGO T-Deck Max (e-paper) base board support (#552) 2026-07-08 08:40:09 +02:00
Ken Van Hoeylandt f4f91f81d6 Service logic moved to kernel (#554)
+ fix BT service file paths
2026-07-07 22:52:19 +02:00
Crazypedia cca7224252 fix(tests): repair stale TestFile.h includes and stop hardcoding g++ in test CMakeLists (#551)
PR #550 moved TestFile.h from Tests/TactilityCore to Tests/Tactility, but
AppManifestParsingTest.cpp and PropertiesFileTest.cpp still include the old
path, so the test build fails on main.
2026-07-05 22:05:54 +02:00
Ken Van Hoeylandt 66a4eb66d6 Remove TactilityCore (#550) 2026-07-05 12:47:37 +02:00
Ken Van Hoeylandt dfaeb9a2d9 Crypt module (#549)
- Moved cryptography code out of Tactility project and into a kernel module.
- Converted C++ code to C style interface
- Hardened security
2026-07-05 11:17:42 +02:00
Ken Van Hoeylandt 9d5993930d Replaced Logger usage with LOG_x (#548) 2026-07-04 23:49:19 +02:00
Ken Van Hoeylandt ecad2248d9 Various improvements (#547)
- Fixed crash when returning to Setup app (from any of the steps)
- Fixed crash when returning to TimeDateSettings app (after locale selection)
- Fixed GuiService inconsistent behaviour: now always perform operations async (e.g. to show/hide apps). This fixes crashes in some onHide() calls where onHide() might be called before onShow() was called.
- Fix for incorrect WebServService path
- Remove CYD-4848S040C SD card functionality, but added a GPIO fix for releasing 3-wire SPI pin sharing.
- Fix for saving/loading settings for various apps
2026-07-04 21:26:43 +02:00
Ken Van Hoeylandt a323f8e148 Implement SD card for WaveShare S3 Touch LCD 4.3" (#546) 2026-07-04 09:28:31 +02:00
Ken Van Hoeylandt 05720821f8 Require SD card or >4MB flash (#545) 2026-07-03 23:56:03 +02:00
Ken Van Hoeylandt 90afba647e Update properties parsing for app manifest and device manifest files (#544) 2026-07-03 00:29:01 +02:00
Ken Van Hoeylandt 35fd7dd536 Post-release changes (#543)
- Update version to 0.8.0-dev
- Add new release scripts
- Update release docs
2026-07-02 20:52:26 +02:00
Ken Van Hoeylandt cd07c64926 Release 0.7.0 (#542)
Build Firmware / BuildSdk (map[arch:esp32 id:generic-esp32]) (push) Has been cancelled
Build Firmware / BuildSdk (map[arch:esp32c6 id:generic-esp32c6]) (push) Has been cancelled
Build Firmware / BuildSdk (map[arch:esp32p4 id:generic-esp32p4]) (push) Has been cancelled
Build Firmware / BuildSdk (map[arch:esp32s3 id:generic-esp32s3]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32 id:cyd-2432s024c]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32 id:cyd-2432s024r]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32 id:cyd-2432s028r]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32 id:cyd-2432s028rv3]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32 id:cyd-2432s032c]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32 id:cyd-3248s035c]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32 id:cyd-e32r28t]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32 id:cyd-e32r32p]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32 id:elecrow-crowpanel-basic-28]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32 id:elecrow-crowpanel-basic-35]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32 id:guition-jc2432w328c]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32 id:lilygo-tdisplay]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32 id:m5stack-core2]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32 id:m5stack-stickc-plus2]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32 id:m5stack-stickc-plus]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32p4 id:guition-jc1060p470ciwy]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32p4 id:m5stack-tab5]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:btt-panda-touch]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:cyd-4848s040c]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:cyd-8048s043c]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:elecrow-crowpanel-advance-28]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:elecrow-crowpanel-advance-35]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:elecrow-crowpanel-advance-50]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:elecrow-crowpanel-basic-50]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:guition-jc3248w535c]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:guition-jc8048w550c]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:heltec-wifi-lora-32-v3]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:lilygo-tdeck]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:lilygo-tdisplay-s3]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:lilygo-tdongle-s3]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:lilygo-thmi]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:lilygo-tlora-pager]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:m5stack-cardputer-adv]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:m5stack-cardputer]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:m5stack-cores3]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:m5stack-papers3]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:m5stack-stackchan]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:m5stack-sticks3]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:unphone]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:waveshare-esp32-s3-geek]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:waveshare-s3-lcd-13]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:waveshare-s3-touch-lcd-128]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:waveshare-s3-touch-lcd-147]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:waveshare-s3-touch-lcd-43]) (push) Has been cancelled
Build Firmware / BuildFirmware (map[arch:esp32s3 id:wireless-tag-wt32-sc01-plus]) (push) Has been cancelled
Build Firmware / BundleArtifacts (push) Has been cancelled
Build Firmware / PublishFirmwareSnapshot (push) Has been cancelled
Build Firmware / PublishFirmwareStable (push) Has been cancelled
Build Firmware / PublishSdk (push) Has been cancelled
2026-07-02 17:34:40 +02:00
Ken Van Hoeylandt 2f5e183f18 Setup app (#541)
- Implement Setup app for device's first boot
- Implement device simple name and vendor name variables
- Remove region setting (locale setting is already available)
2026-07-02 00:29:03 +02:00
Ken Van Hoeylandt d3439f6f45 Fixes & memory optimizations (#540)
- Disable BlueTooth driver by default, to ensure it doesn't allocate memory
- Update BlueTooth settings app behaviour to make sure it starts/stops the devices
- Disable SPI RAM usage for ST7789 as it broke App Hub
- Reduce T-Display and T-Deck display buffers from 1/3rd to 1/10th of resolution
- Enabled dynamic buffers for MbedTLS to optimize memory
- TLS 1.3 did not work with dynamic buffers: downgrade to 1.2 for now
- WiFi is now enabled from the Boot app callback to the WiFi service, instead of the WiFi service start() function. This avoids a lockup when WiFi is started by the service while the Boot app is updating the WiFi settings.
2026-07-01 21:11:46 +02:00
Ken Van Hoeylandt 599fa46766 Driver improvements (#535)
- New drivers:
  - SD SPI
  - spi_peripheral
  - touch_placeholder
  - display_placeholder
- Devicetree compiler:
  - Implement phandle-arrays
  - Implement device addresses
- Add placeholder drivers to all devices with a SPI display
- SPI driver: add `cs-pins` and set them to high on driver start
- FileSystem: add `file_system_set_owner()` and `file_system_get_owner()`
- File locking is now checking if the related `FileSystem` is part of a shared SPI bus
- Add `device_get_child_count()`
- SDMMC driver: Remove default of `slot` value
- Fix for Crowpanel Basic 3.5" display (add delay to booting)
- Fix for LilyGO T-HMI SD card mounting (delayed mounting by disabling it initially in the dts)
2026-06-27 17:32:05 +02:00
Ken Van Hoeylandt e50659a3fb Fix for Gt911Touch. (#538) 2026-06-22 08:18:55 +02:00
Ken Van Hoeylandt aeccc15ab6 Fix for Gt911Touch when using new I2C driver. (#536)
Committing this straight to main branch to avoid wasting pipelines.
2026-06-21 22:20:07 +02:00
Shadowtrance 594b8bd27e Smart tab5keyboard (#533) 2026-06-19 22:14:07 +02:00
Ken Van Hoeylandt e8b9a1f2a9 Fixes and improvements (#534) 2026-06-19 20:46:56 +02:00
Ken Van Hoeylandt a35c88c8fd Grove driver, I2C migrations, bugfixes and docs (#532) 2026-06-19 00:52:31 +02:00
Ken Van Hoeylandt 8dabda2b5b Implement new I2C driver (#531) 2026-06-12 18:46:22 +02:00
Shadowtrance 8dd9bee8d0 M5Stack Tab5 TinyUSB MSC support implemented (#530) 2026-06-10 22:39:36 +02:00
Ken Van Hoeylandt 543390a977 Fix for CoreS3 touch (#529)
The FT6 driver does a hardware ID check, which fails on the CoreS3 but
not on Stackchan for some reason. FT5 works on Stackchan, so we'll use
that for all devices, just like M5GFX does.
2026-06-10 00:24:18 +02:00
Shadowtrance 62266dff58 Tab5 Keyboard (#528) 2026-06-09 23:19:56 +02:00
Shadowtrance 3dcc95f6f3 USB host support (#527) 2026-06-03 23:10:37 +02:00
Shadowtrance a59fbf4ed5 Tab5 features, StackChan, fixes, drivers.... (#526) 2026-05-28 23:31:25 +02:00
Shadowtrance 5c78d55b04 Bluetooth (#518)
* Bluetooth LE addition

* fixes

* use the psram!

helps a little on S3 (t-deck)

* custom device name

* Update symbols.c

* Feedback + fixes

Fixes external app start/stop server (child devices)
Fixes BtManage causing a full system hang upon disabling bt when a device is connected to the host.

* updoot

* more updoot

* move back!

* Revert "move back!"

This reverts commit d3694365c634acc5db62ac59771c496cb971a727.

* fix some of the things

* Addressing feedback? hmm

* Fixes

Bug 1 — Reconnect loop / Reconnect not working fixed
Bug 2 — Name-only advertising overwrites HID advertising
Bug 3 — BleHidDeviceCtx leak on re-enable
Enhancement — HID device auto-start on radio re-enable

* stuff...

* update for consistency with others

* fix crashes

and some bonus symbols

* a few symbols, i2c speed, cdn message

100kHz i2c speed seems to be more compatible with m5stack modules...and probably in general.
cdn message no longer applies

* Hide BT Settings when bt not enabled

* Addressing things and device fixes

* Missed one!

* stuff
2026-05-22 22:49:37 +02:00
Pirata 895e6bc50d Add merged binaries to release assets (#524) 2026-05-21 22:53:52 +02:00
Ken Van Hoeylandt 4170b86137 Various fixes and improvements (#515)
* Optional internal pull-ups for SD/MMC pins in DTS
  * Selectable on‑chip LDO channel for SD/MMC power (can be disabled)
  * Added several sensor/driver modules to generic ESP32 device configurations so that they become part of the SDKs
  * SD card mount now prints card information for clearer diagnostics
  * Fix for bug DTS boolean parsing. Improved tests to catch these issues.
  * Expanded SDK integration test to include new modules and headers
  * Modularized packaging to generate per‑module build files and include driver assets
2026-04-28 17:26:03 +02:00
NellowTCS be2cdc0b90 Implement device: CYD-2432S024R (#521) 2026-04-13 20:59:15 +02:00
NellowTCS 10ba4f58e2 Add calibration methods and app (#520) 2026-04-13 20:58:27 +02:00
NellowTCS 4dd2762b79 Implemented device CYD-3248S035C (#522) 2026-04-13 20:32:33 +02:00
Shadowtrance e64f4ff16b M5Stack StickS3 - New Tab5 - driver modules (#516)
Font size set to 18 for 800x480 displays
Fix web server dashboard not rendering when sdcard isn't present

Added new driver modules
-  BM8563 RTC
- RX8130CE RTC
- MPU6886 IMU
- QMI8658 IMU
- M5PM1 Power Management Chip

Applied the above modules to applicable devicetrees.

Added new device: M5Stack StickS3

Added new M5Stack Tab5 St7123 variant.

ButtonControl changed to use interupts and xQueue, added AppClose action.

And some bonus symbols of course, the apps are hungry for symbols.
2026-03-20 10:07:57 +01:00
Shadowtrance e560cc7df2 Styling fixes for paper displays (#514) 2026-03-14 17:40:29 +01:00
Ken Van Hoeylandt aa7530e515 New kernel drivers, filesystem API, and more (#513)
* **New Features**
  * BMI270 6-axis IMU driver added; new unified filesystem abstraction for mounted filesystems.
  * Public Wi‑Fi API surface (no implementation yet)
  * SDMMC driver added (kernel drive$)
  * expanded GPIO interrupt/callback support
* **Improvements**
  * M5Stack Tab5: revamped GPIO/power initialization and IMU integration.
  * LVGL updates including device fontSize configuration.
  * Updated all code related to SD card device/fs handling
  * Rename LilyGO T-HMI S3 to LilyGO T-HMI
* **Bug Fixes**
  * Simplified and consolidated SD card handling and mount discovery.
2026-03-07 16:13:39 +01:00
Shadowtrance 2de35b2d2d M5Stack PaperS3 improvements and other bug fixes (#512) 2026-03-06 21:45:56 +01:00
Rivair Sabino dos Santos 9fc0aa51d7 Implement battery support for LilyGO T-HMI S3 (#511) 2026-03-05 23:21:10 +01:00
Rivair Sabino dos Santos 2426c387eb Add initial support for LilyGO T-HMI S3 with device configuration and… (#509) 2026-03-03 22:38:42 +01:00
Shadowtrance 33caf09856 Files App - Copy, Cut, Paste Actions (#510) 2026-02-26 20:11:05 +01:00
Ken Van Hoeylandt d2048e01b6 Tab5 power expander driver and devicetree parsing improvements (#507)
* **New Features**
  * PI4IOE5V6408 I2C I/O expander driver with public GPIO APIs
  * CLI tool to list devicetree dependencies

* **Device Tree Updates**
  * M5Stack Tab5 configured with two I2C IO expanders; PI4IOE5V6408 binding added

* **Build / Tooling**
  * Devicetree code generation integrated into build; generated artifacts and dynamic dependency resolution exposed

* **Refactor**
  * Kernel/run APIs updated to accept a null‑terminated devicetree modules array; many module symbols renamed

* **Documentation**
  * Added README and Apache‑2.0 license for new driver module
2026-02-17 22:59:30 +01:00
Shadowtrance f0f764baff Mbedtls symbols and more (#508) 2026-02-17 19:00:08 +01:00
Ken Van Hoeylandt d860ba1f34 Tab5 audio, I2C improvements, UiDensity moved to lvgl-module and cleanup (#506)
- UiDensity moved to lvgl-module
- Deleted tt_hal and tt_hal_gpio (breaks apps, but will fix those right after merging)
- Added I2C 8 bit register operations
- Added device.properties to simulator
- Improved Tab5 hardware init, implement audio
- Add README.md to kernel
2026-02-15 19:45:12 +01:00
Ken Van Hoeylandt 3a24d058c9 Rename icons, fix T-Lora Pager config and more (#502)
* **New Features**
  * Added NFC chip-select to SD card hardware configuration.

* **Refactor**
  * Consolidated and renamed icon resources; apps and status-bar now reference unified icon headers and new icon constants.
  * Renamed LVGL lock API (timed → lvgl_try_lock) and updated callers.

* **Documentation**
  * Updated module README and license files; added Apache-2.0 license document.
2026-02-15 13:32:52 +01:00
Shadowtrance 72b55b221e Update device.properties to fix Waveshare GEEK PSRAM issue (#504) 2026-02-15 12:39:15 +01:00
Ken Van Hoeylandt 9a11e6f47b Implement UI scaling and more (#501)
**New Features**
 * Runtime font accessors and new symbol fonts for text, launcher, statusbar, and shared icons.
 * Added font height base setting to device.properties
 * Text fonts now have 3 sizes: small, default, large

**Improvements**
 * Renamed `UiScale` to `UiDensity`
 * Statusbar, toolbar and many UI components now compute heights and spacing from fonts/density.
 * SSD1306 initialization sequence refined for more stable startup.
 * Multiple image assets replaced by symbol-font rendering.
 * Many layout improvements related to density, font scaling and icon scaling
 * Updated folder name capitalization for newer style
2026-02-15 01:41:47 +01:00
Ken Van Hoeylandt 72c9b2b113 Add custom icon fonts to lvgl-module (#499)
* **New Features**
  * Added Material Design symbol fonts and LVGL font aliases for launcher, status bar, and shared UI icons.

* **Style**
  * Migrated app icons across the UI to the new symbol font system.
  * Updated launcher button sizing, font styling, recoloring and icon text color for consistency.
  * Default text/icon font macros set for consistent sizing across the UI.

* **Documentation**
  * Updated third‑party notices to include Material Design Icons links.
2026-02-13 20:27:08 +01:00
Shadowtrance 4ab29ae466 Guition 535 and 550 i2s config (#500) 2026-02-13 20:11:51 +01:00
Ken Van Hoeylandt 8ff990d635 Boot apps refactored (#498)
- Specify launcher via menuconfig
- Specify auto-start app via menuconfig
- Implement more rigid boot.properties fallbacks
- Devices with tiny screen now auto-start ApWebServer
- ApWebServer UI fixes
2026-02-12 00:10:04 +01:00
Shadowtrance 49632d15c9 AP Web Server App (#497)
Auto starts the web server in AP mode with generated SSID and Password.
For small devices.... or any i guess.
Hidden by default.
May need adjustments to suit even smaller screens than the waveshare GEEK.
And a few symbols for good measure. :)
2026-02-11 20:37:22 +01:00
Ken Van Hoeylandt 26c17986c6 GPIO refactored (#495)
* **Refactor**
  * GPIO subsystem moved to a descriptor-based model for per-pin ownership and runtime pin management; many platform drivers now acquire/release descriptors.
  * Device trees and drivers now use GPIO phandle-style pin specifications across all boards and all drivers.

* **Behavior**
  * Device list now encodes per-device status (ok/disabled); boot will skip disabled devices accordingly.

* **Deprecation**
  * Legacy GPIO HAL marked deprecated and replaced with descriptor-based interfaces.

* **Chores**
  * Bindings and platform configs updated to the new GPIO pin-spec format.
2026-02-11 20:34:54 +01:00
Ken Van Hoeylandt dff93cb655 Add lv_arc.h symbols (#496) 2026-02-10 12:35:40 +01:00
Ken Van Hoeylandt 25c3f19e5d Merge develop into main (#494)
* Updated runtime gating to enable LilyGO T-Deck specific apps and services
  * New device compatibility and model-detection APIs
  * Added a buffer-overflow error code and message
  * Updated GitHub Actions checkout to v4
  * Adjusted an LVGL-related library version
  * Device config now emits a T-Deck workaround flag when applicable
  * Removed internal developer comments and minor cleanups
2026-02-09 22:12:03 +01:00
Ken Van Hoeylandt 93efadd5e3 Devicetree DTS and YAML format improvements (#492)
* **DevicetreeCompiler**
  * Binding properties now support default values.
  * Compiler returns meaningful exit codes and reports errors more clearly.
  * Stronger validation of device configurations with unified error handling.
  * Added integration tests and a dedicated Devicetree test workflow.

* **Changes**
  * Platform binding schemas updated: some fields made required, others gained explicit defaults.
  * Many device-tree files simplified by removing unused/placeholder pin and transfer-size entries.

* **Documentation**
  * Removed several outdated TODO items.
2026-02-09 17:38:06 +01:00
Ken Van Hoeylandt d27404964a SPI device migration (#490)
- Implement SPI devices in dts files for all devices
- Removed `tt::hal::spi` HAL and its configurations
- Fix for devicetree generator "boolean" support
- Remove unused custom locks in all `DisplayDevice` implementations
- Fixed some bugs with devices
- Updated XPT2046 driver
- Fix for `WifiEsp` deadlock
- Export a lot of new `math.h` symbols with `tt_init.cpp`
- Created `SpiDeviceLock` in `TactilityCore` as a wrapper for kernel SPI locking
- Improved `TactilityKernel` SPI driver.
2026-02-08 22:14:18 +01:00
Ken Van Hoeylandt 74127a5f6c Add kernel drivers for SPI and UART and make locking APIs more consistent (#489)
- Add kernel support for SPI driver
- Add kernel support for UART driver
- Implemented ESP32 UART kernel driver
- Update existing UART-related code in Tactility to use new kernel driver
- Remove UART from tt::hal::Configuration
- Remove tt_hal_uart functionality but keep functions for now
- Update devicetrees for UART changes
- Kernel mutex and recursive mutex: improved locking API design
- Other kernel improvements
- Added device_exists_of_type() and device_find_by_name()
2026-02-07 21:28:11 +01:00
Rivair Sabino dos Santos 7e24105d0c Implement pagination for file entries in View class (#486)
* Implement pagination for file entries in View class

* Add resolveDirentFromListIndex method and refactor entry handling in View class

* Fix current_start_index calculation in View::update to prevent out-of-bounds access
2026-02-07 12:15:55 +01:00
Ken Van Hoeylandt 2aa41cb562 Revert LVGL from 9.4.0 to 9.3.0 (#488)
Because of stability issues on T-Deck
2026-02-07 08:26:21 +01:00
Ken Van Hoeylandt 0042ce6d32 Fix SDK (#487)
* **New Features**
  * Added a full SDK integration test suite with a minimal sample app and automated multi-platform build/run flows.
  * Added a new CLI build tool to orchestrate SDK download, build, packaging, and device install/run.

* **Documentation**
  * Added typography design token suggestion to ideas.

* **Chores**
  * Updated CI to run SDK integration prep and test steps.
  * Adjusted build artifact paths, license mappings, and repository ignore rules (including .tactility).
2026-02-06 22:50:13 +01:00
Ken Van Hoeylandt 79e43b093a Kernel improvements (#485)
* **New Features**
  * Added public accessors for querying module/device start and ready state.

* **Refactor**
  * Internal state moved to opaque internal objects; module/device/driver initializers now explicitly initialize internal pointers.
  * Lifecycle handling updated to construct/destruct internal state and use accessors.

* **Tests**
  * Tests updated to use public accessors and explicit construct/destruct lifecycle calls.

* **Chores**
  * Test build/include paths and small metadata updated.
2026-02-06 16:32:30 +01:00
Ken Van Hoeylandt 1757af859c Update LVGL, esp_lvgl_port and esp_lcd_touch (#484)
- LVGL: 9.3.0 -> 9.4.0
- esp_lvgl_port:  2.5.0 -> 2.7.0
- eps_lcd_touch: 1.1.2 -> 1.2.1
2026-02-06 00:35:41 +01:00
Ken Van Hoeylandt 626d0d9776 Devicetree DTS alias support (#483)
* **New Features**
  * Phandle support for device-to-device property references.
  * Recognition of #define-style declarations in device trees.
  * Device nodes may include optional aliases alongside node names.

* **Improvements**
  * Flatter, consistent device hierarchy processing for generation.
  * Error and log messages now reference node names for clearer diagnostics.

* **Other**
  * Added a static ESP32-based device tree and minor DTS comment updates.
2026-02-05 23:10:11 +01:00
Fuji Pebri ecc0a9c076 Added support for 1-line bus width SDMMC device mode (#482) 2026-02-05 22:46:55 +01:00
Ken Van Hoeylandt 4fe4faf422 Devicetree updates (#481)
* **New Features**
  * Added I2S audio support (i2s0) for LilyGO TLora Pager, M5Stack Cardputer (standard & Adv), M5Stack Core2, M5Stack CoreS3, and Guition JC1060P; moved i2s0 entry in LilyGO TDeck.

* **Chores**
  * Device-tree grammar now separately recognizes and ignores line (//) and block (/* */) comments.
  * Added reference docs to severa DTS files

* **Documentation**
  * Reworked ideas/roadmap
2026-02-05 19:31:47 +01:00
Ken Van Hoeylandt a1c835e073 I2S driver implementation (#480)
* **New Features**
  * ESP32 I2S controller support: runtime-configurable digital audio I/O with read/write/set/get operations and multiple formats.

* **Board Support**
  * LilyGO T-Deck device tree entry added to enable I2S peripheral pin configuration.

* **Documentation**
  * New/updated bindings and descriptors for I2S, I2C, GPIO, and root nodes.

* **Other**
  * Added GPIO "no pin" sentinel and exposed I2S controller API symbols.
2026-02-04 23:40:16 +01:00
Ken Van Hoeylandt 9a672a30ff Kernel and TactilitySDK improvements (#479)
* **New Features**
  * Expanded public device and driver APIs (accessors, sync, lifecycle, binding) and a module construct+start helper.
  * Added kernel symbol registry and new exported symbols (lvgl, C++ nothrow, I2S APIs, additional math funcs).

* **Refactor**
  * Renamed device traversal APIs for consistency (device_for_each*).
  * Moved inline helpers to explicit public declarations.

* **Chores**
  * Replaced several shell release scripts with Python-based SDK release tooling.
* **Style**
  * Header naming consistency fixes.
2026-02-03 23:24:37 +01:00
Ken Van Hoeylandt 9cc96fd32b M5Stack PaperS3 implementation (#478)
Selectively imported code from @juicecultus [fork](https://github.com/juicecultus/Tactility) with some changes/additions from me.
2026-02-03 21:22:40 +01:00
Ken Van Hoeylandt a935410f82 Kernel and buildscript improvements (#477)
* **New Features**
  * Centralized module management with global symbol resolution
  * Level-aware logging with colored prefixes and millisecond timestamps

* **Breaking Changes**
  * ModuleParent hierarchy and getModuleParent() removed
  * Logging API and adapter model replaced; LogLevel-driven log_generic signature changed

* **Improvements**
  * Unified, simplified module registration across build targets
  * Tests updated to reflect new module lifecycle and global symbol resolution
2026-02-03 08:35:29 +01:00
Ken Van Hoeylandt 1a61eac8e0 Export more symbols (#476)
* **Export more symbols:**
  * Expanded standard library support with additional math functions (trigonometric, exponential, and rounding operations), string comparison, directory operations, and locale configuration
  * Added C++ static initialization guard utilities to enhance object initialization support
2026-02-02 08:18:51 +01:00
Ken Van Hoeylandt 1f9e7f82fd Implement support for module symbols (#475)
* **New Features**
  - Adds module symbol support and per-module symbol tables, including LVGL symbol exports moved into a dedicated table.
* **API**
  - Adds symbol-resolution APIs and an accessor to enable dynamic lookup between modules.
* **Bug Fixes / Chores**
  - Explicitly initializes module symbol pointers across device and platform modules to avoid uninitialized state.
* **Tests**
  - Updates tests to account for symbol pointer initialization.
2026-02-02 07:50:43 +01:00
Ken Van Hoeylandt 9f721e6655 Refactor LVGL code into kernel module (#472)
* **New Features**
  * Added a standalone LVGL module and enabled LVGL support in the simulator for richer local UI testing.

* **Refactor**
  * HAL and LVGL split into distinct modules; startup and device attach/detach flows reorganized for clearer lifecycle management.
  * Public APIs tightened with clearer nullability/documentation.

* **Bug Fixes**
  * More consistent LVGL start/stop and device attach/detach behavior for improved stability.
2026-02-01 22:57:45 +01:00
Ken Van Hoeylandt 3fe1dc0312 Create hal-device module, fix GPIO, fix tests, fix TactilityC (#471)
* **New Features**
  * Added a HAL device module providing device enumeration, type queries and a HAL↔kernel bridge.

* **Improvements**
  * Integrated HAL module into startup; standardized module names, includes and lifecycle logging; safer file append behavior; broader build support.

* **API Changes**
  * Driver lifecycle now uses explicit add/remove semantics; C and HAL device type/lookup APIs clarified.

* **Chores**
  * Added module README and Apache‑2.0 license; updated build configuration to include the new module.

* **Fixes**
  * Updated tests and object file handling to behave correctly.
2026-02-01 01:05:16 +01:00
Ken Van Hoeylandt 5993ceb232 Rename device modules (#470)
Standardised device module identifiers across all supported devices to use consistent naming conventions with lowercase alphanumeric and hyphen-separated formats.
2026-01-31 13:11:36 +01:00
Ken Van Hoeylandt 399dca5e14 Partial reimplementation of TactilityC GPIO (#469)
* **New Features**
  * Added a GPIO hardware abstraction layer for reading pin levels from applications.
  * Applications can now query the number of available GPIO pins so they can adapt to different devices.
* **Chores**
  * Integrations updated so GPIO capabilities are discoverable and exported to running applications.
2026-01-31 12:34:45 +01:00
Ken Van Hoeylandt c9185740d7 Kernel improvements (#468)
* **New Features**
  * Plugin-style modules for platforms and devices with start/stop lifecycle and a runtime-consumable device tree array.

* **Refactor**
  * Consolidated initialization into a kernel/module startup flow.
  * Generated devicetree artifacts moved to the build Generated directory.

* **Changes**
  * Removed legacy no-op registration hooks and I2C lock/unlock wrappers.
  * Driver ownership and private state moved to explicit module/owner model.
  * Added ERROR_NOT_ALLOWED error code.
2026-01-31 09:18:02 +01:00
Shadowtrance d62314f41f Guition JC3248W535C (#467)
* Guition JC3248W535C

Files app fix
alert dialog and selection dialog fixes
symbol export

* Update Axs15231bDisplay.cpp

* Update Axs15231bDisplay.cpp
2026-01-31 00:01:12 +01:00
Ken Van Hoeylandt 87ca888bb4 Create DTS files for all devices and implement I2C changes (#466)
Devictree changes:
- Create DTS files for all remaining devices
- Update corresponding `devicetree.yaml`
- Remove `i2c` configuration from corresponding `tt::hal::Configuration`

Apps & HAL:
- Removed I2C Settings (we'll make a new one later after I rework that part of the HAL)
- Delete TactilityC GPIO and I2C functionality
- Delete Related SystemEvent types
- Refactor `tt::hal::i2c` to only use `struct Device*` wrapping

Scripting:
- Fix DevicetreeCompiler boolean parsing
- Create `build-all.py`
2026-01-29 22:01:19 +01:00
Ken Van Hoeylandt 71f8369377 TactilityKernel improvements (#464)
* **New Features**
  * Thread API with lifecycle, priority, affinity and state monitoring
  * Timer subsystem: one-shot/periodic timers, reset, pending callbacks, expiry queries
  * Expanded I²C: register-level ops, bulk writes, presence checks, ESP32 integration and new config properties
  * GPIO controller: pin level and options APIs
  * Error utilities: new error code, error-to-string, timeout helper and common macros
  * Device construction helpers (construct+start)

* **Tests**
  * New unit tests for thread and timer behavior

* **Documentation**
  * Expanded coding style guide (files/folders, C conventions)
2026-01-28 23:58:11 +01:00
Shadowtrance f6ddb14ec1 Dashboard auto refresh toggle (#465)
asset sync now works (AssetVersion)...could probably do with some improvements.
disable auth username and password if not enabled.
2026-01-28 21:15:36 +01:00
Ken Van Hoeylandt d551e467b8 Moved and renamed files for consistent C code style (#463)
* **Documentation**
  * Added new C coding style guide detailing naming conventions for files, directories, macros, constants, variables, functions, and type definitions with illustrative examples.
  * Updated C++ coding style documentation with clarifications on C naming conventions and header directory organization patterns.

* **Refactor**
  * Updated header include paths throughout the codebase to use lowercase naming conventions consistently.
2026-01-27 20:17:33 +01:00
Shadowtrance c05d46a28c Screensavers (#462)
Adds screensavers in addition to the backlight idle off. 
More info in screensavers.md

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

* **New Features**
  * Added a screensaver system with multiple styles (Bouncing Balls, Mystify, Matrix Rain) and a common screensaver interface; auto-starts after inactivity, dismisses on interaction, and supports auto-off/backlight behavior.
  * New Display setting and UI dropdown to choose and persist the screensaver.

* **Documentation**
  * Added comprehensive screensaver docs covering usage, extension, and configuration.

* **Chores**
  * Registered the display-idle service.

* **Bug Fixes**
  * Updated LVGL API calls to match renamed functions.

<sub>✏️ Tip: You can customize this high-level summary in your review settings.</sub>
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-01-27 17:21:16 +01:00
Ken Van Hoeylandt e6abd496f9 Various improvements (#461)
* **New Features**
  * Time and delay utilities added (ticks, ms, µs); SD card now uses an expansion-header CS pin; HTTP downloads warn when run on the GUI task and yield to avoid blocking.

* **Bug Fixes / Reliability**
  * Many hard-crash paths converted to guarded checks to reduce abrupt termination and improve stability.

* **Tests**
  * Unit tests added to validate time and delay accuracy.

* **Chores**
  * License header and build/macro updates.
2026-01-27 08:04:21 +01:00
Ken Van Hoeylandt 619b5aa53b M5Stack Tab5 support (#449)
* **New Features**
  * Added support for M5Stack Tab5: integrated display (ILI9881C MIPI-DSI), touch, and SD card.

* **User Interface**
  * Changed toolbar label from "External Apps" to "Installed Apps."

* **Improvements**
  * Clarified boot log messages ("Init boot"/"Init boot failed") for better diagnostics.
  * Firmware build matrix and configuration updated to include the M5Stack Tab5 target.
2026-01-27 00:18:53 +01:00
Shadowtrance 10381b10cd Chat app update, EspNow v2 & GPS Info (#460) 2026-01-26 17:32:57 +01:00
Ken Van Hoeylandt dfe2c865d1 TactilityKernel improvements and more (#459) 2026-01-25 23:54:33 +01:00
Ken Van Hoeylandt 96eccbdc8d Add tests and update licenses (#458)
Replace LGPL from past commit with Apache License 2.0 for the newly created projects:
- in Platforms/*
- TactilityKernel

Add license headers to source code in:
- in Platforms/*
- TactilityKernel
- TactilityFreeRtos

Updated LICENSE.md
2026-01-24 21:33:44 +01:00
Ken Van Hoeylandt 2839ea4c35 Update domain name and related URLs (#457) 2026-01-24 18:18:55 +01:00
Ken Van Hoeylandt 51b9547e99 Revert last change (#456) 2026-01-24 16:38:59 +01:00
Ken Van Hoeylandt d3797abf4e Update GitHub group references (#455)
ByteWelder -> TactilityProject
2026-01-24 16:34:04 +01:00
Ken Van Hoeylandt 4b6ed871a9 Implemented TactilityKernel and DevicetreeCompiler, updated licenses & copyrights (#452)
**New features**

- Created a devicetree DTS and YAML parser in Python
- Created new modules:
  - TactilityKernel (LGPL v3.0 license)
  - Platforms/PlatformEsp32 (LGPL v3.0 license) 
  - Platforms/PlatformPosix (LGPL v3.0 license)
  - Tests/TactilityKernelTests

Most boards have a placeholder DTS file, while T-Lora Pager has a few devices attached.

**Licenses**

Clarified licenses and copyrights better.

- Add explanation about the intent behind them.
- Added explanation about licenses for past and future subprojects
- Added more details explanations with regards to the logo usage
- Copied licenses to subprojects to make it more explicit
2026-01-24 15:47:11 +01:00
Shadowtrance 0d16eb606f ESP-NOW chat & P4 fixes (#454)
* Espnow chat fix

Fixes chat app not appearing and coexistence with wifi STA mode.
Wifi OFF and obviously not connected, espnow starts.
Wifi ON and connected, espnow starts.
Wifi ON and NOT connected, espnow starts.

* Fix P4 build
2026-01-24 12:42:49 +01:00
Shadowtrance b8214fd378 Trackball Pointer Mode & driver rewrite (#453) 2026-01-23 17:30:13 +01:00
Shadowtrance 01ffe420eb Webserver addition and TactilityC symbols (#451) 2026-01-21 21:47:59 +01:00
Ken Van Hoeylandt c98cb2bf10 Add Guition JC1060P470CIWY and update other Guition device IDs (#447)
This commit contains @josemalm32 's  implementation for the Guition JC1060P470CIWY  (see https://github.com/ByteWelder/Tactility/issues/427)

I've added these changes:
- Updated the branch for the new logging method
- Updated the branch for the PR that I mentioned in the above linked issue
- Replaced the manually pasted in esp_lcd_jd9165 driver with the one from the component registry
- Updated Spanish to English
- Updated all drivers' mutexes/locks
- Fixed the display color format
- Fixed bug in power deinit
- Renamed I2C bus in config
- Added device to continuous integration
- Renamed several Guition devices from CYD to Guition
- Fix for `EspLcdDisplayV2` init for when features are not supported
- Pin esp_wifi_remote to version 1.2.3
- Fix in `WifiManage` logging
- Fix for `WifiEsp.cpp`'s check for wifi presence
- Fix for `WifiEsp`'s scan list logging
- Fix for `gcc_soft_float_symbols` in TactiltyC
2026-01-07 22:41:45 +01:00
Ken Van Hoeylandt f620255c41 New logging and more (#446)
- `TT_LOG_*` macros are replaced by `Logger` via `#include<Tactility/Logger.h>`
- Changed default timezone to Europe/Amsterdam
- Fix for logic bug in unPhone hardware
- Fix for init/deinit in DRV2605 driver
- Other fixes
- Removed optimization that broke unPhone (disabled the moving of heap-related functions to flash)
2026-01-06 22:35:39 +01:00
Ken Van Hoeylandt 719f7bcece Fixes and improvements (#445)
- Remove unnecessary CS work-around for Cardputers
- Don't compile WifiMock when not necessary
- Fix for running apps on devices without SPIRAM
- Disable backlight dimming by default
2026-01-04 14:27:10 +01:00
Ken Van Hoeylandt 2ca8ae62fb Various fixes (#444)
- Add missing symbols for TactilitySDK
- Disable display idle logic when there's no LVGL display
2026-01-04 01:50:33 +01:00
Ken Van Hoeylandt fa544f9b3c Add missing timer methods to TactilityC (#443) 2026-01-03 22:34:51 +01:00
Ken Van Hoeylandt 812c2901db TactilitySDK updates (#442)
- Removed custom `TickType`
- Removed TactilityC functionality that is now covered by TactilityFreeRtos
2026-01-03 22:00:31 +01:00
Ken Van Hoeylandt 524b197105 Add TactilityFreeRtos to TactilitySDK (#441)
- TactlitySDK updates fro TactilityFreeRtos
- Enable auto-uploading of SDKs to the CDN when merging code
2026-01-03 16:28:07 +01:00
Ken Van Hoeylandt 7283920def Create TactilityFreertos subproject (#440) 2026-01-03 00:19:40 +01:00
Shadowtrance a4dc633063 Feature additions (#434)
Lots of things "ported" over from the "enhanced" fork. With some adjustments here and there.

KeyboardBacklight driver (for T-Deck only currently)
Trackball driver (for T-Deck only currently)
Keyboard backlight sleep/wake (for T-Deck only currently...also requires keyboard firmware update)
Display sleep/wake
Files - create file/folder
Keyboard settings (for T-Deck only currently)
Time & Date settings tweaks
Locale settings tweaks
Systeminfo additions
Espnow wifi coexist

initI2cDevices - moved to T-deck init.cpp / initBoot
KeyboardInitService - removed,  moved to T-deck init.cpp / initBoot
Adjusted TIMER_UPDATE_INTERVAL to 2 seconds.
Added lock to ActionCreateFolder

Maybe missed some things in the list.

Display wake could do with some kind of block on wake first touch to prevent UI elements being hit when waking device with touch. Same with encoder/trackball/keyboard press i guess.

The original code was written by @cscott0108 at https://github.com/cscott0108/tactility-enhanced-t-deck
2026-01-02 12:14:55 +01:00
Shadowtrance feaeb11e49 Added TactilityC symbols and DPI updates(#438)
+ btt-panda-touch size correction and dpi update
+ wt32-sc01-plus dpi update
2025-12-29 18:16:08 +01:00
Ken Van Hoeylandt 3fc2ff8bc6 Split off RecursiveMutex from Mutex (#437)
* Split off RecursiveMutex from Mutex

* Fix

* Code quality
2025-12-28 12:30:54 +01:00
Ken Van Hoeylandt f48654d3dc Various fixes and improvements (#435)
- Fix for `sdkconfig` generation: the keys that contained the MCU type in its name weren't properly upper-cased.
- Moved WiFi configuration property files to the user data path of the app instead of a fixed location.
- Moved more properties from `device.py` to `sdkconfig/default.properties`
- Fix for `device.cmake` device id parsing: separate basic property parsing from device id validation
- Created internal `tt::service::wifi::findServiceContext()`
- Changed Wi-Fi service id to lowercase (will change it for other services later)
2025-12-25 15:41:39 +01:00
Ken Van Hoeylandt 261796068e Fix for simulator SDL settings (#433) 2025-12-22 22:35:59 +01:00
Ken Van Hoeylandt 134e0b34b6 Fix for simulator build and improve ESP-IDF build (#432) 2025-12-22 21:16:51 +01:00
Shadowtrance 6c4a9975a4 Added TactilityC symbols (#429) 2025-12-18 09:45:53 +01:00
Ken Van Hoeylandt 776e3cd4c0 Fix Wi-Fi provisioning from /data (#428)
- Import from `/data/settings` instead of `/data`
- Removed unnecessary functions
- Header syntax cleanup
2025-12-17 14:38:29 +01:00
Ken Van Hoeylandt 76686e5c90 Fix for sdkconfig generation with device.py (#426) 2025-12-06 15:22:53 +01:00
Ken Van Hoeylandt cbaa32c27e Add LVGL lv_obj_ functions (#425) 2025-12-06 12:02:41 +01:00
NellowTCS 65d3d55cc4 Various fixes and improvements (#424)
- Read WiFi provisioning from /data
- Fix for finding apps at /data
- Expose more LVGL functions with TactilityC
2025-12-05 13:18:23 +01:00
Shadowtrance 62124541e9 WT32 SC01 Plus (#416) 2025-11-28 17:40:24 +01:00
NellowTCS 8de88dd3fd Software Rotation for ST7789 i8080 Driver (#422) 2025-11-27 22:40:33 +01:00
Ken Van Hoeylandt c6cc4034df Fix for CDN publishing script (#423) 2025-11-25 20:42:43 +01:00
Ken Van Hoeylandt b565d56029 Implement support for ESP32 C6 and P4 SOCs (#421)
- Implement generic ESP32 devices
- Updated GitHub Actions to first build the SDKs. These are now based on the generic device implementations and the build act as a filter before compiling the dozens of other devices. It should save on resources when boards fail to compile.
- Adapted code to C6 and P4 differences, heavily borrowed from from https://github.com/ByteWelder/Tactility/pull/394 written by @marciogranzotto, with some changes of my own
- Updated `device.py` to make the `[display]` section optional
2025-11-24 19:28:07 +01:00
Ken Van Hoeylandt fec8033fd7 Fixes for minitar related to app install (#420) 2025-11-24 00:22:12 +01:00
Ken Van Hoeylandt 6ab6ae5686 Merge develop into main (#419)
- Apply IRAM optimization to all platforms instead of only ESP32
- Implement performance optimizations
- Created `tt::hal::uart::open(uart_port_t)`
2025-11-23 00:11:08 +01:00
Ken Van Hoeylandt eba1f8955a Merge develop into main (#418)
- WiFi code cleanup
- When WifiConnect opens and SSID is filled in, automatically focus on the password field
- When no touch screen is present, toolbar close buttons should be automatically selected
- When `device.py` selects a device, print it on screen
2025-11-14 23:29:20 +01:00
Ken Van Hoeylandt a4f4784ed9 Add low memory warning (#417) 2025-11-14 15:43:00 +01:00
Ken Van Hoeylandt dddca1ea76 Generate commit hash and timestamp for CDN (#415) 2025-11-14 00:23:25 +01:00
Ken Van Hoeylandt c1ff024657 Rename Boards/ to Devices/ (#414) 2025-11-13 23:50:43 +01:00
Shadowtrance c7c9618f48 Waveshare GEEK (#413) 2025-11-13 22:32:02 +01:00
Ken Van Hoeylandt 0df6b78bd6 CDN script fixes (#412) 2025-11-12 23:28:16 +01:00
Ken Van Hoeylandt 7918451699 Replace sdkconfig with device.properties (#411) 2025-11-12 22:36:08 +01:00
NellowTCS 8335611796 Board Support: Heltec v3 (#407) 2025-11-05 09:04:40 +01:00
Shadowtrance 0d8c0a37cc LilyGo T-Display (#406)
+ expose lvglSwapBytes setting for the St7789Display driver.
+ updated all relevant boards accordingly.
2025-11-02 16:56:03 +01:00
NellowTCS ab2aa2c4d4 Access to the "/data" partition via USB Mass Storage (#405) 2025-11-02 16:26:35 +01:00
Ken Van Hoeylandt e2ec39304c Fixes for enums in TactilityC (#404) 2025-11-01 09:38:32 +01:00
Ken Van Hoeylandt 569cce38fa Implement automatic CDN publishing (#403) 2025-10-31 23:39:41 +01:00
Ken Van Hoeylandt 9ae3e48600 Create bundle-firmware action for release branch (#401) 2025-10-30 22:46:52 +01:00
Shadowtrance 388c2cfe4b BigTreeTech Panda Touch / K Touch (#402) 2025-10-30 22:09:09 +01:00
NellowTCS adea6678a5 New board: T-Display S3 (no touch) (#398) 2025-10-29 20:12:46 +01:00
Ken Van Hoeylandt 4a343e58cc Update version to 0.6.0 (#400) 2025-10-29 19:25:59 +01:00
Ken Van Hoeylandt 61277e74b8 Align board project names with board ids (#399)
To avoid keeping track of a list that maps board project names to board ids.
Because of this change, we don't have to manually edit `boards.cmake` anymore when adding a new board.
2025-10-28 09:07:54 +01:00
Ken Van Hoeylandt efd3c6041c Cardputer adv and more (#395)
- Fixed TCA8418 driver
- Updated T-Lora Pager for TCA driver fixes
- Fixed issues with T-Lora keyboard driver
- Implemented Cardputer Adv
- Cleanup of Cardputer (regular)
- Fix sdkconfig for E32R28T and E32R32P
- Disable Wi-Fi on boot (was accidentally pushed before)
2025-10-28 00:39:31 +01:00
NellowTCS 647678ff82 New board: CYD-E32R32P (#393) 2025-10-27 19:59:53 +01:00
Ken Van Hoeylandt 8115ca4fd9 Merge develop into main (#392)
- Refactor `Ili934xDisplay` to use `EspLcdSpiDisplay` as base class
- Update `St7789Display` for changes to `EspLcdDisplayV2` related to ILI934x driver
- Updated all board driver implementations for ILI934x driver changes
- Simplified board configurations:
  - All boards now have a `Configuration.cpp`
  - All board config's headers are removed
  - Removed `Boards.h`
- Fix for untar-ing large files
- Increase main task stack size to avoid stackoverflow when downloading apps in App Hub
- Reduce SPI frequency for ST7789 displays (according to spec)
2025-10-26 23:26:28 +01:00
Ken Van Hoeylandt db6d3b4acb Merge develop into main (#391)
## Improvements

- Created new base driver classes: `EspLcdDisplayV2' and `EspLcdSpiDisplay`
- Updated `St7789Display` to implement `EspLcdSpiDisplay`
- Updated all boards with ST7789 display

## Fixes

- Ensure that `tmp/` is created on startup (for all writeable filesystems)
- Fix for `lv_list` padding on small screen devices
- Fix for `PreferencesEsp` not processing result when writing string to NVS

## Other

- Remove unused build scripts
2025-10-26 13:50:17 +01:00
Ken Van Hoeylandt 37420db000 Update GitHub actions to use matrices (#389) 2025-10-25 22:34:30 +02:00
Ken Van Hoeylandt b067978c16 Change cJSON submodule source (#388) 2025-10-25 20:56:29 +02:00
Ken Van Hoeylandt 09f8031bff Fix for open Wi-Fi (#387)
Don't encrypt password if there's no password set
2025-10-25 18:57:43 +02:00
Giasone 1450ca319d Add CYD-2432S028RV3 board support (#385) 2025-10-25 18:16:55 +02:00
Ken Van Hoeylandt c139300a58 Thread+locking improvements and more (#386) 2025-10-25 18:08:46 +02:00
Ken Van Hoeylandt d0d05c67ca PR review fixes (#384) 2025-10-25 13:47:43 +02:00
Ken Van Hoeylandt f660550f86 App hub and more (#383)
- Added `AppHub` app
- Added `AppHubDetails` app
- Added `cJSON` dependency
- Renamed `AppSim` module to `FirmwareSim`
- Added extra `tt::app::alertdialg::start()`
- Renamed `addApp()`, `removeApp()`, `findAppById()` and `getApps()` to `addAppManifest()`, `removeAppManifest()`, `findAppManifestById()` and `getAppManifests()`
- Added `tt::lvgl::toolbar_clear_actions()`
- Added `tt::network::EspHttpClient` as a thread-safe wrapper around `esp_http_client`
- Added `tt::network::http::download()` to download files
- Added `tt::network::ntp::isSynced()`
- When time is synced, the timestamp is stored in NVS flash. On boot, it is restored. This helps SSL connections when doing a quick reset: when WiFi reconnects, the user doesn't have to wait for NTP sync before SSL works.
- Added `tt::json::Reader` as a `cJSON` wrapper
- Added `int64_t` support for `Preferences`
- Added `int64_t` support for `Bundle`
- Added dependencies: `cJSON`, `esp-tls`
- When time is synced via NTP, disable time sync.
- Added docs to 'tt::file::` functions
- Added `tt::string::join()` that works with `std::vector<const char*>`
- Fixed `tt::file::getLastPathSegment()` for the scenario when a path was passed with only a single segment
- Set `CONFIG_ESP_MAIN_TASK_STACK_SIZE=5120` (from about 3k) for all boards
- Set `CONFIG_MBEDTLS_SSL_PROTO_TLS1_3=y` for all boards
2025-10-25 00:20:48 +02:00
Ken Van Hoeylandt e9384e0c11 Merge develop into main (#381)
Various fixes and improvements
2025-10-22 23:15:33 +02:00
Ken Van Hoeylandt 9c5a427a34 Merge develop into main (#377)
- Extract web server from `DevelopmentService` into a separate class: `HttpServer`
- Export more functions in `tt_init.cpp`
2025-10-16 18:59:23 +02:00
Ken Van Hoeylandt d8346998ce Merge develop into main (#368)
New boards:
- LilyGO T-Dongle S3
- M5Stack StickC Plus
- M5Stack StickC Plus2

New drivers:
- AXP192: power control via I2C
- ButtonControl: GPIO button input as LVGL device

Other changes:
- Updated implementation of AXP192 driver for Core2 board
- Fix launcher UX for vertical layout
- Fix error when properties file had an empty line
- Add `__floatsidf` to `tt_init.cpp`
2025-10-14 20:39:23 +02:00
Ken Van Hoeylandt 3a59540365 Export more functions with TactilityC (#367) 2025-10-09 23:42:28 +02:00
Ken Van Hoeylandt d25603166a Merge develop into main (#365)
### TactilityC
- Create UART HAL
- Refactor locking APIs
- Bind new C++ functionality
- Bind new LVGL functionality

### Apps
- Remove Serial Console as it has been ported as an external app
2025-10-08 23:16:45 +02:00
Ken Van Hoeylandt 17b4fc6a47 Created app settings and app details applications (#364) 2025-10-07 22:13:01 +02:00
Ken Van Hoeylandt 45a8379426 Changed TactilityC/TactilitySDK license from MIT to Apache V2.0 license (#363) 2025-10-05 23:07:09 +02:00
Ken Van Hoeylandt 1e4234d895 Refactored app registration (#362)
`AppManifest` is renamed to `AppRegistration` because it was confusing with the actual app manifest (as in: the properties file).
Instead of passing a pointer, we're now passing the struct by value.
I also moved some files around in `TactilityC/`.
2025-10-05 21:02:34 +02:00
Ken Van Hoeylandt 2cb413c3d1 Merge develop into main (#361) 2025-10-05 19:37:59 +02:00
Ken Van Hoeylandt 5777a1381b Remove GPIO and Calculator app (#360) 2025-10-05 19:00:05 +02:00
Ken Van Hoeylandt 15de4e20b8 TactilityC improvements (#359)
- Expose HAL Configuration's `UiScale`
- Updated docs
- Fix for `tt_timer_alloc()`
- Changed `enum class` to regular C `enum`
- Renamed enums (add prefix)
- Include `<stdbool.h>` where needed
2025-10-05 18:31:54 +02:00
Ken Van Hoeylandt 3802679de4 File locking and DevelopmentService improvements (#358)
- Moved `file::getlock(path)` from `Tactility` to `TactilityCore`
- Changed all existing `file::*` functions to implement locking by default
- Removed all manual locking where `file::*` functions were used
- When `DevelopmentService` receives a file, it doesn't try to allocate it all in memory. This fixes going out-of-memory on devices without PSRAM.
- Fix for TactilityC include
2025-10-05 16:16:55 +02:00
Ken Van Hoeylandt a05a6afaaf Path fixes for simulator (#357) 2025-10-03 22:12:55 +02:00
Ken Van Hoeylandt efd9662cfc Fixed path for system.properties (#356) 2025-10-03 19:53:03 +02:00
Ken Van Hoeylandt 00347cbd29 TactilityC and Toolbar improvements (#355) 2025-10-02 23:40:40 +02:00
Ken Van Hoeylandt b214a3358e Merge develop into main (#353)
## TactilityC
- Add `tt_lvgl_lock()` and `tt_lvgl_unlock()`
- Add `tt_thread_set_affinity()`
- Add support for STL symbols

## Other
- Add `Thread::setAffinity()`
- `GuiService`: replace `#define` with `constexpr`
- Remove log storage and log app for now
- Split up ELF symbols into more groups
2025-10-01 23:07:47 +02:00
Ken Van Hoeylandt c7621b5e4c SDK improvements (#352)
TactilityC additions for:
- C randomization functions
- Tactility app paths
- Tactility locks
2025-09-29 22:45:14 +02:00
Ken Van Hoeylandt 6dc4f698c9 SDK release folder changed (#351)
This new way matches the `tactility.py`'s `.tactility/` folder names.
2025-09-29 21:49:36 +02:00
Ken Van Hoeylandt f97ca26b01 Changed SDK release folder naming (#350) 2025-09-29 08:04:11 +02:00
Ken Van Hoeylandt 98bbea3e9c Add lv_spinbox functions to TactilityC (#349) 2025-09-27 19:49:27 +02:00
Ken Van Hoeylandt f6cdabf3c0 Merge develop into main (#348)
## App state

Improved app state management in `LoaderService` and `GuiService`:

- Re-ordered some of the state transitions
- Hardened `GuiService` for repeated events (that might trigger a re-render of an app that's already rendered)
- Validate state transitions in `LoaderService` and crash if an app transitions from the wrong state to the next one.

## LoaderService

- Removed `tt::loader::` functions and expose `LoaderService` interface publicly.
- Implement `stopAll()` and `stopAll(id)` which stops all instances of an app, including any apps that were launched by it.
- Rename `stop()` functions to `stopTop()`
- Created `stopTop(id)` which only stops the top-most app when the app id matches.
- Moved `loader::LoaderEvent` to `loader::LoaderService::Event`
- Changed app instance `std::stack` to `std::vector`

## Improvements

- `ElfApp`: error 22 now shows a hint that `main()` might be missing
- Starting, installing and uninstalling apps now stops any running app (and its children) on the stack

## Bugfixes

- `HttpdReq` out of memory issue now shows an error message and doesn't crash anymore (this would happen on devices without PSRAM with WiFi active, when an app was installed)
- `GuiService::hideApp()` lock should not wait for timeout and now waits indefinitely
- `Buildscript/release-sdk-current.sh` deletes the previous local release before building a new one

## Code correctness

- App classes were made `final`
- Apps that had a `void start()` now have a `LaunchId start()`
- `tt::app::State`: renamed `Started` to `Created` and `Stopped` to `Destroyed` to properly reflect earlier name changes
2025-09-27 18:04:09 +02:00
Ken Van Hoeylandt dcf28d0868 elf_loader refactored and added more symbols (#347) 2025-09-27 09:18:51 +02:00
Ken Van Hoeylandt 9cc58099b4 Remove external apps (#346) 2025-09-23 23:21:58 +02:00
Ken Van Hoeylandt 1216862aec Fix for touch configuration of Waveshare Touch LCD 1.28" 2025-09-23 17:49:59 +02:00
Ken Van Hoeylandt 7ad0a3cb04 Create GPIO HAL (#344) 2025-09-22 23:24:01 +02:00
Ken Van Hoeylandt bab3eb19bc Merge develop into main (#343)
- Refactor `AppManifest`: add new fields and rename existing ones
- Parse and validate the manifest from an app that is being installed.
- Remove deprecated `scoped()` from `Lock`
- Create `Tactility/Paths.h`
- App loading at boot now properly parses the manifest files of external apps
- Properly lock both source and destination locations during app install
- Remove LVGL path variants from `AppPaths` and `ServicePaths`
- Removed `xPath` base classes for apps and services. There's now `AppPaths` and `ServicePaths`.
- Renamed app and service paths: "data" and "system" paths are now "user data" and "assets"
2025-09-22 08:03:21 +02:00
Ken Van Hoeylandt a4d15b2a1e Add esp_http_client and expose it to TactilityC (#341) 2025-09-20 13:07:34 +02:00
Ken Van Hoeylandt 41ad569154 UI/UX improvements for small screen devices (#340)
- Improved UI/UX of various WiFi apps to make it compatible with Cardputer.
- Improved UI/UX of Serial Console to make it compatible with Cardputer.
- Boot app now shows a smaller logo on Cardputer
- CrashDiagnostics app: Use different text if no touch screen is present
2025-09-20 00:19:29 +02:00
Ken Van Hoeylandt faab6d825f Merge develop into main (#339)
- Update ILI9341 driver to v2.0.1
- Lots of code cleanup for apps
- Refactor app "type" into "category" and added flags to the manifest (for show/hide statusbar and for hidden apps)
- Rename some ElfApp-related functionality and improved the way the static data was managed
- Rename "filebrowser" to "files"
- Added cstring functions to tt_init.cpp
- Minor fix in Boot app
- Updated external apps for SDK changes
2025-09-17 23:42:49 +02:00
Ken Van Hoeylandt a2af95b92d Merge develop into main (#338)
### Cardputer:
- Fix keyboard issue with up/down button conflict when selecting switch
- Fix backlight flickering

### UI improvements
- Removed a 3 pixel border that went around the entire desktop environment
- Improved system layout (GuiService)
- Statusbar: improved layout (mainly margin/padding)
- Toolbar: fixed margin/padding of all buttons, fixed alignment of all content
- Improved layout/UI of many apps

### Other
- Update LVGL to 9.3.0 official release (was dev version)
2025-09-16 23:12:07 +02:00
Ken Van Hoeylandt 53b711584f Merge develop into main (#337)
- Implement `UiScale` in `hal::Configuration`: small screens with no touch can now opt for a more optimized experience (e.g. Cardputer, Waveshare 1.47, Waveshare 1.3", etc.)
- Fix for Cardputer UART configuration and added I2C configuration
- Fix for software keyboard bug in Gui
- Removed deprecated fields from `hal::Configuration`
- Updated the simulator devices to use the new HAL config
- add `bool tt::hal::hasDevice(Device::Type)`
- Cleanup of `AppList` app code
- Improve `Gpio` app for small screen devices
- Added various ESP32 GCC wrappers to wrap LVGL functions (with manipulations for small screen devices)
- Moved `Launcher` assets to `assets/` subfolder
- Optimized `Toolbar` for small screen devices
- Stop showing `system/` partition in `FileBrowser` because it's read-only and not very useful. Created `config::SHOW_SYSTEM_PARTITION` to override this behaviour.
- Hide apps when their required hardware isn't available (I2C, UART, PowerDevice)
- Fix for `CYD-2432S032C` DPI setting
2025-09-15 22:46:12 +02:00
Ken Van Hoeylandt ce8ac61d42 Implement CardputerPower and improve EstimatedPower driver (#335) 2025-09-14 15:42:10 +02:00
Ken Van Hoeylandt d5c94c7a8a Merge develop to main (#334)
- `FileBrowser` app now supports deleting directories (recursively)
- `DevelopmentService` and `tactility.py` now support the app `uninstall` action
- Fix crash for `File` app: implement file locking in several places (SPI SD cards need it)
- Remove I2C configuration from `M5stackCardputer.cpp` because we don't support the "Cardputer Adv" variant in that firmware.
2025-09-14 13:37:34 +02:00
Shadowtrance 7027da00b8 New waveshare boards + GC9A01 Display driver (#333) 2025-09-14 12:12:56 +02:00
Ken Van Hoeylandt 095c8146c3 Fix for Cardputer partition size (#332) 2025-09-14 02:32:58 +02:00
Ken Van Hoeylandt 62c613477a Implement M5Stack Cardputer + minor Tactility improvements (#331)
- Implement M5Stack Cardputer: display, SD card and keyboard
- `St7789Display` now supports a "gap" configuration
- `ElfApp` has improved errors
2025-09-14 02:25:10 +02:00
Ken Van Hoeylandt d83b98e99b Fix for I2C Scanner crash and updated CYD-2432S028R board (#330)
- Fix for crash when I2C Scanner is started and no I2C devices were found in the board configuration
- Add I2C and UART configurations to CYD-2432S028R board
2025-09-14 00:50:36 +02:00
Ken Van Hoeylandt ade86c99b4 Update gitmodules with proper URL to fix minitar link (#329) 2025-09-12 23:50:37 +02:00
Ken Van Hoeylandt 980b115f1d Add board: Waveshare S3 Touch LCD 1.47 (#328)
Touch isn't working yet.
Fixed a SPI lock issue.
2025-09-12 23:45:37 +02:00
Ken Van Hoeylandt 84049658db Merge develop into main (#327)
## New features
- Implemented support for app packaging in firmware and `tactility.py`: load `.app` files instead of `.elf` files. Install apps remotely or via `FileBrowser`.
- Ensure headless mode works: all services that require LVGL can deal with the absence of a display
- Service `onStart()` is now allowed to fail (return `bool` result)
- Added and improved various file-related helper functions

## Improvements
- Completely revamped the SystemInfo app UI
- Improved Calculator UI of internal and external variant
- Fix Chat UI and removed the emoji buttons for now
- Fix for toolbar bottom padding issue in all apps

## Fixes
- Fix for allowing recursive locking for certain SPI SD cards
& more
2025-09-12 16:24:22 +02:00
Ken Van Hoeylandt 068600f98c Post release changes (#326)
- Updated version to `0.6.0-dev`
- Updated docs
- Updated external app SDK version to `0.5.0`
2025-09-07 17:25:20 +02:00
Ken Van Hoeylandt fe7fdd8583 Fix HAL init when touch isn't configured (#325) 2025-09-07 12:47:58 +02:00
Ken Van Hoeylandt f26266ba76 Fix bug and update external app sdk versions (#324)
- Fix bug in Development app: when launching/stopping external app due to LVGL being stopped and a timer still being active (sometimes, as it's a race condition)
- Added TODO to fix the same bug in other apps
- Update external app SDKs to `0.5.0-SNAPSHOT`
2025-09-07 11:44:18 +02:00
Ken Van Hoeylandt 35a918c82b Merge develop into main (#323)
- Support larger ROM sizes
- Add storage status to SystemInfo app
- Made DisplayDevice more robust (drivers must specify LVGL/DisplayDriver support explicitly)
2025-09-07 10:17:44 +02:00
Ken Van Hoeylandt 63866fb371 Merge develop into main (#322)
- Fix crash in TactilityC
- Improve MAX_TICKS implementation (and renamed to TT_MAX_TICKS)
2025-09-06 18:43:11 +02:00
Ken Van Hoeylandt 457c21ffd8 Merge develop into main (#321)
- Implemented `TouchDriver` for `Xpt2046SoftSpi`
- Refactored system initialization
2025-09-06 17:17:39 +02:00
Ken Van Hoeylandt 65335578a4 Update CYD-E32R28T and fixed some minor issues (#319) 2025-09-06 15:12:40 +02:00
Ken Van Hoeylandt c0ed8f0a44 Merge develop into main (#318)
- Disable `DisplayDriver` for `St7701Display` (on CYD 4848)
- Improve `GraphicsDemo`: check for feature capability and show alert dialog if there's an issue
- `DevelopmentService` installs to `/data` instead of `/sdcard`
- Fixed `tt_app_get_data_directory()` and `tt_app_get_data_directory_lvgl()` (C++ to C)
- `tt_kernel.h` now defines `MAX_TICKS`
- `tt_init.cpp` now exports `esp_log()` which is required since ESP-IDF 5.5
2025-09-06 14:44:41 +02:00
NellowTCS a9b69010d8 CYD-E28R32T Implementation (#317)
- Add implementation for CYD-E28R28T. This implementation has the SD card working, using the same driver as the CYD-2432S028R.
- Edit .gitignore for some missing things.
- run chmod +x on some build scripts
- Make EspLcdDisplay's reference public for access from drivers (needed for driver St7789i8080)
> ```class EspLcdDisplay : public tt::hal::display::DisplayDevice {```
2025-09-06 13:52:46 +02:00
Ken Van Hoeylandt 1627b9fa85 Merge develop into main (#316)
- Updated all boards to use `hal::Configuration.createDevices`
- Updated all boards to use new directory structure and file naming convention
- Refactored `Xpt2046SoftSpi` driver.
- Created `Axp2101Power` device in `Drivers/AXP2101`
- Removed global static instances from some drivers (instances that kept a reference to the Device*)
- Improved `SystemInfoApp` UI: better memory labels, hide external memory bar when there's no PSRAM
- Fix for HAL: register touch devices after displays are registered
- Fix for Boot splash hanging on WiFi init: unlock file lock after using it
2025-09-03 22:05:28 +02:00
Rivair Sabino dos Santos 1deaf4c426 Refactored CYD-2432S028R board initialization, touch, and SD drivers (#314)
* feat(board): add support for CYD-2432S028R board and update XPT2046 driver

- Added CONFIG_TT_BOARD_CYD_2432S028R in Kconfig.
- Included support for CYD2432S028R in Boards.h and board.cmake.
- Updated Xpt2046Touch driver to use configuration->spiDevice instead of SPI2_HOST when creating the SPI handle.
- Note: SD card is not working on this board yet.

This commit introduces full support for the CYD-2432S028R board and improves the touchscreen driver flexibility by allowing dynamic SPI device configuration. SD card functionality still needs to be implemented.

* Added a new GitHub Actions job to build firmware for the cyd-2432s028r board
using the existing build-firmware action. This ensures continuous integration
coverage for the new board alongside other supported ESP32 variants.

* Removed unnecessary file

* Refactor CYD-2432S028R board initialization, touch, and SD drivers

- Updated board CMakeLists to use `XPT2046-Bitbang` instead of `XPT2046`.
- Added `YellowSdCard` support and initialized SD card in board configuration.
- Updated SPI pin assignments for touch and SD card to match hardware setup.
- Refactored touch driver to use bit-banged SPI with proper start/stop handling.
  - Touch adaptation was based on a merge of:
    - https://github.com/NellowTCS/Tactility/blob/main/Drivers/XPT2046-Bitbang/Source/XPT2046-Bitbang.cpp
    - https://github.com/ddxfish/XPT2046_Bitbang_Arduino_Library/blob/main/XPT2046_Bitbang.cpp
  - Calibration is currently static in code:
        Calibration cal = {
            .xMin = 100,
            .xMax = 1900,
            .yMin = 100,
            .yMax = 1900
        };
    This removes the need for manual touchscreen calibration, but code was adjusted to support dynamic calibration in the future.
- Added comments and constants for software SPI touch pins.
- Updated `YellowDisplay` to use new touch driver configuration.

* Refactor XPT2046 touch driver: replace Bitbang with SoftSPI implementation, update CMake and README files
2025-09-02 22:28:37 +02:00
Ken Van Hoeylandt 0f8380e8fe Merge develop into main (#313)
- Add app path get() functions to `TactilityC`
- Improved `Dispatcher` and `DispatcherThread`
- Improved `PubSub` (type safety)
- Created test for `DispatcherThread` and `PubSub`
- Save properties files on app exit (various apps) by posting it to the main dispatcher (fixes UI hanging briefly on app exit)
- Fixed bug with `SystemSettings` being read from the wrong file path.
- `loadPropertiesFile()` now uses `file::readLines()` instead of doing that manually
- Increased timer task stack size (required due to issues when reading a properties file for the very first time)
- General cleanup
- Created `EstimatedPower` driver that uses an ADC pin to measure voltage and estimate the battery charge that is left.
- Cleanup of T-Deck board (updated to new style)
2025-09-01 23:07:00 +02:00
Ken Van Hoeylandt 5cc5b50694 Merge develop into main (#312)
- Move various settings to `/data/settings` and `/sdcard/settings`
- Fix for `Gui` and `Statusbar` errors on startup (LVGL start)
- Implement Development service settings as properties file
- Rename `service::findManifestId()` to `service::findManifestById()`
- Renamed various classes like `BootProperties` to `BootSettings`
- Renamed `settings.properties` to `system.properties`. Code was moved to `settings` namespace/folder
- `DevelopmentSettings` is now in `settings` namespace/folder (moved from service)
2025-08-31 20:31:31 +02:00
Rivair Sabino dos Santos 5dfc6d70da Implemented CYD-2432S028R board and update XPT2046 driver (#308)
- Added CONFIG_TT_BOARD_CYD_2432S028R in Kconfig.
- Included support for CYD2432S028R in Boards.h and board.cmake.
- Updated Xpt2046Touch driver to use configuration->spiDevice instead of SPI2_HOST when creating the SPI handle.
- Note: SD card is not working on this board yet.

This commit introduces full support for the CYD-2432S028R board and improves the touchscreen driver flexibility by allowing dynamic SPI device configuration. SD card functionality still needs to be implemented.
2025-08-31 14:49:55 +02:00
Ken Van Hoeylandt 50007ea9ed Merge develop into main (#307)
## Launcher

- Launcher now has optional power button to show
- Launcher layout improvements
- Removed text from Launcher (translations with larger amounts of text did not fit small device formats)

## T-Lora Pager

- Implement power off (created `BQ25896` driver)
- Implemented haptics (created `DRV2605` driver project) and buzz on startup
- Reversed scroll wheel
- Created `TloraEncoder` device and relocated its logic from `TloraKeyboard`
- Disabled SPIRAM test to save 0.5 seconds of boot time (current boot time is very slow)
- Update `ST7796` esp_lcd driver to v1.3.4
- Fixed keyboard bug: delete queue in destructor
- Fixed driver dependencies: Avoiding usage of global static shared_ptr. Properly constructor-inject everywhere, or use `tt::hal::findDevices()`
- I2C configuration is now immutable (you cannot disable it anymore from the I2C Settings app, as it would break crucial drivers)
- Renamed I2C and UART subsystems to "Internal"

## Drivers

- On/off interface added to `PowerDevice`
- Created `tt::hal::Configuration.createDevices`, which is intended to replace all custom create calls for display, keyboard, etc.
- Created `EncoderDevice` as a `Device` subtype

## Other Improvements

- Changed `findDevices(type, function)` into a templatized function.
- Improved SD card mounting

## Fixes

- Show Screenshot app again
- Fixed Statusbar: some updates were allowed to time out and fail silently: When the Statusbar service would do a state update, the LVGL statusbar would never get updated due to this timeout.
- Fixed memory leaks in all `createSdCard()` functions (in most board implementations)
2025-08-30 21:54:55 +02:00
Ken Van Hoeylandt e9f72490fc Upgrade ESP-IDF to v5.5 (#306) 2025-08-28 22:34:24 +02:00
Ken Van Hoeylandt 8c8ccd8783 Merge develop into main (#305)
## New features

- Implement translations for apps
- Created `tt::settings::setLanguage` and `::getLanguage()`
- External app errors are now reported to the user via an AlertDialog
- Store system settings in `/data/settings.properties`
- Created a "Region & Language" app and moved the timezone setting there.

## Other changes

- Change `/data` and `/system` filesystem sector size from 4096 to 512 bytes to allow for more small files (60+ files of 4kB were over the limit of 256kB for the filesystem)
- Increased size of `/data` and `/system`
- Moved `tt::time::*` to `tt::settings`
- Removed the timezone setting from the "Time & Date" setting app
- Reverse encoder direction of Lilygo T-Lora Pager
- Improved partability of `Time.cpp` (removed separate set of functions for PC/sim)
2025-08-28 21:50:29 +02:00
Ken Van Hoeylandt ee5a5a7181 Merge develop into main (#304)
## New

- Read property files with `PropertiesFile`
- Support `boot.properties` so the user can specify the launcher app and an optional app to start after the launcher finishes. (see `BootProperties.cpp`)
- Create registry for CPU affinity and update code to make use of it
- `AppRegistration` and `ServiceRegistration` now also ensure that the `/data` directories always exist for all apps
- `Notes` is now the default app for opening text files. `TextViewer` is removed entirely. Created `tt::app::notes::start(path)` function.
- WiFi settings moved from NVS to properties file.
- Specify `*.ap.properties` file on the SD card for automatic WiFi settings import on start-up.
- Added `file::getLock(path)` and `file::withLock(path, function)` to do safe file operations on SD cards

## Improvements

- Update TinyUSB to `1.7.6~1`
- Improved `Boot.cpp` code. General code quality fixes and some restructuring to improve readability.
- `tt::string` functionality improvements
- Rename `AppRegistry` to `AppRegistration`
- Rename `ServiceRegistry` to `ServiceRegistration`
- Cleanup in `Notes.cpp`
- `FileTest.cpp` fix for PC
- Created `TestFile` helper class for tests, which automatically deletes files after the test.
- Renamed `Partitions.h` to `MountPoints.h`
- Created `std::string getMountPoints()` function for easy re-use
- Other code quality improvements
- `SdCardDevice`'s `getState()` and `isMounted()` now have a timeout argument

## Fixes

- ELF loading now has a lock so to avoid a bug when 2 ELF apps are loaded in parallel
2025-08-23 17:10:18 +02:00
Ken Van Hoeylandt fbaff8cbac Merge develop into main (#303)
- `DisplayDevice` improvements related `DisplayDriver`
- Replaced incorrect usage of `spiBusHandle` with `spiHostDevice` in all SPI display devices
- Disabled `DisplayDriver` support for RGB displays for now
- Updated `GraphicsDemo` project for the above changes
- TactilityC improvements:
  - created `tt_hal_device_find()`
  - created `tt_hal_display_*`
  - created `tt_hal_touch_*`
  - created `tt_lvgl_*`
  - export `tt_app_*` calls
2025-08-17 22:48:51 +02:00
Ken Van Hoeylandt d875ade8cb Touch and display driver subsystems reworked (and more) (#302)
- Refactored `TouchDevice`: it can now start/stop LVGL separately, and it has an optional `TouchDriver` interface
- Refactored `DisplayDevice`: it can now start/stop LVGL separately, and it has an optional `DisplayDriver` interface
- Updated all boards and drivers for above changes
- LVGL can now be stopped and (re)started on the fly
- Fixed issues with restarting Gui and Statusbar services
- Refactored `Gui` service to be class and renamed `Gui` to `GuiService`
- Fixed `Statusbar` service: forgot to deregister one of the icons
- Updated `esp_lcd_st7701` to v1.1.3
- `lv_textarea_create()` now automatically registers the hardware keyboard hooks (by wrapping the function)
- Fixed and updated `tactility.py`
- Cleanup of a lot of code
- `BootInitLvglBegin` and `BootInitLvglEnd` are replaced by `LvglStarted` and `LvglStopped`.
- Introduced `tt::service::State` which is accessible via `tt::service::getState()` (and internally via `ServiceInstance`)
- Started replacing `#define TAG` with `constexpr auto TAG = "..";`
2025-08-16 20:22:49 +02:00
Ken Van Hoeylandt 15f4fbfdc6 Merge Develop into Main (#300)
- Made an external app from internal Calculator app
- Update tactility.py to v1.2.0 (fix bug with selfupdate)
- Added warning to Development service UI
- Add context to `SECURITY.md`
- Split `ObjectFileReader` and `ObjectFileWriter` into separate cpp files
- Fix related to GPS config read errors
2025-08-02 12:28:28 +02:00
Ken Van Hoeylandt 982fce9207 Project updates for Lilygo T-Lora Pager (#299)
- Updated build scripts for manual release
- Updated GitHub Actions
- Added reference to [esp32s3-gc9a01-lvgl](https://github.com/UsefulElectronics/esp32s3-gc9a01-lvgl) in `COPYRIGHT.md`
2025-07-23 23:09:56 +02:00
flip 00b62a2831 Implemented LilyGO T-Lora Pager (#295) 2025-07-23 22:45:57 +02:00
Ken Van Hoeylandt ab4cf79a47 Merge Develop into Main (#298)
Various improvements and new internal APIs including a new Development service+app which allows `tactility.py` to upload and run applications remotely.
2025-07-19 00:27:49 +02:00
Ken Van Hoeylandt d06197a6aa Updated README.md and its screenshots (#293) 2025-06-15 13:55:35 +02:00
Ken Van Hoeylandt efd3dc43ed Revert "Updated screenshots and .gitignore of HelloWorld (#291)" (#292)
This reverts commit 6de0f442fb.
2025-06-15 13:50:29 +02:00
Ken Van Hoeylandt 6de0f442fb Updated screenshots and .gitignore of HelloWorld (#291)
* T-Deck Pro work in progress

* Add .gitignore to HelloWorld
2025-06-15 13:49:00 +02:00
Ken Van Hoeylandt 29e4350517 Update docs and version (#290) 2025-06-15 13:28:09 +02:00
Ken Van Hoeylandt f9acf04dcb Update tactility.py and tactility.properties for new release (#289) 2025-06-09 21:05:21 +02:00
Ken Van Hoeylandt a091923353 Fixed & improved build scripts (#288)
* Fixed&improved build scripts

* Fixes and updates

* Fix for esp-idf-ci-action

* Build fixes
2025-06-09 21:03:18 +02:00
Ken Van Hoeylandt 1593eb80ce TactilityC additions (#287)
New TactilityC implementations for:
- WiFi
- GPS
- Preferences
- Timezone

Also includes:
- Some fixes to enums/naming
- Cleanup elsewhere
2025-06-09 13:46:08 +02:00
Ken Van Hoeylandt 869a56125f App build system (#285)
from https://github.com/ByteWelder/TactilityTool
2025-06-08 10:38:20 +02:00
Ken Van Hoeylandt 6116521556 Update launcher icon sizes (#286)
This is a missing commit from a previous PR
2025-06-08 10:37:57 +02:00
Ken Van Hoeylandt 3dfc27e93e Fixes for colours and margins in GPIO app and more (#284)
- Fixes for colours and margins in GPIO app
- Removed unused imports
2025-06-01 17:52:09 +02:00
Ken Van Hoeylandt e4ecec64c9 Reduced desktop icon sizes (#283)
This improves loading performance (and uses less memory on ESP32 devices
without PSRAM)
2025-06-01 17:11:29 +02:00
Shadowtrance ce96474d84 Cleanup of Notes.cpp (#282) 2025-05-27 08:08:04 +02:00
Ken Van Hoeylandt 2691dbb014 Implemented LaunchId and FileSelection, updated Notes (#281)
- Implemented `LaunchId` to keep track of the apps that are started
- Implemented `FileSelection` app to select existing and/or new files.
- Moved some re-usable file functionality to `tt::file::`
- Renamed `Files` app to `FileBrowser`
- Updated `Notes` app to use new `FileSelection` functionality, and cleaned it up a bit.
- General code cleanliness improvements
2025-05-25 22:11:50 +02:00
Ken Van Hoeylandt 74eb830870 Buildscript and kernel improvements (#280)
- Implemented `constexpr long int getMicros()` in `Kernel.h`
- Changed `secondsToTicks()`, `minutesToTicks()` and `bool isIsr()` to `constexpr`
- Added more relevant build info
2025-05-24 17:27:37 +02:00
Shadowtrance 870924229a Switch to dark theme (#278) 2025-05-06 19:52:55 +02:00
Ken Van Hoeylandt b2647f46bb Cleanup (#277) 2025-04-11 21:56:16 +02:00
Shadowtrance d1c1a3a369 Add Notes app (#276) 2025-04-11 21:35:29 +02:00
Ken Van Hoeylandt a5090ec194 Refactor display app (#275)
- Moved more code into class
- Refactored some logic
- UI is more dynamic: hide elements that are not supported by the hardware (gamma and/or brightness slider)
2025-04-08 22:38:03 +02:00
Ken Van Hoeylandt f67cb241b7 SDK fixes (#272)
- Fix for `ExternalApps/HelloWorld/build.sh`
- Fix portability issue with regards to the SDK release script
2025-04-03 23:38:47 +02:00
Ken Van Hoeylandt b2d4dc5ecb Simplify AppList (#271)
Remove categories, disable HelloWorld app
2025-04-03 23:06:54 +02:00
Shadowtrance a7c5d6a2ee Add Calculator app (#270)
Add Calculator app

Originally created by @maxbrito500 and tweaked/updated by me.
2025-04-03 18:28:15 +02:00
Ken Van Hoeylandt 08029a84dd Various fixes and improvements (#269)
- Bump version for next release
- Fix default gamma for CYD 2432S032C
- Remember gamma curve setting from Display settings app
- Add UART to Core2 (still has no voltage on Grove port, though)
- LVGL performance improvements: pin to second core and set task priority to "critical"
- Fix build warnings, including deprecations
- Removed deprecated `Thread` constructor
- Fix WaveShare S3 display: Some displays would show a white screen at 12MHz, so I'm putting it back to the
official config values.
2025-04-01 23:42:56 +02:00
Ken Van Hoeylandt eb4e9f9649 Fixes and cleanup (#266)
- Fix issue with GT911 driver: fixed a crash and an init issue
- Cleanup of unused code
2025-03-31 15:59:50 +02:00
Ken Van Hoeylandt 3f1bfee3f5 Various improvements (#264)
- Replace C function pointers with C++ `std::function` in `Thread`, `Timer` and `DispatcherThread`
- Rename `SystemEvent`-related functions
- WiFi: fix auto-connect when WiFi disconnects from bad signal
- WiFi: fix auto-connect when WiFi fails to auto-connect
- WiFi: implement disconnect() when tapping connected WiFi ap in WiFi management app
2025-03-30 21:59:31 +02:00
Ken Van Hoeylandt d72852a6e2 Merge TactilityHeadless into Tactility (#263)
There currently is no practical use to have TactilityHeadless as a subproject. I'm merging it with the Tactility project.
2025-03-30 10:54:36 +02:00
Ken Van Hoeylandt d0ca3b16f8 GPS refactored (#262)
- Refactored GPS service and HAL: GPS is no longer part of the HAL configuration. You can now add configure new GPS devices from the GPS settings app.
- T-Deck adds a boot hook to check if a GPS configuration exists and adds it when the config is empty.
- Implemented the concept of ObjectFile to read/write arrays of a raw data type (e.g. struct) to disk.
- Implemented more file utils (e.g. to create all directories of a path)
2025-03-30 01:14:22 +01:00
Ken Van Hoeylandt 81ece6f2e7 Revert GT911 driver update (#261) 2025-03-29 19:10:33 +01:00
Ken Van Hoeylandt 49a46f6236 ESP-NOW service (#259)
Implemented Chat app with ESP-NOW service.

The Chat app was originally created by @maxbrito500 and adapted by me.
2025-03-29 10:45:34 +01:00
Ken Van Hoeylandt 358954f8be Update esp_lcd_touch_gt911 to v1.1.3 (#256)
This fixes a crash.
https://github.com/ByteWelder/Tactility/issues/255
2025-03-23 22:05:53 +01:00
Ken Van Hoeylandt 59ab11d498 Fix release-sdk.sh (#254) 2025-03-23 17:04:29 +01:00
Ken Van Hoeylandt ebd2c7c6f9 Build improvements (#250)
- Fix case for board configs
-  CMake now only builds a single board instead of all boards for the selected SOC. This makes it quicker to compile a single firmware.
2025-03-16 22:04:03 +01:00
Shadowtrance 7f33364bf4 Shadowtrance board updates (#249)
* Shadowtrance board updates

External i2c disabled by default.
Added UART and GPS

* Update CYD8048S043C.cpp

Removed GPS entry

* Update JC2432W328C.cpp

Removed GPS entry

* Update JC8048W550C.cpp

Removed GPS entry

---------

Co-authored-by: Ken Van Hoeylandt <git@kenvanhoeylandt.net>
2025-03-15 17:01:49 +01:00
Ken Van Hoeylandt 0ebc022946 New board: Waveshare ESP32 S3 Touch LCD 4.3" (#248) 2025-03-14 23:55:48 +01:00
Ken Van Hoeylandt f85d0239ff Board implementations and fixes (#247)
- Implemented Elecrow Crowpanel Basic 5.0"
- Implemented Elecrow Crowpanel Advance 5.0"
- Implemented CYD 2432S032C
- Fix for CYD 4848S040C rendering drift (lower transfer speed)
- Fix for SD card locking mechanism for various boards
2025-03-14 22:37:09 +01:00
PabloPL 21936f7e9e Fix issue with External I2C power on M5Stack Core S3. (#246)
It's just https://github.com/espressif/esp-bsp/commit/214ce6f191fae75ae4b3872b295eebb58b9fd0a0 adapted to Tactility source code.
All credits to original author of fix.

Signed-off-by: Paweł Chmiel <pawel.mikolaj.chmiel@gmail.com>
2025-03-13 21:33:31 +01:00
Ken Van Hoeylandt 19521791c5 CYD 4848S040C improvements and more (#245)
4848S040C:
- Fix SD card CS pin setting for 
- Fixes for colour
- Implement PwmBacklight driver 

Other:
- Fix for TouchDevice type
- Show landscape launcher for square displays
2025-03-12 23:45:49 +01:00
Shadowtrance ef410086d9 Implemented board CYD-4848S040C (#244) 2025-03-12 18:16:03 +01:00
Shadowtrance 2d535fec2a RGB Display Improvements (#243)
* 550 Buffer size

* 043 to use the RgbDisplay driver too

Both rgb displays are pretty snappy (as snappy as 800 * 480 can be on an esp32)
2025-03-12 08:15:12 +01:00
Ken Van Hoeylandt 778e003d4d Shadowtrance board implementations (#241)
Adapted from pull request https://github.com/ByteWelder/Tactility/pull/238
- JC2432W328C - ST7789 - CST820 (816) 240x320 - 2.8 inch
- ESP32-8048S043C - ST7262 - GT911 800x480 - 4.3 inch
- JC8048W550C - ST7262 - GT911 800x480 - 5 inch
2025-03-11 21:21:44 +01:00
Ken Van Hoeylandt 85a6ad3bbe Keyboard improvements (#240)
- Renamed various keyboard functions so it's easier to differentiate hardware versus software keyboard functionality
- Created `Tactility/lvgl/Keyboard.h` as a proxy  for the internal `Gui` service.
- Implemented `tt_lvgl_keyboard.h` in `TactilityC`.
2025-03-10 00:21:49 +01:00
Ken Van Hoeylandt 13d7e84ef3 Implement Serial Console app & more (#239)
- Implemented new app: Serial Console
- `Uart::writeString()`: fixed 2 mutex bugs
- `AlertDialog::start()` with default "OK" button added
- Created `tt::lvgl::defaultLockTime` for re-use
- Removed various usages of deprecated `lvgl::obj_set_style_no_padding()`
- Implemented `hal::uart::getNames()` to list all interface names
2025-03-07 21:58:52 +01:00
Ken Van Hoeylandt 83a82be901 Simplify I2C and SPI code (#237) 2025-02-26 17:47:19 +01:00
Ken Van Hoeylandt b85ef7a2e7 UART refactored (#236)
`Uart` is now an abstract class with a `UartEsp` and a `UartPosix` implementation.
2025-02-26 17:13:37 +01:00
Ken Van Hoeylandt de46401d85 Loader refactored (#235)
- Moved all Loader functionality into Loader class
- Improvement for Dispatcher construction
- Dispatcher and DispatcherThread: you can now specify the timeout when calling `dispatch()`. Default timeout is max timeout.
2025-02-23 16:08:00 +01:00
Ken Van Hoeylandt bd2786b122 Updated elf_loader library to latest from GitHub (#234) 2025-02-22 23:57:45 +01:00
Ken Van Hoeylandt 6d1d08944b LVGL improvements for TactilityC (#233)
- Expose various `lv_event`-related functions
- Expose `tt::lvgl::toolbar`-related functions
- Update sample app and improved docs
2025-02-22 23:12:03 +01:00
Ken Van Hoeylandt 70d36131f6 Implemented CrowPanel Basic 3.5" (#232) 2025-02-22 22:43:49 +01:00
Ken Van Hoeylandt b14887d5fb New board: Elecrow CrowPanel Advance 3.5" (#231)
- Implement CrowPanel Advance 3.5"
- New driver subproject: ILI9488
- New driver subproject: GT911
- Refactor T-Deck to use new driver subproject
- Fix for `flash.ps1`: don't set flash speed
2025-02-22 19:09:15 +01:00
Ken Van Hoeylandt 44b366b557 Update esp_lvgl_port (#230)
Updated to espressif/esp-bsp@531ad57
https://github.com/espressif/esp-bsp/commit/531ad57f6abe178d6b43d898fac495c59747803f
2025-02-22 17:23:56 +01:00
Ken Van Hoeylandt ee88a563dc Fix for display settings (#229) 2025-02-22 16:39:17 +01:00
Shadowtrance 09cdf07b7c Bring the ST7789 driver inline with the ILI934x driver (#228)
more configuration options as not every display / board is the same.
2025-02-22 13:53:48 +01:00
Ken Van Hoeylandt d29e47f0eb Logging improvements & other cleanup (#227) 2025-02-21 14:38:51 +01:00
Ken Van Hoeylandt 933bc5fb97 Driver improvements (#226)
- Created driver subprojects: `FT5x06`, `FT6x36`, `CST816S`.
- Refactored existing projects to use new drivers.
- Improve `PwmBacklight` driver: expose frequency, channel id and timer id
- Update `build-and-release-all.sh` for recent board addition
2025-02-20 22:41:56 +01:00
Ken Van Hoeylandt 6e8fbae62b New board: Elecrow CrowPanel Basic 2.8" (#225)
- Implemented Elecrow CrowPanel Basic 2.8"
- Change default "invert" setting for ILI934x driver from `true` to `false`
- Created `Xpt2046` driver subproject
- Refactored unPhone to use new `Xpt2046` driver subproject
2025-02-19 22:41:39 +01:00
Ken Van Hoeylandt 0563e42dc9 New board: Elecrow CrowPanel Avance 2.8" (#224)
- Added new board
- Extracted ST7789 driver and backlight PWM driver into separate subprojects
- Refactored T-Deck to use the shared driver modules
- Fix bug in WiFi service: searching for APs was broken
2025-02-19 21:01:13 +01:00
Ken Van Hoeylandt 5055fa7822 Improved GPS Settings app and GPS service (#222)
- Fixes and improvements to `GpsSettings` app, `GpsDevice` and `GpsService`
- Implemented location/GPS statusbar icon
- Added app icon
- Added support for other GPS models (based on Meshtastic code)
2025-02-18 22:07:37 +01:00
Ken Van Hoeylandt ad2cad3bf1 Renamed getLvglSyncLock() to getSyncLock() (#221) 2025-02-14 00:06:52 +01:00
Shadowtrance 6e77d5027f Windows Build and release scripts (#220) 2025-02-13 12:08:16 +01:00
Ken Van Hoeylandt 55bfb9fe3b Lockable renamed to Lock (#219)
Also changed usage from unique_ptr to class value.
2025-02-12 22:28:22 +01:00
Ken Van Hoeylandt 2e86d4774b Added HAL docs, improved HAL init&locking (#218) 2025-02-12 18:12:20 +01:00
Ken Van Hoeylandt b7f39f883d Reduce splash duration from 1.5s to 1s (#217) 2025-02-11 23:48:00 +01:00
Ken Van Hoeylandt 14e459e50f GPS implementation (#216)
Implemented basic GPS support:
- GPS HAL
- GPS Service
- GPS Settings app
2025-02-11 23:46:52 +01:00
Ken Van Hoeylandt 2345ba6d13 HAL renaming & relocation (#215)
Implemented more consistent naming:
- Moved all HAL devices into their own namespace (and related folder)
- Post-fixed all HAL device names with "Device"
2025-02-09 16:48:23 +01:00
Ken Van Hoeylandt a7a3b17ff6 SD card improvements (#214)
- Implement SD card locking logic and helper functions
- Fix issue with running ELF apps from SD card: this would crash when launched from the AppList
- Reduce Boot app wait time to 1 second
- Speed up boot by about 0.1 second by moving app&service registration to the Boot app
- Files app now uses proper SD card mount point name (and multiple SD cards)
- Removed `TT_SCREENSHOT_MODE`
2025-02-09 12:01:01 +01:00
Ken Van Hoeylandt fd1e31dec4 Fix serial config for T-Deck (#213)
Port 0 clashed with the serial monitor and affected performance.
2025-02-09 00:00:14 +01:00
Ken Van Hoeylandt c5fc8790bb Implement UART HAL (#212)
- Implement UART HAL
- Improved I2C and SPI HAL mocking mechanism (removed mock files)
2025-02-08 23:10:31 +01:00
Ken Van Hoeylandt e1bfdd7c91 Improve source file processing in CMakeLists.txt (#211) 2025-02-08 21:42:14 +01:00
Ken Van Hoeylandt 5b375c21bb Implemented new driver projects (#210)
Moved drivers from the `Boards` projects to `Drivers` folder:
- BQ24295
- AW9523
- AXP2101

The I2C drivers are theoretically cross-platform, but for now they are only built for ESP32.
2025-02-08 21:08:23 +01:00
Ken Van Hoeylandt c74006f8b6 Created Drivers folder with ILI934x subproject (#209)
Refactored all existing boards to re-use the ILI934x driver code.
2025-02-08 18:54:09 +01:00
Ken Van Hoeylandt 8ccba15c25 Simplify LVGL init: move code into Tactility (#208)
The esp_lvgl_port code was duplicated across all boards, so I moved it into the Tactility subproject to simplify the board implementations.
2025-02-08 17:06:16 +01:00
Ken Van Hoeylandt c1f55429b6 SPI HAL implemented and more (#207)
- Cleanup unused code and move ISR/IRQ checks to `Kernel.h`
- Improve clang-format
- Fix for LVGL lock transfer: ensure lock isn't activate when changing the lock
- Implement SPI HAL
- Remove `initHardware` HAL configuration entry
- Fix `I2cScanner`: don't scan when port isn't started
2025-02-08 00:21:50 +01:00
Ken Van Hoeylandt 88b3bfbe3e Logging improvements and C++23 (#206)
- Improved logging code by splitting functionality up into different files
- Set C++23 as new standard (it was already the implied standard due to some code, but now it's explicit)
2025-02-06 22:55:51 +01:00
Ken Van Hoeylandt 6337458992 Refactor app access (#205)
- Use `tt::app::` functions to start/stop apps and get current app(context) instead of using loader everywhere
- Removed `tt_service_loader.*` from TactilityC
- Created `tt_app_stop()` for TactilityC
- Bumped version to 0.3.0 to prepare for upcoming release
2025-02-05 21:57:27 +01:00
Ken Van Hoeylandt 68e34ca740 Various improvements (#204)
- Fixed crash in logging app when not selecting filter
- Cleanup of unused code
- Cleanup of app code
2025-02-04 23:05:28 +01:00
Ken Van Hoeylandt 5ec96f60f1 Performance improvements (#203)
- Use DMA buffers for drawing
- Fix for draw buffer sizes
- Reduced rendering refresh interval
- Removed custom icons from wifi app to fix scroll performance issue
2025-02-02 23:02:50 +01:00
Ken Van Hoeylandt c0f4738abe I2C improvements and fixes (#201)
- Show I2C device name in I2C Scanner app
- Register various I2C devices from board implementations
- Fix M5Stack Core2 power status
- Fix pre-allocation issue in `hal::Device`
2025-02-02 17:54:36 +01:00
Ken Van Hoeylandt 2e61aea93c Remember last selected bus/port and auto-scan when launching (#200)
- Remember last selected bus/port
- Auto-scan when starting or resuming the app
- Auto-scan when selecting new bus/port
- Cleaned up app code a bit
2025-02-02 16:14:59 +01:00
Ken Van Hoeylandt cff0605b0a Implement device management (#199)
- Added `tt::hal::Device` and functions (de)register devices and search for them.
- Refactored apps: `Power` and `Display` settings apps now use the device API to find devices.
- Implemented the new API for all existing drivers for all devices, including the simulator.
- Updated HAL Configuration to return `std::shared_ptr` instead of raw pointers.
- Added test project for headless tests and implemented tests for the new code.
2025-02-02 15:16:51 +01:00
Ken Van Hoeylandt c87200a80d Project restructuring (fixes macOS builds) (#198)
- Create `Include/` folder for all main projects
- Fix some issues here and there (found while moving things)
- All includes are now in `Tactility/` subfolder and must be included with that prefix. This fixes issues with clashing POSIX headers (e.g. `<semaphore.h>` versus Tactility's `Semaphore.h`)
2025-02-01 18:13:20 +01:00
Ken Van Hoeylandt 7856827ecf Refactored manifest onStart/onStop to onCreate/onDestroy (#195)
When writing documentation, I realized how `onStart`/`onStop` isn't clearly communicating what it does (it could imply show/hide), so I renamed it to `onCreate` and `onDestroy`.
2025-01-28 21:34:48 +01:00
Ken Van Hoeylandt 6c67845645 Cleanup and improvements (#194)
- Lots of changes for migrating C code to C++
- Improved `Lockable` in several ways like adding `withLock()` (+ tests)
- Improved `Semaphore` a bit for improved readability, and also added some tests
- Upgrade Linux machine in GitHub Actions so that we can compile with a newer GCC
- Simplification of WiFi connection
- Updated funding options
- (and more)
2025-01-28 17:39:58 +01:00
2405 changed files with 151193 additions and 34193 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ IndentPPDirectives: None
IndentWidth: 4 IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: true KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2 MaxEmptyLinesToKeep: 2
NamespaceIndentation: All NamespaceIndentation: None
ObjCSpaceAfterProperty: false ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true ObjCSpaceBeforeProtocolList: true
PointerAlignment: Left PointerAlignment: Left
+1 -1
View File
@@ -10,6 +10,6 @@ liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username issuehunt: # Replace with a single IssueHunt username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
polar: # Replace with a single Polar username polar: # Replace with a single Polar username
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username buy_me_a_coffee: bytewelder
thanks_dev: # Replace with a single thanks.dev username thanks_dev: # Replace with a single thanks.dev username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
+1 -1
View File
@@ -30,4 +30,4 @@ If applicable, add screenshots to help explain your problem.
**Additional context** **Additional context**
Add any other context about the problem here. Add any other context about the problem here.
Add your oops.tactility.one URL if you had a crash (scanned from QR). Add your oops.tactilityproject.org URL if you had a crash (scanned from QR).
@@ -1,7 +1,7 @@
### Checklist ### Checklist
- [ ] I read [contribution guidelines](https://github.com/ByteWelder/Tactility/blob/main/CONTRIBUTING.md) - [ ] I read [contribution guidelines](https://github.com/TactilityProject/Tactility/blob/main/CONTRIBUTING.md)
- [ ] Code adheres to the [coding style](https://github.com/ByteWelder/Tactility/blob/main/CODING_STYLE.md) - [ ] Code adheres to the [coding style](https://github.com/TactilityProject/Tactility/blob/main/CODING_STYLE.md)
### Description ### Description
+17 -4
View File
@@ -11,21 +11,28 @@ inputs:
runs: runs:
using: "composite" using: "composite"
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
with: with:
submodules: recursive submodules: recursive
- name: 'Board select' - name: 'Board select'
shell: bash shell: bash
run: cp sdkconfig.board.${{ inputs.board_id }} sdkconfig run: python device.py ${{ inputs.board_id }}
- name: 'Build' - name: 'Build'
uses: espressif/esp-idf-ci-action@main uses: espressif/esp-idf-ci-action@v1
with: with:
esp_idf_version: v5.4 esp_idf_version: v5.5.2
target: ${{ inputs.arch }} target: ${{ inputs.arch }}
path: './' path: './'
- name: 'Release' - name: 'Release'
shell: bash shell: bash
run: Buildscripts/release.sh ${{ inputs.board_id }} run: Buildscripts/release.sh ${{ inputs.board_id }}
- name: 'Merge binary'
shell: bash
run: |
python -m pip install esptool
cd release/Tactility-${{ inputs.board_id }}
bash ./merge.sh ${{ inputs.arch }}
mv Binaries/merged_binary.bin ../Tactility-${{ inputs.board_id }}.bin
- name: 'Upload Artifact: Release' - name: 'Upload Artifact: Release'
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
@@ -38,3 +45,9 @@ runs:
name: Tactility-${{ inputs.board_id }}-symbols name: Tactility-${{ inputs.board_id }}-symbols
path: release/Tactility-${{ inputs.board_id }}-symbols path: release/Tactility-${{ inputs.board_id }}-symbols
retention-days: 30 retention-days: 30
- name: 'Upload Artifact: Merged binary'
uses: actions/upload-artifact@v4
with:
name: Tactility-${{ inputs.board_id }}.bin
path: release/Tactility-${{ inputs.board_id }}.bin
retention-days: 30
+23 -5
View File
@@ -11,21 +11,39 @@ inputs:
runs: runs:
using: "composite" using: "composite"
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
with: with:
submodules: recursive submodules: recursive
- name: 'Board select' - name: 'Board select'
shell: bash shell: bash
run: cp sdkconfig.board.${{ inputs.board_id }} sdkconfig run: python device.py ${{ inputs.board_id }}
- name: 'Build' - name: 'Build'
uses: espressif/esp-idf-ci-action@main uses: espressif/esp-idf-ci-action@v1
with: with:
esp_idf_version: v5.4 # NOTE: Update with ESP-IDF!
esp_idf_version: v5.5.2
target: ${{ inputs.arch }} target: ${{ inputs.arch }}
path: './' path: './'
- name: 'Release' - name: 'Release'
shell: bash shell: bash
run: Buildscripts/release-sdk.sh release/TactilitySDK env:
# NOTE: Update with ESP-IDF!
ESP_IDF_VERSION: '5.5.2'
run: python Buildscripts/release-sdk.py release/TactilitySDK
- name: 'Test Integration Prep'
shell: bash
# The manifest.properties of our integration test uses version 0.0.0 to indicate that it is not using a normal SDK
# This way, it only works with our custom build. That means we have to create a copy of the SDK with the correct folder structure:
run: |
TACTILITY_SDK_NAME="0.0.0-${{ inputs.arch }}"
mkdir -p test_sdk/$TACTILITY_SDK_NAME
cp -r release/TactilitySDK test_sdk/$TACTILITY_SDK_NAME
- name: 'Test Integration'
uses: espressif/esp-idf-ci-action@v1
with:
esp_idf_version: v5.5.2
target: ${{ inputs.arch }}
command: export TACTILITY_SDK_PATH=../../test_sdk && cd Tests/SdkIntegration && python tactility.py build ${{ inputs.arch }} --local-sdk
- name: 'Upload Artifact' - name: 'Upload Artifact'
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
+7 -4
View File
@@ -15,7 +15,7 @@ runs:
using: "composite" using: "composite"
steps: steps:
- name: "Checkout repo" - name: "Checkout repo"
uses: actions/checkout@v2 uses: actions/checkout@v6
with: with:
submodules: recursive submodules: recursive
- name: Install Linux Dependencies for SDL - name: Install Linux Dependencies for SDL
@@ -23,6 +23,7 @@ runs:
shell: bash shell: bash
# See Libraries/SDL/docs/README-linux.md # See Libraries/SDL/docs/README-linux.md
run: > run: >
sudo apt-get update &&
sudo apt-get install build-essential git make sudo apt-get install build-essential git make
pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev pkg-config cmake ninja-build gnome-desktop-testing libasound2-dev libpulse-dev
libaudio-dev libjack-dev libsndio-dev libx11-dev libxext-dev libaudio-dev libjack-dev libsndio-dev libx11-dev libxext-dev
@@ -35,14 +36,16 @@ runs:
WLR_LIBINPUT_NO_DEVICES: 1 WLR_LIBINPUT_NO_DEVICES: 1
WAYLAND_DISPLAY: wayland-1 WAYLAND_DISPLAY: wayland-1
GTK_USE_PORTAL: 0 GTK_USE_PORTAL: 0
- name: "Configure Project" - name: Setup cmake
uses: threeal/cmake-action@v1.3.0 uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.31.x'
- name: "Prepare Project" - name: "Prepare Project"
shell: bash shell: bash
run: cmake -S ./ -B buildsim run: cmake -S ./ -B buildsim
- name: "Build Tests" - name: "Build Tests"
shell: bash shell: bash
run: cmake --build buildsim --target AppSim run: cmake --build buildsim --target FirmwareSim
- name: 'Release' - name: 'Release'
shell: bash shell: bash
run: Buildscripts/release-simulator.sh buildsim release/Simulator-${{ inputs.os_name }}-${{ inputs.platform_name }} run: Buildscripts/release-simulator.sh buildsim release/Simulator-${{ inputs.os_name }}-${{ inputs.platform_name }}
@@ -0,0 +1,15 @@
name: Bundle All
runs:
using: 'composite'
steps:
- name: 'Download artifacts'
uses: actions/download-artifact@v4
with:
path: artifacts
- name: 'Upload Artifact'
uses: actions/upload-artifact@v4
with:
name: 'all-artifacts'
path: artifacts/
retention-days: 3
@@ -0,0 +1,24 @@
name: Publish Firmware
inputs:
cdn_version:
description: The version that determines the path on the CDN
required: true
runs:
using: 'composite'
steps:
- name: 'Download all-artifacts'
uses: actions/download-artifact@v4
with:
name: 'all-artifacts'
path: artifacts
- name: 'Install boto3'
shell: bash
run: pip install boto3
- name: 'Generate files'
shell: bash
run: version=`cat version.txt` && python Buildscripts/CDN/generate-firmware-files.py artifacts artifacts-cdn $version
- name: 'Upload files'
shell: bash
run: python Buildscripts/CDN/upload-firmware-files.py artifacts-cdn ${{ inputs.cdn_version }} ${{ env.CDN_ID }} ${{ env.CDN_TOKEN_NAME }} ${{ env.CDN_TOKEN_VALUE }}
+19
View File
@@ -0,0 +1,19 @@
name: Publish SDK
runs:
using: 'composite'
steps:
- name: 'Download all-artifacts'
uses: actions/download-artifact@v4
with:
name: 'all-artifacts'
path: artifacts
- name: 'Install boto3'
shell: bash
run: pip install boto3
- name: 'Generate files'
shell: bash
run: version=`cat version.txt` && python Buildscripts/CDN/generate-sdk-files.py artifacts artifacts-cdn $version
- name: 'Upload files'
shell: bash
run: version=`cat version.txt` && python Buildscripts/CDN/upload-sdk-files.py artifacts-cdn $version ${{ env.CDN_ID }} ${{ env.CDN_TOKEN_NAME }} ${{ env.CDN_TOKEN_VALUE }}
-56
View File
@@ -1,56 +0,0 @@
name: Build Firmware
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
permissions: read-all
jobs:
cyd-2432S024c:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Build"
uses: ./.github/actions/build-firmware
with:
board_id: cyd-2432S024c
arch: esp32
lilygo-tdeck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Build"
uses: ./.github/actions/build-firmware
with:
board_id: lilygo-tdeck
arch: esp32s3
m5stack-core2:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Build"
uses: ./.github/actions/build-firmware
with:
board_id: m5stack-core2
arch: esp32
m5stack-cores3:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Build"
uses: ./.github/actions/build-firmware
with:
board_id: m5stack-cores3
arch: esp32s3
unphone:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Build"
uses: ./.github/actions/build-firmware
with:
board_id: unphone
arch: esp32s3
-29
View File
@@ -1,29 +0,0 @@
name: Build SDK
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
permissions: read-all
jobs:
esp32:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Build"
uses: ./.github/actions/build-sdk
with:
board_id: cyd-2432S024c
arch: esp32
esp32s3:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Build"
uses: ./.github/actions/build-sdk
with:
board_id: lilygo-tdeck
arch: esp32s3
+10 -6
View File
@@ -5,22 +5,26 @@ on:
branches: branches:
- main - main
pull_request: pull_request:
types: [opened, synchronize, reopened] types: [ opened, synchronize, reopened ]
jobs: jobs:
Build-Simulator-Linux: Linux:
runs-on: ubuntu-22.04 runs-on: ubuntu-24.04
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
with:
persist-credentials: false
- name: "Build" - name: "Build"
uses: ./.github/actions/build-simulator uses: ./.github/actions/build-simulator
with: with:
os_name: linux os_name: linux
platform_name: amd64 platform_name: amd64
publish: true publish: true
Build-Simulator-macOS: macOS:
runs-on: macos-latest runs-on: macos-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
with:
persist-credentials: false
- name: "Build" - name: "Build"
uses: ./.github/actions/build-simulator uses: ./.github/actions/build-simulator
with: with:
+109
View File
@@ -0,0 +1,109 @@
name: Build Firmware
on:
push:
branches:
- main
tags:
- v*
pull_request:
types: [ opened, synchronize, reopened ]
permissions: read-all
jobs:
BuildSdk:
strategy:
matrix:
board: [
{ id: generic-esp32, arch: esp32 },
{ id: generic-esp32c6, arch: esp32c6 },
{ id: generic-esp32p4, arch: esp32p4 },
{ id: generic-esp32s3, arch: esp32s3 },
]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: "Build SDK"
uses: ./.github/actions/build-sdk
with:
board_id: ${{ matrix.board.id }}
arch: ${{ matrix.board.arch }}
GenerateDeviceMatrix:
runs-on: ubuntu-latest
needs: [ BuildSdk ]
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- id: set-matrix
run: python3 Buildscripts/gh-generate-device-matrix.py
BuildFirmware:
runs-on: ubuntu-latest
needs: GenerateDeviceMatrix
strategy:
matrix: ${{ fromJSON(needs.GenerateDeviceMatrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: "Build Firmware"
uses: ./.github/actions/build-firmware
with:
board_id: ${{ matrix.board.id }}
arch: ${{ matrix.board.arch }}
BundleArtifacts:
runs-on: ubuntu-latest
needs: [ BuildFirmware ]
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: "Bundle Artifacts"
uses: ./.github/actions/bundle-artifacts
PublishFirmwareSnapshot:
runs-on: ubuntu-latest
needs: [ BundleArtifacts ]
if: (github.event_name == 'push' && github.ref == 'refs/heads/main')
steps:
- uses: actions/checkout@v6
- name: "Publish Firmware Snapshot"
env:
CDN_ID: ${{ secrets.CDN_ID }}
CDN_TOKEN_NAME: ${{ secrets.CDN_TOKEN_NAME }}
CDN_TOKEN_VALUE: ${{ secrets.CDN_TOKEN_VALUE }}
uses: ./.github/actions/publish-firmware
with:
cdn_version: snapshot
PublishFirmwareStable:
runs-on: ubuntu-latest
needs: [ BundleArtifacts ]
if: (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
steps:
- uses: actions/checkout@v6
- name: "Publish Firmware Stable"
env:
CDN_ID: ${{ secrets.CDN_ID }}
CDN_TOKEN_NAME: ${{ secrets.CDN_TOKEN_NAME }}
CDN_TOKEN_VALUE: ${{ secrets.CDN_TOKEN_VALUE }}
uses: ./.github/actions/publish-firmware
with:
cdn_version: stable
PublishSdk:
runs-on: ubuntu-latest
needs: [ BundleArtifacts ]
if: (github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')))
steps:
- uses: actions/checkout@v6
- name: "Publish SDKs"
env:
CDN_ID: ${{ secrets.CDN_ID }}
CDN_TOKEN_NAME: ${{ secrets.CDN_TOKEN_NAME }}
CDN_TOKEN_VALUE: ${{ secrets.CDN_TOKEN_VALUE }}
uses: ./.github/actions/publish-sdk
+25 -5
View File
@@ -4,13 +4,13 @@ on:
branches: branches:
- main - main
pull_request: pull_request:
types: [opened, synchronize, reopened] types: [ opened, synchronize, reopened ]
jobs: jobs:
Run: TactilityTests:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: "Checkout repo" - name: "Checkout repo"
uses: actions/checkout@v2 uses: actions/checkout@v6
with: with:
submodules: recursive submodules: recursive
- name: "Configure Project" - name: "Configure Project"
@@ -19,5 +19,25 @@ jobs:
run: cmake -S ./ -B build run: cmake -S ./ -B build
- name: "Build Tests" - name: "Build Tests"
run: cmake --build build --target build-tests run: cmake --build build --target build-tests
- name: "Run Tests" - name: "Run TactilityFreeRtos Tests"
run: build/Tests/TactilityCore/TactilityCoreTests --exit run: build/Tests/TactilityFreeRtos/TactilityFreeRtosTests
- name: "Run Tactility Tests"
run: build/Tests/Tactility/TactilityTests
- name: "Run TactilityKernel Tests"
run: build/Tests/TactilityKernel/TactilityKernelTests
- name: "Run CryptModuleTests Tests"
run: build/Tests/crypt-module/CryptModuleTests
DevicetreeTests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
submodules: recursive
- name: "Install Python Dependencies"
shell: bash
run: pip install lark==1.3.1 pyyaml==6.0.3
- name: "Run Devicetree Tests"
shell: bash
working-directory: Buildscripts/DevicetreeCompiler/tests
run: python test_integration.py
+13 -2
View File
@@ -3,10 +3,11 @@
build/ build/
buildsim/ buildsim/
build-sim/ build-*/
cmake-build-*/ cmake-*/
CMakeCache.txt CMakeCache.txt
*.cbp *.cbp
CMakeFiles
release/ release/
@@ -16,3 +17,13 @@ sdkconfig.old
managed_components/ managed_components/
dependencies.lock dependencies.lock
.vscode/
*.code-workspace
.gitpod.yml
sdkconfig.board.*.dev
.tactility/
.caveman.json
.ai/mcp
+6
View File
@@ -10,3 +10,9 @@
[submodule "Libraries/SDL"] [submodule "Libraries/SDL"]
path = Libraries/SDL path = Libraries/SDL
url = https://github.com/libsdl-org/SDL.git url = https://github.com/libsdl-org/SDL.git
[submodule "Libraries/minitar/minitar"]
path = Libraries/minitar/minitar
url = https://github.com/ByteWelder/minitar.git
[submodule "Libraries/cJSON/cJSON"]
path = Libraries/cJSON/cJSON
url = https://github.com/DaveGamble/cJSON.git
-40
View File
@@ -1,40 +0,0 @@
cmake_minimum_required(VERSION 3.20)
if (DEFINED ENV{ESP_IDF_VERSION})
set(BOARD_COMPONENTS Tactility TactilityC)
if("${IDF_TARGET}" STREQUAL "esp32")
list(APPEND BOARD_COMPONENTS
CYD-2432S024C
M5stackCore2
)
endif()
if("${IDF_TARGET}" STREQUAL "esp32s3")
list(APPEND BOARD_COMPONENTS
LilygoTdeck
M5stackCoreS3
UnPhone
)
endif()
idf_component_register(
SRC_DIRS "Source"
"Source/HelloWorld"
REQUIRES ${BOARD_COMPONENTS}
)
else()
file(GLOB_RECURSE SOURCES "Source/*.c*")
add_executable(AppSim ${SOURCES})
target_link_libraries(AppSim
PRIVATE Tactility
PRIVATE TactilityCore
PRIVATE TactilityHeadless
PRIVATE Simulator
PRIVATE SDL2::SDL2-static SDL2-static
)
add_definitions(-D_Nullable=)
add_definitions(-D_Nonnull=)
endif()
-36
View File
@@ -1,36 +0,0 @@
# Kconfig file for Tactility example app
menu "Tactility App"
config TT_BOARD_NAME
string "Board Name"
default ""
config TT_BOARD_ID
string "Board ID"
default ""
choice
prompt "Board"
default TT_BOARD_CUSTOM
config TT_BOARD_CUSTOM
bool "Custom"
config TT_BOARD_CYD_2432S024C
bool "CYD 2432S024C"
config TT_BOARD_LILYGO_TDECK
bool "LilyGo T-Deck"
config TT_BOARD_M5STACK_CORE2
bool "M5Stack Core2"
config TT_BOARD_M5STACK_CORES3
bool "M5Stack CoreS3"
config TT_BOARD_UNPHONE
bool "unPhone"
help
Select a board/hardware configuration.
Use TT_BOARD_CUSTOM if you will manually configure the board in your project.
endchoice
config TT_SPLASH_DURATION
int "Splash Duration (ms)"
default 1500
range 0 3000
help
The minimum time to show the splash screen in milliseconds.
When set to 0, startup will continue to desktop as soon as boot operations are finished.
endmenu
-34
View File
@@ -1,34 +0,0 @@
#pragma once
#ifdef ESP_PLATFORM
#include "sdkconfig.h"
// Supported hardware:
#if defined(CONFIG_TT_BOARD_LILYGO_TDECK)
#include "LilygoTdeck.h"
#define TT_BOARD_HARDWARE &lilygo_tdeck
#elif defined(CONFIG_TT_BOARD_CYD_2432S024C)
#include "CYD2432S024C.h"
#define TT_BOARD_HARDWARE &cyd_2432S024c_config
#elif defined(CONFIG_TT_BOARD_M5STACK_CORE2)
#include "M5stackCore2.h"
#define TT_BOARD_HARDWARE &m5stack_core2
#elif defined(CONFIG_TT_BOARD_M5STACK_CORES3)
#include "M5stackCoreS3.h"
#define TT_BOARD_HARDWARE &m5stack_cores3
#elif defined(CONFIG_TT_BOARD_UNPHONE)
#include "UnPhone.h"
#define TT_BOARD_HARDWARE &unPhone
#else
#define TT_BOARD_HARDWARE NULL
#error Replace TT_BOARD_HARDWARE in main.c with your own. Or copy one of the ./sdkconfig.board.* files into ./sdkconfig.
#endif
#else // else simulator
#include "Simulator.h"
extern tt::hal::Configuration hardware;
#define TT_BOARD_HARDWARE &hardware
#endif // ESP_PLATFORM
-23
View File
@@ -1,23 +0,0 @@
#include "app/AppManifest.h"
#include "lvgl.h"
#include "lvgl/Toolbar.h"
using namespace tt::app;
class HelloWorldApp : public App {
void onShow(AppContext& context, lv_obj_t* parent) override {
lv_obj_t* toolbar = tt::lvgl::toolbar_create(parent, context);
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
lv_obj_t* label = lv_label_create(parent);
lv_label_set_text(label, "Hello, world!");
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
}
};
extern const AppManifest hello_world_app = {
.id = "HelloWorld",
.name = "Hello World",
.createApp = create<HelloWorldApp>
};
-31
View File
@@ -1,31 +0,0 @@
#include "Boards.h"
#include "Tactility.h"
#ifdef ESP_PLATFORM
#include "tt_init.h"
#endif
extern const tt::app::AppManifest hello_world_app;
extern "C" {
void app_main() {
static const tt::Configuration config = {
/**
* Auto-select a board based on the ./sdkconfig.board.* file
* that you copied to ./sdkconfig before you opened this project.
*/
.hardware = TT_BOARD_HARDWARE,
.apps = {
&hello_world_app,
}
};
#ifdef ESP_PLATFORM
tt_init_tactility_c(); // ELF bindings for side-loading on ESP32
#endif
tt::run(config);
}
} // extern
-14
View File
@@ -1,14 +0,0 @@
dependencies:
espressif/esp_lcd_ili9341: "2.0.0"
espressif/esp_lcd_touch: "1.1.2"
atanisoft/esp_lcd_touch_xpt2046: "1.0.5"
espressif/esp_lcd_touch_cst816s: "1.0.3"
espressif/esp_lcd_touch_gt911: "1.1.1~2"
espressif/esp_lcd_touch_ft5x06: "1.0.6~1"
espressif/esp_io_expander: "1.0.1"
espressif/esp_io_expander_tca95xx_16bit: "1.0.1"
espressif/esp_tinyusb:
version: "1.5.0"
rules:
- if: "target == esp32s3"
idf: '5.4'
-5
View File
@@ -1,5 +0,0 @@
idf_component_register(
SRC_DIRS "Source" "Source/hal"
INCLUDE_DIRS "Source"
REQUIRES Tactility esp_lvgl_port esp_lcd_touch_cst816s esp_lcd_ili9341 driver vfs fatfs
)
-84
View File
@@ -1,84 +0,0 @@
#include "YellowConfig.h"
#include "TactilityCore.h"
#include "hal/YellowTouchConstants.h"
#include <driver/spi_common.h>
#define TAG "twodotfour_bootstrap"
static bool init_i2c() {
TT_LOG_I(TAG, LOG_MESSAGE_I2C_INIT_START);
const i2c_config_t i2c_conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_33,
.scl_io_num = GPIO_NUM_32,
.sda_pullup_en = false,
.scl_pullup_en = false,
.master = {
.clk_speed = 400000
}
};
if (i2c_param_config(TWODOTFOUR_TOUCH_I2C_PORT, &i2c_conf) != ESP_OK) {
TT_LOG_E(TAG, LOG_MESSAGE_I2C_INIT_CONFIG_FAILED );
return false;
}
if (i2c_driver_install(TWODOTFOUR_TOUCH_I2C_PORT, i2c_conf.mode, 0, 0, 0) != ESP_OK) {
TT_LOG_E(TAG, LOG_MESSAGE_I2C_INIT_DRIVER_INSTALL_FAILED);
return false;
}
return true;
}
static bool init_spi2() {
TT_LOG_I(TAG, LOG_MESSAGE_SPI_INIT_START_FMT, SPI2_HOST);
const spi_bus_config_t bus_config = {
.mosi_io_num = TWODOTFOUR_SPI2_PIN_MOSI,
.miso_io_num = GPIO_NUM_NC,
.sclk_io_num = TWODOTFOUR_SPI2_PIN_SCLK,
.quadwp_io_num = GPIO_NUM_NC,
.quadhd_io_num = GPIO_NUM_NC,
.max_transfer_sz = TWODOTFOUR_SPI2_TRANSACTION_LIMIT
};
if (spi_bus_initialize(SPI2_HOST, &bus_config, SPI_DMA_CH_AUTO) != ESP_OK) {
TT_LOG_E(TAG, LOG_MESSAGE_SPI_INIT_FAILED_FMT, SPI2_HOST);
return false;
}
return true;
}
static bool init_spi3() {
TT_LOG_I(TAG, LOG_MESSAGE_SPI_INIT_START_FMT, SPI3_HOST);
const spi_bus_config_t bus_config = {
.mosi_io_num = TWODOTFOUR_SPI3_PIN_MOSI,
.miso_io_num = TWODOTFOUR_SPI3_PIN_MISO,
.sclk_io_num = TWODOTFOUR_SPI3_PIN_SCLK,
.quadwp_io_num = GPIO_NUM_NC,
.quadhd_io_num = GPIO_NUM_NC,
.data4_io_num = 0,
.data5_io_num = 0,
.data6_io_num = 0,
.data7_io_num = 0,
.max_transfer_sz = TWODOTFOUR_SPI3_TRANSACTION_LIMIT,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
};
if (spi_bus_initialize(SPI3_HOST, &bus_config, SPI_DMA_CH_AUTO) != ESP_OK) {
TT_LOG_E(TAG, LOG_MESSAGE_SPI_INIT_FAILED_FMT, SPI3_HOST);
return false;
}
return true;
}
bool twodotfour_boot() {
return init_i2c() && init_spi2() && init_spi3();
}
@@ -1,52 +0,0 @@
#include "CYD2432S024C.h"
#include "hal/YellowDisplay.h"
#include "hal/YellowSdCard.h"
bool twodotfour_lvgl_init();
bool twodotfour_boot();
const tt::hal::Configuration cyd_2432S024c_config = {
.initBoot = &twodotfour_boot,
.initLvgl = &twodotfour_lvgl_init,
.createDisplay = createDisplay,
.sdcard = createYellowSdCard(),
.power = nullptr,
.i2c = {
tt::hal::i2c::Configuration {
.name = "First",
.port = I2C_NUM_0,
.initMode = tt::hal::i2c::InitMode::Disabled,
.canReinit = true,
.hasMutableConfiguration = true,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_NC,
.scl_io_num = GPIO_NUM_NC,
.sda_pullup_en = false,
.scl_pullup_en = false,
.master = {
.clk_speed = 400000
},
.clk_flags = 0
}
},
tt::hal::i2c::Configuration {
.name = "Second",
.port = I2C_NUM_1,
.initMode = tt::hal::i2c::InitMode::Disabled,
.canReinit = true,
.hasMutableConfiguration = true,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_NC,
.scl_io_num = GPIO_NUM_NC,
.sda_pullup_en = false,
.scl_pullup_en = false,
.master = {
.clk_speed = 400000
},
.clk_flags = 0
}
}
}
};
@@ -1,6 +0,0 @@
#pragma once
#include "hal/Configuration.h"
// Capacitive touch version of the 2.4" yellow board
extern const tt::hal::Configuration cyd_2432S024c_config;
-26
View File
@@ -1,26 +0,0 @@
#include "esp_lvgl_port.h"
#include "Log.h"
#include "lvgl/LvglSync.h"
#include "Thread.h"
#define TAG "twodotfour_lvgl"
bool twodotfour_lvgl_init() {
const lvgl_port_cfg_t lvgl_cfg = {
.task_priority = static_cast<UBaseType_t>(tt::THREAD_PRIORITY_RENDER),
.task_stack = 8096,
.task_affinity = -1, // core pinning
.task_max_sleep_ms = 500,
.timer_period_ms = 5
};
if (lvgl_port_init(&lvgl_cfg) != ESP_OK) {
TT_LOG_E(TAG, "lvgl port init failed");
return false;
}
// Set syncing functions
tt::lvgl::syncSet(&lvgl_port_lock, &lvgl_port_unlock);
return true;
}
@@ -1,17 +0,0 @@
#pragma once
#include "driver/spi_common.h"
#include "driver/i2c.h"
#include "driver/gpio.h"
#include "hal/YellowDisplayConstants.h"
// SPI 2 - display
#define TWODOTFOUR_SPI2_PIN_SCLK GPIO_NUM_14
#define TWODOTFOUR_SPI2_PIN_MOSI GPIO_NUM_13
#define TWODOTFOUR_SPI2_TRANSACTION_LIMIT TWODOTFOUR_LCD_DRAW_BUFFER_SIZE
// SPI 3 - sdcard
#define TWODOTFOUR_SPI3_PIN_SCLK GPIO_NUM_18
#define TWODOTFOUR_SPI3_PIN_MOSI GPIO_NUM_23
#define TWODOTFOUR_SPI3_PIN_MISO GPIO_NUM_19
#define TWODOTFOUR_SPI3_TRANSACTION_LIMIT 8192 // TODO: Determine proper limit
@@ -1,214 +0,0 @@
#include "YellowDisplay.h"
#include "YellowDisplayConstants.h"
#include "YellowTouch.h"
#include "Log.h"
#include <TactilityCore.h>
#include <esp_lcd_panel_commands.h>
#include "driver/gpio.h"
#include "driver/ledc.h"
#include "esp_err.h"
#include "esp_lcd_ili9341.h"
#include "esp_lcd_panel_ops.h"
#include "esp_lvgl_port.h"
#define TAG "yellow_display"
static bool isBacklightInitialized = false;
static bool initBacklight() {
ledc_timer_config_t ledc_timer = {
.speed_mode = TWODOTFOUR_LCD_BACKLIGHT_LEDC_MODE,
.duty_resolution = TWODOTFOUR_LCD_BACKLIGHT_LEDC_DUTY_RES,
.timer_num = TWODOTFOUR_LCD_BACKLIGHT_LEDC_TIMER,
.freq_hz = TWODOTFOUR_LCD_BACKLIGHT_LEDC_FREQUENCY,
.clk_cfg = LEDC_AUTO_CLK,
.deconfigure = false
};
if (ledc_timer_config(&ledc_timer) != ESP_OK) {
TT_LOG_E(TAG, "Backlight led timer config failed");
return false;
}
return true;
}
static bool setBacklight(uint8_t duty) {
ledc_channel_config_t ledc_channel = {
.gpio_num = TWODOTFOUR_LCD_PIN_BACKLIGHT,
.speed_mode = TWODOTFOUR_LCD_BACKLIGHT_LEDC_MODE,
.channel = TWODOTFOUR_LCD_BACKLIGHT_LEDC_CHANNEL,
.intr_type = LEDC_INTR_DISABLE,
.timer_sel = TWODOTFOUR_LCD_BACKLIGHT_LEDC_TIMER,
.duty = duty,
.hpoint = 0,
.sleep_mode = LEDC_SLEEP_MODE_NO_ALIVE_NO_PD,
.flags = {
.output_invert = false
}
};
if (ledc_channel_config(&ledc_channel) != ESP_OK) {
TT_LOG_E(TAG, "Backlight init failed");
return false;
}
return true;
}
bool YellowDisplay::start() {
TT_LOG_I(TAG, "Starting");
const esp_lcd_panel_io_spi_config_t panel_io_config = ILI9341_PANEL_IO_SPI_CONFIG(
TWODOTFOUR_LCD_PIN_CS,
TWODOTFOUR_LCD_PIN_DC,
nullptr,
nullptr
);
if (esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)TWODOTFOUR_LCD_SPI_HOST, &panel_io_config, &ioHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to create panel");
return false;
}
const esp_lcd_panel_dev_config_t panel_config = {
.reset_gpio_num = GPIO_NUM_NC,
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_BGR,
.data_endian = LCD_RGB_DATA_ENDIAN_LITTLE,
.bits_per_pixel = TWODOTFOUR_LCD_BITS_PER_PIXEL,
.flags = {
.reset_active_high = false
},
.vendor_config = nullptr
};
if (esp_lcd_new_panel_ili9341(ioHandle, &panel_config, &panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to create ili9341");
return false;
}
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to reset panel");
return false;
}
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to init panel");
return false;
}
if (esp_lcd_panel_mirror(panelHandle, true, false) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to mirror");
return false;
}
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
TT_LOG_E(TAG, "Failed to turn display on");
return false;
}
const lvgl_port_display_cfg_t disp_cfg = {
.io_handle = ioHandle,
.panel_handle = panelHandle,
.control_handle = nullptr,
.buffer_size = TWODOTFOUR_LCD_DRAW_BUFFER_SIZE,
.double_buffer = false,
.trans_size = 0,
.hres = TWODOTFOUR_LCD_HORIZONTAL_RESOLUTION,
.vres = TWODOTFOUR_LCD_VERTICAL_RESOLUTION,
.monochrome = false,
.rotation = {
.swap_xy = false,
.mirror_x = true,
.mirror_y = false,
},
.color_format = LV_COLOR_FORMAT_RGB565,
.flags = {
.buff_dma = true,
.buff_spiram = false,
.sw_rotate = false,
.swap_bytes = true,
.full_refresh = false,
.direct_mode = false
}
};
displayHandle = lvgl_port_add_disp(&disp_cfg);
TT_LOG_I(TAG, "Finished");
return displayHandle != nullptr;
}
bool YellowDisplay::stop() {
assert(displayHandle != nullptr);
lvgl_port_remove_disp(displayHandle);
if (esp_lcd_panel_del(panelHandle) != ESP_OK) {
return false;
}
if (esp_lcd_panel_io_del(ioHandle) != ESP_OK) {
return false;
}
displayHandle = nullptr;
return true;
}
void YellowDisplay::setBacklightDuty(uint8_t backlightDuty) {
if (!isBacklightInitialized) {
tt_check(initBacklight());
isBacklightInitialized = true;
}
if (!setBacklight(backlightDuty)) {
TT_LOG_E(TAG, "Failed to configure display backlight");
}
}
/**
* Note:
* The datasheet implies this should work, but it doesn't:
* https://www.digikey.com/htmldatasheets/production/1640716/0/0/1/ILI9341-Datasheet.pdf
*
* This repo claims it only has 1 curve:
* https://github.com/brucemack/hello-ili9341
*
* I'm leaving it in as I'm not sure if it's just my hardware that's problematic.
*/
void YellowDisplay::setGammaCurve(uint8_t index) {
uint8_t gamma_curve;
switch (index) {
case 0:
gamma_curve = 0x01;
break;
case 1:
gamma_curve = 0x04;
break;
case 2:
gamma_curve = 0x02;
break;
case 3:
gamma_curve = 0x08;
break;
default:
return;
}
const uint8_t param[] = {
gamma_curve
};
if (esp_lcd_panel_io_tx_param(ioHandle , LCD_CMD_GAMSET, param, 1) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set gamma");
}
}
tt::hal::Touch* _Nullable YellowDisplay::createTouch() {
return static_cast<tt::hal::Touch*>(new YellowTouch());
}
tt::hal::Display* createDisplay() {
return static_cast<tt::hal::Display*>(new YellowDisplay());
}
@@ -1,34 +0,0 @@
#pragma once
#include "lvgl.h"
#include "hal/Display.h"
#include "esp_lcd_panel_io.h"
extern lv_disp_t* displayHandle;
class YellowDisplay : public tt::hal::Display {
private:
esp_lcd_panel_io_handle_t ioHandle = nullptr;
esp_lcd_panel_handle_t panelHandle = nullptr;
lv_display_t* displayHandle = nullptr;
public:
bool start() override;
bool stop() override;
tt::hal::Touch* _Nullable createTouch() override;
void setBacklightDuty(uint8_t backlightDuty) override;
bool supportsBacklightDuty() const override { return true; }
void setGammaCurve(uint8_t index) override;
uint8_t getGammaCurveCount() const override { return 4; };
lv_display_t* _Nullable getLvglDisplay() const override { return displayHandle; }
};
tt::hal::Display* createDisplay();
@@ -1,21 +0,0 @@
#pragma once
// Display backlight (PWM)
#define TWODOTFOUR_LCD_BACKLIGHT_LEDC_TIMER LEDC_TIMER_0
#define TWODOTFOUR_LCD_BACKLIGHT_LEDC_MODE LEDC_LOW_SPEED_MODE
#define TWODOTFOUR_LCD_BACKLIGHT_LEDC_CHANNEL LEDC_CHANNEL_0
#define TWODOTFOUR_LCD_BACKLIGHT_LEDC_DUTY_RES LEDC_TIMER_8_BIT
#define TWODOTFOUR_LCD_BACKLIGHT_LEDC_FREQUENCY (1000)
#define TWODOTFOUR_LCD_PIN_BACKLIGHT GPIO_NUM_27
// Display
#define TWODOTFOUR_LCD_SPI_HOST SPI2_HOST
#define TWODOTFOUR_LCD_HORIZONTAL_RESOLUTION 240
#define TWODOTFOUR_LCD_VERTICAL_RESOLUTION 320
#define TWODOTFOUR_LCD_BITS_PER_PIXEL 16
#define TWODOTFOUR_LCD_DRAW_BUFFER_HEIGHT (TWODOTFOUR_LCD_VERTICAL_RESOLUTION / 10)
#define TWODOTFOUR_LCD_DRAW_BUFFER_SIZE (TWODOTFOUR_LCD_HORIZONTAL_RESOLUTION * TWODOTFOUR_LCD_DRAW_BUFFER_HEIGHT * (TWODOTFOUR_LCD_BITS_PER_PIXEL / 8))
#define TWODOTFOUR_LCD_PIN_CS GPIO_NUM_15
#define TWODOTFOUR_LCD_PIN_DC GPIO_NUM_2
@@ -1,29 +0,0 @@
#include "YellowSdCard.h"
#define TAG "twodotfour_sdcard"
#include "lvgl/LvglSync.h"
#include "hal/SpiSdCard.h"
#define SDCARD_SPI_HOST SPI3_HOST
#define SDCARD_PIN_CS GPIO_NUM_5
std::shared_ptr<SdCard> createYellowSdCard() {
auto* configuration = new tt::hal::SpiSdCard::Config(
SDCARD_PIN_CS,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCard::MountBehaviour::AtBoot,
nullptr,
std::vector<gpio_num_t>(),
SDCARD_SPI_HOST
);
auto* sdcard = (SdCard*) new SpiSdCard(
std::unique_ptr<SpiSdCard::Config>(configuration)
);
return std::shared_ptr<SdCard>(sdcard);
}
@@ -1,8 +0,0 @@
#pragma once
#include "hal/SdCard.h"
using namespace tt::hal;
std::shared_ptr<SdCard> createYellowSdCard();
@@ -1,83 +0,0 @@
#include "YellowTouch.h"
#include "YellowTouchConstants.h"
#include "Log.h"
#include "driver/i2c.h"
#include "esp_err.h"
#include "esp_lcd_touch_cst816s.h"
#include "esp_lcd_touch.h"
#include "esp_lvgl_port.h"
#define TAG "twodotfour_touch"
bool YellowTouch::start(lv_display_t* display) {
TT_LOG_I(TAG, "Starting");
const esp_lcd_panel_io_i2c_config_t touch_io_config = ESP_LCD_TOUCH_IO_I2C_CST816S_CONFIG();
if (esp_lcd_new_panel_io_i2c((esp_lcd_i2c_bus_handle_t)TWODOTFOUR_TOUCH_I2C_PORT, &touch_io_config, &ioHandle) != ESP_OK) {
TT_LOG_E(TAG, "Touch I2C IO init failed");
return false;
}
esp_lcd_touch_config_t config = {
.x_max = 240,
.y_max = 320,
.rst_gpio_num = GPIO_NUM_NC, //GPIO_NUM_25,
.int_gpio_num = GPIO_NUM_NC, //GPIO_NUM_21,
.levels = {
.reset = 0,
.interrupt = 0,
},
.flags = {
.swap_xy = 0,
.mirror_x = 0,
.mirror_y = 0,
},
.process_coordinates = nullptr,
.interrupt_callback = nullptr,
.user_data = nullptr,
.driver_data = nullptr
};
if (esp_lcd_touch_new_i2c_cst816s(ioHandle, &config, &touchHandle) != ESP_OK) {
TT_LOG_E(TAG, "Driver init failed");
cleanup();
return false;
}
const lvgl_port_touch_cfg_t touch_cfg = {
.disp = display,
.handle = touchHandle,
};
deviceHandle = lvgl_port_add_touch(&touch_cfg);
if (deviceHandle == nullptr) {
TT_LOG_E(TAG, "Adding touch failed");
cleanup();
return false;
}
TT_LOG_I(TAG, "Finished");
return true;
}
bool YellowTouch::stop() {
cleanup();
return true;
}
void YellowTouch::cleanup() {
if (deviceHandle != nullptr) {
lv_indev_delete(deviceHandle);
deviceHandle = nullptr;
}
if (touchHandle != nullptr) {
esp_lcd_touch_del(touchHandle);
touchHandle = nullptr;
}
if (ioHandle != nullptr) {
esp_lcd_panel_io_del(ioHandle);
ioHandle = nullptr;
}
}
@@ -1,17 +0,0 @@
#pragma once
#include "hal/Touch.h"
#include "TactilityCore.h"
#include <esp_lcd_touch.h>
class YellowTouch : public tt::hal::Touch {
private:
esp_lcd_panel_io_handle_t ioHandle = nullptr;
esp_lcd_touch_handle_t touchHandle = nullptr;
lv_indev_t* _Nullable deviceHandle = nullptr;
void cleanup();
public:
bool start(lv_display_t* display) override;
bool stop() override;
lv_indev_t* _Nullable getLvglIndev() override { return deviceHandle; }
};
@@ -1,5 +0,0 @@
#pragma once
// Touch
#define TWODOTFOUR_TOUCH_I2C_PORT I2C_NUM_0
-5
View File
@@ -1,5 +0,0 @@
idf_component_register(
SRC_DIRS "Source" "Source/hal"
INCLUDE_DIRS "Source"
REQUIRES Tactility esp_lvgl_port esp_lcd esp_lcd_touch_gt911 driver esp_adc
)
@@ -1,51 +0,0 @@
#include "TactilityCore.h"
#include "hal/TdeckDisplayConstants.h"
#include <driver/spi_common.h>
#include <soc/gpio_num.h>
#define TAG "tdeck"
// SPI
#define TDECK_SPI_HOST SPI2_HOST
#define TDECK_SPI_PIN_SCLK GPIO_NUM_40
#define TDECK_SPI_PIN_MOSI GPIO_NUM_41
#define TDECK_SPI_PIN_MISO GPIO_NUM_38
#define TDECK_SPI_TRANSFER_SIZE_LIMIT (TDECK_LCD_HORIZONTAL_RESOLUTION * TDECK_LCD_SPI_TRANSFER_HEIGHT * (TDECK_LCD_BITS_PER_PIXEL / 8))
#define TDECK_LCD_BACKLIGHT_LEDC_TIMER LEDC_TIMER_0
#define TDECK_LCD_BACKLIGHT_LEDC_MODE LEDC_LOW_SPEED_MODE
#define TDECK_LCD_BACKLIGHT_LEDC_CHANNEL LEDC_CHANNEL_0
#define TDECK_LCD_BACKLIGHT_LEDC_DUTY_RES LEDC_TIMER_8_BIT
#define TDECK_LCD_BACKLIGHT_LEDC_FREQUENCY (4000)
static bool init_spi() {
TT_LOG_I(TAG, LOG_MESSAGE_SPI_INIT_START_FMT, TDECK_SPI_HOST);
spi_bus_config_t bus_config = {
.mosi_io_num = TDECK_SPI_PIN_MOSI,
.miso_io_num = TDECK_SPI_PIN_MISO,
.sclk_io_num = TDECK_SPI_PIN_SCLK,
.quadwp_io_num = -1, // Quad SPI LCD driver is not yet supported
.quadhd_io_num = -1, // Quad SPI LCD driver is not yet supported
.data4_io_num = 0,
.data5_io_num = 0,
.data6_io_num = 0,
.data7_io_num = 0,
.data_io_default_level = false,
.max_transfer_sz = TDECK_SPI_TRANSFER_SIZE_LIMIT,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
};
if (spi_bus_initialize(TDECK_SPI_HOST, &bus_config, SPI_DMA_CH_AUTO) != ESP_OK) {
TT_LOG_E(TAG, LOG_MESSAGE_SPI_INIT_FAILED_FMT, TDECK_SPI_HOST);
return false;
}
return true;
}
bool tdeck_init_hardware() {
return init_spi();
}
-57
View File
@@ -1,57 +0,0 @@
#include "hal/Configuration.h"
#include "hal/TdeckDisplay.h"
#include "hal/TdeckKeyboard.h"
#include "hal/TdeckPower.h"
#include "hal/TdeckSdCard.h"
bool tdeck_init_power();
bool tdeck_init_hardware();
bool tdeck_init_lvgl();
extern const tt::hal::Configuration lilygo_tdeck = {
.initBoot = tdeck_init_power,
.initHardware = tdeck_init_hardware,
.initLvgl = tdeck_init_lvgl,
.createDisplay = createDisplay,
.createKeyboard = createKeyboard,
.sdcard = createTdeckSdCard(),
.power = tdeck_get_power,
.i2c = {
tt::hal::i2c::Configuration {
.name = "Internal",
.port = I2C_NUM_0,
.initMode = tt::hal::i2c::InitMode::ByTactility,
.canReinit = false,
.hasMutableConfiguration = false,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_18,
.scl_io_num = GPIO_NUM_8,
.sda_pullup_en = true,
.scl_pullup_en = true,
.master = {
.clk_speed = 400000
},
.clk_flags = 0
}
},
tt::hal::i2c::Configuration {
.name = "External",
.port = I2C_NUM_1,
.initMode = tt::hal::i2c::InitMode::ByTactility,
.canReinit = true,
.hasMutableConfiguration = true,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_43,
.scl_io_num = GPIO_NUM_44,
.sda_pullup_en = false,
.scl_pullup_en = false,
.master = {
.clk_speed = 400000
},
.clk_flags = 0
}
}
}
};
-5
View File
@@ -1,5 +0,0 @@
#pragma once
#include <hal/Configuration.h>
extern const tt::hal::Configuration lilygo_tdeck;
-33
View File
@@ -1,33 +0,0 @@
#include "Log.h"
#include "Thread.h"
#include "lvgl/LvglSync.h"
#include "esp_lvgl_port.h"
#include "hal/TdeckDisplay.h"
#define TAG "tdeck_lvgl"
// LVGL
// The minimum task stack seems to be about 3500, but that crashes the wifi app in some scenarios
// At 8192, it sometimes crashes when wifi-auto enables and is busy connecting and then you open WifiManage
#define TDECK_LVGL_TASK_STACK_DEPTH 9216
bool tdeck_init_lvgl() {
static lv_disp_t* display = nullptr;
const lvgl_port_cfg_t lvgl_cfg = {
.task_priority = static_cast<UBaseType_t>(tt::THREAD_PRIORITY_RENDER),
.task_stack = TDECK_LVGL_TASK_STACK_DEPTH,
.task_affinity = -1, // core pinning
.task_max_sleep_ms = 500,
.timer_period_ms = 5
};
TT_LOG_D(TAG, "LVGL port init");
if (lvgl_port_init(&lvgl_cfg) != ESP_OK) {
TT_LOG_E(TAG, "LVGL port init failed");
return false;
}
tt::lvgl::syncSet(&lvgl_port_lock, &lvgl_port_unlock);
return true;
}
@@ -1,238 +0,0 @@
#include "TdeckDisplay.h"
#include "TdeckDisplayConstants.h"
#include "TdeckTouch.h"
#include "Log.h"
#include <TactilityCore.h>
#include <esp_lcd_panel_commands.h>
#include "driver/ledc.h"
#include "driver/spi_master.h"
#include "esp_err.h"
#include "esp_lcd_panel_ops.h"
#include "esp_lcd_panel_vendor.h"
#include "esp_lvgl_port.h"
#define TAG "tdeck_display"
static bool isBacklightInitialized = false;
static bool initBacklight() {
TT_LOG_I(TAG, "Init backlight");
ledc_timer_config_t ledc_timer = {
.speed_mode = TDECK_LCD_BACKLIGHT_LEDC_MODE,
.duty_resolution = TDECK_LCD_BACKLIGHT_LEDC_DUTY_RES,
.timer_num = TDECK_LCD_BACKLIGHT_LEDC_TIMER,
.freq_hz = TDECK_LCD_BACKLIGHT_LEDC_FREQUENCY,
.clk_cfg = LEDC_AUTO_CLK,
.deconfigure = false
};
if (ledc_timer_config(&ledc_timer) != ESP_OK) {
TT_LOG_E(TAG, "Backlight led timer config failed");
return false;
}
return true;
}
static bool setBacklight(uint8_t duty) {
ledc_channel_config_t ledc_channel = {
.gpio_num = TDECK_LCD_PIN_BACKLIGHT,
.speed_mode = TDECK_LCD_BACKLIGHT_LEDC_MODE,
.channel = TDECK_LCD_BACKLIGHT_LEDC_CHANNEL,
.intr_type = LEDC_INTR_DISABLE,
.timer_sel = TDECK_LCD_BACKLIGHT_LEDC_TIMER,
.duty = duty,
.hpoint = 0,
.sleep_mode = LEDC_SLEEP_MODE_NO_ALIVE_NO_PD,
.flags = {
.output_invert = 0
}
};
// Setting the config in the timer init and then calling ledc_set_duty() doesn't work when
// the app is running. For an unknown reason we have to call this config method every time:
return ledc_channel_config(&ledc_channel) == ESP_OK;
}
bool TdeckDisplay::start() {
TT_LOG_I(TAG, "Starting");
const esp_lcd_panel_io_spi_config_t panel_io_config = {
.cs_gpio_num = TDECK_LCD_PIN_CS,
.dc_gpio_num = TDECK_LCD_PIN_DC,
.spi_mode = 0,
.pclk_hz = TDECK_LCD_SPI_FREQUENCY,
.trans_queue_depth = 10,
.on_color_trans_done = nullptr,
.user_ctx = nullptr,
.lcd_cmd_bits = 8,
.lcd_param_bits = 8,
.cs_ena_pretrans = 0,
.cs_ena_posttrans = 0,
.flags = {
.dc_high_on_cmd = 0,
.dc_low_on_data = 0,
.dc_low_on_param = 0,
.octal_mode = 0,
.quad_mode = 0,
.sio_mode = 1,
.lsb_first = 0,
.cs_high_active = 0,
}
};
if (esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)TDECK_LCD_SPI_HOST, &panel_io_config, &ioHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to create panel IO");
return false;
}
const esp_lcd_panel_dev_config_t panel_config = {
.reset_gpio_num = GPIO_NUM_NC,
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB,
.data_endian = LCD_RGB_DATA_ENDIAN_LITTLE,
.bits_per_pixel = TDECK_LCD_BITS_PER_PIXEL,
.flags = {
.reset_active_high = 0
},
.vendor_config = nullptr
};
if (esp_lcd_new_panel_st7789(ioHandle, &panel_config, &panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to create panel");
return false;
}
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to reset panel");
return false;
}
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to init panel");
return false;
}
if (esp_lcd_panel_invert_color(panelHandle, true) != ESP_OK) {
TT_LOG_E(TAG, "Failed to init panel");
return false;
}
if (esp_lcd_panel_swap_xy(panelHandle, true) != ESP_OK) {
TT_LOG_E(TAG, "Failed to swap XY ");
return false;
}
if (esp_lcd_panel_mirror(panelHandle, true, false) != ESP_OK) {
TT_LOG_E(TAG, "Failed to mirror panel");
return false;
}
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
TT_LOG_E(TAG, "Failed to turn display on");
return false;
}
const lvgl_port_display_cfg_t disp_cfg = {
.io_handle = ioHandle,
.panel_handle = panelHandle,
.control_handle = nullptr,
.buffer_size = TDECK_LCD_HORIZONTAL_RESOLUTION * TDECK_LCD_DRAW_BUFFER_HEIGHT * (TDECK_LCD_BITS_PER_PIXEL / 8),
.double_buffer = true, // Disable to free up SPIRAM
.trans_size = 0,
.hres = TDECK_LCD_HORIZONTAL_RESOLUTION,
.vres = TDECK_LCD_VERTICAL_RESOLUTION,
.monochrome = false,
.rotation = {
.swap_xy = true,
.mirror_x = true,
.mirror_y = false,
},
.color_format = LV_COLOR_FORMAT_RGB565,
.flags = {
.buff_dma = false,
.buff_spiram = true,
.sw_rotate = false,
.swap_bytes = false,
.full_refresh = false,
.direct_mode = false
}
};
displayHandle = lvgl_port_add_disp(&disp_cfg);
TT_LOG_I(TAG, "Finished");
return displayHandle != nullptr;
}
bool TdeckDisplay::stop() {
assert(displayHandle != nullptr);
lvgl_port_remove_disp(displayHandle);
if (esp_lcd_panel_del(panelHandle) != ESP_OK) {
return false;
}
if (esp_lcd_panel_io_del(ioHandle) != ESP_OK) {
return false;
}
displayHandle = nullptr;
return true;
}
void TdeckDisplay::setPowerOn(bool turnOn) {
if (esp_lcd_panel_disp_on_off(panelHandle, turnOn) != ESP_OK) {
TT_LOG_E(TAG, "Failed to turn display on/off");
} else {
poweredOn = turnOn;
}
}
tt::hal::Touch* _Nullable TdeckDisplay::createTouch() {
return static_cast<tt::hal::Touch*>(new TdeckTouch());
}
void TdeckDisplay::setBacklightDuty(uint8_t backlightDuty) {
if (!isBacklightInitialized) {
tt_check(initBacklight());
isBacklightInitialized = true;
}
if (!setBacklight(backlightDuty)) {
TT_LOG_E(TAG, "Failed to configure display backlight");
}
}
void TdeckDisplay::setGammaCurve(uint8_t index) {
uint8_t gamma_curve;
switch (index) {
case 0:
gamma_curve = 0x01;
break;
case 1:
gamma_curve = 0x04;
break;
case 2:
gamma_curve = 0x02;
break;
case 3:
gamma_curve = 0x08;
break;
default:
return;
}
const uint8_t param[] = {
gamma_curve
};
if (esp_lcd_panel_io_tx_param(ioHandle , LCD_CMD_GAMSET, param, 1) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set gamma");
}
}
tt::hal::Display* createDisplay() {
return static_cast<tt::hal::Display*>(new TdeckDisplay());
}
@@ -1,43 +0,0 @@
#pragma once
#include <esp_lcd_types.h>
#include "lvgl.h"
#include "hal/Display.h"
extern lv_disp_t* displayHandle;
class TdeckDisplay : public tt::hal::Display {
private:
esp_lcd_panel_io_handle_t ioHandle = nullptr;
esp_lcd_panel_handle_t panelHandle = nullptr;
lv_display_t* displayHandle = nullptr;
bool poweredOn = false;
public:
bool start() override;
bool stop() override;
void setPowerOn(bool turnOn) override;
bool isPoweredOn() const override { return poweredOn; };
bool supportsPowerControl() const override { return true; }
tt::hal::Touch* _Nullable createTouch() override;
void setBacklightDuty(uint8_t backlightDuty) override;
bool supportsBacklightDuty() const override { return true; }
void setGammaCurve(uint8_t index) override;
uint8_t getGammaCurveCount() const override { return 4; };
lv_display_t* _Nullable getLvglDisplay() const override { return displayHandle; }
private:
static bool startBacklight();
};
tt::hal::Display* createDisplay();
@@ -1,20 +0,0 @@
#pragma once
#define TDECK_LCD_SPI_HOST SPI2_HOST
#define TDECK_LCD_PIN_CS GPIO_NUM_12
#define TDECK_LCD_PIN_DC GPIO_NUM_11 // RS
#define TDECK_LCD_PIN_BACKLIGHT GPIO_NUM_42
#define TDECK_LCD_SPI_FREQUENCY 80000000
#define TDECK_LCD_HORIZONTAL_RESOLUTION 320
#define TDECK_LCD_VERTICAL_RESOLUTION 240
#define TDECK_LCD_BITS_PER_PIXEL 16
#define TDECK_LCD_DRAW_BUFFER_HEIGHT (TDECK_LCD_VERTICAL_RESOLUTION / 10)
#define TDECK_LCD_SPI_TRANSFER_HEIGHT (TDECK_LCD_VERTICAL_RESOLUTION / 10)
// Backlight (PWM)
#define TDECK_LCD_BACKLIGHT_LEDC_TIMER LEDC_TIMER_0
#define TDECK_LCD_BACKLIGHT_LEDC_MODE LEDC_LOW_SPEED_MODE
#define TDECK_LCD_BACKLIGHT_LEDC_CHANNEL LEDC_CHANNEL_0
#define TDECK_LCD_BACKLIGHT_LEDC_DUTY_RES LEDC_TIMER_8_BIT
#define TDECK_LCD_BACKLIGHT_LEDC_FREQUENCY (4000)
@@ -1,67 +0,0 @@
#include "TdeckKeyboard.h"
#include "hal/i2c/I2c.h"
#include <driver/i2c.h>
#define TAG "tdeck_keyboard"
#define TDECK_KEYBOARD_I2C_BUS_HANDLE I2C_NUM_0
#define TDECK_KEYBOARD_SLAVE_ADDRESS 0x55
static inline bool keyboard_i2c_read(uint8_t* output) {
return tt::hal::i2c::masterRead(TDECK_KEYBOARD_I2C_BUS_HANDLE, TDECK_KEYBOARD_SLAVE_ADDRESS, output, 1, 100 / portTICK_PERIOD_MS);
}
/**
* The callback simulates press and release events, because the T-Deck
* keyboard only publishes press events on I2C.
* LVGL currently works without those extra release events, but they
* are implemented for correctness and future compatibility.
*
* @param indev_drv
* @param data
*/
static void keyboard_read_callback(TT_UNUSED lv_indev_t* indev, lv_indev_data_t* data) {
static uint8_t last_buffer = 0x00;
uint8_t read_buffer = 0x00;
// Defaults
data->key = 0;
data->state = LV_INDEV_STATE_RELEASED;
if (keyboard_i2c_read(&read_buffer)) {
if (read_buffer == 0 && read_buffer != last_buffer) {
TT_LOG_D(TAG, "Released %d", last_buffer);
data->key = last_buffer;
data->state = LV_INDEV_STATE_RELEASED;
} else if (read_buffer != 0) {
TT_LOG_D(TAG, "Pressed %d", read_buffer);
data->key = read_buffer;
data->state = LV_INDEV_STATE_PRESSED;
}
}
last_buffer = read_buffer;
}
bool TdeckKeyboard::start(lv_display_t* display) {
deviceHandle = lv_indev_create();
lv_indev_set_type(deviceHandle, LV_INDEV_TYPE_KEYPAD);
lv_indev_set_read_cb(deviceHandle, &keyboard_read_callback);
lv_indev_set_display(deviceHandle, display);
lv_indev_set_user_data(deviceHandle, this);
return true;
}
bool TdeckKeyboard::stop() {
lv_indev_delete(deviceHandle);
deviceHandle = nullptr;
return true;
}
bool TdeckKeyboard::isAttached() const {
return tt::hal::i2c::masterHasDeviceAtAddress(TDECK_KEYBOARD_I2C_BUS_HANDLE, TDECK_KEYBOARD_SLAVE_ADDRESS, 100);
}
tt::hal::Keyboard* createKeyboard() {
return dynamic_cast<tt::hal::Keyboard*>(new TdeckKeyboard());
}
@@ -1,18 +0,0 @@
#pragma once
#include "hal/Keyboard.h"
#include <TactilityCore.h>
#include "esp_lcd_panel_io_interface.h"
#include "esp_lcd_touch.h"
class TdeckKeyboard : public tt::hal::Keyboard {
private:
lv_indev_t* _Nullable deviceHandle = nullptr;
public:
bool start(lv_display_t* display) override;
bool stop() override;
bool isAttached() const override;
lv_indev_t* _Nullable getLvglIndev() override { return deviceHandle; }
};
tt::hal::Keyboard* createKeyboard();
@@ -1,131 +0,0 @@
#include "TdeckPower.h"
#include "Log.h"
#include "CoreDefines.h"
#define TAG "power"
/**
* 2.0 ratio, but +.11 added as display voltage sag compensation.
*/
#define ADC_MULTIPLIER 2.11
#define ADC_REF_VOLTAGE 3.3f
#define BATTERY_VOLTAGE_MIN 3.2f
#define BATTERY_VOLTAGE_MAX 4.2f
static adc_oneshot_unit_init_cfg_t adcConfig = {
.unit_id = ADC_UNIT_1,
.clk_src = ADC_RTC_CLK_SRC_DEFAULT,
.ulp_mode = ADC_ULP_MODE_DISABLE,
};
static adc_oneshot_chan_cfg_t adcChannelConfig = {
.atten = ADC_ATTEN_DB_12,
.bitwidth = ADC_BITWIDTH_DEFAULT,
};
static uint8_t estimateChargeLevelFromVoltage(uint32_t milliVolt) {
float volts = TT_MIN((float)milliVolt / 1000.f, BATTERY_VOLTAGE_MAX);
float voltage_percentage = (volts - BATTERY_VOLTAGE_MIN) / (BATTERY_VOLTAGE_MAX - BATTERY_VOLTAGE_MIN);
float voltage_factor = TT_MIN(1.0f, voltage_percentage);
auto charge_level = (uint8_t) (voltage_factor * 100.f);
TT_LOG_V(TAG, "mV = %lu, scaled = %.2f, factor = %.2f, result = %d", milliVolt, volts, voltage_factor, charge_level);
return charge_level;
}
TdeckPower::TdeckPower() {
if (adc_oneshot_new_unit(&adcConfig, &adcHandle) != ESP_OK) {
TT_LOG_E(TAG, "ADC config failed");
return;
}
if (adc_oneshot_config_channel(adcHandle, ADC_CHANNEL_3, &adcChannelConfig) != ESP_OK) {
TT_LOG_E(TAG, "ADC channel config failed");
adc_oneshot_del_unit(adcHandle);
return;
}
}
TdeckPower::~TdeckPower() {
if (adcHandle) {
adc_oneshot_del_unit(adcHandle);
}
}
bool TdeckPower::supportsMetric(MetricType type) const {
switch (type) {
case MetricType::BatteryVoltage:
case MetricType::ChargeLevel:
return true;
case MetricType::IsCharging:
case MetricType::Current:
return false;
}
return false; // Safety guard for when new enum values are introduced
}
bool TdeckPower::getMetric(Power::MetricType type, Power::MetricData& data) {
switch (type) {
case MetricType::BatteryVoltage:
return readBatteryVoltageSampled(data.valueAsUint32);
case MetricType::ChargeLevel:
if (readBatteryVoltageSampled(data.valueAsUint32)) {
data.valueAsUint32 = estimateChargeLevelFromVoltage(data.valueAsUint32);
return true;
} else {
return false;
}
case MetricType::IsCharging:
case MetricType::Current:
return false;
}
return false; // Safety guard for when new enum values are introduced
}
bool TdeckPower::readBatteryVoltageOnce(uint32_t& output) {
int raw;
if (adc_oneshot_read(adcHandle, ADC_CHANNEL_3, &raw) == ESP_OK) {
output = ADC_MULTIPLIER * ((1000.f * ADC_REF_VOLTAGE) / 4096.f) * (float)raw;
TT_LOG_V(TAG, "Raw = %d, voltage = %lu", raw, output);
return true;
} else {
TT_LOG_E(TAG, "Read failed");
return false;
}
}
#define MAX_VOLTAGE_SAMPLES 15
bool TdeckPower::readBatteryVoltageSampled(uint32_t& output) {
size_t samples_read = 0;
uint32_t sample_accumulator = 0;
uint32_t sample_read_buffer;
for (size_t i = 0; i < MAX_VOLTAGE_SAMPLES; ++i) {
if (readBatteryVoltageOnce(sample_read_buffer)) {
sample_accumulator += sample_read_buffer;
samples_read++;
}
}
if (samples_read > 0) {
output = sample_accumulator / samples_read;
return true;
} else {
return false;
}
}
static std::shared_ptr<Power> power;
std::shared_ptr<Power> tdeck_get_power() {
if (power == nullptr) {
power = std::make_shared<TdeckPower>();
}
return power;
}
@@ -1,27 +0,0 @@
#pragma once
#include "hal/Power.h"
#include <esp_adc/adc_oneshot.h>
#include <memory>
using namespace tt::hal;
class TdeckPower : public Power {
adc_oneshot_unit_handle_t adcHandle = nullptr;
public:
TdeckPower();
~TdeckPower();
bool supportsMetric(MetricType type) const override;
bool getMetric(Power::MetricType type, Power::MetricData& data) override;
private:
bool readBatteryVoltageSampled(uint32_t& output);
bool readBatteryVoltageOnce(uint32_t& output);
};
std::shared_ptr<Power> tdeck_get_power();
@@ -1,32 +0,0 @@
#include "TdeckSdCard.h"
#include "lvgl/LvglSync.h"
#include "hal/SpiSdCard.h"
#include <esp_vfs_fat.h>
#include <sdmmc_cmd.h>
#define TDECK_SDCARD_PIN_CS GPIO_NUM_39
#define TDECK_LCD_PIN_CS GPIO_NUM_12
#define TDECK_RADIO_PIN_CS GPIO_NUM_9
std::shared_ptr<SdCard> createTdeckSdCard() {
auto* configuration = new tt::hal::SpiSdCard::Config(
TDECK_SDCARD_PIN_CS,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCard::MountBehaviour::AtBoot,
tt::lvgl::getLvglSyncLockable(),
{
TDECK_RADIO_PIN_CS,
TDECK_LCD_PIN_CS
}
);
auto* sdcard = (SdCard*) new SpiSdCard(
std::unique_ptr<SpiSdCard::Config>(configuration)
);
return std::shared_ptr<SdCard>(sdcard);
}
@@ -1,7 +0,0 @@
#pragma once
#include "hal/SdCard.h"
using namespace tt::hal;
std::shared_ptr<SdCard> createTdeckSdCard();
@@ -1,85 +0,0 @@
#include "TdeckTouch.h"
#include "esp_err.h"
#include "esp_lcd_touch_gt911.h"
#include "Log.h"
#include "esp_lvgl_port.h"
#define TAG "tdeck_touch"
// Touch (GT911)
#define TDECK_TOUCH_I2C_BUS_HANDLE I2C_NUM_0
#define TDECK_TOUCH_X_MAX 240
#define TDECK_TOUCH_Y_MAX 320
bool TdeckTouch::start(lv_display_t* display) {
const esp_lcd_panel_io_i2c_config_t io_config = ESP_LCD_TOUCH_IO_I2C_GT911_CONFIG();
if (esp_lcd_new_panel_io_i2c(TDECK_TOUCH_I2C_BUS_HANDLE, &io_config, &ioHandle) != ESP_OK) {
TT_LOG_E(TAG, "touch io i2c creation failed");
return false;
}
esp_lcd_touch_config_t config = {
.x_max = TDECK_TOUCH_X_MAX,
.y_max = TDECK_TOUCH_Y_MAX,
.rst_gpio_num = GPIO_NUM_NC,
.int_gpio_num = GPIO_NUM_NC, // There is no reset pin for touch on the T-Deck, leading to a bug in esp_lvgl_port firing multiple click events when tapping the screen
.levels = {
.reset = 0,
.interrupt = 0,
},
.flags = {
.swap_xy = 1,
.mirror_x = 1,
.mirror_y = 0,
},
.process_coordinates = nullptr,
.interrupt_callback = nullptr,
.user_data = nullptr,
.driver_data = nullptr
};
if (esp_lcd_touch_new_i2c_gt911(ioHandle, &config, &touchHandle) != ESP_OK) {
TT_LOG_E(TAG, "GT199 driver init failed");
cleanup();
return false;
}
const lvgl_port_touch_cfg_t touch_cfg = {
.disp = display,
.handle = touchHandle,
};
TT_LOG_I(TAG, "Adding touch to LVGL");
deviceHandle = lvgl_port_add_touch(&touch_cfg);
if (deviceHandle == nullptr) {
TT_LOG_E(TAG, "Adding touch failed");
cleanup();
return false;
}
return true;
}
bool TdeckTouch::stop() {
cleanup();
return true;
}
void TdeckTouch::cleanup() {
if (deviceHandle != nullptr) {
lv_indev_delete(deviceHandle);
deviceHandle = nullptr;
}
if (touchHandle != nullptr) {
esp_lcd_touch_del(touchHandle);
touchHandle = nullptr;
}
if (ioHandle != nullptr) {
esp_lcd_panel_io_del(ioHandle);
ioHandle = nullptr;
}
}
@@ -1,18 +0,0 @@
#pragma once
#include "hal/Touch.h"
#include "TactilityCore.h"
#include "esp_lcd_panel_io_interface.h"
#include "esp_lcd_touch.h"
class TdeckTouch : public tt::hal::Touch {
private:
esp_lcd_panel_io_handle_t _Nullable ioHandle = nullptr;
esp_lcd_touch_handle_t _Nullable touchHandle = nullptr;
lv_indev_t* _Nullable deviceHandle = nullptr;
void cleanup();
public:
bool start(lv_display_t* display) override;
bool stop() override;
lv_indev_t* _Nullable getLvglIndev() override { return deviceHandle; }
};
-5
View File
@@ -1,5 +0,0 @@
idf_component_register(
SRC_DIRS "Source" "Source/hal" "Source/ft6x36" "Source/axp192"
INCLUDE_DIRS "Source"
REQUIRES Tactility esp_lvgl_port esp_lcd esp_lcd_ili9341 driver vfs fatfs
)
-11
View File
@@ -1,11 +0,0 @@
# M5Stack Core2
This board implementation concerns the original Core2 hardware and **not** the v1.1 variant.
Reference implementations:
- [ESP-BSP](https://github.com/espressif/esp-bsp/tree/master/bsp/m5stack_core_2)
- [M5Unified](https://github.com/m5stack/M5Unified)
- [M5GFX](https://github.com/m5stack/M5GFX)
Docs:
- [M5Stack.com](https://docs.m5stack.com/en/core/Core2)
-74
View File
@@ -1,74 +0,0 @@
#include <driver/i2c.h>
#include <driver/spi_master.h>
#include <esp_intr_types.h>
#include "Log.h"
#include "hal/Core2DisplayConstants.h"
#include "axp192/axp192.h"
#include "hal/i2c/I2c.h"
#include "CoreDefines.h"
#define TAG "core2"
#define CORE2_SPI2_PIN_SCLK GPIO_NUM_18
#define CORE2_SPI2_PIN_MOSI GPIO_NUM_23
#define CORE2_SPI2_PIN_MISO GPIO_NUM_38
axp192_t axpDevice;
static int32_t axpI2cRead(TT_UNUSED void* handle, uint8_t address, uint8_t reg, uint8_t* buffer, uint16_t size) {
return tt::hal::i2c::masterReadRegister(I2C_NUM_0, address, reg, buffer, size, 50 / portTICK_PERIOD_MS);
}
static int32_t axpI2cWrite(TT_UNUSED void* handle, uint8_t address, uint8_t reg, const uint8_t* buffer, uint16_t size) {
return tt::hal::i2c::masterWriteRegister(I2C_NUM_0, address, reg, buffer, size, 50 / portTICK_PERIOD_MS);
}
static bool initSpi2() {
TT_LOG_I(TAG, LOG_MESSAGE_SPI_INIT_START_FMT, SPI2_HOST);
const spi_bus_config_t bus_config = {
.mosi_io_num = CORE2_SPI2_PIN_MOSI,
.miso_io_num = CORE2_SPI2_PIN_MISO,
.sclk_io_num = CORE2_SPI2_PIN_SCLK,
.data2_io_num = GPIO_NUM_NC,
.data3_io_num = GPIO_NUM_NC,
.data4_io_num = GPIO_NUM_NC,
.data5_io_num = GPIO_NUM_NC,
.data6_io_num = GPIO_NUM_NC,
.data7_io_num = GPIO_NUM_NC,
.max_transfer_sz = CORE2_LCD_DRAW_BUFFER_SIZE,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
};
if (spi_bus_initialize(SPI2_HOST, &bus_config, SPI_DMA_CH_AUTO) != ESP_OK) {
TT_LOG_E(TAG, LOG_MESSAGE_SPI_INIT_FAILED_FMT, SPI2_HOST);
return false;
}
return true;
}
bool initAxp() {
axpDevice.read = axpI2cRead;
axpDevice.write = axpI2cWrite;
axp192_ioctl(&axpDevice, AXP192_LDO2_SET_VOLTAGE, 3300); // LCD + SD
axp192_ioctl(&axpDevice, AXP192_LDO3_SET_VOLTAGE, 0); // VIB_MOTOR STOP
axp192_ioctl(&axpDevice, AXP192_DCDC3_SET_VOLTAGE, 3300);
axp192_ioctl(&axpDevice, AXP192_LDO2_ENABLE);
axp192_ioctl(&axpDevice, AXP192_LDO3_DISABLE);
axp192_ioctl(&axpDevice, AXP192_DCDC3_ENABLE);
axp192_write(&axpDevice, AXP192_PWM1_DUTY_CYCLE_2, 255); // PWM 255 (LED OFF)
axp192_write(&axpDevice, AXP192_GPIO1_CONTROL, 0x02); // GPIO1 PWM
// TODO: We could charge at 390mA according to the M5Unified code, but the AXP driver in M5Unified limits to 132mA, so it's unclear what the AXP supports.
return true;
}
bool initBoot() {
TT_LOG_I(TAG, "initBoot");
return initAxp() && initSpi2();
}
-3
View File
@@ -1,3 +0,0 @@
#pragma once
bool initBoot();
-31
View File
@@ -1,31 +0,0 @@
#include "Log.h"
#include "Thread.h"
#include "lvgl/LvglSync.h"
#include "esp_lvgl_port.h"
#define TAG "core2"
// LVGL
// The minimum task stack seems to be about 3500, but that crashes the wifi app in some scenarios
// At 4000, it crashes when the fps renderer is available
#define CORE2_LVGL_TASK_STACK_DEPTH 9216
bool initLvgl() {
const lvgl_port_cfg_t lvgl_cfg = {
.task_priority = static_cast<UBaseType_t>(tt::THREAD_PRIORITY_RENDER),
.task_stack = CORE2_LVGL_TASK_STACK_DEPTH,
.task_affinity = -1, // core pinning
.task_max_sleep_ms = 500,
.timer_period_ms = 5
};
TT_LOG_D(TAG, "LVGL port init");
if (lvgl_port_init(&lvgl_cfg) != ESP_OK) {
TT_LOG_E(TAG, "LVGL port init failed");
return false;
}
tt::lvgl::syncSet(&lvgl_port_lock, &lvgl_port_unlock);
return true;
}
-3
View File
@@ -1,3 +0,0 @@
#pragma once
bool initLvgl();
@@ -1,52 +0,0 @@
#include "M5stackCore2.h"
#include "InitBoot.h"
#include "InitLvgl.h"
#include "hal/Core2Display.h"
#include "hal/Core2SdCard.h"
#include "hal/Core2Power.h"
extern const tt::hal::Configuration m5stack_core2 = {
.initBoot = initBoot,
.initLvgl = initLvgl,
.createDisplay = createDisplay,
.sdcard = createSdCard(),
.power = createPower,
.i2c = {
tt::hal::i2c::Configuration {
.name = "Internal",
.port = I2C_NUM_0,
.initMode = tt::hal::i2c::InitMode::ByTactility,
.canReinit = false, // Might be set to try after trying out what it does AXP and screen
.hasMutableConfiguration = false,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_21,
.scl_io_num = GPIO_NUM_22,
.sda_pullup_en = true,
.scl_pullup_en = true,
.master = {
.clk_speed = 400000
},
.clk_flags = 0
}
},
tt::hal::i2c::Configuration {
.name = "External", // (Grove)
.port = I2C_NUM_1,
.initMode = tt::hal::i2c::InitMode::ByTactility,
.canReinit = true,
.hasMutableConfiguration = true,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_32,
.scl_io_num = GPIO_NUM_33,
.sda_pullup_en = true,
.scl_pullup_en = true,
.master = {
.clk_speed = 400000
},
.clk_flags = 0
}
}
}
};
@@ -1,5 +0,0 @@
#pragma once
#include "hal/Configuration.h"
extern const tt::hal::Configuration m5stack_core2;
-21
View File
@@ -1,21 +0,0 @@
MIT License
Copyright (c) 2019-2021 Mika Tuupola
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -1,4 +0,0 @@
From https://github.com/tuupola/axp192
Changed some code for Tactility:
- `axp192_write()` now accepts a byte value instead of a byte pointer
-440
View File
@@ -1,440 +0,0 @@
/*
MIT License
Copyright (c) 2019-2021 Mika Tuupola
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-cut-
This file is part of hardware agnostic I2C driver for AXP192:
https://github.com/tuupola/axp192
SPDX-License-Identifier: MIT
Version: 0.6.0
*/
#include <stdarg.h>
#include <stdint.h>
#include "axp192_config.h"
#include "axp192.h"
static axp192_err_t read_coloumb_counter(const axp192_t *axp, float *buffer);
static axp192_err_t read_battery_power(const axp192_t *axp, float *buffer);
static const axp192_init_command_t init_commands[] = {
#ifdef AXP192_INCLUDE_SDKCONFIG_H
/* Currently you have to use menuconfig to be able to use axp192_init() */
{AXP192_DCDC1_VOLTAGE, {CONFIG_AXP192_DCDC1_VOLTAGE}, 1},
{AXP192_DCDC3_VOLTAGE, {CONFIG_AXP192_DCDC3_VOLTAGE}, 1},
{AXP192_LDO23_VOLTAGE, {CONFIG_AXP192_LDO23_VOLTAGE}, 1},
{AXP192_GPIO0_LDOIO0_VOLTAGE, {CONFIG_AXP192_GPIO0_LDOIO0_VOLTAGE}, 1},
{AXP192_DCDC13_LDO23_CONTROL, {CONFIG_AXP192_DCDC13_LDO23_CONTROL}, 1},
{AXP192_EXTEN_DCDC2_CONTROL, {CONFIG_AXP192_EXTEN_DCDC2_CONTROL}, 1},
{AXP192_GPIO0_CONTROL, {CONFIG_AXP192_GPIO0_CONTROL}, 1},
{AXP192_GPIO1_CONTROL, {CONFIG_AXP192_GPIO1_CONTROL}, 1},
{AXP192_GPIO2_CONTROL, {CONFIG_AXP192_GPIO2_CONTROL}, 1},
{AXP192_GPIO43_FUNCTION_CONTROL, {CONFIG_AXP192_GPIO43_FUNCTION_CONTROL}, 1},
{AXP192_ADC_ENABLE_1, {CONFIG_AXP192_ADC_ENABLE_1}, 1},
{AXP192_CHARGE_CONTROL_1, {CONFIG_AXP192_CHARGE_CONTROL_1}, 1},
{AXP192_BATTERY_CHARGE_CONTROL, {CONFIG_AXP192_BATTERY_CHARGE_CONTROL}, 1},
#endif /* AXP192_INCLUDE_SDKCONFIG_H */
/* End of commands. */
{0, {0}, 0xff},
};
axp192_err_t axp192_init(const axp192_t *axp)
{
uint8_t cmd = 0;
axp192_err_t status;
/* Send all the commands. */
while (init_commands[cmd].count != 0xff) {
status = axp->write(
axp->handle,
AXP192_ADDRESS,
init_commands[cmd].command,
init_commands[cmd].data,
init_commands[cmd].count & 0x1f
);
if (AXP192_OK != status) {
return status;
}
cmd++;
}
return AXP192_OK;
}
static axp192_err_t axp192_read_adc(const axp192_t *axp, uint8_t reg, float *buffer)
{
uint8_t tmp[4];
float sensitivity = 1.0;
float offset = 0.0;
axp192_err_t status;
switch (reg) {
case AXP192_ACIN_VOLTAGE:
case AXP192_VBUS_VOLTAGE:
/* 1.7mV per LSB */
sensitivity = 1.7 / 1000;
break;
case AXP192_ACIN_CURRENT:
/* 0.375mA per LSB */
sensitivity = 0.625 / 1000;
break;
case AXP192_VBUS_CURRENT:
/* 0.375mA per LSB */
sensitivity = 0.375 / 1000;
break;
case AXP192_TEMP:
/* 0.1C per LSB, 0x00 = -144.7C */
sensitivity = 0.1;
offset = -144.7;
break;
case AXP192_TS_INPUT:
/* 0.8mV per LSB */
sensitivity = 0.8 / 1000;
break;
case AXP192_BATTERY_POWER:
/* 1.1mV * 0.5mA per LSB */
return read_battery_power(axp, buffer);
break;
case AXP192_BATTERY_VOLTAGE:
/* 1.1mV per LSB */
sensitivity = 1.1 / 1000;
break;
case AXP192_CHARGE_CURRENT:
case AXP192_DISCHARGE_CURRENT:
/* 0.5mV per LSB */
sensitivity = 0.5 / 1000;
break;
case AXP192_APS_VOLTAGE:
/* 1.4mV per LSB */
sensitivity = 1.4 / 1000;
break;
case AXP192_COULOMB_COUNTER:
/* This is currently untested. */
return read_coloumb_counter(axp, buffer);
break;
}
status = axp->read(axp->handle, AXP192_ADDRESS, reg, tmp, 2);
if (AXP192_OK != status) {
return status;
}
*buffer = (((tmp[0] << 4) + tmp[1]) * sensitivity) + offset;
return AXP192_OK;
}
axp192_err_t axp192_read(const axp192_t *axp, uint8_t reg, void *buffer) {
switch (reg) {
case AXP192_ACIN_VOLTAGE:
case AXP192_VBUS_VOLTAGE:
case AXP192_ACIN_CURRENT:
case AXP192_VBUS_CURRENT:
case AXP192_TEMP:
case AXP192_TS_INPUT:
case AXP192_BATTERY_POWER:
case AXP192_BATTERY_VOLTAGE:
case AXP192_CHARGE_CURRENT:
case AXP192_DISCHARGE_CURRENT:
case AXP192_APS_VOLTAGE:
case AXP192_COULOMB_COUNTER:
/* Return ADC value. */
return axp192_read_adc(axp, reg, buffer);
break;
default:
/* Return raw register value. */
return axp->read(axp->handle, AXP192_ADDRESS, reg, buffer, 1);
}
}
axp192_err_t axp192_write(const axp192_t *axp, uint8_t reg, uint8_t value) {
switch (reg) {
case AXP192_ACIN_VOLTAGE:
case AXP192_VBUS_VOLTAGE:
case AXP192_ACIN_CURRENT:
case AXP192_VBUS_CURRENT:
case AXP192_TEMP:
case AXP192_TS_INPUT:
case AXP192_BATTERY_POWER:
case AXP192_BATTERY_VOLTAGE:
case AXP192_CHARGE_CURRENT:
case AXP192_DISCHARGE_CURRENT:
case AXP192_APS_VOLTAGE:
case AXP192_COULOMB_COUNTER:
/* Read only register. */
return AXP192_ERROR_ENOTSUP;
break;
default:
/* Write raw register value. */
return axp->write(axp->handle, AXP192_ADDRESS, reg, &value, 1);
}
}
axp192_err_t axp192_ioctl(const axp192_t *axp, int command, ...)
{
uint8_t reg = command >> 8;
uint8_t tmp;
uint16_t argument;
va_list ap;
switch (command) {
case AXP192_COULOMB_COUNTER_ENABLE:
tmp = 0b10000000;
return axp->write(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
break;
case AXP192_COULOMB_COUNTER_DISABLE:
tmp = 0b00000000;
return axp->write(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
break;
case AXP192_COULOMB_COUNTER_SUSPEND:
tmp = 0b11000000;
return axp->write(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
break;
case AXP192_COULOMB_COUNTER_CLEAR:
tmp = 0b10100000;
return axp->write(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
break;
/* This is currently untested. */
case AXP192_LDOIO0_ENABLE:
/* 0x02 = LDO */
tmp = 0b00000010;
return axp->write(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
break;
/* This is currently untested. */
case AXP192_LDOIO0_DISABLE:
/* 0x07 = float */
tmp = 0b00000111;
return axp->write(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
break;
case AXP192_LDO2_ENABLE:
/* This is currently untested. */
case AXP192_EXTEN_ENABLE:
axp->read(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
tmp |= 0b00000100;
return axp->write(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
break;
case AXP192_LDO2_DISABLE:
/* This is currently untested. */
case AXP192_EXTEN_DISABLE:
axp->read(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
tmp &= ~0b00000100;
return axp->write(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
break;
/* This is currently untested. */
case AXP192_GPIO2_SET_LEVEL:
axp->read(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
va_start(ap, command);
argument = (uint8_t) va_arg(ap, int);
va_end(ap);
if (argument) {
tmp |= 0b00000100;
} else {
tmp &= ~0b00000100;
}
return axp->write(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
break;
case AXP192_LDO3_ENABLE:
axp->read(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
tmp |= 0b00001000;
return axp->write(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
break;
case AXP192_LDO3_DISABLE:
axp->read(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
tmp &= ~0b00001000;
return axp->write(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
break;
/* This is currently untested. */
case AXP192_DCDC1_ENABLE:
/* This is currently untested. */
case AXP192_DCDC2_ENABLE:
axp->read(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
tmp |= 0b00000001;
return axp->write(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
break;
/* This is currently untested. */
case AXP192_DCDC1_DISABLE:
/* This is currently untested. */
case AXP192_DCDC2_DISABLE:
axp->read(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
tmp &= ~0b00000001;
return axp->write(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
break;
case AXP192_DCDC3_ENABLE:
axp->read(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
tmp |= 0b00000010;
return axp->write(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
break;
case AXP192_DCDC3_DISABLE:
axp->read(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
tmp &= ~0b00000010;
return axp->write(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
break;
case AXP192_GPIO1_SET_LEVEL:
case AXP192_GPIO4_SET_LEVEL:
axp->read(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
va_start(ap, command);
argument = (uint8_t) va_arg(ap, int);
va_end(ap);
if (argument) {
tmp |= 0b00000010;
} else {
tmp &= ~0b00000010;
}
return axp->write(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
break;
/* This is currently untested. */
case AXP192_GPIO0_SET_LEVEL:
axp->read(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
va_start(ap, command);
argument = (uint8_t) va_arg(ap, int);
va_end(ap);
if (argument) {
tmp |= 0b00000001;
} else {
tmp &= ~0b00000001;
}
return axp->write(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
break;
case AXP192_DCDC1_SET_VOLTAGE:
case AXP192_DCDC3_SET_VOLTAGE:
va_start(ap, command);
argument = (uint16_t) va_arg(ap, int);
va_end(ap);
/* 700-3500mv 25mV per step */
if ((argument < 700) || (argument > 3500)) {
return AXP192_ERROR_EINVAL;
}
tmp = (argument - 700) / 25;
return axp->write(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
break;
/* This is currently untested. */
case AXP192_DCDC2_SET_VOLTAGE:
va_start(ap, command);
argument = (uint16_t) va_arg(ap, int);
va_end(ap);
/* 700-2275mV 25mV per step */
if ((argument < 700) || (argument > 2275)) {
return AXP192_ERROR_EINVAL;
}
tmp = (argument - 700) / 25;
return axp->write(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
break;
/* This is currently untested. */
case AXP192_LDO2_SET_VOLTAGE:
va_start(ap, command);
argument = (uint16_t) va_arg(ap, int);
va_end(ap);
/* 1800-3300mV 100mV per step */
if ((argument < 1800) || (argument > 3300)) {
return AXP192_ERROR_EINVAL;
}
axp->read(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
tmp &= ~0xf0;
tmp |= (((argument - 1800) / 100) << 4);
return axp->write(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
break;
/* This is currently untested. */
case AXP192_LDO3_SET_VOLTAGE:
va_start(ap, command);
argument = (uint16_t) va_arg(ap, int);
va_end(ap);
/* 1800-3300mV 100mV per step */
if ((argument < 1800) || (argument > 3300)) {
return AXP192_ERROR_EINVAL;
}
axp->read(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
tmp &= ~0x0f;
tmp |= ((argument - 1800) / 100);
return axp->write(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
break;
/* This is currently untested. */
case AXP192_LDOIO0_SET_VOLTAGE:
va_start(ap, command);
argument = (uint16_t) va_arg(ap, int);
va_end(ap);
/* 1800-3300mV 100mV per step, 2800mV default. */
if ((argument < 1800) || (argument > 3300)) {
return AXP192_ERROR_EINVAL;
}
tmp = (((argument - 1800) / 100) << 4);
return axp->write(axp->handle, AXP192_ADDRESS, reg, &tmp, 1);
break;
}
return AXP192_ERROR_NOTTY;
}
static axp192_err_t read_coloumb_counter(const axp192_t *axp, float *buffer)
{
uint8_t tmp[4];
int32_t coin, coout;
axp192_err_t status;
status = axp->read(axp->handle, AXP192_ADDRESS, AXP192_CHARGE_COULOMB, tmp, sizeof(coin));
if (AXP192_OK != status) {
return status;
}
coin = (tmp[0] << 24) + (tmp[1] << 16) + (tmp[2] << 8) + tmp[3];
status = axp->read(axp->handle, AXP192_ADDRESS, AXP192_DISCHARGE_COULOMB, tmp, sizeof(coout));
if (AXP192_OK != status) {
return status;
}
coout = (tmp[0] << 24) + (tmp[1] << 16) + (tmp[2] << 8) + tmp[3];
/* CmAh = 65536 * 0.5mA *(coin - cout) / 3600 / ADC sample rate */
*buffer = 32768 * (coin - coout) / 3600 / 25;
return AXP192_OK;
}
static axp192_err_t read_battery_power(const axp192_t *axp, float *buffer)
{
uint8_t tmp[4];
float sensitivity;
axp192_err_t status;
/* 1.1mV * 0.5mA per LSB */
sensitivity = 1.1 * 0.5 / 1000;
status = axp->read(axp->handle, AXP192_ADDRESS, AXP192_BATTERY_POWER, tmp, 3);
if (AXP192_OK != status) {
return status;
}
*buffer = (((tmp[0] << 16) + (tmp[1] << 8) + tmp[2]) * sensitivity);
return AXP192_OK;
}
-213
View File
@@ -1,213 +0,0 @@
/*
MIT License
Copyright (c) 2019-2021 Mika Tuupola
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-cut-
This file is part of hardware agnostic I2C driver for AXP192:
https://github.com/tuupola/axp192
SPDX-License-Identifier: MIT
Version: 0.6.0
*/
#ifndef _AXP192_H
#define _AXP192_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#define AXP192_ADDRESS (0x34)
/* Power control registers */
#define AXP192_POWER_STATUS (0x00)
#define AXP192_CHARGE_STATUS (0x01)
#define AXP192_OTG_VBUS_STATUS (0x04)
#define AXP192_DATA_BUFFER0 (0x06)
#define AXP192_DATA_BUFFER1 (0x07)
#define AXP192_DATA_BUFFER2 (0x08)
#define AXP192_DATA_BUFFER3 (0x09)
#define AXP192_DATA_BUFFER4 (0x0a)
#define AXP192_DATA_BUFFER5 (0x0b)
/* Output control: 2 EXTEN, 0 DCDC2 */
#define AXP192_EXTEN_DCDC2_CONTROL (0x10)
/* Power output control: 6 EXTEN, 4 DCDC2, 3 LDO3, 2 LDO2, 1 DCDC3, 0 DCDC1 */
#define AXP192_DCDC13_LDO23_CONTROL (0x12)
#define AXP192_DCDC2_VOLTAGE (0x23)
#define AXP192_DCDC2_SLOPE (0x25)
#define AXP192_DCDC1_VOLTAGE (0x26)
#define AXP192_DCDC3_VOLTAGE (0x27)
/* Output voltage control: 7-4 LDO2, 3-0 LDO3 */
#define AXP192_LDO23_VOLTAGE (0x28)
#define AXP192_VBUS_IPSOUT_CHANNEL (0x30)
#define AXP192_SHUTDOWN_VOLTAGE (0x31)
#define AXP192_SHUTDOWN_BATTERY_CHGLED_CONTROL (0x32)
#define AXP192_CHARGE_CONTROL_1 (0x33)
#define AXP192_CHARGE_CONTROL_2 (0x34)
#define AXP192_BATTERY_CHARGE_CONTROL (0x35)
#define AXP192_PEK (0x36)
#define AXP192_DCDC_FREQUENCY (0x37)
#define AXP192_BATTERY_CHARGE_LOW_TEMP (0x38)
#define AXP192_BATTERY_CHARGE_HIGH_TEMP (0x39)
#define AXP192_APS_LOW_POWER1 (0x3A)
#define AXP192_APS_LOW_POWER2 (0x3B)
#define AXP192_BATTERY_DISCHARGE_LOW_TEMP (0x3c)
#define AXP192_BATTERY_DISCHARGE_HIGH_TEMP (0x3d)
#define AXP192_DCDC_MODE (0x80)
#define AXP192_ADC_ENABLE_1 (0x82)
#define AXP192_ADC_ENABLE_2 (0x83)
#define AXP192_ADC_RATE_TS_PIN (0x84)
#define AXP192_GPIO30_INPUT_RANGE (0x85)
#define AXP192_GPIO0_ADC_IRQ_RISING (0x86)
#define AXP192_GPIO0_ADC_IRQ_FALLING (0x87)
#define AXP192_TIMER_CONTROL (0x8a)
#define AXP192_VBUS_MONITOR (0x8b)
#define AXP192_TEMP_SHUTDOWN_CONTROL (0x8f)
/* GPIO control registers */
#define AXP192_GPIO0_CONTROL (0x90)
#define AXP192_GPIO0_LDOIO0_VOLTAGE (0x91)
#define AXP192_GPIO1_CONTROL (0x92)
#define AXP192_GPIO2_CONTROL (0x93)
#define AXP192_GPIO20_SIGNAL_STATUS (0x94)
#define AXP192_GPIO43_FUNCTION_CONTROL (0x95)
#define AXP192_GPIO43_SIGNAL_STATUS (0x96)
#define AXP192_GPIO20_PULLDOWN_CONTROL (0x97)
#define AXP192_PWM1_FREQUENCY (0x98)
#define AXP192_PWM1_DUTY_CYCLE_1 (0x99)
#define AXP192_PWM1_DUTY_CYCLE_2 (0x9a)
#define AXP192_PWM2_FREQUENCY (0x9b)
#define AXP192_PWM2_DUTY_CYCLE_1 (0x9c)
#define AXP192_PWM2_DUTY_CYCLE_2 (0x9d)
#define AXP192_N_RSTO_GPIO5_CONTROL (0x9e)
/* Interrupt control registers */
#define AXP192_ENABLE_CONTROL_1 (0x40)
#define AXP192_ENABLE_CONTROL_2 (0x41)
#define AXP192_ENABLE_CONTROL_3 (0x42)
#define AXP192_ENABLE_CONTROL_4 (0x43)
#define AXP192_ENABLE_CONTROL_5 (0x4a)
#define AXP192_IRQ_STATUS_1 (0x44)
#define AXP192_IRQ_STATUS_2 (0x45)
#define AXP192_IRQ_STATUS_3 (0x46)
#define AXP192_IRQ_STATUS_4 (0x47)
#define AXP192_IRQ_STATUS_5 (0x4d)
/* ADC data registers */
#define AXP192_ACIN_VOLTAGE (0x56)
#define AXP192_ACIN_CURRENT (0x58)
#define AXP192_VBUS_VOLTAGE (0x5a)
#define AXP192_VBUS_CURRENT (0x5c)
#define AXP192_TEMP (0x5e)
#define AXP192_TS_INPUT (0x62)
#define AXP192_GPIO0_VOLTAGE (0x64)
#define AXP192_GPIO1_VOLTAGE (0x66)
#define AXP192_GPIO2_VOLTAGE (0x68)
#define AXP192_GPIO3_VOLTAGE (0x6a)
#define AXP192_BATTERY_POWER (0x70)
#define AXP192_BATTERY_VOLTAGE (0x78)
#define AXP192_CHARGE_CURRENT (0x7a)
#define AXP192_DISCHARGE_CURRENT (0x7c)
#define AXP192_APS_VOLTAGE (0x7e)
#define AXP192_CHARGE_COULOMB (0xb0)
#define AXP192_DISCHARGE_COULOMB (0xb4)
#define AXP192_COULOMB_COUNTER_CONTROL (0xb8)
/* Computed ADC */
#define AXP192_COULOMB_COUNTER (0xff)
/* IOCTL commands */
#define AXP192_READ_POWER_STATUS (0x0001)
#define AXP192_READ_CHARGE_STATUS (0x0101)
#define AXP192_COULOMB_COUNTER_ENABLE (0xb801)
#define AXP192_COULOMB_COUNTER_DISABLE (0xb802)
#define AXP192_COULOMB_COUNTER_SUSPEND (0xb803)
#define AXP192_COULOMB_COUNTER_CLEAR (0xb804)
#define AXP192_LDOIO0_ENABLE (0x9000)
#define AXP192_LDOIO0_DISABLE (0x9001)
#define AXP192_DCDC2_ENABLE (0x1000)
#define AXP192_DCDC2_DISABLE (0x1001)
#define AXP192_EXTEN_ENABLE (0x1002)
#define AXP192_EXTEN_DISABLE (0x1003)
#define AXP192_LDO2_ENABLE (0x1200)
#define AXP192_LDO2_DISABLE (0x1201)
#define AXP192_LDO3_ENABLE (0x1202)
#define AXP192_LDO3_DISABLE (0x1203)
#define AXP192_DCDC1_ENABLE (0x1204)
#define AXP192_DCDC1_DISABLE (0x1205)
#define AXP192_DCDC3_ENABLE (0x1206)
#define AXP192_DCDC3_DISABLE (0x1207)
#define AXP192_DCDC1_SET_VOLTAGE (0x2600)
#define AXP192_DCDC2_SET_VOLTAGE (0x2300)
#define AXP192_DCDC3_SET_VOLTAGE (0x2700)
#define AXP192_LDO2_SET_VOLTAGE (0x2800)
#define AXP192_LDO3_SET_VOLTAGE (0x2801)
#define AXP192_LDOIO0_SET_VOLTAGE (0x9100)
#define AXP192_LOW (0)
#define AXP192_HIGH (1)
#define AXP192_GPIO0_SET_LEVEL (0x9400)
#define AXP192_GPIO1_SET_LEVEL (0x9401)
#define AXP192_GPIO2_SET_LEVEL (0x9402)
#define AXP192_GPIO4_SET_LEVEL (0x9601)
/* Error codes */
#define AXP192_OK (0)
#define AXP192_ERROR_NOTTY (-1)
#define AXP192_ERROR_EINVAL (-22)
#define AXP192_ERROR_ENOTSUP (-95)
typedef struct {
uint8_t command;
uint8_t data[2];
uint8_t count;
} axp192_init_command_t;
/* These should be provided by the HAL. */
typedef struct {
int32_t (* read)(void *handle, uint8_t address, uint8_t reg, uint8_t *buffer, uint16_t size);
int32_t (* write)(void *handle, uint8_t address, uint8_t reg, const uint8_t *buffer, uint16_t size);
void *handle;
} axp192_t;
typedef int32_t axp192_err_t;
axp192_err_t axp192_init(const axp192_t *axp);
axp192_err_t axp192_read(const axp192_t *axp, uint8_t reg, void *buffer);
axp192_err_t axp192_write(const axp192_t *axp, uint8_t reg, uint8_t value);
axp192_err_t axp192_ioctl(const axp192_t *axp, int command, ...);
#ifdef __cplusplus
}
#endif
#endif
@@ -1,125 +0,0 @@
/*
MIT License
Copyright (c) 2019-2021 Mika Tuupola
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-cut-
This file is part of hardware agnostic I2C driver for AXP192:
https://github.com/tuupola/axp192
SPDX-License-Identifier: MIT
Version: 0.6.0
*/
#ifndef _AXP192_CONFIG_H
#define _AXP192_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef AXP192_INCLUDE_SDKCONFIG_H
#include "sdkconfig.h"
/* This requires you to run menuconfig first. */
#define CONFIG_AXP192_EXTEN_DCDC2_CONTROL ( \
CONFIG_AXP192_EXTEN_DCDC2_CONTROL_BIT2 | \
CONFIG_AXP192_EXTEN_DCDC2_CONTROL_BIT0 \
)
#define CONFIG_AXP192_DCDC13_LDO23_CONTROL ( \
CONFIG_AXP192_DCDC13_LDO23_CONTROL_BIT6 | \
CONFIG_AXP192_DCDC13_LDO23_CONTROL_BIT4 | \
CONFIG_AXP192_DCDC13_LDO23_CONTROL_BIT3 | \
CONFIG_AXP192_DCDC13_LDO23_CONTROL_BIT2 | \
CONFIG_AXP192_DCDC13_LDO23_CONTROL_BIT1 | \
CONFIG_AXP192_DCDC13_LDO23_CONTROL_BIT0 \
)
#define CONFIG_AXP192_LDO23_VOLTAGE ( \
CONFIG_AXP192_LDO23_VOLTAGE_BIT74 | \
CONFIG_AXP192_LDO23_VOLTAGE_BIT30 \
)
#define CONFIG_AXP192_DCDC1_VOLTAGE ( \
CONFIG_AXP192_DCDC1_VOLTAGE_BIT60 \
)
#define CONFIG_AXP192_DCDC3_VOLTAGE ( \
CONFIG_AXP192_DCDC3_VOLTAGE_BIT60 \
)
#define CONFIG_AXP192_ADC_ENABLE_1 ( \
CONFIG_AXP192_ADC_ENABLE_1_BIT7 | \
CONFIG_AXP192_ADC_ENABLE_1_BIT6 | \
CONFIG_AXP192_ADC_ENABLE_1_BIT5 | \
CONFIG_AXP192_ADC_ENABLE_1_BIT4 | \
CONFIG_AXP192_ADC_ENABLE_1_BIT3 | \
CONFIG_AXP192_ADC_ENABLE_1_BIT2 | \
CONFIG_AXP192_ADC_ENABLE_1_BIT1 | \
CONFIG_AXP192_ADC_ENABLE_1_BIT0 \
)
#define CONFIG_AXP192_CHARGE_CONTROL_1 ( \
CONFIG_AXP192_CHARGE_CONTROL_1_BIT7 | \
CONFIG_AXP192_CHARGE_CONTROL_1_BIT65 | \
CONFIG_AXP192_CHARGE_CONTROL_1_BIT4 | \
CONFIG_AXP192_CHARGE_CONTROL_1_BIT30 \
)
#define CONFIG_AXP192_BATTERY_CHARGE_CONTROL ( \
CONFIG_AXP192_BATTERY_CHARGE_CONTROL_BIT7 | \
CONFIG_AXP192_BATTERY_CHARGE_CONTROL_BIT65 | \
CONFIG_AXP192_BATTERY_CHARGE_CONTROL_BIT10 \
)
#define CONFIG_AXP192_GPIO0_CONTROL ( \
CONFIG_AXP192_GPIO0_CONTROL_BIT20 \
)
#define CONFIG_AXP192_GPIO1_CONTROL ( \
CONFIG_AXP192_GPIO1_CONTROL_BIT20 \
)
#define CONFIG_AXP192_GPIO2_CONTROL ( \
CONFIG_AXP192_GPIO2_CONTROL_BIT20 \
)
#define CONFIG_AXP192_GPIO43_FUNCTION_CONTROL ( \
CONFIG_AXP192_GPIO43_FUNCTION_CONTROL_BIT7 | \
CONFIG_AXP192_GPIO43_FUNCTION_CONTROL_BIT32 | \
CONFIG_AXP192_GPIO43_FUNCTION_CONTROL_BIT10 \
)
#define CONFIG_AXP192_GPIO0_LDOIO0_VOLTAGE ( \
CONFIG_AXP192_GPIO0_LDOIO0_VOLTAGE_BIT74 \
)
#endif /* AXP192_INCLUDE_SDKCONFIG_H */
#ifdef __cplusplus
}
#endif
#endif
@@ -1,378 +0,0 @@
#include "FT6X36.h"
#include "freertos/FreeRTOS.h"
#define CONFIG_FT6X36_DEBUG false
FT6X36 *FT6X36::_instance = nullptr;
static const char *TAG = "i2c-touch";
//Handle indicating I2C is ready to read the touch
SemaphoreHandle_t TouchSemaphore = xSemaphoreCreateBinary();
FT6X36::FT6X36(i2c_port_t port, gpio_num_t interruptPin)
{
_instance = this;
_port = port;
_intPin = interruptPin;
}
// Destructor should detach interrupt to the pin
FT6X36::~FT6X36()
{
if (_intPin >= 0)
gpio_isr_handler_remove((gpio_num_t)_intPin);
}
bool FT6X36::begin(uint8_t threshold, uint16_t width, uint16_t height)
{
_touch_width = width;
_touch_height = height;
if (width == 0 || height ==0) {
ESP_LOGE(TAG,"begin(uint8_t threshold, uint16_t width, uint16_t height) did not receive the width / height so touch cannot be rotation aware");
}
uint8_t data_panel_id;
readRegister8(FT6X36_REG_PANEL_ID, &data_panel_id);
if (data_panel_id != FT6X36_VENDID) {
ESP_LOGE(TAG,"FT6X36_VENDID does not match. Received:0x%x Expected:0x%x\n",data_panel_id,FT6X36_VENDID);
return false;
}
ESP_LOGI(TAG, "\tDevice ID: 0x%02x", data_panel_id);
uint8_t chip_id;
readRegister8(FT6X36_REG_CHIPID, &chip_id);
if (chip_id != FT6206_CHIPID && chip_id != FT6236_CHIPID && chip_id != FT6336_CHIPID) {
ESP_LOGE(TAG,"FT6206_CHIPID does not match. Received:0x%x\n",chip_id);
return false;
}
ESP_LOGI(TAG, "\tFound touch controller with Chip ID: 0x%02x", chip_id);
if (_intPin >= 0)
{
// INT pin triggers the callback function on the Falling edge of the GPIO
gpio_config_t io_conf;
io_conf.intr_type = GPIO_INTR_NEGEDGE; // GPIO_INTR_NEGEDGE repeats always interrupt
io_conf.pin_bit_mask = 1ULL<<_intPin;
io_conf.mode = GPIO_MODE_INPUT;
io_conf.pull_down_en = (gpio_pulldown_t) 0; // disable pull-down mode
io_conf.pull_up_en = (gpio_pullup_t) 1; // pull-up mode
gpio_config(&io_conf);
esp_err_t isr_service = gpio_install_isr_service(0);
printf("ISR trigger install response: 0x%x %s\n", isr_service, (isr_service==0)?"ESP_OK":"");
gpio_isr_handler_add((gpio_num_t)_intPin, isr, (void*) 1);
}
writeRegister8(FT6X36_REG_DEVICE_MODE, 0x00);
writeRegister8(FT6X36_REG_THRESHHOLD, threshold);
writeRegister8(FT6X36_REG_TOUCHRATE_ACTIVE, 0x0E);
return true;
}
void FT6X36::registerTouchHandler(void (*fn)(TPoint point, TEvent e))
{
_touchHandler = fn;
if (CONFIG_FT6X36_DEBUG) printf("Touch handler function registered\n");
}
uint8_t FT6X36::touched()
{
uint8_t data_buf;
esp_err_t ret = readRegister8(FT6X36_REG_NUM_TOUCHES, &data_buf);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Error reading from device: %s", esp_err_to_name(ret));
}
if (data_buf > 2)
{
data_buf = 0;
}
return data_buf;
}
void FT6X36::loop()
{
processTouch();
}
void IRAM_ATTR FT6X36::isr(void* arg)
{
/* Un-block the interrupt processing task now */
xSemaphoreGive(TouchSemaphore);
//xQueueSendFromISR(gpio_evt_queue, &gpio_num, NULL);
}
void FT6X36::processTouch()
{
/* Task move to Block state to wait for interrupt event */
if (_intPin >= 0)
{
if (xSemaphoreTake(TouchSemaphore, portMAX_DELAY) == false) return;
}
readData();
uint8_t n = 0;
TRawEvent event = (TRawEvent)_touchEvent[n];
TPoint point{_touchX[n], _touchY[n]};
switch (event) {
case TRawEvent::PressDown:
_points[0] = point;
_dragMode = false;
// Note: Is in microseconds. Ref https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/esp_timer.html
_touchStartTime = esp_timer_get_time()/1000;
fireEvent(point, TEvent::TouchStart);
break;
case TRawEvent::Contact:
// Dragging makes no sense IMHO. Since the X & Y are not getting updated while dragging
// Dragging && _points[0].aboutEqual(point) - Not used IDEA 2: && (lastEvent == 2)
if (!_dragMode &&
(abs(lastX-_touchX[n]) <= maxDeviation || abs(lastY-_touchY[n])<=maxDeviation) &&
esp_timer_get_time()/1000 - _touchStartTime > 300) {
_dragMode = true;
fireEvent(point, TEvent::DragStart);
#if defined(CONFIG_FT6X36_DEBUG_EVENTS) && CONFIG_FT6X36_DEBUG_EVENTS==1
printf("EV: DragStart\n");
#endif
} else if (_dragMode) {
fireEvent(point, TEvent::DragMove);
#if defined(CONFIG_FT6X36_DEBUG_EVENTS) && CONFIG_FT6X36_DEBUG_EVENTS==1
printf("EV: DragMove\n");
#endif
}
fireEvent(point, TEvent::TouchMove);
// For me the _touchStartTime shouold be set in both PressDown & Contact events, but after Drag detection
_touchStartTime = esp_timer_get_time()/1000;
break;
case TRawEvent::LiftUp:
_points[9] = point;
_touchEndTime = esp_timer_get_time()/1000;
//printf("TIMEDIFF: %lu End: %lu\n", _touchEndTime - _touchStartTime, _touchEndTime);
fireEvent(point, TEvent::TouchEnd);
if (_dragMode) {
fireEvent(point, TEvent::DragEnd);
#if defined(CONFIG_FT6X36_DEBUG_EVENTS) && CONFIG_FT6X36_DEBUG_EVENTS==1
printf("EV: DragEnd\n");
#endif
_dragMode = false;
}
if ( _touchEndTime - _touchStartTime <= 900) {
// Do not get why this: _points[0].aboutEqual(point) (Original library)
fireEvent(point, TEvent::Tap);
_points[0] = {0, 0};
_touchStartTime = 0;
#if defined(CONFIG_FT6X36_DEBUG_EVENTS) && CONFIG_FT6X36_DEBUG_EVENTS==1
printf("EV: Tap\n");
#endif
_dragMode = false;
}
break;
case TRawEvent::NoEvent:
#if defined(CONFIG_FT6X36_DEBUG_EVENTS) && CONFIG_FT6X36_DEBUG_EVENTS==1
printf("EV: NoEvent\n");
#endif
break;
}
// Store lastEvent
lastEvent = (int) event;
lastX = _touchX[0];
lastY = _touchY[0];
}
void FT6X36::poll(TPoint * point, TEvent * e)
{
readData();
// TPoint point{_touchX[0], _touchY[0]};
TRawEvent event = (TRawEvent)_touchEvent[0];
if (point != NULL)
{
point->x = _touchX[0];
point->y = _touchY[0];
}
if (e != NULL)
{
switch (event)
{
case TRawEvent::PressDown:
*e = TEvent::TouchStart;
break;
case TRawEvent::Contact:
*e = TEvent::TouchMove;
break;
case TRawEvent::LiftUp:
default:
*e = TEvent::TouchEnd;
break;
}
}
}
uint8_t FT6X36::read8(uint8_t regName) {
uint8_t buf;
readRegister8(regName, &buf);
return buf;
}
#define data_size 16 // Discarding last 2: 0x0E & 0x0F as not relevant
bool FT6X36::readData(void)
{
esp_err_t ret;
uint8_t data[data_size];
uint8_t touch_pnt_cnt; // Number of detected touch points
readRegister8(FT6X36_REG_NUM_TOUCHES, &touch_pnt_cnt);
// Read data
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (FT6X36_ADDR<<1), ACK_CHECK_EN);
i2c_master_write_byte(cmd, 0, ACK_CHECK_EN);
i2c_master_stop(cmd);
ret = i2c_master_cmd_begin(_port, cmd, 1000 / portTICK_PERIOD_MS);
i2c_cmd_link_delete(cmd);
if (ret != ESP_OK) {
return ret;
}
cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (FT6X36_ADDR<<1)|1, ACK_CHECK_EN);
i2c_master_read(cmd, data, data_size, I2C_MASTER_LAST_NACK);
i2c_master_stop(cmd);
ret = i2c_master_cmd_begin(_port, cmd, 1000 / portTICK_PERIOD_MS);
i2c_cmd_link_delete(cmd);
if (CONFIG_FT6X36_DEBUG) {
//printf("REGISTERS:\n");
for (int16_t i = 0; i < data_size; i++)
{
printf("%x:%x ", i, data[i]);
}
printf("\n");
}
const uint8_t addrShift = 6;
// READ X, Y and Touch events (X 2)
for (uint8_t i = 0; i < 2; i++)
{
_touchX[i] = data[FT6X36_REG_P1_XH + i * addrShift] & 0x0F;
_touchX[i] <<= 8;
_touchX[i] |= data[FT6X36_REG_P1_XL + i * addrShift];
_touchY[i] = data[FT6X36_REG_P1_YH + i * addrShift] & 0x0F;
_touchY[i] <<= 8;
_touchY[i] |= data[FT6X36_REG_P1_YL + i * addrShift];
_touchEvent[i] = data[FT6X36_REG_P1_XH + i * addrShift] >> 6;
}
// Make _touchX[idx] and _touchY[idx] rotation aware
switch (_rotation)
{
case 1:
swap(_touchX[0], _touchY[0]);
swap(_touchX[1], _touchY[1]);
_touchY[0] = _touch_width - _touchY[0] -1;
_touchY[1] = _touch_width - _touchY[1] -1;
break;
case 2:
_touchX[0] = _touch_width - _touchX[0] - 1;
_touchX[1] = _touch_width - _touchX[1] - 1;
_touchY[0] = _touch_height - _touchY[0] - 1;
_touchY[1] = _touch_height - _touchY[1] - 1;
break;
case 3:
swap(_touchX[0], _touchY[0]);
swap(_touchX[1], _touchY[1]);
_touchX[0] = _touch_height - _touchX[0] - 1;
_touchX[1] = _touch_height - _touchX[1] - 1;
break;
}
if (CONFIG_FT6X36_DEBUG) {
printf("X0:%d Y0:%d EVENT:%d\n", _touchX[0], _touchY[0], _touchEvent[0]);
//printf("X1:%d Y1:%d EVENT:%d\n", _touchX[1], _touchY[1], _touchEvent[1]);
}
return true;
}
void FT6X36::writeRegister8(uint8_t reg, uint8_t value)
{
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, FT6X36_ADDR << 1 | I2C_MASTER_WRITE, ACK_CHECK_EN);
i2c_master_write_byte(cmd, reg , ACK_CHECK_EN);
i2c_master_write_byte(cmd, value , ACK_CHECK_EN);
i2c_master_stop(cmd);
i2c_master_cmd_begin(_port, cmd, 1000 / portTICK_PERIOD_MS);
i2c_cmd_link_delete(cmd);
}
uint8_t FT6X36::readRegister8(uint8_t reg, uint8_t *data_buf)
{
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, FT6X36_ADDR << 1 | I2C_MASTER_WRITE, ACK_CHECK_EN);
i2c_master_write_byte(cmd, reg, I2C_MASTER_ACK);
// Research: Why it's started a 2nd time here
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (FT6X36_ADDR << 1) | I2C_MASTER_READ, true);
i2c_master_read_byte(cmd, data_buf, I2C_MASTER_NACK);
i2c_master_stop(cmd);
esp_err_t ret = i2c_master_cmd_begin(_port, cmd, 1000 / portTICK_PERIOD_MS);
i2c_cmd_link_delete(cmd);
//FT6X36_REG_GESTURE_ID. Check if it can be read!
#if defined(FT6X36_DEBUG) && FT6X36_DEBUG==1
printf("REG 0x%x: 0x%x\n",reg,ret);
#endif
return ret;
}
void FT6X36::fireEvent(TPoint point, TEvent e)
{
if (_touchHandler)
_touchHandler(point, e);
}
void FT6X36::debugInfo()
{
printf(" TH_DIFF: %d CTRL: %d\n", read8(FT6X36_REG_FILTER_COEF), read8(FT6X36_REG_CTRL));
printf(" TIMEENTERMONITOR: %d PERIODACTIVE: %d\n", read8(FT6X36_REG_TIME_ENTER_MONITOR), read8(FT6X36_REG_TOUCHRATE_ACTIVE));
printf(" PERIODMONITOR: %d RADIAN_VALUE: %d\n", read8(FT6X36_REG_TOUCHRATE_MONITOR), read8(FT6X36_REG_RADIAN_VALUE));
printf(" OFFSET_LEFT_RIGHT: %d OFFSET_UP_DOWN: %d\n", read8(FT6X36_REG_OFFSET_LEFT_RIGHT), read8(FT6X36_REG_OFFSET_UP_DOWN));
printf("DISTANCE_LEFT_RIGHT: %d DISTANCE_UP_DOWN: %d\n", read8(FT6X36_REG_DISTANCE_LEFT_RIGHT), read8(FT6X36_REG_DISTANCE_UP_DOWN));
printf(" DISTANCE_ZOOM: %d CIPHER: %d\n", read8(FT6X36_REG_DISTANCE_ZOOM), read8(FT6X36_REG_CHIPID));
printf(" G_MODE: %d PWR_MODE: %d\n", read8(FT6X36_REG_INTERRUPT_MODE), read8(FT6X36_REG_POWER_MODE));
printf(" FIRMID: %d FOCALTECH_ID: %d STATE: %d\n", read8(FT6X36_REG_FIRMWARE_VERSION), read8(FT6X36_REG_PANEL_ID), read8(FT6X36_REG_STATE));
}
void FT6X36::setRotation(uint8_t rotation) {
_rotation = rotation;
}
void FT6X36::setTouchWidth(uint16_t width) {
printf("touch w:%d\n",width);
_touch_width = width;
}
void FT6X36::setTouchHeight(uint16_t height) {
printf("touch h:%d\n",height);
_touch_height = height;
}
-184
View File
@@ -1,184 +0,0 @@
#include <stdint.h>
#include <cstdlib>
#include "driver/gpio.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include <stdio.h>
#include "esp_log.h"
#include "driver/i2c.h"
#include "sdkconfig.h"
#include <esp_timer.h>
#ifndef ft6x36_h
#define ft6x36_h
// I2C Constants
#define I2C_MASTER_TX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */
#define I2C_MASTER_RX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */
#define ACK_CHECK_EN 0x1 /*!< I2C master will check ack from slave*/
#define ACK_CHECK_DIS 0x0 /*!< I2C master will not check ack from slave */
#define ACK_VAL 0x0 /*!< I2C ack value */
#define NACK_VAL 0x1 /*!< I2C nack value */
//SemaphoreHandle_t print_mux = NULL;
#define FT6X36_ADDR 0x38
#define FT6X36_REG_DEVICE_MODE 0x00
#define FT6X36_REG_GESTURE_ID 0x01
#define FT6X36_REG_NUM_TOUCHES 0x02
#define FT6X36_REG_P1_XH 0x03
#define FT6X36_REG_P1_XL 0x04
#define FT6X36_REG_P1_YH 0x05
#define FT6X36_REG_P1_YL 0x06
#define FT6X36_REG_P1_WEIGHT 0x07
#define FT6X36_REG_P1_MISC 0x08
#define FT6X36_REG_P2_XH 0x09
#define FT6X36_REG_P2_XL 0x0A
#define FT6X36_REG_P2_YH 0x0B
#define FT6X36_REG_P2_YL 0x0C
#define FT6X36_REG_P2_WEIGHT 0x0D
#define FT6X36_REG_P2_MISC 0x0E
#define FT6X36_REG_THRESHHOLD 0x80
#define FT6X36_REG_FILTER_COEF 0x85
#define FT6X36_REG_CTRL 0x86
#define FT6X36_REG_TIME_ENTER_MONITOR 0x87
#define FT6X36_REG_TOUCHRATE_ACTIVE 0x88
#define FT6X36_REG_TOUCHRATE_MONITOR 0x89 // value in ms
#define FT6X36_REG_RADIAN_VALUE 0x91
#define FT6X36_REG_OFFSET_LEFT_RIGHT 0x92
#define FT6X36_REG_OFFSET_UP_DOWN 0x93
#define FT6X36_REG_DISTANCE_LEFT_RIGHT 0x94
#define FT6X36_REG_DISTANCE_UP_DOWN 0x95
#define FT6X36_REG_DISTANCE_ZOOM 0x96
#define FT6X36_REG_LIB_VERSION_H 0xA1
#define FT6X36_REG_LIB_VERSION_L 0xA2
#define FT6X36_REG_CHIPID 0xA3
#define FT6X36_REG_INTERRUPT_MODE 0xA4
#define FT6X36_REG_POWER_MODE 0xA5
#define FT6X36_REG_FIRMWARE_VERSION 0xA6
#define FT6X36_REG_PANEL_ID 0xA8
#define FT6X36_REG_STATE 0xBC
#define FT6X36_PMODE_ACTIVE 0x00
#define FT6X36_PMODE_MONITOR 0x01
#define FT6X36_PMODE_STANDBY 0x02
#define FT6X36_PMODE_HIBERNATE 0x03
/* Possible values returned by FT6X36_GEST_ID_REG */
#define FT6X36_GEST_ID_NO_GESTURE 0x00
#define FT6X36_GEST_ID_MOVE_UP 0x10
#define FT6X36_GEST_ID_MOVE_RIGHT 0x14
#define FT6X36_GEST_ID_MOVE_DOWN 0x18
#define FT6X36_GEST_ID_MOVE_LEFT 0x1C
#define FT6X36_GEST_ID_ZOOM_IN 0x48
#define FT6X36_GEST_ID_ZOOM_OUT 0x49
#define FT6X36_VENDID 0x11
#define FT6206_CHIPID 0x06
#define FT6236_CHIPID 0x36
#define FT6336_CHIPID 0x64
#define FT6X36_DEFAULT_THRESHOLD 22
// From: https://github.com/lvgl/lv_port_esp32/blob/master/components/lvgl_esp32_drivers/lvgl_touch/ft6x36.h
#define FT6X36_MSB_MASK 0x0F
#define FT6X36_LSB_MASK 0xFF
enum class TRawEvent
{
PressDown,
LiftUp,
Contact,
NoEvent
};
enum class TEvent
{
None,
TouchStart,
TouchMove,
TouchEnd,
Tap,
DragStart,
DragMove,
DragEnd
};
struct TPoint
{
uint16_t x;
uint16_t y;
/**
* This is being used in the original library but I'm not using it in this implementation
*/
bool aboutEqual(const TPoint point)
{
return abs(x - point.x) <= 5 && abs(y - point.y) <= 5;
}
};
class FT6X36
{
static void IRAM_ATTR isr(void* arg);
public:
// TwoWire * wire will be replaced by ESP-IDF https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/i2c.html
FT6X36(i2c_port_t = I2C_NUM_0, gpio_num_t interruptPin = GPIO_NUM_NC);
~FT6X36();
bool begin(uint8_t threshold = FT6X36_DEFAULT_THRESHOLD, uint16_t width = 0, uint16_t height = 0);
void registerTouchHandler(void(*fn)(TPoint point, TEvent e));
uint8_t touched();
void loop();
void processTouch();
void debugInfo();
void poll(TPoint * point, TEvent * event);
// Helper functions to make the touch display aware
void setRotation(uint8_t rotation);
void setTouchWidth(uint16_t width);
void setTouchHeight(uint16_t height);
// Pending implementation. How much x->touch y↓touch is placed (In case is smaller than display)
void setXoffset(uint16_t x_offset);
void setYoffset(uint16_t y_offset);
// Smart template from EPD to swap x,y:
template <typename T> static inline void
swap(T& a, T& b)
{
T t = a;
a = b;
b = t;
}
void(*_touchHandler)(TPoint point, TEvent e) = nullptr;
bool readData(void);
private:
void writeRegister8(uint8_t reg, uint8_t val);
uint8_t readRegister8(uint8_t reg, uint8_t *data_buf);
void fireEvent(TPoint point, TEvent e);
uint8_t read8(uint8_t regName);
static FT6X36 * _instance;
i2c_port_t _port;
int8_t _intPin;
// Make touch rotation aware:
uint8_t _rotation = 0;
uint16_t _touch_width = 0;
uint16_t _touch_height = 0;
uint8_t _touches;
uint16_t _touchX[2], _touchY[2], _touchEvent[2];
TPoint _points[10];
uint8_t _pointIdx = 0;
unsigned long _touchStartTime = 0;
unsigned long _touchEndTime = 0;
uint8_t lastEvent = 3; // No event
uint16_t lastX = 0;
uint16_t lastY = 0;
bool _dragMode = false;
const uint8_t maxDeviation = 5;
};
#endif
-21
View File
@@ -1,21 +0,0 @@
MIT License
Copyright (c) 2019 strange_v
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -1,8 +0,0 @@
This project is an adaption of the code at https://github.com/martinberlin/FT6X36-IDF which is an adaptation of https://github.com/strange-v/FT6X36
The original license is an MIT license and is included in this directory.
Changes:
- Remove Kconfig-based configuratio
- Removed I2C init code
- Allow for passing a different I2C port
@@ -1,164 +0,0 @@
#include "Core2Display.h"
#include "Core2DisplayConstants.h"
#include "Log.h"
#include <TactilityCore.h>
#include <esp_lcd_panel_commands.h>
#include "driver/gpio.h"
#include "esp_err.h"
#include "esp_lcd_ili9341.h"
#include "esp_lcd_panel_ops.h"
#include "esp_lvgl_port.h"
#include "Core2Touch.h"
#define TAG "core2_display"
bool Core2Display::start() {
TT_LOG_I(TAG, "Starting");
const esp_lcd_panel_io_spi_config_t panel_io_config = ILI9341_PANEL_IO_SPI_CONFIG(
CORE2_LCD_PIN_CS,
CORE2_LCD_PIN_DC,
nullptr,
nullptr
);
if (esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)CORE2_LCD_SPI_HOST, &panel_io_config, &ioHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to create panel");
return false;
}
const esp_lcd_panel_dev_config_t panel_config = {
.reset_gpio_num = GPIO_NUM_NC,
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_BGR,
.data_endian = LCD_RGB_DATA_ENDIAN_LITTLE,
.bits_per_pixel = CORE2_LCD_BITS_PER_PIXEL,
.flags = {
.reset_active_high = false
},
.vendor_config = nullptr
};
if (esp_lcd_new_panel_ili9341(ioHandle, &panel_config, &panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to create ili9341");
return false;
}
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to reset panel");
return false;
}
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to init panel");
return false;
}
if (esp_lcd_panel_mirror(panelHandle, false, false) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to mirror");
return false;
}
if (esp_lcd_panel_invert_color(panelHandle, true) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to invert");
return false;
}
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
TT_LOG_E(TAG, "Failed to turn display on");
return false;
}
const lvgl_port_display_cfg_t disp_cfg = {
.io_handle = ioHandle,
.panel_handle = panelHandle,
.control_handle = nullptr,
.buffer_size = CORE2_LCD_DRAW_BUFFER_SIZE,
.double_buffer = true,
.trans_size = 0,
.hres = CORE2_LCD_HORIZONTAL_RESOLUTION,
.vres = CORE2_LCD_VERTICAL_RESOLUTION,
.monochrome = false,
.rotation = {
.swap_xy = false,
.mirror_x = false,
.mirror_y = false,
},
.color_format = LV_COLOR_FORMAT_RGB565,
.flags = {
.buff_dma = false,
.buff_spiram = true,
.sw_rotate = false,
.swap_bytes = true,
.full_refresh = false,
.direct_mode = false
}
};
displayHandle = lvgl_port_add_disp(&disp_cfg);
TT_LOG_I(TAG, "Finished");
return displayHandle != nullptr;
}
bool Core2Display::stop() {
assert(displayHandle != nullptr);
lvgl_port_remove_disp(displayHandle);
if (esp_lcd_panel_del(panelHandle) != ESP_OK) {
return false;
}
if (esp_lcd_panel_io_del(ioHandle) != ESP_OK) {
return false;
}
displayHandle = nullptr;
return true;
}
/**
* Note:
* The datasheet implies this should work, but it doesn't:
* https://www.digikey.com/htmldatasheets/production/1640716/0/0/1/ILI9341-Datasheet.pdf
*
* This repo claims it only has 1 curve:
* https://github.com/brucemack/hello-ili9341
*
* I'm leaving it in as I'm not sure if it's just my hardware that's problematic.
*/
void Core2Display::setGammaCurve(uint8_t index) {
uint8_t gamma_curve;
switch (index) {
case 0:
gamma_curve = 0x01;
break;
case 1:
gamma_curve = 0x04;
break;
case 2:
gamma_curve = 0x02;
break;
case 3:
gamma_curve = 0x08;
break;
default:
return;
}
const uint8_t param[] = {
gamma_curve
};
if (esp_lcd_panel_io_tx_param(ioHandle , LCD_CMD_GAMSET, param, 1) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set gamma");
}
}
tt::hal::Touch* _Nullable Core2Display::createTouch() {
return static_cast<tt::hal::Touch*>(new Core2Touch());
}
tt::hal::Display* createDisplay() {
return static_cast<tt::hal::Display*>(new Core2Display());
}
@@ -1,34 +0,0 @@
#pragma once
#include "lvgl.h"
#include "hal/Display.h"
#include <esp_lcd_types.h>
extern lv_disp_t* displayHandle;
class Core2Display : public tt::hal::Display {
private:
esp_lcd_panel_io_handle_t ioHandle = nullptr;
esp_lcd_panel_handle_t panelHandle = nullptr;
lv_display_t* displayHandle = nullptr;
public:
bool start() override;
bool stop() override;
tt::hal::Touch* _Nullable createTouch() override;
bool supportsBacklightDuty() const override { return false; }
void setGammaCurve(uint8_t index) override;
uint8_t getGammaCurveCount() const override { return 4; };
lv_display_t* _Nullable getLvglDisplay() const override { return displayHandle; }
};
tt::hal::Display* createDisplay();
@@ -1,11 +0,0 @@
#pragma once
// Display
#define CORE2_LCD_SPI_HOST SPI2_HOST
#define CORE2_LCD_PIN_CS GPIO_NUM_5
#define CORE2_LCD_PIN_DC GPIO_NUM_15
#define CORE2_LCD_HORIZONTAL_RESOLUTION 320
#define CORE2_LCD_VERTICAL_RESOLUTION 240
#define CORE2_LCD_BITS_PER_PIXEL 16
#define CORE2_LCD_DRAW_BUFFER_HEIGHT (CORE2_LCD_VERTICAL_RESOLUTION / 10)
#define CORE2_LCD_DRAW_BUFFER_SIZE (CORE2_LCD_HORIZONTAL_RESOLUTION * CORE2_LCD_DRAW_BUFFER_HEIGHT * (CORE2_LCD_BITS_PER_PIXEL / 8))
@@ -1,108 +0,0 @@
#include "Core2Power.h"
#include "TactilityCore.h"
#include "axp192/axp192.h"
#define TAG "core2_power"
extern axp192_t axpDevice;
bool Core2Power::supportsMetric(MetricType type) const {
switch (type) {
case MetricType::BatteryVoltage:
case MetricType::ChargeLevel:
case MetricType::IsCharging:
return true;
case MetricType::Current:
return false;
}
return false; // Safety guard for when new enum values are introduced
}
bool Core2Power::getMetric(Power::MetricType type, Power::MetricData& data) {
switch (type) {
case MetricType::BatteryVoltage: {
float voltage;
if (axp192_read(&axpDevice, AXP192_BATTERY_VOLTAGE, &voltage) == ESP_OK) {
data.valueAsUint32 = (uint32_t)TT_MAX((voltage * 1000.f), 0.0f);
return true;
} else {
return false;
}
}
case MetricType::ChargeLevel: {
float vbat, charge_current;
if (
axp192_read(&axpDevice, AXP192_BATTERY_VOLTAGE, &vbat) == ESP_OK &&
axp192_read(&axpDevice, AXP192_CHARGE_CURRENT, &charge_current) == ESP_OK
) {
float max_voltage = 4.20f;
float min_voltage = 2.69f; // From M5Unified
float voltage_correction = (charge_current > 0.01f) ? -0.1f : 0.f; // Roughly 0.1V drop when ccharging
float corrected_voltage = vbat + voltage_correction;
if (corrected_voltage > 2.69f) {
float charge_factor = (corrected_voltage - min_voltage) / (max_voltage - min_voltage);
data.valueAsUint8 = (uint8_t)(charge_factor * 100.f);
} else {
data.valueAsUint8 = 0;
}
return true;
} else {
return false;
}
}
case MetricType::IsCharging: {
float charge_current;
if (axp192_read(&axpDevice, AXP192_CHARGE_CURRENT, &charge_current) == ESP_OK) {
data.valueAsBool = charge_current > 0.001f;
return true;
} else {
return false;
}
}
case MetricType::Current: {
float charge_current, discharge_current;
if (
axp192_read(&axpDevice, AXP192_CHARGE_CURRENT, &charge_current) == ESP_OK &&
axp192_read(&axpDevice, AXP192_DISCHARGE_CURRENT, &discharge_current) == ESP_OK
) {
if (charge_current > 0.0f) {
data.valueAsInt32 = (int32_t) (charge_current * 1000.0f);
} else {
data.valueAsInt32 = -(int32_t) (discharge_current * 1000.0f);
}
return true;
} else {
return false;
}
}
}
return false; // Safety guard for when new enum values are introduced
}
bool Core2Power::isAllowedToCharge() const {
uint8_t buffer;
if (axp192_read(&axpDevice, AXP192_CHARGE_CONTROL_1, &buffer) == ESP_OK) {
return buffer & 0x80;
} else {
return false;
}
}
void Core2Power::setAllowedToCharge(bool canCharge) {
uint8_t buffer;
if (axp192_read(&axpDevice, AXP192_CHARGE_CONTROL_1, &buffer) == ESP_OK) {
buffer = (buffer & 0x7F) + (canCharge ? 0x80 : 0x00);
axp192_write(&axpDevice, AXP192_CHARGE_CONTROL_1, buffer);
}
}
static std::shared_ptr<Power> power;
std::shared_ptr<Power> createPower() {
if (power == nullptr) {
power = std::make_shared<Core2Power>();
}
return power;
}
@@ -1,23 +0,0 @@
#pragma once
#include "hal/Power.h"
#include <memory>
using namespace tt::hal;
class Core2Power : public Power {
public:
Core2Power() = default;
~Core2Power() override = default;
bool supportsMetric(MetricType type) const override;
bool getMetric(Power::MetricType type, Power::MetricData& data) override;
bool supportsChargeControl() const override { return true; }
bool isAllowedToCharge() const override;
void setAllowedToCharge(bool canCharge) override;
};
std::shared_ptr<Power> createPower();
@@ -1,29 +0,0 @@
#include "Core2SdCard.h"
#include "lvgl/LvglSync.h"
#include "hal/SpiSdCard.h"
#include <esp_vfs_fat.h>
#define CORE2_SDCARD_PIN_CS GPIO_NUM_4
#define CORE2_LCD_PIN_CS GPIO_NUM_5
std::shared_ptr<SdCard> createSdCard() {
auto* configuration = new tt::hal::SpiSdCard::Config(
CORE2_SDCARD_PIN_CS,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCard::MountBehaviour::AtBoot,
tt::lvgl::getLvglSyncLockable(),
{
CORE2_LCD_PIN_CS
}
);
auto* sdcard = (SdCard*) new SpiSdCard(
std::unique_ptr<SpiSdCard::Config>(configuration)
);
return std::shared_ptr<SdCard>(sdcard);
}
@@ -1,7 +0,0 @@
#pragma once
#include "hal/SdCard.h"
using namespace tt::hal;
std::shared_ptr<SdCard> createSdCard();
@@ -1,94 +0,0 @@
#include "Core2Touch.h"
#include <esp_lvgl_port.h>
#define TAG "core2_touch"
static void touchReadCallback(lv_indev_t* indev, lv_indev_data_t* data) {
auto* touch = (Core2Touch*)lv_indev_get_driver_data(indev);
touch->readLast(data);
}
static int32_t threadCallback(void* context) {
auto* touch = (Core2Touch*)context;
touch->driverThreadMain();
return 0;
}
Core2Touch::Core2Touch() :
driverThread(tt::Thread("core2_touch", 4096, threadCallback, this))
{ }
void Core2Touch::driverThreadMain() {
TPoint point = { .x = 0, .y = 0 };
TEvent event = TEvent::None;
while (!shouldInterruptDriverThread()) {
driver.processTouch();
driver.poll(&point, &event);
if (mutex.lock(100)) {
switch (event) {
case TEvent::TouchStart:
case TEvent::TouchMove:
case TEvent::DragStart:
case TEvent::DragMove:
case TEvent::DragEnd:
lastState = LV_INDEV_STATE_PR;
lastPoint.x = point.x;
lastPoint.y = point.y;
break;
case TEvent::TouchEnd:
lastState = LV_INDEV_STATE_REL;
lastPoint.x = point.x;
lastPoint.y = point.y;
break;
case TEvent::Tap:
case TEvent::None:
break;
}
mutex.unlock();
}
}
}
bool Core2Touch::shouldInterruptDriverThread() {
bool interrupt = false;
if (mutex.lock(50 / portTICK_PERIOD_MS)) {
interrupt = interruptDriverThread;
mutex.unlock();
}
return interrupt;
}
bool Core2Touch::start(lv_display_t* display) {
TT_LOG_I(TAG, "start");
driverThread.start();
uint16_t width = lv_display_get_horizontal_resolution(display);
uint16_t height = lv_display_get_vertical_resolution(display);
if (!driver.begin(FT6X36_DEFAULT_THRESHOLD, width, height)) {
TT_LOG_E(TAG, "driver.begin() failed");
return false;
}
deviceHandle = lv_indev_create();
lv_indev_set_type(deviceHandle, LV_INDEV_TYPE_POINTER);
lv_indev_set_driver_data(deviceHandle, this);
lv_indev_set_read_cb(deviceHandle, touchReadCallback);
TT_LOG_I(TAG, "start success");
return true;
}
bool Core2Touch::stop() {
lv_indev_delete(deviceHandle);
interruptDriverThread = true;
driverThread.join();
return true;
}
void Core2Touch::readLast(lv_indev_data_t* data) {
data->point = lastPoint;
data->state = lastState;
}
@@ -1,32 +0,0 @@
#pragma once
#include "hal/Touch.h"
#include "TactilityCore.h"
#include "ft6x36/FT6X36.h"
class Core2Touch : public tt::hal::Touch {
private:
lv_indev_t* _Nullable deviceHandle = nullptr;
FT6X36 driver = FT6X36(I2C_NUM_0, GPIO_NUM_39);
tt::Thread driverThread;
bool interruptDriverThread = false;
tt::Mutex mutex;
lv_point_t lastPoint = { .x = 0, .y = 0 };
lv_indev_state_t lastState = LV_INDEV_STATE_RELEASED;
bool shouldInterruptDriverThread();
public:
Core2Touch();
bool start(lv_display_t* display) override;
bool stop() override;
void readLast(lv_indev_data_t* data);
lv_indev_t* _Nullable getLvglIndev() override { return deviceHandle; }
void driverThreadMain();
};
-5
View File
@@ -1,5 +0,0 @@
idf_component_register(
SRC_DIRS "Source" "Source/hal" "Source/Axp2101" "Source/Aw9523"
INCLUDE_DIRS "Source"
REQUIRES Tactility esp_lvgl_port esp_lcd esp_lcd_ili9341 esp_lcd_touch_ft5x06 driver vfs fatfs
)
-9
View File
@@ -1,9 +0,0 @@
# M5Stack CoreS3
Reference implementations:
- [ESP-BSP](https://github.com/espressif/esp-bsp/tree/master/bsp/m5stack_core_s3)
- [M5Unified](https://github.com/m5stack/M5Unified)
- [M5GFX](https://github.com/m5stack/M5GFX)
Docs:
- [M5Stack.com](https://docs.m5stack.com/en/core/CoreS3)
@@ -1,24 +0,0 @@
#include "Aw9523.h"
#define AW9523_REGISTER_P0 0x02
#define AW9523_REGISTER_P1 0x03
bool Aw9523::readP0(uint8_t& output) const {
return readRegister8(AW9523_REGISTER_P0, output);
}
bool Aw9523::readP1(uint8_t& output) const {
return readRegister8(AW9523_REGISTER_P1, output);
}
bool Aw9523::writeP0(uint8_t value) const {
return writeRegister8(AW9523_REGISTER_P0, value);
}
bool Aw9523::writeP1(uint8_t value) const {
return writeRegister8(AW9523_REGISTER_P1, value);
}
bool Aw9523::bitOnP1(uint8_t bitmask) const {
return bitOn(AW9523_REGISTER_P1, bitmask);
}
@@ -1,20 +0,0 @@
#pragma once
#include "hal/i2c/I2cDevice.h"
#define AW9523_ADDRESS 0x58
class Aw9523 : I2cDevice {
public:
explicit Aw9523(i2c_port_t port) : I2cDevice(port, AW9523_ADDRESS) {}
bool readP0(uint8_t& output) const;
bool readP1(uint8_t& output) const;
bool writeP0(uint8_t value) const;
bool writeP1(uint8_t value) const;
bool bitOnP1(uint8_t bitmask) const;
};
@@ -1,59 +0,0 @@
#include "Axp2101.h"
#include "Log.h"
bool Axp2101::getBatteryVoltage(float& vbatMillis) const {
return readRegister14(0x34, vbatMillis);
}
bool Axp2101::getChargeStatus(ChargeStatus& status) const {
uint8_t value;
if (readRegister8(0x01, value)) {
value = (value >> 5) & 0b11;
status = (value == 1) ? CHARGE_STATUS_CHARGING : ((value == 2) ? CHARGE_STATUS_DISCHARGING : CHARGE_STATUS_STANDBY);
return true;
} else {
return false;
}
}
bool Axp2101::isChargingEnabled(bool& enabled) const {
uint8_t value;
if (readRegister8(0x18, value)) {
enabled = value & 0b10;
return true;
} else {
return false;
}
}
bool Axp2101::setChargingEnabled(bool enabled) const {
uint8_t value;
if (readRegister8(0x18, value)) {
return writeRegister8(0x18, (value & 0xFD) | (enabled << 1));
} else {
return false;
}
}
bool Axp2101::isVBus() const {
uint8_t value;
return readRegister8(0x00, value) && (value & 0x20);
}
bool Axp2101::getVBusVoltage(float& out) const {
if (!isVBus()) {
return false;
} else {
float vbus;
if (readRegister14(0x38, vbus) && vbus < 16375) {
out = vbus / 1000.0f;
return true;
} else {
return false;
}
}
}
bool Axp2101::setRegisters(uint8_t* bytePairs, size_t bytePairsSize) const {
return tt::hal::i2c::masterWriteRegisterArray(port, address, bytePairs, bytePairsSize, DEFAULT_TIMEOUT);
}
@@ -1,33 +0,0 @@
#pragma once
#include "hal/i2c/I2cDevice.h"
#define AXP2101_ADDRESS 0x34
/**
* References:
* - https://github.com/m5stack/M5Unified/blob/master/src/utility/AXP2101_Class.cpp
* - http://file.whycan.com/files/members/6736/AXP2101_Datasheet_V1.0_en_3832.pdf
*/
class Axp2101 : I2cDevice {
public:
enum ChargeStatus {
CHARGE_STATUS_CHARGING = 0b01,
CHARGE_STATUS_DISCHARGING = 0b10,
CHARGE_STATUS_STANDBY = 0b00
};
explicit Axp2101(i2c_port_t port) : I2cDevice(port, AXP2101_ADDRESS) {}
bool setRegisters(uint8_t* bytePairs, size_t bytePairsSize) const;
bool getBatteryVoltage(float& vbatMillis) const;
bool getChargeStatus(ChargeStatus& status) const;
bool isChargingEnabled(bool& enabled) const;
bool setChargingEnabled(bool enabled) const;
bool isVBus() const;
bool getVBusVoltage(float& out) const;
};
@@ -1,4 +0,0 @@
#pragma once
#define AXP2101_ADDRESS 0x34
#define AW9523_ADDRESS 0x58
-185
View File
@@ -1,185 +0,0 @@
#include <driver/i2c.h>
#include <driver/spi_master.h>
#include <esp_intr_types.h>
#include "Log.h"
#include "hal/CoreS3DisplayConstants.h"
#include "kernel/Kernel.h"
#include "Axp2101/Axp2101.h"
#include "Aw9523/Aw9523.h"
#define TAG "core2"
#define CORES3_SPI2_PIN_SCLK GPIO_NUM_36
#define CORES3_SPI2_PIN_MOSI GPIO_NUM_37
#define CORES3_SPI2_PIN_MISO GPIO_NUM_35
/**
* For details see https://github.com/espressif/esp-bsp/blob/master/bsp/m5stack_core_s3/m5stack_core_s3.c
*/
static bool initSpi3() {
TT_LOG_I(TAG, LOG_MESSAGE_SPI_INIT_START_FMT, SPI3_HOST);
const spi_bus_config_t bus_config = {
.mosi_io_num = CORES3_SPI2_PIN_MOSI,
.miso_io_num = CORES3_SPI2_PIN_MISO,
.sclk_io_num = CORES3_SPI2_PIN_SCLK,
.data2_io_num = GPIO_NUM_NC,
.data3_io_num = GPIO_NUM_NC,
.data4_io_num = GPIO_NUM_NC,
.data5_io_num = GPIO_NUM_NC,
.data6_io_num = GPIO_NUM_NC,
.data7_io_num = GPIO_NUM_NC,
.data_io_default_level = false,
.max_transfer_sz = CORES3_LCD_DRAW_BUFFER_SIZE,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
};
if (spi_bus_initialize(SPI3_HOST, &bus_config, SPI_DMA_CH_AUTO) != ESP_OK) {
TT_LOG_E(TAG, LOG_MESSAGE_SPI_INIT_FAILED_FMT, SPI3_HOST);
return false;
}
return true;
}
/**
* For details see https://github.com/espressif/esp-bsp/blob/master/bsp/m5stack_core_s3/m5stack_core_s3.c
* and schematic: https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/datasheet/core/K128%20CoreS3/Sch_M5_CoreS3_v1.0.pdf
*/
bool initGpioExpander() {
TT_LOG_I(TAG, "AW9523 init");
/**
* P0 pins:
* 0: Touch reset
* 1: Bus out enable
* 2: AW88298 reset (I2S)
* 3: ES7210 interrupt (Audio ADC)
* 4: SD Card SW(itch on?)
* 5: USB OTG enable
* 6: /
* 7: /
*/
/**
* P1 pins:
* 0: Cam reset
* 1: LCD reset
* 2: Touch interrupt
* 3: AW88298 interrupt (I2S)
* 4: /
* 5: /
* 6: /
* 7: Boost enable
*/
uint8_t p0_state = 0U;
uint8_t p1_state = 0U;
// Enable touch
p0_state |= (1U);
// Bus out enable
p0_state |= (1U << 1U);
// I2S
p0_state |= (1U << 2U);
// SD card
p0_state |= (1U << 4U);
// Enable LCD
p1_state |= (1U << 1U);
// Boost enable
p1_state |= (1U << 7U);
Aw9523 aw(I2C_NUM_0);
if (!aw.writeP0(p0_state)) {
TT_LOG_E(TAG, "AW9523: Failed to set P0");
return false;
}
if (!aw.writeP1(p1_state)) {
TT_LOG_E(TAG, "AW9523: Failed to set P1");
return false;
}
Axp2101 axp(I2C_NUM_0);
if (axp.isVBus()) {
float voltage = 0.0f;
axp.getVBusVoltage(voltage);
TT_LOG_I(TAG, "AXP2101: VBus at %.2f", voltage);
} else {
TT_LOG_W(TAG, "AXP2101: VBus disabled");
}
return true;
}
bool initPowerControl() {
TT_LOG_I(TAG, "Init power control (AXP2101)");
Aw9523 aw(I2C_NUM_0);
// Source: https://github.com/m5stack/M5Unified/blob/b8cfec7fed046242da7f7b8024a4e92004a51ff7/src/utility/Power_Class.cpp#L61
aw.bitOnP1(0b10000000); // SY7088 boost enable
/** AXP2101 usage
Source: https://github.com/m5stack/M5Unified/blob/b8cfec7fed046242da7f7b8024a4e92004a51ff7/README.md?plain=1#L223
| |M5Stack<BR>CoreS3<BR>CoreS3SE| |
|:---------:|:-----------------:|:---------:|
| ALDO1 |VDD 1v8 | ALDO1 |
| ALDO2 |VDDA 3v3 | ALDO2 |
| ALDO3 |CAM 3v3 | ALDO3 |
| ALDO4 |TF 3v3 | ALDO4 |
| BLDO1 |AVDD | BLDO1 |
| BLDO2 |DVDD | BLDO2 |
| DLDO1/DC1 |LCD BL | DLDO1/DC1 |
| DLDO2/DC2 | --- | DLDO2/DC2 |
| BACKUP |RTC BAT | BACKUP |
*/
/**
* 0x92 = ALD01
* 0x93 = ALD02
* 0x94 = ALD03
* 0x95 = ALD04
* 0x96 = BLD01
* 0x97 = BLD02
*
* DCDC1 : 0.7-3.5V, 25mV/step 1200mA
* DCDC2 : 0.7-2.275V,25mV/step 1600mA
* DCDC3 : 0.7-3.5V, 25mV/step 700mA
* LDOio0: 1.8-3.3V, 100mV/step 50mA
* LDO1 : 30mA always on
* LDO2 : 1.8-3.3V, 100mV/step 200mA
* LDO3 : 1.8-3.3V, 100mV/step 200mA
*/
// Source: https://github.com/m5stack/M5Unified/blob/b8cfec7fed046242da7f7b8024a4e92004a51ff7/src/utility/Power_Class.cpp#L64
static constexpr uint8_t reg_data_array[] = {
0x90U, 0xBFU, // LDOS ON/OFF control 0 (backlight)
0x92U, 18U -5U, // ALDO1 set to 1.8v // for AW88298
0x93U, 33U -5U, // ALDO2 set to 3.3v // for ES7210
0x94U, 33U -5U, // ALDO3 set to 3.3v // for camera
0x95U, 33U -5U, // ALDO3 set to 3.3v // for TF card slot
0x27, 0x00, // PowerKey Hold=1sec / PowerOff=4sec
0x69, 0x11, // CHGLED setting
0x10, 0x30, // PMU common config
0x30, 0x0F // ADC enabled (for voltage measurement)
};
Axp2101 axp(I2C_NUM_0);
if (axp.setRegisters((uint8_t*)reg_data_array, sizeof(reg_data_array))) {
TT_LOG_I(TAG, "AXP2101 initialized with %d registers", sizeof(reg_data_array) / 2);
return true;
} else {
TT_LOG_E(TAG, "AXP2101: Failed to set registers");
return false;
}
}
bool initBoot() {
TT_LOG_I(TAG, "initBoot()");
return initPowerControl() &&
initGpioExpander() &&
initSpi3();
}
-3
View File
@@ -1,3 +0,0 @@
#pragma once
bool initBoot();
-31
View File
@@ -1,31 +0,0 @@
#include "Log.h"
#include "Thread.h"
#include "lvgl/LvglSync.h"
#include "esp_lvgl_port.h"
#define TAG "core2"
// LVGL
// The minimum task stack seems to be about 3500, but that crashes the wifi app in some scenarios
// At 4000, it crashes when the fps renderer is available
#define CORE2_LVGL_TASK_STACK_DEPTH 9216
bool initLvgl() {
const lvgl_port_cfg_t lvgl_cfg = {
.task_priority = static_cast<UBaseType_t>(tt::THREAD_PRIORITY_RENDER),
.task_stack = CORE2_LVGL_TASK_STACK_DEPTH,
.task_affinity = -1, // core pinning
.task_max_sleep_ms = 500,
.timer_period_ms = 5
};
TT_LOG_D(TAG, "LVGL port init");
if (lvgl_port_init(&lvgl_cfg) != ESP_OK) {
TT_LOG_E(TAG, "LVGL port init failed");
return false;
}
tt::lvgl::syncSet(&lvgl_port_lock, &lvgl_port_unlock);
return true;
}
-3
View File
@@ -1,3 +0,0 @@
#pragma once
bool initLvgl();
@@ -1,52 +0,0 @@
#include "M5stackCoreS3.h"
#include "InitBoot.h"
#include "InitLvgl.h"
#include "hal/CoreS3Display.h"
#include "hal/CoreS3SdCard.h"
#include "hal/CoreS3Power.h"
const tt::hal::Configuration m5stack_cores3 = {
.initBoot = initBoot,
.initLvgl = initLvgl,
.createDisplay = createDisplay,
.sdcard = createSdCard(),
.power = createPower,
.i2c = {
tt::hal::i2c::Configuration {
.name = "Internal",
.port = I2C_NUM_0,
.initMode = tt::hal::i2c::InitMode::ByTactility,
.canReinit = false,
.hasMutableConfiguration = false,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_12,
.scl_io_num = GPIO_NUM_11,
.sda_pullup_en = true,
.scl_pullup_en = true,
.master = {
.clk_speed = 400000
},
.clk_flags = 0
}
},
tt::hal::i2c::Configuration {
.name = "External", // Grove
.port = I2C_NUM_1,
.initMode = tt::hal::i2c::InitMode::ByTactility,
.canReinit = true,
.hasMutableConfiguration = true,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_2,
.scl_io_num = GPIO_NUM_1,
.sda_pullup_en = true,
.scl_pullup_en = true,
.master = {
.clk_speed = 400000
},
.clk_flags = 0
}
}
}
};
@@ -1,5 +0,0 @@
#pragma once
#include "hal/Configuration.h"
extern const tt::hal::Configuration m5stack_cores3;
@@ -1,191 +0,0 @@
#include "CoreS3Display.h"
#include "CoreS3DisplayConstants.h"
#include "Log.h"
#include <TactilityCore.h>
#include <esp_lcd_panel_commands.h>
#include "driver/gpio.h"
#include "esp_err.h"
#include "esp_lcd_ili9341.h"
#include "esp_lcd_panel_ops.h"
#include "esp_lvgl_port.h"
#include "hal/i2c/I2c.h"
#include "CoreS3Constants.h"
#include "CoreS3Touch.h"
#define TAG "cores3_display"
bool CoreS3Display::start() {
TT_LOG_I(TAG, "Starting");
const esp_lcd_panel_io_spi_config_t panel_io_config = {
.cs_gpio_num = CORES3_LCD_PIN_CS,
.dc_gpio_num = CORES3_LCD_PIN_DC,
.spi_mode = 0,
.pclk_hz = 40000000,
.trans_queue_depth = 10,
.on_color_trans_done = nullptr,
.user_ctx = nullptr,
.lcd_cmd_bits = 8,
.lcd_param_bits = 8,
.cs_ena_pretrans = 0,
.cs_ena_posttrans = 0,
.flags = {
.dc_high_on_cmd = 0,
.dc_low_on_data = 0,
.dc_low_on_param = 0,
.octal_mode = 0,
.quad_mode = 0,
.sio_mode = 0,
.lsb_first = 0,
.cs_high_active = 0
}
};
if (esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)CORES3_LCD_SPI_HOST, &panel_io_config, &ioHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to create panel");
return false;
}
const esp_lcd_panel_dev_config_t panel_config = {
.reset_gpio_num = GPIO_NUM_NC,
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_BGR,
.data_endian = LCD_RGB_DATA_ENDIAN_LITTLE,
.bits_per_pixel = CORES3_LCD_BITS_PER_PIXEL,
.flags = {
.reset_active_high = false
},
.vendor_config = nullptr
};
if (esp_lcd_new_panel_ili9341(ioHandle, &panel_config, &panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to create ili9341");
return false;
}
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to reset panel");
return false;
}
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
TT_LOG_E(TAG, "Failed to init panel");
return false;
}
if (esp_lcd_panel_mirror(panelHandle, false, false) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to mirror");
return false;
}
if (esp_lcd_panel_invert_color(panelHandle, true) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set panel to invert");
return false;
}
if (esp_lcd_panel_disp_on_off(panelHandle, true) != ESP_OK) {
TT_LOG_E(TAG, "Failed to turn display on");
return false;
}
const lvgl_port_display_cfg_t disp_cfg = {
.io_handle = ioHandle,
.panel_handle = panelHandle,
.control_handle = nullptr,
.buffer_size = CORES3_LCD_DRAW_BUFFER_SIZE,
.double_buffer = true,
.trans_size = 0,
.hres = CORES3_LCD_HORIZONTAL_RESOLUTION,
.vres = CORES3_LCD_VERTICAL_RESOLUTION,
.monochrome = false,
.rotation = {
.swap_xy = false,
.mirror_x = false,
.mirror_y = false,
},
.color_format = LV_COLOR_FORMAT_RGB565,
.flags = {
.buff_dma = false,
.buff_spiram = true,
.sw_rotate = false,
.swap_bytes = true,
.full_refresh = false,
.direct_mode = false
}
};
displayHandle = lvgl_port_add_disp(&disp_cfg);
TT_LOG_I(TAG, "Finished");
return displayHandle != nullptr;
}
bool CoreS3Display::stop() {
assert(displayHandle != nullptr);
lvgl_port_remove_disp(displayHandle);
if (esp_lcd_panel_del(panelHandle) != ESP_OK) {
return false;
}
if (esp_lcd_panel_io_del(ioHandle) != ESP_OK) {
return false;
}
displayHandle = nullptr;
return true;
}
/**
* Note:
* The datasheet implies this should work, but it doesn't:
* https://www.digikey.com/htmldatasheets/production/1640716/0/0/1/ILI9341-Datasheet.pdf
*
* This repo claims it only has 1 curve:
* https://github.com/brucemack/hello-ili9341
*
* I'm leaving it in as I'm not sure if it's just my hardware that's problematic.
*/
void CoreS3Display::setGammaCurve(uint8_t index) {
uint8_t gamma_curve;
switch (index) {
case 0:
gamma_curve = 0x01;
break;
case 1:
gamma_curve = 0x04;
break;
case 2:
gamma_curve = 0x02;
break;
case 3:
gamma_curve = 0x08;
break;
default:
return;
}
const uint8_t param[] = {
gamma_curve
};
if (esp_lcd_panel_io_tx_param(ioHandle , LCD_CMD_GAMSET, param, 1) != ESP_OK) {
TT_LOG_E(TAG, "Failed to set gamma");
}
}
void CoreS3Display::setBacklightDuty(uint8_t backlightDuty) {
const uint8_t voltage = 20 + ((8 * backlightDuty) / 255); // [0b00000, 0b11100] - under 20 is too dark
// TODO: Refactor to use Axp2102 class with https://github.com/m5stack/M5Unified/blob/b8cfec7fed046242da7f7b8024a4e92004a51ff7/src/utility/AXP2101_Class.cpp#L42
if (!tt::hal::i2c::masterWriteRegister(I2C_NUM_0, AXP2101_ADDRESS, 0x99, &voltage, 1, 1000)) { // Sets DLD01
TT_LOG_E(TAG, "Failed to set display backlight voltage");
}
}
tt::hal::Touch* _Nullable CoreS3Display::createTouch() {
return static_cast<tt::hal::Touch*>(new CoreS3Touch());
}
tt::hal::Display* createDisplay() {
return static_cast<tt::hal::Display*>(new CoreS3Display());
}
@@ -1,35 +0,0 @@
#pragma once
#include "lvgl.h"
#include "hal/Display.h"
#include <esp_lcd_types.h>
extern lv_disp_t* displayHandle;
class CoreS3Display : public tt::hal::Display {
private:
esp_lcd_panel_io_handle_t ioHandle = nullptr;
esp_lcd_panel_handle_t panelHandle = nullptr;
lv_display_t* displayHandle = nullptr;
public:
bool start() override;
bool stop() override;
tt::hal::Touch* _Nullable createTouch() override;
void setBacklightDuty(uint8_t backlightDuty) override;
bool supportsBacklightDuty() const override { return true; }
void setGammaCurve(uint8_t index) override;
uint8_t getGammaCurveCount() const override { return 4; };
lv_display_t* _Nullable getLvglDisplay() const override { return displayHandle; }
};
tt::hal::Display* createDisplay();
@@ -1,11 +0,0 @@
#pragma once
// Display
#define CORES3_LCD_SPI_HOST SPI3_HOST
#define CORES3_LCD_PIN_CS GPIO_NUM_3
#define CORES3_LCD_PIN_DC GPIO_NUM_35
#define CORES3_LCD_HORIZONTAL_RESOLUTION 320
#define CORES3_LCD_VERTICAL_RESOLUTION 240
#define CORES3_LCD_BITS_PER_PIXEL 16
#define CORES3_LCD_DRAW_BUFFER_HEIGHT (CORES3_LCD_VERTICAL_RESOLUTION / 10)
#define CORES3_LCD_DRAW_BUFFER_SIZE (CORES3_LCD_HORIZONTAL_RESOLUTION * CORES3_LCD_DRAW_BUFFER_HEIGHT * (CORES3_LCD_BITS_PER_PIXEL / 8))
@@ -1,83 +0,0 @@
#include "CoreS3Power.h"
#include "TactilityCore.h"
#define TAG "core2_power"
bool CoreS3Power::supportsMetric(MetricType type) const {
switch (type) {
case MetricType::BatteryVoltage:
case MetricType::IsCharging:
case MetricType::ChargeLevel:
return true;
case MetricType::Current:
return false;
}
return false; // Safety guard for when new enum values are introduced
}
bool CoreS3Power::getMetric(Power::MetricType type, Power::MetricData& data) {
switch (type) {
case MetricType::BatteryVoltage: {
float milliVolt;
if (axpDevice.getBatteryVoltage(milliVolt)) {
data.valueAsUint32 = (uint32_t)milliVolt;
return true;
} else {
return false;
}
}
case MetricType::ChargeLevel: {
float vbatMillis;
if (axpDevice.getBatteryVoltage(vbatMillis)) {
float vbat = vbatMillis / 1000.f;
float max_voltage = 4.20f;
float min_voltage = 2.69f; // From M5Unified
if (vbat > 2.69f) {
float charge_factor = (vbat - min_voltage) / (max_voltage - min_voltage);
data.valueAsUint8 = (uint8_t)(charge_factor * 100.f);
} else {
data.valueAsUint8 = 0;
}
return true;
} else {
return false;
}
}
case MetricType::IsCharging: {
Axp2101::ChargeStatus status;
if (axpDevice.getChargeStatus(status)) {
data.valueAsBool = (status == Axp2101::CHARGE_STATUS_CHARGING);
return true;
} else {
return false;
}
}
case MetricType::Current:
return false;
}
return false; // Safety guard for when new enum values are introduced
}
bool CoreS3Power::isAllowedToCharge() const {
bool enabled;
if (axpDevice.isChargingEnabled(enabled)) {
return enabled;
} else {
return false;
}
}
void CoreS3Power::setAllowedToCharge(bool canCharge) {
axpDevice.setChargingEnabled(canCharge);
}
static std::shared_ptr<Power> power;
std::shared_ptr<Power> createPower() {
if (power == nullptr) {
power = std::make_shared<CoreS3Power>();
}
return power;
}
@@ -1,26 +0,0 @@
#pragma once
#include "hal/Power.h"
#include "Axp2101/Axp2101.h"
#include <memory>
using namespace tt::hal;
class CoreS3Power : public Power {
Axp2101 axpDevice = Axp2101(I2C_NUM_0);
public:
CoreS3Power() = default;
~CoreS3Power() override = default;
bool supportsMetric(MetricType type) const override;
bool getMetric(Power::MetricType type, Power::MetricData& data) override;
bool supportsChargeControl() const override { return true; }
bool isAllowedToCharge() const override;
void setAllowedToCharge(bool canCharge) override;
};
std::shared_ptr<Power> createPower();
@@ -1,30 +0,0 @@
#include "CoreS3SdCard.h"
#include "lvgl/LvglSync.h"
#include "hal/SpiSdCard.h"
#include <esp_vfs_fat.h>
#define CORES3_SDCARD_PIN_CS GPIO_NUM_4
#define CORES3_LCD_PIN_CS GPIO_NUM_3
std::shared_ptr<SdCard> createSdCard() {
auto* configuration = new tt::hal::SpiSdCard::Config(
CORES3_SDCARD_PIN_CS,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCard::MountBehaviour::AtBoot,
tt::lvgl::getLvglSyncLockable(),
{
CORES3_LCD_PIN_CS
},
SPI3_HOST
);
auto* sdcard = (SdCard*) new SpiSdCard(
std::unique_ptr<SpiSdCard::Config>(configuration)
);
return std::shared_ptr<SdCard>(sdcard);
}
@@ -1,7 +0,0 @@
#pragma once
#include "hal/SdCard.h"
using namespace tt::hal;
std::shared_ptr<SdCard> createSdCard();
@@ -1,83 +0,0 @@
#include "CoreS3Touch.h"
#include "Log.h"
#include "driver/i2c.h"
#include "esp_err.h"
#include "esp_lcd_touch_ft5x06.h"
#include "esp_lcd_touch.h"
#include "esp_lvgl_port.h"
#define TAG "cores3_touch"
bool CoreS3Touch::start(lv_display_t* display) {
TT_LOG_I(TAG, "Starting");
esp_lcd_panel_io_i2c_config_t touch_io_config = ESP_LCD_TOUCH_IO_I2C_FT5x06_CONFIG();
if (esp_lcd_new_panel_io_i2c(I2C_NUM_0, &touch_io_config, &ioHandle) != ESP_OK) {
TT_LOG_E(TAG, "Touch I2C IO init failed");
return false;
}
esp_lcd_touch_config_t config = {
.x_max = 320,
.y_max = 240,
.rst_gpio_num = GPIO_NUM_NC,
.int_gpio_num = GPIO_NUM_NC,
.levels = {
.reset = 0,
.interrupt = 0,
},
.flags = {
.swap_xy = 0,
.mirror_x = 0,
.mirror_y = 0,
},
.process_coordinates = nullptr,
.interrupt_callback = nullptr,
.user_data = nullptr,
.driver_data = nullptr
};
if (esp_lcd_touch_new_i2c_ft5x06(ioHandle, &config, &touchHandle) != ESP_OK) {
TT_LOG_E(TAG, "Driver init failed");
cleanup();
return false;
}
const lvgl_port_touch_cfg_t touch_cfg = {
.disp = display,
.handle = touchHandle,
};
deviceHandle = lvgl_port_add_touch(&touch_cfg);
if (deviceHandle == nullptr) {
TT_LOG_E(TAG, "Adding touch failed");
cleanup();
return false;
}
TT_LOG_I(TAG, "Finished");
return true;
}
bool CoreS3Touch::stop() {
cleanup();
return true;
}
void CoreS3Touch::cleanup() {
if (deviceHandle != nullptr) {
lv_indev_delete(deviceHandle);
deviceHandle = nullptr;
}
if (touchHandle != nullptr) {
esp_lcd_touch_del(touchHandle);
touchHandle = nullptr;
}
if (ioHandle != nullptr) {
esp_lcd_panel_io_del(ioHandle);
ioHandle = nullptr;
}
}

Some files were not shown because too many files have changed in this diff Show More