diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f4afb1ea..cc1b18ef 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -132,6 +132,7 @@ - { env: "waveshare-esp32-c5-lcd-147" } - { env: "waveshare-esp32-c6-lcd-147" } - { env: "waveshare-esp32-c6-lcd-130" } + - { env: "waveshare-esp32-s3-touch-amoled-206"} - { env: "ES3C28P" } - { env: "xteink-x3-x4" } - { env: "xteink-x4pro" } diff --git a/boards/waveshare-esp32-s3-touch-amoled-206/interface.cpp b/boards/waveshare-esp32-s3-touch-amoled-206/interface.cpp new file mode 100644 index 00000000..bf9bd679 --- /dev/null +++ b/boards/waveshare-esp32-s3-touch-amoled-206/interface.cpp @@ -0,0 +1,97 @@ +#include "display/Arduino_CO5300.h" +#include "hal/device.h" +#include "hal/inputs/buttons.h" +#include "hal/inputs/touch.h" + +#include "idf/launcher_platform.h" +#include "powerSave.h" +#include +#include +#include + +#define BOARD_I2C_SDA 15 +#define BOARD_I2C_SCL 14 +#define BOARD_TOUCH_INT 38 +#define BOARD_TOUCH_RST 9 +#define BOARD_TOUCH_ADDRESS 0x38 +#define BTN1 0 +#define BTN2 10 + +XPowersAXP2101 axp2101; + +static bool touch_OK = false; + +static DeviceTouch touchCfg() { + DeviceTouch cfg; + cfg.pin_rst = BOARD_TOUCH_RST; + cfg.pin_irq = BOARD_TOUCH_INT; + return cfg; +} + +void _setup_gpio() { + Wire.begin(BOARD_I2C_SDA, BOARD_I2C_SCL); + axp2101.init(Wire, BOARD_I2C_SDA, BOARD_I2C_SCL); + + axp2101.clearIrqStatus(); + + axp2101.enableVbusVoltageMeasure(); + axp2101.enableBattVoltageMeasure(); + axp2101.enableSystemVoltageMeasure(); + axp2101.enableTemperatureMeasure(); + + // It is necessary to disable the detection function of the TS pin on the board + // without the battery temperature detection function, otherwise it will cause abnormal charging + axp2101.disableTSPinMeasure(); + + // Disable all interrupts + axp2101.disableIRQ(XPOWERS_AXP2101_ALL_IRQ); + // Clear all interrupt flags + axp2101.clearIrqStatus(); + // Enable the required interrupt function + axp2101.enableIRQ( + XPOWERS_AXP2101_BAT_INSERT_IRQ | XPOWERS_AXP2101_BAT_REMOVE_IRQ | // BATTERY + XPOWERS_AXP2101_VBUS_INSERT_IRQ | XPOWERS_AXP2101_VBUS_REMOVE_IRQ | // VBUS + XPOWERS_AXP2101_PKEY_SHORT_IRQ | XPOWERS_AXP2101_PKEY_LONG_IRQ | // POWER KEY + XPOWERS_AXP2101_BAT_CHG_DONE_IRQ | XPOWERS_AXP2101_BAT_CHG_START_IRQ // CHARGE + // XPOWERS_AXP2101_PKEY_NEGATIVE_IRQ | XPOWERS_AXP2101_PKEY_POSITIVE_IRQ | //POWER KEY + ); + + hal_buttons_init_2(DeviceButtons{BTN1, BTN2}, 600); + + touch_OK = hal_touch_init(touchCfg(), BOARD_TOUCH_ADDRESS); +} + +int getBattery() { + int percent = axp2101.getBatteryPercent(); + return percent; +} + +void _setBrightness(uint8_t brightval) { + auto *panel = static_cast(tft->outputDriver()); + if (panel) panel->setBrightness((brightval * 255) / 100); +} + + +void InputHandler(void) { + if (touch_OK) { + static unsigned long tm = 0; + LTouchPoint t; + bool touched = hal_touch_read(touchCfg(), t); + vTaskDelay(pdMS_TO_TICKS(50)); + if ((launcherMillis() - tm) > 200 || LongPress) { // one reading each 500ms + if (touched) { + tm = launcherMillis(); + if (!hal_touch_apply(t)) return; + } + } + } + + hal_buttons_poll_2(); + return; +} + +void powerOff() { axp2101.shutdown(); } + +void reboot() { + ESP.restart(); +} diff --git a/boards/waveshare-esp32-s3-touch-amoled-206/platformio.ini b/boards/waveshare-esp32-s3-touch-amoled-206/platformio.ini new file mode 100644 index 00000000..9460795b --- /dev/null +++ b/boards/waveshare-esp32-s3-touch-amoled-206/platformio.ini @@ -0,0 +1,54 @@ +[env:waveshare-esp32-s3-touch-amoled-206] +board = esp32s3 +board_build.partitions = support_files/custom_32Mb.csv + +board_build.arduino.memory_type = qio_qspi +board_upload.flash_size = 32MB +board_upload.maximum_size = 33554432 + +build_src_filter =${env.build_src_filter} +<../boards/waveshare-esp32-s3-touch-amoled-206> +build_flags = + ${env.build_flags} + -DBOARD_HAS_PSRAM + -DARDUINO_USB_MODE=1 + -DARDUINO_USB_CDC_ON_BOOT=1 + + -D DEVICE_NAME='"Waveshare ESP32-S3 Touch AMOLED 2.06"' + -D OTA_TAG='"waveshare_amoled_206"' + -D OTA_EXTRA='"esp=S3"' + -D LAUNCHER_DEFAULT_SPIFFS_THRESHOLD=0x500000 + + -D ROTATION=0 + -D DIMMER_SETUP=20 + -D HAS_2_BUTTONS=1 + -D BUTTONS_IDF_COMPONENT=1 + -D HAS_TOUCH=1 + -D TOUCH_CTRL_FT6X36=1 + + -D ROUND_EDGE_SIZE=57 # to use when the rounded edges hide text or icons on screen + -D TFT_DATABUS_N=1 # Arduino_ESP32QSPI + -D TFT_DISPLAY_DRIVER_N=41 # CO5300 + -D TFT_WIDTH=502 + -D TFT_HEIGHT=410 + -D TFT_CS=12 + -D TFT_RST=8 + -D TFT_SCLK=11 + -D TFT_D0=4 + -D TFT_D1=5 + -D TFT_D2=6 + -D TFT_D3=7 + -D TFT_IPS=0 + -D TFT_COL_OFS1=0 + -D TFT_ROW_OFS1=22 + -D TFT_COL_OFS2=0 + -D TFT_ROW_OFS2=22 + + -D SDCARD_CS=17 + -D SDCARD_SCK=2 + -D SDCARD_MISO=3 + -D SDCARD_MOSI=1 + + +lib_deps = + ${env.lib_deps} + https://github.com/bmorcelli/ESP32_Button diff --git a/platformio.ini b/platformio.ini index 92551945..decaa5b4 100644 --- a/platformio.ini +++ b/platformio.ini @@ -94,6 +94,7 @@ default_envs = ; waveshare-esp32-c5-lcd-147 ; waveshare-esp32-c6-lcd-147 ; waveshare-esp32-c6-lcd-130 + ; waveshare-esp32-s3-touch-amoled-206 ; xteink-x3-x4 ; xteink-x4pro ; xueersi-xiaomiao diff --git a/support_files/custom_32Mb.csv b/support_files/custom_32Mb.csv new file mode 100644 index 00000000..fb8238eb --- /dev/null +++ b/support_files/custom_32Mb.csv @@ -0,0 +1,5 @@ +# Name, Type, SubType, Offset, Size, Flags +nvs, data, nvs, 0x9000, 0x5000, +otadata, data, ota, 0xE000, 0x2000, +app0, app, test, 0x10000, 0x210000, +coredump, data, coredump, 0x220000, 0x10000,