Skip to content

Commit

Permalink
fix bad macros for 3.0.0-alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
tobozo committed Oct 10, 2023
1 parent 07b12e2 commit 033fc23
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/drivers/Odroid-Go/Battery/battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "battery.h"

#if defined ARDUINO_ODROID_ESP32
#if defined ARDUINO_ODROID_ESP32 && defined HAS_ADC_CAL_SUPPORT

#include <esp_sleep.h>
#include <math.h>
Expand Down
65 changes: 35 additions & 30 deletions src/drivers/Odroid-Go/Battery/battery.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,41 @@
#include <esp_arduino_version.h>
#endif

#if defined ESP_ARDUINO_VERSION_VAL
#if ESP_ARDUINO_VERSION > ESP_ARDUINO_VERSION_VAL(2,0,14)
#include <driver/adc.h>
#include <esp_adc_cal.h>

#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 <driver/adc.h>
#include <esp_adc_cal.h>

#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

0 comments on commit 033fc23

Please sign in to comment.