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:
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user