Revision 210
Somewhat working version of recharging.
branches/autonomous_recharging/code/projects/autonomous_recharging/dragonfly/wl_recharge_group.c | ||
---|---|---|
104 | 104 |
void wl_recharge_stop() |
105 | 105 |
{ |
106 | 106 |
recharge_state = NOT_RECHARGING; |
107 |
station = -1; |
|
107 | 108 |
} |
108 | 109 |
|
109 | 110 |
/** |
... | ... | |
347 | 348 |
case WL_RECHARGE_DOCKED: |
348 | 349 |
wl_recharge_docked(source); |
349 | 350 |
break; |
351 |
//TODO: remove this, only for demo purposes |
|
352 |
case 9: |
|
353 |
if (recharge_state == NOT_RECHARGING) |
|
354 |
wl_recharge_begin(); |
|
355 |
break; |
|
350 | 356 |
default: |
351 | 357 |
RECHARGE_DEBUG_PRINT("Error packet of unknown type received.\n"); |
352 | 358 |
break; |
branches/autonomous_recharging/code/projects/autonomous_recharging/dragonfly/recharge.c | ||
---|---|---|
134 | 134 |
//if (battery_low() || button2_click()) |
135 | 135 |
if (button2_click()) |
136 | 136 |
{ |
137 |
recharge_i2c_set_battery_full(0); |
|
137 | 138 |
wl_recharge_begin(); |
138 | 139 |
move(0, 0); |
139 | 140 |
} |
... | ... | |
164 | 165 |
**/ |
165 | 166 |
void recharge_check_charging_complete() |
166 | 167 |
{ |
167 |
//if (recharge_i2c_is_battery_full() || button2_click()) |
|
168 |
if (button2_click()) |
|
168 |
if (recharge_i2c_is_battery_full() || button2_click()) |
|
169 | 169 |
{ |
170 | 170 |
wl_recharge_depart(); |
171 | 171 |
} |
branches/autonomous_recharging/code/projects/autonomous_recharging/dragonfly/homing.c | ||
---|---|---|
3 | 3 |
|
4 | 4 |
// values for homing sensor readings |
5 | 5 |
#define LEFT_LOW 6 |
6 |
#define LEFT_HIGH 7
|
|
7 |
#define CENTER_LOW 18
|
|
6 |
#define LEFT_HIGH 8
|
|
7 |
#define CENTER_LOW 17
|
|
8 | 8 |
#define CENTER_HIGH 19 |
9 |
#define RIGHT_LOW 12
|
|
9 |
#define RIGHT_LOW 11
|
|
10 | 10 |
#define RIGHT_HIGH 13 |
11 | 11 |
|
12 | 12 |
/** |
branches/autonomous_recharging/code/projects/autonomous_recharging/dragonfly/recharge_i2c.h | ||
---|---|---|
6 | 6 |
int recharge_i2c_is_battery_full(void); |
7 | 7 |
int recharge_i2c_is_battery_charging(void); |
8 | 8 |
|
9 |
void recharge_i2c_set_battery_full(int full); |
|
10 |
|
branches/autonomous_recharging/code/projects/autonomous_recharging/dragonfly/main.c | ||
---|---|---|
12 | 12 |
range_init(); |
13 | 13 |
orb_enable(); |
14 | 14 |
wl_init(); |
15 |
wl_set_channel(0xA); |
|
15 | 16 |
//orb_set_color(YELLOW); |
16 | 17 |
wl_token_ring_register(); |
17 | 18 |
wl_token_ring_join(); |
branches/autonomous_recharging/code/projects/autonomous_recharging/dragonfly/seeking.c | ||
---|---|---|
13 | 13 |
#define SEEK_WITH_HOMING 2 |
14 | 14 |
|
15 | 15 |
#define SEEKING_BOM_VELOCITY -170 |
16 |
#define SEEKING_HOMING_VELOCITY -180 |
|
16 |
#define SEEKING_HOMING_VELOCITY -170 |
|
17 |
#define SEEKING_HOMING_FORWARD_VELOCITY -180 |
|
17 | 18 |
|
18 | 19 |
//function prototypes |
19 | 20 |
int seek_station_with_bom(int station); |
... | ... | |
69 | 70 |
int seek_station_with_homing_sensor(void) |
70 | 71 |
{ |
71 | 72 |
int widthcount = recharge_i2c_get_homing_reading(); |
72 |
int direction = homing_direction(widthcount);
|
|
73 |
|
|
74 |
switch(direction)
|
|
75 |
{
|
|
76 |
case HOMING_NONE:
|
|
77 |
return SEEK_WITH_BOM;
|
|
78 |
break;
|
|
79 |
case HOMING_FORWARD:
|
|
80 |
move(SEEKING_HOMING_VELOCITY, 0);
|
|
81 |
break;
|
|
82 |
case HOMING_LEFT:
|
|
83 |
move(SEEKING_HOMING_VELOCITY, 3);
|
|
84 |
break;
|
|
85 |
case HOMING_RIGHT:
|
|
86 |
move(SEEKING_HOMING_VELOCITY, -3);
|
|
87 |
break;
|
|
88 |
}
|
|
89 |
|
|
73 |
int direction = homing_direction(widthcount);
|
|
74 |
|
|
75 |
switch(direction)
|
|
76 |
{
|
|
77 |
case HOMING_NONE:
|
|
78 |
return SEEK_WITH_BOM;
|
|
79 |
break;
|
|
80 |
case HOMING_FORWARD:
|
|
81 |
move(SEEKING_HOMING_FORWARD_VELOCITY, 0);
|
|
82 |
break;
|
|
83 |
case HOMING_LEFT:
|
|
84 |
move(SEEKING_HOMING_VELOCITY, 3);
|
|
85 |
break;
|
|
86 |
case HOMING_RIGHT:
|
|
87 |
move(SEEKING_HOMING_VELOCITY, -3);
|
|
88 |
break;
|
|
89 |
}
|
|
90 |
|
|
90 | 91 |
return SEEK_WITH_HOMING; |
91 | 92 |
} |
92 | 93 |
|
branches/autonomous_recharging/code/projects/autonomous_recharging/dragonfly/recharge_i2c.c | ||
---|---|---|
44 | 44 |
return recharge_i2c_battery_full; |
45 | 45 |
} |
46 | 46 |
|
47 |
void recharge_i2c_set_battery_full(int full) |
|
48 |
{ |
|
49 |
if (!full) |
|
50 |
recharge_i2c_battery_charging = 0; |
|
51 |
recharge_i2c_battery_full = full; |
|
52 |
} |
|
53 |
|
|
47 | 54 |
int recharge_i2c_is_battery_charging() |
48 | 55 |
{ |
49 | 56 |
return recharge_i2c_battery_charging; |
Also available in: Unified diff