Firmware SDK
twr_module_battery.h
1 #ifndef _TWR_MODULE_BATTERY_H
2 #define _TWR_MODULE_BATTERY_H
3 
4 #include <twr_tick.h>
5 
9 
11 
12 typedef enum
13 {
16 
19 
22 
24 
26 
27 typedef enum
28 {
31 
34 
37 
40 
42 
44 
45 void twr_module_battery_init(void);
46 
50 
51 void twr_module_battery_set_event_handler(void (*event_handler)(twr_module_battery_event_t, void *), void *event_param);
52 
55 
57 
61 
62 void twr_module_battery_set_threshold_levels(float level_low_threshold, float level_critical_threshold);
63 
65 
67 
71 
73 
78 
79 bool twr_module_battery_get_voltage(float *voltage);
80 
85 
86 bool twr_module_battery_get_charge_level(int *percentage);
87 
89 
91 
93 
94 #endif // _TWR_MODULE_BATTERY_H
void twr_module_battery_set_event_handler(void(*event_handler)(twr_module_battery_event_t, void *), void *event_param)
Set callback function.
void twr_module_battery_init(void)
Initialize Battery Module.
bool twr_module_battery_is_present(void)
Get Battery Module is pressent, can use without twr_module_battery_init.
twr_module_battery_format_t twr_module_battery_get_format()
Get Battery Module format.
bool twr_module_battery_get_voltage(float *voltage)
Get Battery Module voltage.
twr_module_battery_event_t
Battery Module event.
void twr_module_battery_set_update_interval(twr_tick_t interval)
Set update interval.
twr_module_battery_format_t
Battery Module format.
void twr_module_battery_set_threshold_levels(float level_low_threshold, float level_critical_threshold)
Set voltage levels.
bool twr_module_battery_get_charge_level(int *percentage)
Get Battery Module charge in percents.
bool twr_module_battery_measure(void)
Start mesurement.
@ TWR_MODULE_BATTERY_EVENT_LEVEL_LOW
Event low level.
@ TWR_MODULE_BATTERY_EVENT_ERROR
Event error.
@ TWR_MODULE_BATTERY_EVENT_UPDATE
Event update.
@ TWR_MODULE_BATTERY_EVENT_LEVEL_CRITICAL
Event critical level.
@ TWR_MODULE_BATTERY_FORMAT_UNKNOWN
Format is unknown.
@ TWR_MODULE_BATTERY_FORMAT_STANDARD
Format is standard 4xAAA.
@ TWR_MODULE_BATTERY_FORMAT_MINI
Format is mini 2xAAA.
uint64_t twr_tick_t
Timestamp data type.
Definition: twr_tick.h:16