Battery

Functions for reading battery voltage. More...


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.


Detailed Description

Functions for reading battery voltage.

Contains functions for checking the current voltage of the battery. Include battery.h to access these functions.


Function Documentation

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.

Returns:
the voltage of the battery in deciVolts.
See also:
analog_init, battery8

References analog8(), and BATT_PORT.

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.

Returns:
the voltage of the battery as an analog8 reading
See also:
analog_init, battery, analog8

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.

Parameters:
n_samples the number of times to sample the battery voltage
Returns:
the average reading for the battery voltage, where 128 is approximately 5 Volts.
See also:
analog_init, battery

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.

Returns:
1 if the battery is low, 0 otherwise
See also:
analog_init

References battery8(), and BATTERY_LOWV.


Generated on Mon Sep 7 19:07:28 2009 for libdragonfly by  doxygen 1.5.9