Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
97 changes: 97 additions & 0 deletions boards/waveshare-esp32-s3-touch-amoled-206/interface.cpp
Original file line number Diff line number Diff line change
@@ -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 <Wire.h>
#include <XPowersLib.h>
#include <interface.h>

#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<Arduino_CO5300 *>(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();
}
54 changes: 54 additions & 0 deletions boards/waveshare-esp32-s3-touch-amoled-206/platformio.ini
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions support_files/custom_32Mb.csv
Original file line number Diff line number Diff line change
@@ -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,