30 lines
727 B
C
30 lines
727 B
C
#ifndef BATTERY_H
|
|
#define BATTERY_H
|
|
|
|
#include "nvs_flash.h"
|
|
#include "esp_adc/adc_oneshot.h"
|
|
#include "esp_adc/adc_cali.h"
|
|
|
|
struct battery_data {
|
|
uint8_t battery_percent;
|
|
uint16_t min_mv; // 0% in mV
|
|
uint16_t scale; // scaling between mV reading and percent
|
|
};
|
|
typedef struct battery_data battery_data_t;
|
|
|
|
struct battery_conf {
|
|
battery_data_t* data;
|
|
adc_channel_t adc_channel;
|
|
adc_oneshot_unit_handle_t adc_handle;
|
|
adc_cali_handle_t cali_handle;
|
|
uint16_t poll_delay;
|
|
uint8_t read_retry_nb;
|
|
};
|
|
typedef struct battery_conf battery_conf_t;
|
|
|
|
battery_conf_t* get_battery_configuration(nvs_handle_t nvs);
|
|
|
|
void init_battery_level_adc(battery_conf_t* batt_conf);
|
|
void update_battery_level(battery_conf_t* batt_conf);
|
|
|
|
#endif |