Project

General

Profile

Statistics
| Revision:

root / branches / simulator / lib / include / libdragonfly / battery.h @ 943

History | View | Annotate | Download (3.22 KB)

1
/**
2
 * Copyright (c) 2007 Colony Project
3
 * 
4
 * Permission is hereby granted, free of charge, to any person
5
 * obtaining a copy of this software and associated documentation
6
 * files (the "Software"), to deal in the Software without
7
 * restriction, including without limitation the rights to use,
8
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
9
 * copies of the Software, and to permit persons to whom the
10
 * Software is furnished to do so, subject to the following
11
 * conditions:
12
 * 
13
 * The above copyright notice and this permission notice shall be
14
 * included in all copies or substantial portions of the Software.
15
 * 
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23
 * OTHER DEALINGS IN THE SOFTWARE.
24
 **/
25

    
26

    
27
/**
28
 * @file battery.h
29
 * @brief Definitions for checking battery voltage.
30
 * 
31
 * Contains definitions for checking the voltage of the 
32
 * battery.
33
 *
34
 * @author Colony Project, CMU Robotics Club
35
 **/
36

    
37
#ifndef _BATTERY_H_
38
#define _BATTERY_H_
39

    
40
/**
41
 * @defgroup battery Battery
42
 * @brief Functions for reading battery voltage.
43
 * 
44
 * Contains functions for checking the current
45
 * voltage of the battery. Include battery.h to
46
 * access these functions.
47
 *
48
 * @{
49
 **/
50

    
51
/** @brief Normal battery voltage. (6 V) **/
52
#define BATTERY_NORMALV 154
53
/** @brief Charging battery voltage. (7 V) **/
54
#define BATTERY_CHARINGV 179
55
/** @brief Low battery voltage. ( < 6 V) **/
56
#define BATTERY_LOWV 152
57

    
58
/**
59
 * @brief Read the battery voltage.
60
 *
61
 * Returns the voltage of the battery as an analog8
62
 * reading. 128 is approximately 5 volts. analog_init
63
 * must be called before using this function.
64
 *
65
 * @return the voltage of the battery as an analog8
66
 * reading
67
 *
68
 * @see analog_init, battery, analog8
69
 **/
70
int battery8(void);
71

    
72
/**
73
 * @brief Read the battery voltage in deciVolts.
74
 *
75
 * Returns the voltage of the battery in deciVolts.
76
 * analog_init must be called before using this function.
77
 *
78
 * @return the voltage of the battery in deciVolts.
79
 *
80
 * @see analog_init, battery8
81
 **/
82
int battery(void);
83

    
84
/**
85
 * @brief Check if the battery is low.
86
 *
87
 * Checks if the battery is low. analog_init must be called before
88
 * this function can be used. This function waits for several low
89
 * battery readings in a row to avoid false positives.
90
 *
91
 * @return 1 if the battery is low, 0 otherwise
92
 *
93
 * @see analog_init
94
 **/
95
char battery_low(void);
96

    
97
/**
98
 * @brief Get an average battery voltage reading.
99
 *
100
 * Averages n_samples battery8 readings. This function may
101
 * take a while to complete, and is only made available
102
 * for convenience. analog_init must be called before this
103
 * function may be used.
104
 *
105
 * @param n_samples the number of times to sample the battery voltage
106
 *
107
 * @return the average reading for the battery voltage, where 128
108
 * is approximately 5 Volts.
109
 *
110
 * @see analog_init, battery
111
 **/
112
int battery8_avg(int n_samples);
113

    
114
/** @} **/ //end addtogroup
115

    
116
#endif
117