From 033fc23eb69456e38ede3caf61c49b58020c175d Mon Sep 17 00:00:00 2001 From: tobozo Date: Tue, 10 Oct 2023 19:30:22 +0200 Subject: [PATCH] fix bad macros for 3.0.0-alpha --- src/drivers/Odroid-Go/Battery/battery.cpp | 2 +- src/drivers/Odroid-Go/Battery/battery.h | 65 ++++++++++++----------- 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/src/drivers/Odroid-Go/Battery/battery.cpp b/src/drivers/Odroid-Go/Battery/battery.cpp index aa2b3b5..6b837f2 100644 --- a/src/drivers/Odroid-Go/Battery/battery.cpp +++ b/src/drivers/Odroid-Go/Battery/battery.cpp @@ -8,7 +8,7 @@ #include "battery.h" -#if defined ARDUINO_ODROID_ESP32 +#if defined ARDUINO_ODROID_ESP32 && defined HAS_ADC_CAL_SUPPORT #include #include diff --git a/src/drivers/Odroid-Go/Battery/battery.h b/src/drivers/Odroid-Go/Battery/battery.h index ad31399..d51de13 100644 --- a/src/drivers/Odroid-Go/Battery/battery.h +++ b/src/drivers/Odroid-Go/Battery/battery.h @@ -12,36 +12,41 @@ #include #endif -#if defined ESP_ARDUINO_VERSION_VAL - #if ESP_ARDUINO_VERSION > ESP_ARDUINO_VERSION_VAL(2,0,14) - #include - #include - - #define BATTERY_RESISTANCE_NUM 2 - #define BATTERY_SAMPLES 64 - #define BATTERY_VMAX 420 - #define BATTERY_VMIN 330 - #define BATTERY_CUTOFF 325 - - class Battery - { - public: - Battery(void); - - void begin(); - double getVoltage(); - int getPercentage(); - void setProtection(bool enable); - void update(); - - private: - #if defined ESP_ARDUINO_VERSION_VAL - #if ESP_ARDUINO_VERSION < ESP_ARDUINO_VERSION_VAL(3,0,0) - esp_adc_cal_characteristics_t _adc_chars; - #endif - #endif - bool _enable_protection; - }; +#define HAS_ADC_CAL_SUPPORT +#if defined ESP_ARDUINO_VERSION_VAL + #if ESP_ARDUINO_VERSION > ESP_ARDUINO_VERSION_VAL(2,0,14) + #undef HAS_ADC_CAL_SUPPORT #endif #endif + + +#include +#include + +#define BATTERY_RESISTANCE_NUM 2 +#define BATTERY_SAMPLES 64 +#define BATTERY_VMAX 420 +#define BATTERY_VMIN 330 +#define BATTERY_CUTOFF 325 + +class Battery +{ +public: + Battery(void); + + void begin(); + double getVoltage(); + int getPercentage(); + void setProtection(bool enable); + void update(); + +private: + #if defined HAS_ADC_CAL_SUPPORT + esp_adc_cal_characteristics_t _adc_chars; + #endif + bool _enable_protection; +}; + +// #endif +// #endif