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
This commit is contained in:
khoanguyen-3fc
2026-05-07 19:51:58 +07:00
committed by GitHub
parent 1847b58935
commit c1d520d700
3 changed files with 18 additions and 2 deletions

View File

@ -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)
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)

View File

@ -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"
]

View File

@ -10,6 +10,7 @@
#include "button.h"
#include "config.h"
#include "mcp_server.h"
#include "adc_battery_monitor.h"
#include <esp_log.h>
#include <driver/i2c_master.h>
@ -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<FreenoveESP32S3Display*>(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);