Revision 820
updated recharging code for the dragonfly. added doxygen comments. should be merged to trunk soon.
branches/autonomous_recharging/code/projects/autonomous_recharging/dragonfly/recharge_i2c.c | ||
---|---|---|
1 |
/** |
|
2 |
* @file recharge_i2c.c |
|
3 |
* @brief Handles I2C data |
|
4 |
* |
|
5 |
* Handles I2C data received from charge board and updates battery status |
|
6 |
* |
|
7 |
* @author Colony Project, CMU Robotics Club |
|
8 |
**/ |
|
9 |
|
|
1 | 10 |
#include "recharge_i2c.h" |
2 | 11 |
|
3 | 12 |
#include "recharge_defs.h" |
... | ... | |
39 | 48 |
return (int)recharge_i2c_homing_sensor_data; |
40 | 49 |
} |
41 | 50 |
|
51 |
/** |
|
52 |
* Check if battery is fully charged. |
|
53 |
* |
|
54 |
* @return 1 is battery is full, 0 if not |
|
55 |
**/ |
|
42 | 56 |
int recharge_i2c_is_battery_full() |
43 | 57 |
{ |
44 | 58 |
return recharge_i2c_battery_full; |
45 | 59 |
} |
46 | 60 |
|
61 |
/** |
|
62 |
* Set battery status. |
|
63 |
* |
|
64 |
* @param 1 is battery is full, 0 if not |
|
65 |
**/ |
|
47 | 66 |
void recharge_i2c_set_battery_full(int full) |
48 | 67 |
{ |
49 |
if (!full) |
|
50 |
recharge_i2c_battery_charging = 0; |
|
51 | 68 |
recharge_i2c_battery_full = full; |
52 | 69 |
} |
53 | 70 |
|
71 |
/** |
|
72 |
* Check if battery is charging. |
|
73 |
* |
|
74 |
* @return 1 is battery is charging, 0 if not |
|
75 |
**/ |
|
54 | 76 |
int recharge_i2c_is_battery_charging() |
55 | 77 |
{ |
56 | 78 |
return recharge_i2c_battery_charging; |
... | ... | |
63 | 85 |
**/ |
64 | 86 |
void recharge_i2c_receive(char i2c_byte) |
65 | 87 |
{ |
66 |
usb_putc(i2c_byte); |
|
67 | 88 |
if(recharge_i2c_prev_byte == I2C_MSG_HOMING_DATA) |
68 | 89 |
{ |
69 | 90 |
recharge_i2c_homing_sensor_data = i2c_byte; |
70 | 91 |
recharge_i2c_prev_byte = i2c_byte; |
71 |
//usb_puti(i2c_byte); |
|
72 | 92 |
return; |
73 | 93 |
} |
74 | 94 |
|
branches/autonomous_recharging/code/projects/autonomous_recharging/dragonfly/departing.c | ||
---|---|---|
1 |
/** |
|
2 |
* @file departing.c |
|
3 |
* @brief Departing charging station |
|
4 |
* |
|
5 |
* Contains functions for robots departing charging station when charging |
|
6 |
* is complete. |
|
7 |
* |
|
8 |
* @author Colony Project, CMU Robotics Club |
|
9 |
**/ |
|
10 |
|
|
1 | 11 |
#include "departing.h" |
2 | 12 |
|
3 | 13 |
#include <rangefinder.h> |
branches/autonomous_recharging/code/projects/autonomous_recharging/dragonfly/recharge.c | ||
---|---|---|
1 |
/** |
|
2 |
* @file recharge.c |
|
3 |
* @brief Robot recharging code |
|
4 |
* |
|
5 |
* Contains functions for autonomous recharging. |
|
6 |
* |
|
7 |
* @author Colony Project, CMU Robotics Club |
|
8 |
**/ |
|
9 |
|
|
1 | 10 |
#include <move.h> |
2 | 11 |
#include <battery.h> |
3 | 12 |
#include <dio.h> |
branches/autonomous_recharging/code/projects/autonomous_recharging/dragonfly/homing.c | ||
---|---|---|
1 |
/** |
|
2 |
* @file homing.c |
|
3 |
* @brief Interpret homing beacon data |
|
4 |
* |
|
5 |
* Contains functions for translating homing data into directions. |
|
6 |
* |
|
7 |
* @author Colony Project, CMU Robotics Club |
|
8 |
**/ |
|
9 |
|
|
1 | 10 |
#include "homing.h" |
2 | 11 |
#include "recharge_defs.h" |
3 | 12 |
|
... | ... | |
15 | 24 |
* translates homing sensor data into the |
16 | 25 |
* direction the robot needs to turn |
17 | 26 |
* (or if it needs to use the BOM). |
27 |
* |
|
28 |
* @return returns direction flag |
|
18 | 29 |
**/ |
19 | 30 |
int homing_direction(int beaconcount) |
20 | 31 |
{ |
branches/autonomous_recharging/code/projects/autonomous_recharging/dragonfly/recharge_i2c.h | ||
---|---|---|
1 |
|
|
2 |
|
|
1 |
/** |
|
2 |
* @file recharge_i2c.h Recharge_I2C |
|
3 |
* |
|
4 |
* Functions for receiving and using i2c data from charge board. |
|
5 |
**/ |
|
6 |
|
|
3 | 7 |
void recharge_i2c_init(void); |
4 | 8 |
|
9 |
/** @brief Seek the charging station **/ |
|
5 | 10 |
int recharge_i2c_get_homing_reading(void); |
6 | 11 |
int recharge_i2c_is_battery_full(void); |
7 | 12 |
int recharge_i2c_is_battery_charging(void); |
8 | 13 |
|
9 | 14 |
void recharge_i2c_set_battery_full(int full); |
10 |
|
|
15 |
void recharge_i2c_receive(char i2c_byte); |
branches/autonomous_recharging/code/projects/autonomous_recharging/dragonfly/main.c | ||
---|---|---|
3 | 3 |
#include <wl_token_ring.h> |
4 | 4 |
#include <rangefinder.h> |
5 | 5 |
#include "smart_run_around_fsm.h" |
6 |
|
|
7 | 6 |
#include "recharge.h" |
8 | 7 |
|
9 | 8 |
void do_nothing2(void) {} |
... | ... | |
12 | 11 |
int main(void) |
13 | 12 |
{ |
14 | 13 |
dragonfly_init(ALL_ON); |
15 |
//range_init(); |
|
16 |
//orb_enable(); |
|
17 | 14 |
usb_puts("Turned on!\n"); |
18 | 15 |
wl_init(); |
19 | 16 |
usb_puts("Wireless initialized!\n"); |
branches/autonomous_recharging/code/projects/autonomous_recharging/dragonfly/seeking.c | ||
---|---|---|
1 |
/** |
|
2 |
* @file seeking.c |
|
3 |
* @brief Controls seeking movement |
|
4 |
* |
|
5 |
* Contains functions for navigating to a charging station using the BOM |
|
6 |
* and/or homing sensor. |
|
7 |
* |
|
8 |
* @author Colony Project, CMU Robotics Club |
|
9 |
**/ |
|
10 |
|
|
1 | 11 |
#include "seeking.h" |
2 | 12 |
|
3 | 13 |
#include <move.h> |
branches/autonomous_recharging/code/projects/autonomous_recharging/dragonfly/recharge_defs.h | ||
---|---|---|
1 |
/** |
|
2 |
* @file recharge_defs.h Recharge_Defs |
|
3 |
* |
|
4 |
* Definitions used for recharging. |
|
5 |
**/ |
|
6 |
|
|
1 | 7 |
// Recharging group |
2 | 8 |
#define WL_RECHARGE_GROUP 3 |
3 | 9 |
|
branches/autonomous_recharging/code/projects/autonomous_recharging/dragonfly/homing.h | ||
---|---|---|
20 | 20 |
#define HOMING_LEFT 2 |
21 | 21 |
#define HOMING_RIGHT 3 |
22 | 22 |
|
23 |
/** @brief Seek the charging station **/
|
|
23 |
/** @brief Find direction to station **/
|
|
24 | 24 |
int homing_direction(int beacon_count); |
25 | 25 |
|
26 | 26 |
/** @} **/ |
Also available in: Unified diff