Project

General

Profile

Revision 116

Updated recharging code for the robot, it actually runs, trying to fix problem with orbs in debugging mode.

View differences:

recharge.c
1 1
#include <move.h>
2 2
#include <battery.h>
3 3
#include <dio.h>
4
#include <lights.h>
4 5

  
5 6
#include <wl_defs.h>
6 7
#include "wl_recharge_group.h"
7 8
#include "seeking.h"
8 9
#include "departing.h"
10
#include "recharge_i2c.h"
11
#include "recharge_defs.h"
9 12

  
10 13
// Function prototypes
11 14
void recharge_check_low_battery(void);
......
13 16
void recharge_seek(void);
14 17
void recharge_depart(void);
15 18

  
19
//Global variables
20
#ifdef RECHARGE_DEBUG
21
int old_state = -1;
22
#endif
23

  
16 24
/**
17 25
 * Initializes recharging. Before this function may be called,
18 26
 * wl_init must be called.
......
75 83

  
76 84
	// show colors if we are debugging
77 85
	#ifdef RECHARGE_DEBUG
78
	switch (wl_recharge_get_state())
86
	if (old_state != wl_recharge_get_state())
79 87
	{
80
		
88
		old_state = wl_recharge_get_state();
89
		RECHARGE_DEBUG_PUTI(old_state);
90
		switch (wl_recharge_get_state())
91
		{
92
			case NOT_RECHARGING:
93
				orb_set_color(GREEN);
94
				break;
95
			case POLLING:
96
			case REQUESTING:
97
				orb_set_color(RED);
98
				//we shouldn't be in this state
99
				break;
100
			case SEEKING:
101
				orb_set_color(YELLOW);
102
				break;
103
			case DOCKED:
104
				orb_set_color(BLUE);
105
				break;
106
			case DEPARTING:
107
				orb_set_color(PURPLE);
108
				break;
109
			default:
110
				WL_DEBUG_PRINT("Unexpected state.\n");
111
				break;
112
		}
81 113
	}
82 114
	#endif
83 115
	

Also available in: Unified diff