Defines | |
#define | BATTERY_NORMALV 154 |
Normal battery voltage. (6 V). | |
#define | BATTERY_CHARINGV 179 |
Charging battery voltage. (7 V). | |
#define | BATTERY_LOWV 152 |
Low battery voltage. ( < 6 V). | |
Functions | |
int | battery8 (void) |
Read the battery voltage. | |
int | battery (void) |
Read the battery voltage in deciVolts. | |
char | battery_low (void) |
Check if the battery is low. | |
int | battery8_avg (int n_samples) |
Get an average battery voltage reading. |
Contains functions for checking the current voltage of the battery. Include battery.h to access these functions.
int battery | ( | void | ) |
Read the battery voltage in deciVolts.
Returns the voltage of the battery in deciVolts. analog_init must be called before using this function.
int battery8 | ( | void | ) |
Read the battery voltage.
Returns the voltage of the battery as an analog8 reading. 128 is approximately 5 volts. analog_init must be called before using this function.
References analog8(), and BATT_PORT.
Referenced by battery8_avg(), and battery_low().
int battery8_avg | ( | int | n_samples | ) |
Get an average battery voltage reading.
Averages n_samples battery8 readings. This function may take a while to complete, and is only made available for convenience. analog_init must be called before this function may be used.
n_samples | the number of times to sample the battery voltage |
References battery8().
char battery_low | ( | void | ) |
Check if the battery is low.
Checks if the battery is low. analog_init must be called before this function can be used. This function waits for several low battery readings in a row to avoid false positives.
References battery8(), and BATTERY_LOWV.