Compare commits

...

27 Commits

Author SHA1 Message Date
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
540 changed files with 14031 additions and 4126 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ runs:
- name: 'Build' - name: 'Build'
uses: espressif/esp-idf-ci-action@v1 uses: espressif/esp-idf-ci-action@v1
with: with:
esp_idf_version: v5.4 esp_idf_version: v5.5
target: ${{ inputs.arch }} target: ${{ inputs.arch }}
path: './' path: './'
- name: 'Release' - name: 'Release'
+2 -2
View File
@@ -21,14 +21,14 @@ runs:
uses: espressif/esp-idf-ci-action@v1 uses: espressif/esp-idf-ci-action@v1
with: with:
# NOTE: Update with ESP-IDF! # NOTE: Update with ESP-IDF!
esp_idf_version: v5.4 esp_idf_version: v5.5
target: ${{ inputs.arch }} target: ${{ inputs.arch }}
path: './' path: './'
- name: 'Release' - name: 'Release'
shell: bash shell: bash
env: env:
# NOTE: Update with ESP-IDF! # NOTE: Update with ESP-IDF!
ESP_IDF_VERSION: '5.4' ESP_IDF_VERSION: '5.5'
run: Buildscripts/release-sdk.sh release/TactilitySDK run: Buildscripts/release-sdk.sh release/TactilitySDK
- name: 'Upload Artifact' - name: 'Upload Artifact'
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
+27
View File
@@ -18,6 +18,24 @@ jobs:
with: with:
board_id: cyd-2432s024c board_id: cyd-2432s024c
arch: esp32 arch: esp32
cyd-2432s028r:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Build"
uses: ./.github/actions/build-firmware
with:
board_id: cyd-2432s028r
arch: esp32
cyd-e32r28t:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Build"
uses: ./.github/actions/build-firmware
with:
board_id: cyd-e32r28t
arch: esp32
cyd-2432s032c: cyd-2432s032c:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@@ -126,6 +144,15 @@ jobs:
with: with:
board_id: lilygo-tdeck board_id: lilygo-tdeck
arch: esp32s3 arch: esp32s3
lilygo-tlora-pager:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Build"
uses: ./.github/actions/build-firmware
with:
board_id: lilygo-tlora-pager
arch: esp32s3
m5stack-core2: m5stack-core2:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
+5
View File
@@ -7,6 +7,7 @@ build-sim/
cmake-build-*/ cmake-build-*/
CMakeCache.txt CMakeCache.txt
*.cbp *.cbp
CMakeFiles
release/ release/
@@ -16,3 +17,7 @@ sdkconfig.old
managed_components/ managed_components/
dependencies.lock dependencies.lock
.vscode/
.gitpod.yml
sdkconfig.board.*.dev
+6
View File
@@ -13,6 +13,10 @@ menu "Tactility App"
bool "Custom" bool "Custom"
config TT_BOARD_CYD_2432S024C config TT_BOARD_CYD_2432S024C
bool "CYD 2432S024C" bool "CYD 2432S024C"
config TT_BOARD_CYD_2432S028R
bool "CYD 2432S028R"
config TT_BOARD_CYD_E32R28T
bool "CYD E32R28T"
config TT_BOARD_CYD_2432S032C config TT_BOARD_CYD_2432S032C
bool "CYD 2432S032C" bool "CYD 2432S032C"
config TT_BOARD_CYD_8048S043C config TT_BOARD_CYD_8048S043C
@@ -37,6 +41,8 @@ menu "Tactility App"
bool "Elecrow CrowPanel Basic 5.0" bool "Elecrow CrowPanel Basic 5.0"
config TT_BOARD_LILYGO_TDECK config TT_BOARD_LILYGO_TDECK
bool "LilyGo T-Deck" bool "LilyGo T-Deck"
config TT_BOARD_LILYGO_TLORA_PAGER
bool "LilyGo T-Lora Pager"
config TT_BOARD_M5STACK_CORE2 config TT_BOARD_M5STACK_CORE2
bool "M5Stack Core2" bool "M5Stack Core2"
config TT_BOARD_M5STACK_CORES3 config TT_BOARD_M5STACK_CORES3
+9
View File
@@ -8,9 +8,18 @@
#if defined(CONFIG_TT_BOARD_LILYGO_TDECK) #if defined(CONFIG_TT_BOARD_LILYGO_TDECK)
#include "LilygoTdeck.h" #include "LilygoTdeck.h"
#define TT_BOARD_HARDWARE &lilygo_tdeck #define TT_BOARD_HARDWARE &lilygo_tdeck
#elif defined(CONFIG_TT_BOARD_LILYGO_TLORA_PAGER)
#include "LilygoTloraPager.h"
#define TT_BOARD_HARDWARE &lilygo_tlora_pager
#elif defined(CONFIG_TT_BOARD_CYD_2432S024C) #elif defined(CONFIG_TT_BOARD_CYD_2432S024C)
#include "CYD2432S024C.h" #include "CYD2432S024C.h"
#define TT_BOARD_HARDWARE &cyd_2432s024c_config #define TT_BOARD_HARDWARE &cyd_2432s024c_config
#elif defined(CONFIG_TT_BOARD_CYD_2432S028R)
#include "CYD2432S028R.h"
#define TT_BOARD_HARDWARE &cyd_2432s028r_config
#elif defined(CONFIG_TT_BOARD_CYD_E32R28T)
#include "E32R28T.h"
#define TT_BOARD_HARDWARE &cyd_e32r28t_config
#elif defined(CONFIG_TT_BOARD_CYD_2432S032C) #elif defined(CONFIG_TT_BOARD_CYD_2432S032C)
#include "CYD2432S032C.h" #include "CYD2432S032C.h"
#define TT_BOARD_HARDWARE &cyd_2432S032c_config #define TT_BOARD_HARDWARE &cyd_2432S032c_config
+1 -1
View File
@@ -5,7 +5,7 @@
#include "tt_init.h" #include "tt_init.h"
#endif #endif
// extern const tt::app::AppManifest hello_world_app; extern const tt::app::AppManifest hello_world_app;
extern "C" { extern "C" {
+5 -3
View File
@@ -9,12 +9,14 @@ dependencies:
espressif/esp_io_expander: "1.0.1" espressif/esp_io_expander: "1.0.1"
espressif/esp_io_expander_tca95xx_16bit: "1.0.1" espressif/esp_io_expander_tca95xx_16bit: "1.0.1"
espressif/esp_lcd_st7701: espressif/esp_lcd_st7701:
version: "1.1.1" version: "1.1.3"
rules: rules:
- if: "target in [esp32s3, esp32p4]" - if: "target in [esp32s3, esp32p4]"
espressif/esp_lcd_st7796:
version: "1.3.4"
espressif/esp_lcd_panel_io_additions: "1.0.1" espressif/esp_lcd_panel_io_additions: "1.0.1"
espressif/esp_tinyusb: espressif/esp_tinyusb:
version: "1.5.0" version: "1.7.6~1"
rules: rules:
- if: "target == esp32s3" - if: "target == esp32s3"
idf: '5.4' idf: '5.5'
+11 -7
View File
@@ -1,22 +1,26 @@
#include "CYD2432S024C.h" #include "CYD2432S024C.h"
#include "hal/YellowDisplay.h" #include "devices/Display.h"
#include "hal/YellowDisplayConstants.h" #include "devices/SdCard.h"
#include "hal/YellowSdCard.h"
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
#define CYD_SPI_TRANSFER_SIZE_LIMIT (TWODOTFOUR_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8) #define CYD_SPI_TRANSFER_SIZE_LIMIT (TWODOTFOUR_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8)
bool initBoot() { static bool initBoot() {
return driver::pwmbacklight::init(TWODOTFOUR_LCD_PIN_BACKLIGHT); return driver::pwmbacklight::init(TWODOTFOUR_LCD_PIN_BACKLIGHT);
} }
static tt::hal::DeviceVector createDevices() {
return {
createDisplay(),
createSdCard()
};
}
const tt::hal::Configuration cyd_2432s024c_config = { const tt::hal::Configuration cyd_2432s024c_config = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createYellowSdCard(),
.power = nullptr,
.i2c = { .i2c = {
tt::hal::i2c::Configuration { tt::hal::i2c::Configuration {
.name = "First", .name = "First",
@@ -1,6 +1,5 @@
#include "YellowDisplay.h" #include "Display.h"
#include "Cst816Touch.h" #include "Cst816Touch.h"
#include "YellowDisplayConstants.h"
#include <Ili934xDisplay.h> #include <Ili934xDisplay.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
@@ -32,5 +31,6 @@ std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
configuration->mirrorX = true; configuration->mirrorX = true;
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty; configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
return std::make_shared<Ili934xDisplay>(std::move(configuration)); auto display = std::make_shared<Ili934xDisplay>(std::move(configuration));
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
} }
@@ -1,5 +1,8 @@
#pragma once #pragma once
#include "Tactility/hal/display/DisplayDevice.h"
#include <memory>
#define TWODOTFOUR_LCD_PIN_BACKLIGHT GPIO_NUM_27 #define TWODOTFOUR_LCD_PIN_BACKLIGHT GPIO_NUM_27
// Display // Display
@@ -11,3 +14,4 @@
#define TWODOTFOUR_LCD_PIN_CS GPIO_NUM_15 #define TWODOTFOUR_LCD_PIN_CS GPIO_NUM_15
#define TWODOTFOUR_LCD_PIN_DC GPIO_NUM_2 #define TWODOTFOUR_LCD_PIN_DC GPIO_NUM_2
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
@@ -1,16 +1,16 @@
#include "YellowSdCard.h" #include "SdCard.h"
#define TAG "twodotfour_sdcard" #define TAG "twodotfour_sdcard"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h> #include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#define SDCARD_SPI_HOST SPI3_HOST constexpr auto SDCARD_SPI_HOST = SPI3_HOST;
#define SDCARD_PIN_CS GPIO_NUM_5 constexpr auto SDCARD_PIN_CS = GPIO_NUM_5;
using tt::hal::sdcard::SpiSdCardDevice; using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createYellowSdCard() { std::shared_ptr<SdCardDevice> createSdCard() {
auto* configuration = new SpiSdCardDevice::Config( auto configuration = std::make_unique<SpiSdCardDevice::Config>(
SDCARD_PIN_CS, SDCARD_PIN_CS,
GPIO_NUM_NC, GPIO_NUM_NC,
GPIO_NUM_NC, GPIO_NUM_NC,
@@ -21,10 +21,8 @@ std::shared_ptr<SdCardDevice> createYellowSdCard() {
SDCARD_SPI_HOST SDCARD_SPI_HOST
); );
auto* sdcard = (SdCardDevice*) new SpiSdCardDevice( return std::make_shared<SpiSdCardDevice>(
std::unique_ptr<SpiSdCardDevice::Config>(configuration) std::move(configuration)
); );
return std::shared_ptr<SdCardDevice>(sdcard);
} }
@@ -1,8 +0,0 @@
#pragma once
#include "Tactility/hal/sdcard/SdCardDevice.h"
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createYellowSdCard();
@@ -1,5 +0,0 @@
#pragma once
// Touch
#define TWODOTFOUR_TOUCH_I2C_PORT I2C_NUM_0
+7
View File
@@ -0,0 +1,7 @@
file(GLOB_RECURSE SOURCE_FILES Source/*.c*)
idf_component_register(
SRCS ${SOURCE_FILES}
INCLUDE_DIRS "Source"
REQUIRES Tactility esp_lvgl_port ILI934x XPT2046SoftSPI PwmBacklight driver vfs fatfs
)
@@ -0,0 +1,91 @@
#include "CYD2432S028R.h"
#include "devices/Display.h"
#include "devices/SdCard.h"
#include <Tactility/lvgl/LvglSync.h>
#include <PwmBacklight.h>
#include <Tactility/hal/Configuration.h>
// SPI Transfer
#define CYD_SPI_TRANSFER_SIZE_LIMIT (CYD2432S028R_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8)
// Display backlight (PWM)
#define CYD2432S028R_LCD_PIN_BACKLIGHT GPIO_NUM_21
using namespace tt::hal;
static bool initBoot() {
//Set the RGB Led Pins to output and turn them off
ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT)); //Red
ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_16, GPIO_MODE_OUTPUT)); //Green
ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_17, GPIO_MODE_OUTPUT)); //Blue
//0 on, 1 off... yep it's backwards.
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_4, 1)); //Red
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_16, 1)); //Green
ESP_ERROR_CHECK(gpio_set_level(GPIO_NUM_17, 1)); //Blue
return driver::pwmbacklight::init(CYD2432S028R_LCD_PIN_BACKLIGHT);
}
static DeviceVector createDevices() {
return {
createDisplay(),
createSdCard()
};
}
const Configuration cyd_2432s028r_config = {
.initBoot = initBoot,
.createDevices = createDevices,
.i2c = {},
.spi {
//Display
spi::Configuration {
.device = SPI2_HOST,
.dma = SPI_DMA_CH_AUTO,
.config = {
.mosi_io_num = GPIO_NUM_13,
.miso_io_num = GPIO_NUM_12,
.sclk_io_num = GPIO_NUM_14,
.quadwp_io_num = GPIO_NUM_NC,
.quadhd_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 = CYD_SPI_TRANSFER_SIZE_LIMIT,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
},
.initMode = spi::InitMode::ByTactility,
.isMutable = false,
.lock = tt::lvgl::getSyncLock()
},
// SDCard
spi::Configuration {
.device = SPI3_HOST,
.dma = SPI_DMA_CH_AUTO,
.config = {
.mosi_io_num = GPIO_NUM_23,
.miso_io_num = GPIO_NUM_19,
.sclk_io_num = GPIO_NUM_18,
.quadwp_io_num = GPIO_NUM_NC,
.quadhd_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 = 0,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
},
.initMode = spi::InitMode::ByTactility,
.isMutable = false,
.lock = tt::lvgl::getSyncLock() // esp_lvgl_port owns the lock for the display
},
}
};
@@ -0,0 +1,6 @@
#pragma once
#include <Tactility/hal/Configuration.h>
// Resistive touch version of the 2.8" yellow board
extern const tt::hal::Configuration cyd_2432s028r_config;
@@ -0,0 +1,54 @@
#include "Display.h"
#include "Xpt2046SoftSpi.h"
#include <Ili934xDisplay.h>
#include <PwmBacklight.h>
constexpr auto* TAG = "CYD";
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
auto configuration = std::make_unique<Xpt2046SoftSpi::Configuration>(
CYD_TOUCH_MOSI_PIN,
CYD_TOUCH_MISO_PIN,
CYD_TOUCH_SCK_PIN,
CYD_TOUCH_CS_PIN,
CYD2432S028R_LCD_HORIZONTAL_RESOLUTION, // 240
CYD2432S028R_LCD_VERTICAL_RESOLUTION, // 320
false, // swapXY
true, // mirrorX
false // mirrorY
);
// Allocate the driver
auto touch = std::make_shared<Xpt2046SoftSpi>(std::move(configuration));
// Start the driver
if (!touch->start()) {
ESP_LOGE(TAG, "Touch driver start failed");
return nullptr;
}
return touch;
}
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
auto touch = createTouch();
auto configuration = std::make_unique<Ili934xDisplay::Configuration>(
CYD2432S028R_LCD_SPI_HOST,
CYD2432S028R_LCD_PIN_CS,
CYD2432S028R_LCD_PIN_DC,
CYD2432S028R_LCD_HORIZONTAL_RESOLUTION,
CYD2432S028R_LCD_VERTICAL_RESOLUTION,
touch,
false, // swapXY
true, // mirrorX
false, // mirrorY
false,
CYD2432S028R_LCD_DRAW_BUFFER_SIZE
);
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
auto display = std::make_shared<Ili934xDisplay>(std::move(configuration));
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
}
@@ -0,0 +1,22 @@
#pragma once
#include "Tactility/hal/display/DisplayDevice.h"
#include <memory>
// Display
#define CYD2432S028R_LCD_SPI_HOST SPI2_HOST
#define CYD2432S028R_LCD_HORIZONTAL_RESOLUTION 240
#define CYD2432S028R_LCD_VERTICAL_RESOLUTION 320
#define CYD2432S028R_LCD_DRAW_BUFFER_HEIGHT (CYD2432S028R_LCD_VERTICAL_RESOLUTION / 10)
#define CYD2432S028R_LCD_DRAW_BUFFER_SIZE (CYD2432S028R_LCD_HORIZONTAL_RESOLUTION * CYD2432S028R_LCD_DRAW_BUFFER_HEIGHT)
#define CYD2432S028R_LCD_PIN_CS GPIO_NUM_15
#define CYD2432S028R_LCD_PIN_DC GPIO_NUM_2
// Touch (Software SPI)
#define CYD_TOUCH_MISO_PIN GPIO_NUM_39
#define CYD_TOUCH_MOSI_PIN GPIO_NUM_32
#define CYD_TOUCH_SCK_PIN GPIO_NUM_25
#define CYD_TOUCH_CS_PIN GPIO_NUM_33
#define CYD_TOUCH_IRQ_PIN GPIO_NUM_36
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
@@ -0,0 +1,21 @@
#include "SdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h>
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto config = std::make_unique<SpiSdCardDevice::Config>(
GPIO_NUM_5,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
std::make_shared<tt::Mutex>(),
std::vector<gpio_num_t>(),
SPI3_HOST
);
return std::make_shared<SpiSdCardDevice>(std::move(config));
}
+11 -6
View File
@@ -1,7 +1,7 @@
#include "CYD2432S032C.h" #include "CYD2432S032C.h"
#include "Tactility/lvgl/LvglSync.h" #include "Tactility/lvgl/LvglSync.h"
#include "hal/CydDisplay.h" #include "devices/Display.h"
#include "hal/CydSdCard.h" #include "devices/SdCard.h"
#include <Tactility/kernel/SystemEvents.h> #include <Tactility/kernel/SystemEvents.h>
@@ -14,7 +14,7 @@ bool initBoot() {
// This display has a weird glitch with gamma during boot, which results in uneven dark gray colours. // This display has a weird glitch with gamma during boot, which results in uneven dark gray colours.
// Setting gamma curve index to 0 doesn't work at boot for an unknown reason, so we set the curve index to 1: // Setting gamma curve index to 0 doesn't work at boot for an unknown reason, so we set the curve index to 1:
tt::kernel::subscribeSystemEvent(tt::kernel::SystemEvent::BootInitLvglEnd, [](auto event) { tt::kernel::subscribeSystemEvent(tt::kernel::SystemEvent::BootSplash, [](auto) {
auto display = tt::hal::findFirstDevice<tt::hal::display::DisplayDevice>(tt::hal::Device::Type::Display); auto display = tt::hal::findFirstDevice<tt::hal::display::DisplayDevice>(tt::hal::Device::Type::Display);
assert(display != nullptr); assert(display != nullptr);
tt::lvgl::lock(portMAX_DELAY); tt::lvgl::lock(portMAX_DELAY);
@@ -25,11 +25,16 @@ bool initBoot() {
return true; return true;
} }
static tt::hal::DeviceVector createDevices() {
return {
createDisplay(),
createSdCard()
};
}
const tt::hal::Configuration cyd_2432S032c_config = { const tt::hal::Configuration cyd_2432S032c_config = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createSdCard(),
.power = nullptr,
.i2c = { .i2c = {
tt::hal::i2c::Configuration { tt::hal::i2c::Configuration {
.name = "Internal", .name = "Internal",
@@ -1,4 +1,4 @@
#include "CydDisplay.h" #include "Display.h"
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <Ili934xDisplay.h> #include <Ili934xDisplay.h>
@@ -35,5 +35,6 @@ std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty; configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
return std::make_shared<Ili934xDisplay>(std::move(configuration)); auto display = std::make_shared<Ili934xDisplay>(std::move(configuration));
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
} }
@@ -1,6 +1,6 @@
#pragma once #pragma once
#include "Tactility/hal/display/DisplayDevice.h" #include <Tactility/hal/display/DisplayDevice.h>
#include <memory> #include <memory>
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay(); std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
@@ -1,15 +1,15 @@
#include "CydSdCard.h" #include "SdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h> #include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#define SDCARD_SPI_HOST SPI3_HOST constexpr auto SDCARD_SPI_HOST = SPI3_HOST;
#define SDCARD_PIN_CS GPIO_NUM_5 constexpr auto SDCARD_PIN_CS = GPIO_NUM_5;
using tt::hal::sdcard::SpiSdCardDevice; using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() { std::shared_ptr<SdCardDevice> createSdCard() {
auto* configuration = new SpiSdCardDevice::Config( auto configuration = std::make_unique<SpiSdCardDevice::Config>(
SDCARD_PIN_CS, SDCARD_PIN_CS,
GPIO_NUM_NC, GPIO_NUM_NC,
GPIO_NUM_NC, GPIO_NUM_NC,
@@ -20,10 +20,8 @@ std::shared_ptr<SdCardDevice> createSdCard() {
SDCARD_SPI_HOST SDCARD_SPI_HOST
); );
auto* sdcard = (SdCardDevice*) new SpiSdCardDevice( return std::make_shared<SpiSdCardDevice>(
std::unique_ptr<SpiSdCardDevice::Config>(configuration) std::move(configuration)
); );
return std::shared_ptr<SdCardDevice>(sdcard);
} }
@@ -0,0 +1,8 @@
#pragma once
#include <Tactility/hal/sdcard/SdCardDevice.h>
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();
@@ -1,6 +0,0 @@
#pragma once
#include "Tactility/hal/display/DisplayDevice.h"
#include <memory>
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
+1 -1
View File
@@ -3,5 +3,5 @@ file(GLOB_RECURSE SOURCE_FILES Source/*.c*)
idf_component_register( idf_component_register(
SRCS ${SOURCE_FILES} SRCS ${SOURCE_FILES}
INCLUDE_DIRS "Source" INCLUDE_DIRS "Source"
REQUIRES Tactility esp_lvgl_port esp_lcd esp_lcd_st7701 esp_lcd_panel_io_additions GT911 PwmBacklight driver vfs fatfs REQUIRES Tactility EspLcdCompat esp_lcd_st7701 esp_lcd_panel_io_additions GT911 PwmBacklight driver vfs fatfs
) )
+11 -6
View File
@@ -1,20 +1,25 @@
#include "CYD4848S040C.h" #include "CYD4848S040C.h"
#include "hal/CydDisplay.h" #include "devices/St7701Display.h"
#include "hal/CydSdCard.h" #include "devices/SdCard.h"
#include <PwmBacklight.h> #include <PwmBacklight.h>
using namespace tt::hal; using namespace tt::hal;
bool initBoot() { static bool initBoot() {
return driver::pwmbacklight::init(GPIO_NUM_38, 1000); return driver::pwmbacklight::init(GPIO_NUM_38, 1000);
} }
static DeviceVector createDevices() {
return {
std::reinterpret_pointer_cast<Device>(std::make_shared<St7701Display>()),
createSdCard()
};
}
const Configuration cyd_4848s040c_config = { const Configuration cyd_4848s040c_config = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createSdCard(),
.power = nullptr,
.i2c = { .i2c = {
//Touch //Touch
i2c::Configuration { i2c::Configuration {
@@ -1,4 +1,4 @@
#include "CydSdCard.h" #include "SdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h> #include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
@@ -5,3 +5,4 @@
using tt::hal::sdcard::SdCardDevice; using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard(); std::shared_ptr<SdCardDevice> createSdCard();
@@ -1,19 +1,17 @@
#include "CydDisplay.h" #include "St7701Display.h"
#include "PwmBacklight.h"
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <PwmBacklight.h>
#include <Tactility/Log.h> #include <Tactility/Log.h>
#include <driver/gpio.h> #include <driver/gpio.h>
#include <esp_err.h> #include <esp_err.h>
#include <esp_lcd_panel_rgb.h> #include <esp_lcd_panel_rgb.h>
#include <esp_lcd_panel_ops.h> #include <esp_lcd_panel_ops.h>
#include <esp_lcd_panel_io.h>
#include <esp_lcd_panel_io_additions.h> #include <esp_lcd_panel_io_additions.h>
#include <esp_lcd_st7701.h> #include <esp_lcd_st7701.h>
#include <esp_lvgl_port.h>
#define TAG "cyd_display" constexpr auto TAG = "St7701Display";
static const st7701_lcd_init_cmd_t st7701_lcd_init_cmds[] = { static const st7701_lcd_init_cmd_t st7701_lcd_init_cmds[] = {
// {cmd, { data }, data_size, delay_ms} // {cmd, { data }, data_size, delay_ms}
@@ -58,9 +56,7 @@ static const st7701_lcd_init_cmd_t st7701_lcd_init_cmds[] = {
{0x29, (uint8_t[]) {0x00}, 0, 0}, //Display On {0x29, (uint8_t[]) {0x00}, 0, 0}, //Display On
}; };
bool CydDisplay::start() { bool St7701Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
TT_LOG_I(TAG, "Starting");
spi_line_config_t line_config = { spi_line_config_t line_config = {
.cs_io_type = IO_TYPE_GPIO, .cs_io_type = IO_TYPE_GPIO,
.cs_gpio_num = GPIO_NUM_39, .cs_gpio_num = GPIO_NUM_39,
@@ -68,11 +64,13 @@ bool CydDisplay::start() {
.scl_gpio_num = GPIO_NUM_48, .scl_gpio_num = GPIO_NUM_48,
.sda_io_type = IO_TYPE_GPIO, .sda_io_type = IO_TYPE_GPIO,
.sda_gpio_num = GPIO_NUM_47, .sda_gpio_num = GPIO_NUM_47,
.io_expander = NULL, .io_expander = nullptr,
}; };
esp_lcd_panel_io_3wire_spi_config_t panel_io_config = ST7701_PANEL_IO_3WIRE_SPI_CONFIG(line_config, 0); esp_lcd_panel_io_3wire_spi_config_t panel_io_config = ST7701_PANEL_IO_3WIRE_SPI_CONFIG(line_config, 0);
ESP_ERROR_CHECK(esp_lcd_new_panel_io_3wire_spi(&panel_io_config, &ioHandle)); return esp_lcd_new_panel_io_3wire_spi(&panel_io_config, &outHandle) == ESP_OK;
}
bool St7701Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t& panelHandle) {
const esp_lcd_rgb_panel_config_t rgb_config = { const esp_lcd_rgb_panel_config_t rgb_config = {
.clk_src = LCD_CLK_SRC_DEFAULT, .clk_src = LCD_CLK_SRC_DEFAULT,
.timings = { .timings = {
@@ -179,7 +177,11 @@ bool CydDisplay::start() {
TT_LOG_E(TAG, "Failed to turn display on"); TT_LOG_E(TAG, "Failed to turn display on");
} }
const lvgl_port_display_cfg_t disp_cfg = { return true;
}
lvgl_port_display_cfg_t St7701Display::getLvglPortDisplayConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) {
return {
.io_handle = ioHandle, .io_handle = ioHandle,
.panel_handle = panelHandle, .panel_handle = panelHandle,
.control_handle = nullptr, .control_handle = nullptr,
@@ -204,50 +206,31 @@ bool CydDisplay::start() {
.direct_mode = false .direct_mode = false
} }
}; };
}
const lvgl_port_display_rgb_cfg_t rgb_cfg = { lvgl_port_display_rgb_cfg_t St7701Display::getLvglPortDisplayRgbConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) {
return {
.flags = { .flags = {
.bb_mode = true, .bb_mode = true,
.avoid_tearing = false .avoid_tearing = false
} }
}; };
displayHandle = lvgl_port_add_disp_rgb(&disp_cfg, &rgb_cfg);
TT_LOG_I(TAG, "Finished");
return displayHandle != nullptr;
} }
bool CydDisplay::stop() { std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable St7701Display::getTouchDevice() {
assert(displayHandle != nullptr); if (touchDevice == 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;
}
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable CydDisplay::createTouch() {
auto configuration = std::make_unique<Gt911Touch::Configuration>( auto configuration = std::make_unique<Gt911Touch::Configuration>(
I2C_NUM_0, I2C_NUM_0,
480, 480,
480 480
); );
return std::make_shared<Gt911Touch>(std::move(configuration)); touchDevice = std::make_shared<Gt911Touch>(std::move(configuration));
} }
void CydDisplay::setBacklightDuty(uint8_t backlightDuty) { return touchDevice;
}
void St7701Display::setBacklightDuty(uint8_t backlightDuty) {
driver::pwmbacklight::setBacklightDuty(backlightDuty); driver::pwmbacklight::setBacklightDuty(backlightDuty);
} }
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
return std::make_shared<CydDisplay>();
}
@@ -0,0 +1,38 @@
#pragma once
#include <Tactility/Mutex.h>
#include <EspLcdDisplay.h>
#include <lvgl.h>
class St7701Display final : public EspLcdDisplay {
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable touchDevice;
bool createIoHandle(esp_lcd_panel_io_handle_t& outHandle) override;
bool createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t& panelHandle) override;
lvgl_port_display_cfg_t getLvglPortDisplayConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) override;
bool isRgbPanel() const override { return true; }
lvgl_port_display_rgb_cfg_t getLvglPortDisplayRgbConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) override;
public:
St7701Display() : EspLcdDisplay(std::make_shared<tt::Mutex>(tt::Mutex::Type::Recursive)) {}
std::string getName() const override { return "ST7701S"; }
std::string getDescription() const override { return "ST7701S RGB display"; }
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable getTouchDevice() override;
void setBacklightDuty(uint8_t backlightDuty) override;
bool supportsBacklightDuty() const override { return true; }
// TODO: Find out why it crashes
bool supportsDisplayDriver() const override { return false; }
};
@@ -1,32 +0,0 @@
#pragma once
#include "Tactility/hal/display/DisplayDevice.h"
#include <esp_lcd_types.h>
#include <lvgl.h>
class CydDisplay : public tt::hal::display::DisplayDevice {
private:
esp_lcd_panel_io_handle_t ioHandle = nullptr;
esp_lcd_panel_handle_t panelHandle = nullptr;
lv_display_t* displayHandle = nullptr;
public:
std::string getName() const final { return "ST7701S"; }
std::string getDescription() const final { return "RGB Display"; }
bool start() override;
bool stop() override;
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable createTouch() override;
void setBacklightDuty(uint8_t backlightDuty) override;
bool supportsBacklightDuty() const override { return true; }
lv_display_t* _Nullable getLvglDisplay() const override { return displayHandle; }
};
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
+12 -6
View File
@@ -1,19 +1,25 @@
#include "CYD8048S043C.h" // Don't remove, or we get a linker error ("undefined reference to `cyd_8048s043c_config'" - GCC bug?) #include "CYD8048S043C.h" // Don't remove, or we get a linker error ("undefined reference to `cyd_8048s043c_config'" - GCC bug?)
#include "PwmBacklight.h" #include "PwmBacklight.h"
#include "hal/CydDisplay.h" #include "devices/Display.h"
#include "hal/CydSdCard.h" #include "devices/SdCard.h"
using namespace tt::hal; using namespace tt::hal;
bool initBoot() { static bool initBoot() {
// Display backlight
return driver::pwmbacklight::init(GPIO_NUM_2, 200); return driver::pwmbacklight::init(GPIO_NUM_2, 200);
} }
static DeviceVector createDevices() {
return {
createDisplay(),
createSdCard()
};
}
const Configuration cyd_8048s043c_config = { const Configuration cyd_8048s043c_config = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createSdCard(),
.power = nullptr,
.i2c = { .i2c = {
// Touch // Touch
i2c::Configuration { i2c::Configuration {
@@ -1,4 +1,4 @@
#include "CydDisplay.h" #include "Display.h"
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
@@ -1,4 +1,4 @@
#include "CydSdCard.h" #include "SdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h> #include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
+7
View File
@@ -0,0 +1,7 @@
file(GLOB_RECURSE SOURCE_FILES Source/*.c*)
idf_component_register(
SRCS ${SOURCE_FILES}
INCLUDE_DIRS "Source"
REQUIRES Tactility esp_lvgl_port ILI934x XPT2046SoftSPI PwmBacklight driver vfs fatfs
)
+73
View File
@@ -0,0 +1,73 @@
#include "E32R28T.h"
#include "devices/SdCard.h"
#include "devices/Display.h"
#include <Tactility/lvgl/LvglSync.h>
#include <PwmBacklight.h>
#define CYD_SPI_TRANSFER_SIZE_LIMIT (240 * 320 / 4 * 2)
static bool initBoot() {
return driver::pwmbacklight::init(CYD_BACKLIGHT_PIN);
}
static tt::hal::DeviceVector createDevices() {
return {
createDisplay(),
createSdCard()
};
}
const tt::hal::Configuration cyd_e32r28t_config = {
.initBoot = initBoot,
.createDevices = createDevices,
.i2c = {},
.spi = {
tt::hal::spi::Configuration {
.device = SPI2_HOST,
.dma = SPI_DMA_CH_AUTO,
.config = {
.mosi_io_num = GPIO_NUM_13,
.miso_io_num = GPIO_NUM_12,
.sclk_io_num = GPIO_NUM_14,
.quadwp_io_num = GPIO_NUM_NC,
.quadhd_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 = CYD_SPI_TRANSFER_SIZE_LIMIT,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
},
.initMode = tt::hal::spi::InitMode::ByTactility,
.isMutable = false,
.lock = tt::lvgl::getSyncLock()
},
tt::hal::spi::Configuration {
.device = SPI3_HOST,
.dma = SPI_DMA_CH_AUTO,
.config = {
.mosi_io_num = GPIO_NUM_23,
.miso_io_num = GPIO_NUM_19,
.sclk_io_num = GPIO_NUM_18,
.quadwp_io_num = GPIO_NUM_NC,
.quadhd_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 = CYD_SPI_TRANSFER_SIZE_LIMIT,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
},
.initMode = tt::hal::spi::InitMode::ByTactility,
.isMutable = false,
.lock = tt::lvgl::getSyncLock()
},
}
};
+6
View File
@@ -0,0 +1,6 @@
#pragma once
#include <Tactility/hal/Configuration.h>
// Resistive touch version of the waveshare 2.8" yellow board
extern const tt::hal::Configuration cyd_e32r28t_config;
@@ -0,0 +1,41 @@
#include "Display.h"
#include <Xpt2046SoftSpi.h>
#include <Ili934xDisplay.h>
#include <PwmBacklight.h>
#include <Tactility/hal/touch/TouchDevice.h>
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
auto config = std::make_unique<Xpt2046SoftSpi::Configuration>(
CYD_TOUCH_MOSI_PIN,
CYD_TOUCH_MISO_PIN,
CYD_TOUCH_SCK_PIN,
CYD_TOUCH_CS_PIN,
CYD_DISPLAY_HORIZONTAL_RESOLUTION,
CYD_DISPLAY_VERTICAL_RESOLUTION,
false,
true,
false
);
return std::make_shared<Xpt2046SoftSpi>(std::move(config));
}
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
auto configuration = std::make_unique<Ili934xDisplay::Configuration>(
CYD_DISPLAY_SPI_HOST,
CYD_DISPLAY_PIN_CS,
CYD_DISPLAY_PIN_DC,
CYD_DISPLAY_HORIZONTAL_RESOLUTION,
CYD_DISPLAY_VERTICAL_RESOLUTION,
createTouch(),
false,
true,
false,
false,
0,
LCD_RGB_ELEMENT_ORDER_BGR
);
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
return std::make_shared<Ili934xDisplay>(std::move(configuration));
}
@@ -0,0 +1,25 @@
#pragma once
#include <Tactility/hal/display/DisplayDevice.h>
#include <memory>
// Display
#define CYD_DISPLAY_SPI_HOST SPI2_HOST
#define CYD_DISPLAY_PIN_CS GPIO_NUM_15
#define CYD_DISPLAY_PIN_DC GPIO_NUM_2
#define CYD_DISPLAY_HORIZONTAL_RESOLUTION 240
#define CYD_DISPLAY_VERTICAL_RESOLUTION 320
#define CYD_DISPLAY_DRAW_BUFFER_HEIGHT (CYD_DISPLAY_VERTICAL_RESOLUTION / 10)
#define CYD_DISPLAY_DRAW_BUFFER_SIZE (CYD_DISPLAY_HORIZONTAL_RESOLUTION * CYD_DISPLAY_DRAW_BUFFER_HEIGHT)
// Touch (Software SPI)
#define CYD_TOUCH_MISO_PIN GPIO_NUM_39
#define CYD_TOUCH_MOSI_PIN GPIO_NUM_32
#define CYD_TOUCH_SCK_PIN GPIO_NUM_25
#define CYD_TOUCH_CS_PIN GPIO_NUM_33
#define CYD_TOUCH_IRQ_PIN GPIO_NUM_36
// Backlight
#define CYD_BACKLIGHT_PIN GPIO_NUM_21
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
@@ -0,0 +1,21 @@
#include "SdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto configuration = std::make_unique<SpiSdCardDevice::Config>(
GPIO_NUM_5,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
std::make_shared<tt::Mutex>(),
std::vector<gpio_num_t>(),
SPI3_HOST
);
return std::make_shared<SpiSdCardDevice>(
std::move(configuration)
);
}
@@ -0,0 +1,7 @@
#pragma once
#include <Tactility/hal/sdcard/SdCardDevice.h>
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();
+12 -9
View File
@@ -1,18 +1,16 @@
#include "JC2432W328C.h" #include "JC2432W328C.h"
#include "hal/YellowDisplay.h" #include "devices/Display.h"
#include "hal/YellowDisplayConstants.h" #include "devices/SdCard.h"
#include "hal/YellowSdCard.h"
#include <Tactility/lvgl/LvglSync.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
#include <Tactility/lvgl/LvglSync.h>
using namespace tt::hal; using namespace tt::hal;
#define CYD_SPI_TRANSFER_SIZE_LIMIT (JC2432W328C_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8) #define CYD_SPI_TRANSFER_SIZE_LIMIT (JC2432W328C_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8)
bool initBoot() { static bool initBoot() {
//Set the RGB Led Pins to output and turn them off //Set the RGB Led Pins to output and turn them off
ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT)); //Red ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT)); //Red
ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_16, GPIO_MODE_OUTPUT)); //Green ESP_ERROR_CHECK(gpio_set_direction(GPIO_NUM_16, GPIO_MODE_OUTPUT)); //Green
@@ -26,11 +24,16 @@ bool initBoot() {
return driver::pwmbacklight::init(JC2432W328C_LCD_PIN_BACKLIGHT); return driver::pwmbacklight::init(JC2432W328C_LCD_PIN_BACKLIGHT);
} }
static DeviceVector createDevices() {
return {
createDisplay(),
createSdCard()
};
}
const Configuration cyd_jc2432w328c_config = { const Configuration cyd_jc2432w328c_config = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createYellowSdCard(),
.power = nullptr,
.i2c = { .i2c = {
//Touch //Touch
i2c::Configuration { i2c::Configuration {
@@ -1,9 +1,8 @@
#include "YellowDisplay.h" #include "Display.h"
#include "Cst816Touch.h"
#include "YellowDisplayConstants.h"
#include <St7789Display.h> #include <Cst816Touch.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <St7789Display.h>
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() { static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
auto configuration = std::make_unique<Cst816sTouch::Configuration>( auto configuration = std::make_unique<Cst816sTouch::Configuration>(
@@ -34,5 +33,6 @@ std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty; configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
return std::make_shared<St7789Display>(std::move(configuration)); auto display = std::make_shared<St7789Display>(std::move(configuration));
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
} }
@@ -1,5 +1,8 @@
#pragma once #pragma once
#include "Tactility/hal/display/DisplayDevice.h"
#include <memory>
// Display backlight (PWM) // Display backlight (PWM)
#define JC2432W328C_LCD_PIN_BACKLIGHT GPIO_NUM_27 #define JC2432W328C_LCD_PIN_BACKLIGHT GPIO_NUM_27
@@ -12,3 +15,4 @@
#define JC2432W328C_LCD_PIN_CS GPIO_NUM_15 #define JC2432W328C_LCD_PIN_CS GPIO_NUM_15
#define JC2432W328C_LCD_PIN_DC GPIO_NUM_2 #define JC2432W328C_LCD_PIN_DC GPIO_NUM_2
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
@@ -0,0 +1,27 @@
#include "SdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h>
constexpr auto SDCARD_SPI_HOST = SPI3_HOST;
constexpr auto SDCARD_PIN_CS = GPIO_NUM_5;
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto configuration = std::make_unique<SpiSdCardDevice::Config>(
SDCARD_PIN_CS,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
std::make_shared<tt::Mutex>(),
std::vector<gpio_num_t>(),
SDCARD_SPI_HOST
);
return std::make_shared<SpiSdCardDevice>(
std::move(configuration)
);
}
@@ -4,4 +4,5 @@
using tt::hal::sdcard::SdCardDevice; using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createTdeckSdCard(); std::shared_ptr<SdCardDevice> createSdCard();
@@ -1,6 +0,0 @@
#pragma once
#include "Tactility/hal/display/DisplayDevice.h"
#include <memory>
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
@@ -1,31 +0,0 @@
#include "YellowSdCard.h"
#define TAG "jc2432w328c_sdcard"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h>
#define SDCARD_SPI_HOST SPI3_HOST
#define SDCARD_PIN_CS GPIO_NUM_5
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createYellowSdCard() {
auto* configuration = new SpiSdCardDevice::Config(
SDCARD_PIN_CS,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot,
std::make_shared<tt::Mutex>(),
std::vector<gpio_num_t>(),
SDCARD_SPI_HOST
);
auto* sdcard = (SdCardDevice*) new SpiSdCardDevice(
std::unique_ptr<SpiSdCardDevice::Config>(configuration)
);
return std::shared_ptr<SdCardDevice>(sdcard);
}
+11 -6
View File
@@ -1,19 +1,24 @@
#include "JC8048W550C.h" // Don't remove, or we get a linker error ("undefined reference to `cyd_jc8048w550c_config'" - GCC bug?) #include "JC8048W550C.h" // Don't remove, or we get a linker error ("undefined reference to `cyd_jc8048w550c_config'" - GCC bug?)
#include "PwmBacklight.h" #include "PwmBacklight.h"
#include "hal/CydDisplay.h" #include "devices/Display.h"
#include "hal/CydSdCard.h" #include "devices/SdCard.h"
using namespace tt::hal; using namespace tt::hal;
bool initBoot() { static bool initBoot() {
return driver::pwmbacklight::init(GPIO_NUM_2); return driver::pwmbacklight::init(GPIO_NUM_2);
} }
static DeviceVector createDevices() {
return {
createDisplay(),
createSdCard()
};
}
const Configuration cyd_jc8048w550c_config = { const Configuration cyd_jc8048w550c_config = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createSdCard(),
.power = nullptr,
.i2c = { .i2c = {
//Touch //Touch
i2c::Configuration { i2c::Configuration {
@@ -1,9 +1,8 @@
#include "RgbDisplay.h" #include "Display.h"
#include "CydDisplay.h"
#include <PwmBacklight.h>
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <PwmBacklight.h>
#include <RgbDisplay.h>
#include <Tactility/Log.h> #include <Tactility/Log.h>
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable createTouch() { std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable createTouch() {
@@ -1,5 +1,5 @@
#pragma once #pragma once
#include "Tactility/hal/display/DisplayDevice.h" #include <Tactility/hal/display/DisplayDevice.h>
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay(); std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
@@ -1,4 +1,4 @@
#include "CydSdCard.h" #include "SdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h> #include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
@@ -0,0 +1,7 @@
#pragma once
#include <Tactility/hal/sdcard/SdCardDevice.h>
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();
@@ -3,5 +3,5 @@ file(GLOB_RECURSE SOURCE_FILES Source/*.c*)
idf_component_register( idf_component_register(
SRCS ${SOURCE_FILES} SRCS ${SOURCE_FILES}
INCLUDE_DIRS "Source" INCLUDE_DIRS "Source"
REQUIRES Tactility esp_lvgl_port FT5x06 ST7789 PwmBacklight driver REQUIRES Tactility FT5x06 ST7789 PwmBacklight driver
) )
@@ -1,8 +1,7 @@
#include "PwmBacklight.h" #include "PwmBacklight.h"
#include "Tactility/lvgl/LvglSync.h" #include "Tactility/lvgl/LvglSync.h"
#include "hal/CrowPanelDisplay.h" #include "devices/Display.h"
#include "hal/CrowPanelDisplayConstants.h" #include "devices/SdCard.h"
#include "hal/CrowPanelSdCard.h"
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
@@ -10,14 +9,20 @@
using namespace tt::hal; using namespace tt::hal;
bool initBoot() { static bool initBoot() {
return driver::pwmbacklight::init(GPIO_NUM_38); return driver::pwmbacklight::init(GPIO_NUM_38);
} }
static DeviceVector createDevices() {
return {
createDisplay(),
createSdCard()
};
}
extern const Configuration crowpanel_advance_28 = { extern const Configuration crowpanel_advance_28 = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createSdCard(),
.i2c = { .i2c = {
// There is only 1 (internal for touch, and also serves as "I2C-OUT" port) // There is only 1 (internal for touch, and also serves as "I2C-OUT" port)
// Note: You could repurpose 1 or more UART interfaces as I2C interfaces // Note: You could repurpose 1 or more UART interfaces as I2C interfaces
@@ -1,20 +1,17 @@
#include "CrowPanelDisplay.h" #include "Display.h"
#include "CrowPanelDisplayConstants.h"
#include <Ft5x06Touch.h> #include <Ft5x06Touch.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <St7789Display.h> #include <St7789Display.h>
#define TAG "crowpanel_display"
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() { static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
// Note for future changes: Reset pin is 48 and interrupt pin is 47 // Note for future changes: Reset pin is 48 and interrupt pin is 47
auto configuration = std::make_unique<Ft5x06Touch::Configuration>( auto configuration = std::make_unique<Ft5x06Touch::Configuration>(
I2C_NUM_0, I2C_NUM_0,
240, 240,
320, 320,
true, false,
true, false,
false false
); );
@@ -28,16 +25,17 @@ std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
CROWPANEL_LCD_SPI_HOST, CROWPANEL_LCD_SPI_HOST,
CROWPANEL_LCD_PIN_CS, CROWPANEL_LCD_PIN_CS,
CROWPANEL_LCD_PIN_DC, CROWPANEL_LCD_PIN_DC,
320,
240, 240,
320,
touch, touch,
true, false,
true, false,
false, false,
true true
); );
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty; configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
return std::make_shared<St7789Display>(std::move(configuration)); auto display = std::make_shared<St7789Display>(std::move(configuration));
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
} }
@@ -1,8 +1,12 @@
#pragma once #pragma once
#include <Tactility/hal/display/DisplayDevice.h>
#define CROWPANEL_LCD_SPI_HOST SPI2_HOST #define CROWPANEL_LCD_SPI_HOST SPI2_HOST
#define CROWPANEL_LCD_PIN_CS GPIO_NUM_40 #define CROWPANEL_LCD_PIN_CS GPIO_NUM_40
#define CROWPANEL_LCD_PIN_DC GPIO_NUM_41 // RS #define CROWPANEL_LCD_PIN_DC GPIO_NUM_41 // RS
#define CROWPANEL_LCD_HORIZONTAL_RESOLUTION 320 #define CROWPANEL_LCD_HORIZONTAL_RESOLUTION 320
#define CROWPANEL_LCD_VERTICAL_RESOLUTION 240 #define CROWPANEL_LCD_VERTICAL_RESOLUTION 240
#define CROWPANEL_LCD_SPI_TRANSFER_HEIGHT (CROWPANEL_LCD_VERTICAL_RESOLUTION / 10) #define CROWPANEL_LCD_SPI_TRANSFER_HEIGHT (CROWPANEL_LCD_VERTICAL_RESOLUTION / 10)
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
@@ -1,29 +1,25 @@
#include "CrowPanelSdCard.h" #include "SdCard.h"
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h> #include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <esp_vfs_fat.h>
using tt::hal::sdcard::SpiSdCardDevice; using tt::hal::sdcard::SpiSdCardDevice;
#define CROWPANEL_SDCARD_PIN_CS GPIO_NUM_7 constexpr auto CROWPANEL_SDCARD_PIN_CS = GPIO_NUM_7;
std::shared_ptr<SdCardDevice> createSdCard() { std::shared_ptr<SdCardDevice> createSdCard() {
auto* configuration = new SpiSdCardDevice::Config( auto configuration = std::make_unique<SpiSdCardDevice::Config>(
CROWPANEL_SDCARD_PIN_CS, CROWPANEL_SDCARD_PIN_CS,
GPIO_NUM_NC, GPIO_NUM_NC,
GPIO_NUM_NC, GPIO_NUM_NC,
GPIO_NUM_NC, GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot, SdCardDevice::MountBehaviour::AtBoot,
tt::lvgl::getSyncLock(), tt::lvgl::getSyncLock(),
{}, std::vector<gpio_num_t>(),
SPI3_HOST SPI3_HOST
); );
auto* sdcard = (SdCardDevice*) new SpiSdCardDevice( return std::make_shared<SpiSdCardDevice>(
std::unique_ptr<SpiSdCardDevice::Config>(configuration) std::move(configuration)
); );
return std::shared_ptr<SdCardDevice>(sdcard);
} }
@@ -1,40 +0,0 @@
#pragma once
#include "Tactility/hal/display/DisplayDevice.h"
#include <esp_lcd_types.h>
#include <lvgl.h>
class CrowPanelDisplay : public tt::hal::display::DisplayDevice {
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:
std::string getName() const final { return "ST7789"; }
std::string getDescription() const final { return "SPI display"; }
bool start() override;
bool stop() override;
void setPowerOn(bool turnOn) override;
bool isPoweredOn() const override { return poweredOn; };
bool supportsPowerControl() const override { return true; }
std::shared_ptr<tt::hal::touch::TouchDevice> _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; }
};
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
@@ -1,8 +1,7 @@
#include "PwmBacklight.h" #include "PwmBacklight.h"
#include "Tactility/lvgl/LvglSync.h" #include "Tactility/lvgl/LvglSync.h"
#include "hal/CrowPanelDisplay.h" #include "devices/Display.h"
#include "hal/CrowPanelDisplayConstants.h" #include "devices/SdCard.h"
#include "hal/CrowPanelSdCard.h"
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
@@ -10,14 +9,20 @@
using namespace tt::hal; using namespace tt::hal;
bool initBoot() { static bool initBoot() {
return driver::pwmbacklight::init(GPIO_NUM_38); return driver::pwmbacklight::init(GPIO_NUM_38);
} }
static DeviceVector createDevices() {
return {
createDisplay(),
createSdCard()
};
}
extern const Configuration crowpanel_advance_35 = { extern const Configuration crowpanel_advance_35 = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createSdCard(),
.i2c = { .i2c = {
// There is only 1 (internal for touch, and also serves as "I2C-OUT" port) // There is only 1 (internal for touch, and also serves as "I2C-OUT" port)
// Note: You could repurpose 1 or more UART interfaces as I2C interfaces // Note: You could repurpose 1 or more UART interfaces as I2C interfaces
@@ -1,12 +1,9 @@
#include "CrowPanelDisplay.h" #include "Display.h"
#include "CrowPanelDisplayConstants.h"
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <Ili9488Display.h> #include <Ili9488Display.h>
#define TAG "crowpanel_display"
static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() { static std::shared_ptr<tt::hal::touch::TouchDevice> createTouch() {
// Note for future changes: Reset pin is 48 and interrupt pin is 47 // Note for future changes: Reset pin is 48 and interrupt pin is 47
auto configuration = std::make_unique<Gt911Touch::Configuration>( auto configuration = std::make_unique<Gt911Touch::Configuration>(
@@ -36,5 +33,6 @@ std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty; configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
return std::make_shared<Ili9488Display>(std::move(configuration)); auto display = std::make_shared<Ili9488Display>(std::move(configuration));
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
} }
@@ -1,8 +1,12 @@
#pragma once #pragma once
#include <Tactility/hal/display/DisplayDevice.h>
#define CROWPANEL_LCD_SPI_HOST SPI2_HOST #define CROWPANEL_LCD_SPI_HOST SPI2_HOST
#define CROWPANEL_LCD_PIN_CS GPIO_NUM_40 #define CROWPANEL_LCD_PIN_CS GPIO_NUM_40
#define CROWPANEL_LCD_PIN_DC GPIO_NUM_41 // RS #define CROWPANEL_LCD_PIN_DC GPIO_NUM_41 // RS
#define CROWPANEL_LCD_HORIZONTAL_RESOLUTION 320 #define CROWPANEL_LCD_HORIZONTAL_RESOLUTION 320
#define CROWPANEL_LCD_VERTICAL_RESOLUTION 480 #define CROWPANEL_LCD_VERTICAL_RESOLUTION 480
#define CROWPANEL_LCD_SPI_TRANSFER_HEIGHT (CROWPANEL_LCD_VERTICAL_RESOLUTION / 10) #define CROWPANEL_LCD_SPI_TRANSFER_HEIGHT (CROWPANEL_LCD_VERTICAL_RESOLUTION / 10)
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
@@ -1,29 +1,25 @@
#include "CrowPanelSdCard.h" #include "SdCard.h"
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h> #include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <esp_vfs_fat.h>
using tt::hal::sdcard::SpiSdCardDevice; using tt::hal::sdcard::SpiSdCardDevice;
#define CROWPANEL_SDCARD_PIN_CS GPIO_NUM_7 constexpr auto CROWPANEL_SDCARD_PIN_CS = GPIO_NUM_7;
std::shared_ptr<SdCardDevice> createSdCard() { std::shared_ptr<SdCardDevice> createSdCard() {
auto* configuration = new SpiSdCardDevice::Config( auto configuration = std::make_unique<SpiSdCardDevice::Config>(
CROWPANEL_SDCARD_PIN_CS, CROWPANEL_SDCARD_PIN_CS,
GPIO_NUM_NC, GPIO_NUM_NC,
GPIO_NUM_NC, GPIO_NUM_NC,
GPIO_NUM_NC, GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot, SdCardDevice::MountBehaviour::AtBoot,
tt::lvgl::getSyncLock(), tt::lvgl::getSyncLock(),
{}, std::vector<gpio_num_t>(),
SPI3_HOST SPI3_HOST
); );
auto* sdcard = (SdCardDevice*) new SpiSdCardDevice( return std::make_shared<SpiSdCardDevice>(
std::unique_ptr<SpiSdCardDevice::Config>(configuration) std::move(configuration)
); );
return std::shared_ptr<SdCardDevice>(sdcard);
} }
@@ -1,40 +0,0 @@
#pragma once
#include "Tactility/hal/display/DisplayDevice.h"
#include <esp_lcd_types.h>
#include <lvgl.h>
class CrowPanelDisplay : public tt::hal::display::DisplayDevice {
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:
std::string getName() const final { return "ST7789"; }
std::string getDescription() const final { return "SPI display"; }
bool start() override;
bool stop() override;
void setPowerOn(bool turnOn) override;
bool isPoweredOn() const override { return poweredOn; };
bool supportsPowerControl() const override { return true; }
std::shared_ptr<tt::hal::touch::TouchDevice> _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; }
};
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
@@ -1,12 +1,12 @@
#include "hal/CrowPanelDisplay.h" #include "devices/Display.h"
#include "hal/CrowPanelSdCard.h" #include "devices/SdCard.h"
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
#include <TCA9534.h> #include <TCA9534.h>
using namespace tt::hal; using namespace tt::hal;
bool initBoot() { static bool initBoot() {
TCA9534_IO_EXP io_expander = { TCA9534_IO_EXP io_expander = {
.I2C_ADDR = 0x18, .I2C_ADDR = 0x18,
.i2c_master_port = I2C_NUM_0, .i2c_master_port = I2C_NUM_0,
@@ -21,10 +21,16 @@ bool initBoot() {
return true; return true;
} }
static DeviceVector createDevices() {
return {
createDisplay(),
createSdCard()
};
}
extern const Configuration crowpanel_advance_50 = { extern const Configuration crowpanel_advance_50 = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createSdCard(),
.i2c = { .i2c = {
// There is only 1 (internal for touch, and also serves as "I2C-OUT" port) // There is only 1 (internal for touch, and also serves as "I2C-OUT" port)
// Note: You could repurpose 1 or more UART interfaces as I2C interfaces // Note: You could repurpose 1 or more UART interfaces as I2C interfaces
@@ -1,4 +1,4 @@
#include "CrowPanelDisplay.h" #include "Display.h"
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <RgbDisplay.h> #include <RgbDisplay.h>
@@ -1,5 +1,5 @@
#pragma once #pragma once
#include "Tactility/hal/display/DisplayDevice.h" #include <Tactility/hal/display/DisplayDevice.h>
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay(); std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
@@ -1,14 +1,12 @@
#include "CrowPanelSdCard.h" #include "SdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h> #include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#include <esp_vfs_fat.h>
using tt::hal::sdcard::SpiSdCardDevice; using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() { std::shared_ptr<SdCardDevice> createSdCard() {
auto* configuration = new SpiSdCardDevice::Config( auto configuration = std::make_unique<SpiSdCardDevice::Config>(
// See https://github.com/Elecrow-RD/CrowPanel-Advance-HMI-ESP32-AI-Display/blob/master/5.0/factory_code/factory_code.ino // See https://github.com/Elecrow-RD/CrowPanel-Advance-HMI-ESP32-AI-Display/blob/master/5.0/factory_code/factory_code.ino
GPIO_NUM_0, // It's actually not connected, but in the demo pin 0 is used GPIO_NUM_0, // It's actually not connected, but in the demo pin 0 is used
GPIO_NUM_NC, GPIO_NUM_NC,
@@ -17,9 +15,7 @@ std::shared_ptr<SdCardDevice> createSdCard() {
SdCardDevice::MountBehaviour::AtBoot SdCardDevice::MountBehaviour::AtBoot
); );
auto* sdcard = (SdCardDevice*) new SpiSdCardDevice( return std::make_shared<SpiSdCardDevice>(
std::unique_ptr<SpiSdCardDevice::Config>(configuration) std::move(configuration)
); );
return std::shared_ptr<SdCardDevice>(sdcard);
} }
@@ -0,0 +1,7 @@
#pragma once
#include <Tactility/hal/sdcard/SdCardDevice.h>
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();
@@ -1,25 +1,30 @@
#include "PwmBacklight.h" #include "PwmBacklight.h"
#include "Tactility/lvgl/LvglSync.h" #include "devices/Display.h"
#include "hal/CrowPanelDisplay.h" #include "devices/SdCard.h"
#include "hal/CrowPanelDisplayConstants.h"
#include "hal/CrowPanelSdCard.h"
#include <Xpt2046Power.h> #include <Xpt2046Power.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
#include <Tactility/lvgl/LvglSync.h>
#define CROWPANEL_SPI_TRANSFER_SIZE_LIMIT (CROWPANEL_LCD_HORIZONTAL_RESOLUTION * CROWPANEL_LCD_SPI_TRANSFER_HEIGHT * (LV_COLOR_DEPTH / 8)) #define CROWPANEL_SPI_TRANSFER_SIZE_LIMIT (CROWPANEL_LCD_HORIZONTAL_RESOLUTION * CROWPANEL_LCD_SPI_TRANSFER_HEIGHT * (LV_COLOR_DEPTH / 8))
using namespace tt::hal; using namespace tt::hal;
bool initBoot() { static bool initBoot() {
return driver::pwmbacklight::init(GPIO_NUM_27); return driver::pwmbacklight::init(GPIO_NUM_27);
} }
static DeviceVector createDevices() {
return {
std::make_shared<Xpt2046Power>(),
createDisplay(),
createSdCard(),
};
}
extern const Configuration crowpanel_basic_28 = { extern const Configuration crowpanel_basic_28 = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createSdCard(),
.power = getOrCreatePower,
.i2c = { .i2c = {
// There is only 1 (internal for touch, and also serves as "I2C-OUT" port) // There is only 1 (internal for touch, and also serves as "I2C-OUT" port)
// Note: You could repurpose 1 or more UART interfaces as I2C interfaces // Note: You could repurpose 1 or more UART interfaces as I2C interfaces
@@ -1,5 +1,4 @@
#include "CrowPanelDisplay.h" #include "Display.h"
#include "CrowPanelDisplayConstants.h"
#include <Ili934xDisplay.h> #include <Ili934xDisplay.h>
#include <Xpt2046Touch.h> #include <Xpt2046Touch.h>
@@ -35,5 +34,6 @@ std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
configuration->mirrorX = true; configuration->mirrorX = true;
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty; configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
return std::make_shared<Ili934xDisplay>(std::move(configuration)); auto display = std::make_shared<Ili934xDisplay>(std::move(configuration));
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
} }
@@ -1,5 +1,7 @@
#pragma once #pragma once
#include <Tactility/hal/display/DisplayDevice.h>
#define CROWPANEL_LCD_SPI_HOST SPI2_HOST #define CROWPANEL_LCD_SPI_HOST SPI2_HOST
#define CROWPANEL_LCD_PIN_CS GPIO_NUM_15 #define CROWPANEL_LCD_PIN_CS GPIO_NUM_15
#define CROWPANEL_TOUCH_PIN_CS GPIO_NUM_33 #define CROWPANEL_TOUCH_PIN_CS GPIO_NUM_33
@@ -7,3 +9,5 @@
#define CROWPANEL_LCD_HORIZONTAL_RESOLUTION 320 #define CROWPANEL_LCD_HORIZONTAL_RESOLUTION 320
#define CROWPANEL_LCD_VERTICAL_RESOLUTION 240 #define CROWPANEL_LCD_VERTICAL_RESOLUTION 240
#define CROWPANEL_LCD_SPI_TRANSFER_HEIGHT (CROWPANEL_LCD_VERTICAL_RESOLUTION / 10) #define CROWPANEL_LCD_SPI_TRANSFER_HEIGHT (CROWPANEL_LCD_VERTICAL_RESOLUTION / 10)
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
@@ -1,27 +1,23 @@
#include "CrowPanelSdCard.h" #include "SdCard.h"
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h> #include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <esp_vfs_fat.h>
using tt::hal::sdcard::SpiSdCardDevice; using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() { std::shared_ptr<SdCardDevice> createSdCard() {
auto* configuration = new SpiSdCardDevice::Config( auto configuration = std::make_unique<SpiSdCardDevice::Config>(
GPIO_NUM_5, GPIO_NUM_5,
GPIO_NUM_NC, GPIO_NUM_NC,
GPIO_NUM_NC, GPIO_NUM_NC,
GPIO_NUM_NC, GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot, SdCardDevice::MountBehaviour::AtBoot,
tt::lvgl::getSyncLock(), tt::lvgl::getSyncLock(),
{}, std::vector<gpio_num_t>(),
SPI3_HOST SPI3_HOST
); );
auto* sdcard = (SdCardDevice*) new SpiSdCardDevice( return std::make_shared<SpiSdCardDevice>(
std::unique_ptr<SpiSdCardDevice::Config>(configuration) std::move(configuration)
); );
return std::shared_ptr<SdCardDevice>(sdcard);
} }
@@ -1,40 +0,0 @@
#pragma once
#include "Tactility/hal/display/DisplayDevice.h"
#include <esp_lcd_types.h>
#include <lvgl.h>
class CrowPanelDisplay : public tt::hal::display::DisplayDevice {
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:
std::string getName() const final { return "ST7789"; }
std::string getDescription() const final { return "SPI display"; }
bool start() override;
bool stop() override;
void setPowerOn(bool turnOn) override;
bool isPoweredOn() const override { return poweredOn; };
bool supportsPowerControl() const override { return true; }
std::shared_ptr<tt::hal::touch::TouchDevice> _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; }
};
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
@@ -1,25 +1,30 @@
#include "PwmBacklight.h" #include "PwmBacklight.h"
#include "Tactility/lvgl/LvglSync.h" #include "Tactility/lvgl/LvglSync.h"
#include "hal/CrowPanelDisplay.h" #include "devices/Display.h"
#include "hal/CrowPanelDisplayConstants.h" #include "devices/SdCard.h"
#include "hal/CrowPanelSdCard.h"
#include <Xpt2046Power.h> #include <Xpt2046Power.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
#define CROWPANEL_SPI_TRANSFER_SIZE_LIMIT (CROWPANEL_LCD_HORIZONTAL_RESOLUTION * CROWPANEL_LCD_SPI_TRANSFER_HEIGHT * (LV_COLOR_DEPTH / 8)) constexpr auto CROWPANEL_SPI_TRANSFER_SIZE_LIMIT = (CROWPANEL_LCD_HORIZONTAL_RESOLUTION * CROWPANEL_LCD_SPI_TRANSFER_HEIGHT * (LV_COLOR_DEPTH / 8));
using namespace tt::hal; using namespace tt::hal;
bool initBoot() { static bool initBoot() {
return driver::pwmbacklight::init(GPIO_NUM_27); return driver::pwmbacklight::init(GPIO_NUM_27);
} }
static DeviceVector createDevices() {
return {
std::make_shared<Xpt2046Power>(),
createDisplay(),
createSdCard(),
};
}
extern const Configuration crowpanel_basic_35 = { extern const Configuration crowpanel_basic_35 = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createSdCard(),
.power = getOrCreatePower,
.i2c = { .i2c = {
// There is only 1 (internal for touch, and also serves as "I2C-OUT" port) // There is only 1 (internal for touch, and also serves as "I2C-OUT" port)
// Note: You could repurpose 1 or more UART interfaces as I2C interfaces // Note: You could repurpose 1 or more UART interfaces as I2C interfaces
@@ -1,10 +1,8 @@
#include "CrowPanelDisplay.h" #include "Display.h"
#include "CrowPanelDisplayConstants.h"
#include <Ili9488Display.h> #include <Ili9488Display.h>
#include <Xpt2046Touch.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <Xpt2046Touch.h>
std::shared_ptr<Xpt2046Touch> createTouch() { std::shared_ptr<Xpt2046Touch> createTouch() {
auto configuration = std::make_unique<Xpt2046Touch::Configuration>( auto configuration = std::make_unique<Xpt2046Touch::Configuration>(
@@ -12,8 +10,8 @@ std::shared_ptr<Xpt2046Touch> createTouch() {
CROWPANEL_TOUCH_PIN_CS, CROWPANEL_TOUCH_PIN_CS,
320, 320,
480, 480,
true, false,
true, false,
true true
); );
@@ -23,24 +21,20 @@ std::shared_ptr<Xpt2046Touch> createTouch() {
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() { std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
auto touch = createTouch(); auto touch = createTouch();
/**
* This display is mirrored on X, but that doesn't seem to work with the driver.
* Instead, we swap XY, which does work. That results in a landscape image.
*/
auto configuration = std::make_unique<Ili9488Display::Configuration>( auto configuration = std::make_unique<Ili9488Display::Configuration>(
CROWPANEL_LCD_SPI_HOST, CROWPANEL_LCD_SPI_HOST,
CROWPANEL_LCD_PIN_CS, CROWPANEL_LCD_PIN_CS,
CROWPANEL_LCD_PIN_DC, CROWPANEL_LCD_PIN_DC,
480,
320, 320,
480,
touch, touch,
true, false,
false, false,
false false
); );
configuration->mirrorX = true;
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty; configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
return std::make_shared<Ili9488Display>(std::move(configuration)); auto display = std::make_shared<Ili9488Display>(std::move(configuration));
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
} }
@@ -1,5 +1,7 @@
#pragma once #pragma once
#include <Tactility/hal/display/DisplayDevice.h>
#define CROWPANEL_LCD_SPI_HOST SPI2_HOST #define CROWPANEL_LCD_SPI_HOST SPI2_HOST
#define CROWPANEL_LCD_PIN_CS GPIO_NUM_15 #define CROWPANEL_LCD_PIN_CS GPIO_NUM_15
#define CROWPANEL_TOUCH_PIN_CS GPIO_NUM_12 #define CROWPANEL_TOUCH_PIN_CS GPIO_NUM_12
@@ -7,3 +9,5 @@
#define CROWPANEL_LCD_HORIZONTAL_RESOLUTION 320 #define CROWPANEL_LCD_HORIZONTAL_RESOLUTION 320
#define CROWPANEL_LCD_VERTICAL_RESOLUTION 240 #define CROWPANEL_LCD_VERTICAL_RESOLUTION 240
#define CROWPANEL_LCD_SPI_TRANSFER_HEIGHT (CROWPANEL_LCD_VERTICAL_RESOLUTION / 10) #define CROWPANEL_LCD_SPI_TRANSFER_HEIGHT (CROWPANEL_LCD_VERTICAL_RESOLUTION / 10)
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
@@ -1,27 +1,23 @@
#include "CrowPanelSdCard.h" #include "SdCard.h"
#include <Tactility/lvgl/LvglSync.h> #include <Tactility/lvgl/LvglSync.h>
#include <Tactility/hal/sdcard/SpiSdCardDevice.h> #include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <esp_vfs_fat.h>
using tt::hal::sdcard::SpiSdCardDevice; using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() { std::shared_ptr<SdCardDevice> createSdCard() {
auto* configuration = new SpiSdCardDevice::Config( auto configuration = std::make_unique<SpiSdCardDevice::Config>(
GPIO_NUM_5, GPIO_NUM_5,
GPIO_NUM_NC, GPIO_NUM_NC,
GPIO_NUM_NC, GPIO_NUM_NC,
GPIO_NUM_NC, GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot, SdCardDevice::MountBehaviour::AtBoot,
tt::lvgl::getSyncLock(), tt::lvgl::getSyncLock(),
{}, std::vector<gpio_num_t>(),
SPI3_HOST SPI3_HOST
); );
auto* sdcard = (SdCardDevice*) new SpiSdCardDevice( return std::make_shared<SpiSdCardDevice>(
std::unique_ptr<SpiSdCardDevice::Config>(configuration) std::move(configuration)
); );
return std::shared_ptr<SdCardDevice>(sdcard);
} }
@@ -1,40 +0,0 @@
#pragma once
#include "Tactility/hal/display/DisplayDevice.h"
#include <esp_lcd_types.h>
#include <lvgl.h>
class CrowPanelDisplay : public tt::hal::display::DisplayDevice {
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:
std::string getName() const final { return "ST7789"; }
std::string getDescription() const final { return "SPI display"; }
bool start() override;
bool stop() override;
void setPowerOn(bool turnOn) override;
bool isPoweredOn() const override { return poweredOn; };
bool supportsPowerControl() const override { return true; }
std::shared_ptr<tt::hal::touch::TouchDevice> _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; }
};
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
@@ -1,19 +1,26 @@
#include "hal/CrowPanelDisplay.h" #include "devices/Display.h"
#include "hal/CrowPanelSdCard.h" #include "devices/SdCard.h"
#include <PwmBacklight.h> #include <PwmBacklight.h>
#include <Tactility/hal/Configuration.h> #include <Tactility/hal/Configuration.h>
using namespace tt::hal; using namespace tt::hal;
bool initBoot() { static bool initBoot() {
// Note: I tried 100 Hz to 100 kHz and couldn't get the flickering to stop
return driver::pwmbacklight::init(GPIO_NUM_2); return driver::pwmbacklight::init(GPIO_NUM_2);
} }
static DeviceVector createDevices() {
return {
createDisplay(),
createSdCard(),
};
}
extern const Configuration crowpanel_basic_50 = { extern const Configuration crowpanel_basic_50 = {
.initBoot = initBoot, .initBoot = initBoot,
.createDisplay = createDisplay, .createDevices = createDevices,
.sdcard = createSdCard(),
.i2c = { .i2c = {
// There is only 1 (internal for touch, and also serves as "I2C-OUT" port) // There is only 1 (internal for touch, and also serves as "I2C-OUT" port)
// Note: You could repurpose 1 or more UART interfaces as I2C interfaces // Note: You could repurpose 1 or more UART interfaces as I2C interfaces
@@ -1,4 +1,4 @@
#include "CrowPanelDisplay.h" #include "Display.h"
#include <Gt911Touch.h> #include <Gt911Touch.h>
#include <PwmBacklight.h> #include <PwmBacklight.h>
@@ -101,5 +101,6 @@ std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
driver::pwmbacklight::setBacklightDuty driver::pwmbacklight::setBacklightDuty
); );
return std::make_shared<RgbDisplay>(std::move(configuration)); auto display = std::make_shared<RgbDisplay>(std::move(configuration));
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
} }
@@ -1,5 +1,5 @@
#pragma once #pragma once
#include "Tactility/hal/display/DisplayDevice.h" #include <Tactility/hal/display/DisplayDevice.h>
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay(); std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
@@ -1,11 +1,11 @@
#include "WaveshareSdCard.h" #include "SdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h> #include <Tactility/hal/sdcard/SpiSdCardDevice.h>
using tt::hal::sdcard::SpiSdCardDevice; using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() { std::shared_ptr<SdCardDevice> createSdCard() {
auto* configuration = new SpiSdCardDevice::Config( auto configuration = std::make_unique<SpiSdCardDevice::Config>(
GPIO_NUM_10, GPIO_NUM_10,
GPIO_NUM_NC, GPIO_NUM_NC,
GPIO_NUM_NC, GPIO_NUM_NC,
@@ -13,9 +13,7 @@ std::shared_ptr<SdCardDevice> createSdCard() {
SdCardDevice::MountBehaviour::AtBoot SdCardDevice::MountBehaviour::AtBoot
); );
auto* sdcard = (SdCardDevice*) new SpiSdCardDevice( return std::make_shared<SpiSdCardDevice>(
std::unique_ptr<SpiSdCardDevice::Config>(configuration) std::move(configuration)
); );
return std::shared_ptr<SdCardDevice>(sdcard);
} }
@@ -0,0 +1,7 @@
#pragma once
#include <Tactility/hal/sdcard/SdCardDevice.h>
using tt::hal::sdcard::SdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard();
@@ -1,24 +0,0 @@
#include "CrowPanelSdCard.h"
#include <Tactility/hal/sdcard/SpiSdCardDevice.h>
#include <Tactility/lvgl/LvglSync.h>
#include <esp_vfs_fat.h>
using tt::hal::sdcard::SpiSdCardDevice;
std::shared_ptr<SdCardDevice> createSdCard() {
auto* configuration = new SpiSdCardDevice::Config(
GPIO_NUM_10,
GPIO_NUM_NC,
GPIO_NUM_NC,
GPIO_NUM_NC,
SdCardDevice::MountBehaviour::AtBoot
);
auto* sdcard = (SdCardDevice*) new SpiSdCardDevice(
std::unique_ptr<SpiSdCardDevice::Config>(configuration)
);
return std::shared_ptr<SdCardDevice>(sdcard);
}
+7
View File
@@ -0,0 +1,7 @@
file(GLOB_RECURSE SOURCE_FILES Source/*.c*)
idf_component_register(
SRCS ${SOURCE_FILES}
INCLUDE_DIRS "Source"
REQUIRES Tactility esp_lcd ST7796 BQ25896 BQ27220 TCA8418 DRV2605 PwmBacklight driver esp_adc
)
+56
View File
@@ -0,0 +1,56 @@
#include <Bq27220.h>
#include <Tactility/TactilityCore.h>
#include <Tactility/kernel/SystemEvents.h>
#include <Tactility/service/gps/GpsService.h>
#include <Tactility/hal/gps/GpsConfiguration.h>
#include <driver/gpio.h>
#include <PwmBacklight.h>
constexpr auto* TAG = "TLoraPager";
bool tpagerInit() {
ESP_LOGI(TAG, LOG_MESSAGE_POWER_ON_START);
/* 32 Khz and higher gives an issue where the screen starts dimming again above 80% brightness
* when moving the brightness slider rapidly from a lower setting to 100%.
* This is not a slider bug (data was debug-traced) */
if (!driver::pwmbacklight::init(GPIO_NUM_42, 30000)) {
TT_LOG_E(TAG, "Backlight init failed");
return false;
}
tt::kernel::subscribeSystemEvent(tt::kernel::SystemEvent::BootSplash, [](auto) {
tt::hal::findDevices([](auto device) {
if (device->getName() == "BQ27220") {
auto bq27220 = std::reinterpret_pointer_cast<Bq27220>(device);
if (bq27220 != nullptr) {
bq27220->configureCapacity(1500, 1500);
return false;
}
}
return true;
});
auto gps_service = tt::service::gps::findGpsService();
if (gps_service != nullptr) {
std::vector<tt::hal::gps::GpsConfiguration> gps_configurations;
gps_service->getGpsConfigurations(gps_configurations);
if (gps_configurations.empty()) {
if (gps_service->addGpsConfiguration(tt::hal::gps::GpsConfiguration {
.uartName = "Internal",
.baudRate = 38400,
.model = tt::hal::gps::GpsModel::UBLOX10
})) {
TT_LOG_I(TAG, "Configured internal GPS");
} else {
TT_LOG_E(TAG, "Failed to configure internal GPS");
}
}
}
});
return true;
}
@@ -0,0 +1,106 @@
#include "Tactility/lvgl/LvglSync.h"
#include "devices/Display.h"
#include "devices/SdCard.h"
#include "devices/TpagerEncoder.h"
#include "devices/TpagerKeyboard.h"
#include "devices/TpagerPower.h"
#include <Bq25896.h>
#include <Drv2605.h>
#include <Tactility/hal/Configuration.h>
#define TPAGER_SPI_TRANSFER_SIZE_LIMIT (480 * 222 * (LV_COLOR_DEPTH / 8))
bool tpagerInit();
using namespace tt::hal;
static DeviceVector createDevices() {
auto bq27220 = std::make_shared<Bq27220>(I2C_NUM_0);
auto power = std::make_shared<TpagerPower>(bq27220);
auto tca8418 = std::make_shared<Tca8418>(I2C_NUM_0);
auto keyboard = std::make_shared<TpagerKeyboard>(tca8418);
return std::vector<std::shared_ptr<Device>> {
tca8418,
std::make_shared<Bq25896>(I2C_NUM_0),
bq27220,
std::make_shared<Drv2605>(I2C_NUM_0),
power,
createTpagerSdCard(),
createDisplay(),
keyboard,
std::make_shared<TpagerEncoder>()
};
}
extern const Configuration lilygo_tlora_pager = {
.initBoot = tpagerInit,
.createDevices = createDevices,
.i2c = {
i2c::Configuration {
.name = "Internal",
.port = I2C_NUM_0,
.initMode = i2c::InitMode::ByTactility,
.isMutable = false,
.config = (i2c_config_t) {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_3,
.scl_io_num = GPIO_NUM_2,
.sda_pullup_en = false,
.scl_pullup_en = false,
.master = {
.clk_speed = 100'000
},
.clk_flags = 0
}
}
},
.spi {spi::Configuration {
.device = SPI2_HOST,
.dma = SPI_DMA_CH_AUTO,
.config = {
.mosi_io_num = GPIO_NUM_34,
.miso_io_num = GPIO_NUM_33,
.sclk_io_num = GPIO_NUM_35,
.quadwp_io_num = GPIO_NUM_NC, // Quad SPI LCD driver is not yet supported
.quadhd_io_num = GPIO_NUM_NC, // Quad SPI LCD driver is not yet supported
.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 = TPAGER_SPI_TRANSFER_SIZE_LIMIT,
.flags = 0,
.isr_cpu_id = ESP_INTR_CPU_AFFINITY_AUTO,
.intr_flags = 0
},
.initMode = spi::InitMode::ByTactility,
.isMutable = false,
.lock = tt::lvgl::getSyncLock() // esp_lvgl_port owns the lock for the display
}},
.uart {uart::Configuration {
.name = "Internal",
.port = UART_NUM_1,
.rxPin = GPIO_NUM_4,
.txPin = GPIO_NUM_12,
.rtsPin = GPIO_NUM_NC,
.ctsPin = GPIO_NUM_NC,
.rxBufferSize = 1024,
.txBufferSize = 1024,
.config = {
.baud_rate = 38400,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.rx_flow_ctrl_thresh = 0,
.source_clk = UART_SCLK_DEFAULT,
.flags = {
.allow_pd = 0,
.backup_before_sleep = 0,
}
}
}}
};
@@ -0,0 +1,5 @@
#pragma once
#include <Tactility/hal/Configuration.h>
extern const tt::hal::Configuration lilygo_tlora_pager;
@@ -0,0 +1,33 @@
#include "Display.h"
#include <PwmBacklight.h>
#include <St7796Display.h>
#define TPAGER_LCD_SPI_HOST SPI2_HOST
#define TPAGER_LCD_PIN_CS GPIO_NUM_38
#define TPAGER_LCD_PIN_DC GPIO_NUM_37 // RS
#define TPAGER_LCD_HORIZONTAL_RESOLUTION 222
#define TPAGER_LCD_VERTICAL_RESOLUTION 480
#define TPAGER_LCD_SPI_TRANSFER_HEIGHT (TPAGER_LCD_VERTICAL_RESOLUTION / 10)
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
auto configuration = std::make_unique<St7796Display::Configuration>(
TPAGER_LCD_SPI_HOST,
TPAGER_LCD_PIN_CS,
TPAGER_LCD_PIN_DC,
480, // w
222, // h
nullptr,
true, //swapXY
true, //mirrorX
true, //mirrorY
true, //invertColor
0, //gapX
49 //gapY
);
configuration->backlightDutyFunction = driver::pwmbacklight::setBacklightDuty;
auto display = std::make_shared<St7796Display>(std::move(configuration));
return std::reinterpret_pointer_cast<tt::hal::display::DisplayDevice>(display);
}

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