Firmware SDK
twr_module_battery

Driver for Battery Module. More...

Enumerations

enum  twr_module_battery_format_t {
  TWR_MODULE_BATTERY_FORMAT_UNKNOWN = 0 ,
  TWR_MODULE_BATTERY_FORMAT_STANDARD = 1 ,
  TWR_MODULE_BATTERY_FORMAT_MINI = 2
}
 Battery Module format. More...
 
enum  twr_module_battery_event_t {
  TWR_MODULE_BATTERY_EVENT_LEVEL_LOW = 0 ,
  TWR_MODULE_BATTERY_EVENT_LEVEL_CRITICAL = 1 ,
  TWR_MODULE_BATTERY_EVENT_UPDATE = 2 ,
  TWR_MODULE_BATTERY_EVENT_ERROR = 3
}
 Battery Module event. More...
 

Functions

void twr_module_battery_init (void)
 Initialize Battery Module.
 
void twr_module_battery_set_event_handler (void(*event_handler)(twr_module_battery_event_t, void *), void *event_param)
 Set callback function. More...
 
void twr_module_battery_set_update_interval (twr_tick_t interval)
 Set update interval. More...
 
void twr_module_battery_set_threshold_levels (float level_low_threshold, float level_critical_threshold)
 Set voltage levels. More...
 
twr_module_battery_format_t twr_module_battery_get_format ()
 Get Battery Module format.
 
bool twr_module_battery_measure (void)
 Start mesurement. More...
 
bool twr_module_battery_get_voltage (float *voltage)
 Get Battery Module voltage. More...
 
bool twr_module_battery_get_charge_level (int *percentage)
 Get Battery Module charge in percents. More...
 
bool twr_module_battery_is_present (void)
 Get Battery Module is pressent, can use without twr_module_battery_init.
 

Detailed Description

Driver for Battery Module.

Enumeration Type Documentation

◆ twr_module_battery_event_t

Battery Module event.

Enumerator
TWR_MODULE_BATTERY_EVENT_LEVEL_LOW 

Event low level.

TWR_MODULE_BATTERY_EVENT_LEVEL_CRITICAL 

Event critical level.

TWR_MODULE_BATTERY_EVENT_UPDATE 

Event update.

TWR_MODULE_BATTERY_EVENT_ERROR 

Event error.

Definition at line 27 of file twr_module_battery.h.

◆ twr_module_battery_format_t

Battery Module format.

Enumerator
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.

Definition at line 12 of file twr_module_battery.h.

Function Documentation

◆ twr_module_battery_get_charge_level()

bool twr_module_battery_get_charge_level ( int *  percentage)

Get Battery Module charge in percents.

Parameters
[out]percentageMeasured charge
Returns
true On success
false On failure

Definition at line 131 of file twr_module_battery.c.

Here is the call graph for this function:

◆ twr_module_battery_get_voltage()

bool twr_module_battery_get_voltage ( float *  voltage)

Get Battery Module voltage.

Parameters
[out]voltageMeasured voltage
Returns
true On success
false On failure

Definition at line 124 of file twr_module_battery.c.

Referenced by twr_module_battery_get_charge_level().

Here is the caller graph for this function:

◆ twr_module_battery_measure()

bool twr_module_battery_measure ( void  )

Start mesurement.

Returns
true On success
false On failure

Definition at line 108 of file twr_module_battery.c.

Referenced by twr_module_battery_set_update_interval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ twr_module_battery_set_event_handler()

void twr_module_battery_set_event_handler ( void(*)(twr_module_battery_event_t, void *)  event_handler,
void *  event_param 
)

Set callback function.

Parameters
[in]event_handlerFunction address
[in]event_paramOptional event parameter (can be NULL)

Definition at line 74 of file twr_module_battery.c.

◆ twr_module_battery_set_threshold_levels()

void twr_module_battery_set_threshold_levels ( float  level_low_threshold,
float  level_critical_threshold 
)

Set voltage levels.

Parameters
[in]level_low_thresholdVoltage level considered as low
[in]level_critical_thresholdVoltage level considered as critical

Definition at line 97 of file twr_module_battery.c.

◆ twr_module_battery_set_update_interval()

void twr_module_battery_set_update_interval ( twr_tick_t  interval)

Set update interval.

Parameters
[in]intervalUpdate interval

Definition at line 80 of file twr_module_battery.c.

Here is the call graph for this function: