From c1d520d700693354662256232c96995d17307d80 Mon Sep 17 00:00:00 2001 From: khoanguyen-3fc Date: Thu, 7 May 2026 19:51:58 +0700 Subject: [PATCH] Feat: Add battery support and small fixes for Freenove 2.8 board (#1976) * feat(freenove-esp32s3): add battery level retrieval * fix(freenove-esp32s3): add missing comma in config.json * docs(freenove-esp32s3): note possible shared design with ES3C28P/ES3N28P --- .../freenove-esp32s3-display-2.8-lcd/ReadMe.md | 4 +++- .../freenove-esp32s3-display-2.8-lcd/config.json | 2 +- .../freenove-esp32s3-display-2.8-lcd.cc | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/main/boards/freenove-esp32s3-display-2.8-lcd/ReadMe.md b/main/boards/freenove-esp32s3-display-2.8-lcd/ReadMe.md index 391529c..25cf885 100644 --- a/main/boards/freenove-esp32s3-display-2.8-lcd/ReadMe.md +++ b/main/boards/freenove-esp32s3-display-2.8-lcd/ReadMe.md @@ -2,4 +2,6 @@ [product](https://store.freenove.com/products/fnk0104) -Official github: [freenove-esp32s3-display-2.8-lcd](https://github.com/Freenove/Freenove_ESP32_S3_Display) \ No newline at end of file +Official github: [freenove-esp32s3-display-2.8-lcd](https://github.com/Freenove/Freenove_ESP32_S3_Display) + +Likely the same hardware design as [LCD wiki ES3C28P/ES3N28P](https://www.lcdwiki.com/2.8inch_ESP32-S3_Display) diff --git a/main/boards/freenove-esp32s3-display-2.8-lcd/config.json b/main/boards/freenove-esp32s3-display-2.8-lcd/config.json index 0d60753..d19d612 100644 --- a/main/boards/freenove-esp32s3-display-2.8-lcd/config.json +++ b/main/boards/freenove-esp32s3-display-2.8-lcd/config.json @@ -6,7 +6,7 @@ "sdkconfig_append": [ "CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y", "CONFIG_PARTITION_TABLE_CUSTOM_FILENAME=\"partitions/v2/16m.csv\"", - "CONFIG_LANGUAGE_EN_US=y" + "CONFIG_LANGUAGE_EN_US=y", "CONFIG_SR_WN_WN9S_HIESP=y", "CONFIG_SR_WN_WN9_HIESP=y" ] diff --git a/main/boards/freenove-esp32s3-display-2.8-lcd/freenove-esp32s3-display-2.8-lcd.cc b/main/boards/freenove-esp32s3-display-2.8-lcd/freenove-esp32s3-display-2.8-lcd.cc index beadb89..cbdc42c 100644 --- a/main/boards/freenove-esp32s3-display-2.8-lcd/freenove-esp32s3-display-2.8-lcd.cc +++ b/main/boards/freenove-esp32s3-display-2.8-lcd/freenove-esp32s3-display-2.8-lcd.cc @@ -10,6 +10,7 @@ #include "button.h" #include "config.h" #include "mcp_server.h" +#include "adc_battery_monitor.h" #include #include @@ -65,6 +66,11 @@ private: LcdDisplay *display_; i2c_master_bus_handle_t codec_i2c_bus_; TouchDriver touch_; + AdcBatteryMonitor* adc_battery_monitor_; + + void InitializeBatteryMonitor() { + adc_battery_monitor_ = new AdcBatteryMonitor(ADC_UNIT_1, ADC_CHANNEL_8, 200000, 200000, GPIO_NUM_NC); + } static void TouchTask(void *arg) { auto *self = static_cast(arg); @@ -197,6 +203,7 @@ public: FreenoveESP32S3Display(): boot_button_(BOOT_BUTTON_GPIO) { InitializeI2c(); + InitializeBatteryMonitor(); InitializeSpi(); InitializeLcdDisplay(); InitializeTouch(); @@ -224,6 +231,13 @@ public: static PwmBacklight backlight(DISPLAY_BACKLIGHT_PIN, DISPLAY_BACKLIGHT_OUTPUT_INVERT); return &backlight; } + + virtual bool GetBatteryLevel(int &level, bool& charging, bool& discharging) override { + charging = adc_battery_monitor_->IsCharging(); + discharging = adc_battery_monitor_->IsDischarging(); + level = adc_battery_monitor_->GetBatteryLevel(); + return true; + } }; DECLARE_BOARD(FreenoveESP32S3Display);