Revision 442
wrote wrapper functions for new BOM code. also added compiler warning (for deprecated functions) to bom.h. it will show up whenever something that includes bom.h is compiled. have yet to merge new BOM code.
bom.c | ||
---|---|---|
60 | 60 |
//constants |
61 | 61 |
static const char lookup[16] = {7,6,5,0xe,1,4,3,2,0xf,0,0xd,8,0xc,0xb,9,0xa}; |
62 | 62 |
|
63 |
// internal function prototypes |
|
64 |
static void output_high(which); |
|
65 |
static void output_low(which); |
|
63 |
// internal function prototypes |
|
66 | 64 |
static void bom_select(char which); |
67 | 65 |
|
68 | 66 |
/* |
... | ... | |
177 | 175 |
* |
178 | 176 |
* see bom_refresh |
179 | 177 |
**/ |
180 |
int bom_get(char which) {
|
|
178 |
int bom_get(int which) {
|
|
181 | 179 |
return bom_val[which]; |
182 | 180 |
} |
183 | 181 |
|
... | ... | |
189 | 187 |
**/ |
190 | 188 |
int bom_get_max(void) { |
191 | 189 |
int i, lowest_val, lowest_i; |
192 |
|
|
190 |
lowest_i = -1; |
|
193 | 191 |
lowest_val = 255; |
194 | 192 |
for(i = 0; i < NUM_BOM_LEDS; i++) { |
195 | 193 |
printi(bom_val[i]); |
... | ... | |
199 | 197 |
lowest_i = i; |
200 | 198 |
} |
201 | 199 |
} |
202 |
usb_puts("<<< BOM_GET_MAX\n\r");
|
|
200 |
usb_puts("<< BOM_GET_MAX\n\r"); |
|
203 | 201 |
|
204 | 202 |
if(lowest_val < BOM_VALUE_THRESHOLD) |
205 | 203 |
return lowest_i; |
... | ... | |
268 | 266 |
* @see analog_init |
269 | 267 |
**/ |
270 | 268 |
int get_max_bom(void) { |
271 |
int max_bom_temp = 0; |
|
272 |
int a, i, j, h; |
|
273 |
h = 255; |
|
274 |
|
|
275 |
//Turn off the loop so that we can actually use analog8 correctly |
|
276 |
analog_stop_loop(); |
|
277 |
|
|
278 |
//Iterate through through each LED |
|
279 |
for (j = 0; j < 16; j++) |
|
280 |
{ |
|
281 |
i = lookup[j]; |
|
282 |
|
|
283 |
if (i&8) |
|
284 |
output_high(MONK3); |
|
285 |
else |
|
286 |
output_low(MONK3); |
|
287 |
|
|
288 |
if (i&4) |
|
289 |
output_high(MONK2); |
|
290 |
else |
|
291 |
output_low(MONK2); |
|
292 |
|
|
293 |
if (i&2) |
|
294 |
output_high(MONK1); |
|
295 |
else |
|
296 |
output_low(MONK1); |
|
297 |
|
|
298 |
if (i&1) |
|
299 |
output_high(MONK0); |
|
300 |
else |
|
301 |
output_low(MONK0); |
|
302 |
|
|
303 |
a = analog_get8(MONKI); |
|
304 |
printi(a); |
|
305 |
usb_puts(" "); |
|
306 |
|
|
307 |
if (a < h) |
|
308 |
{ |
|
309 |
h = a; |
|
310 |
max_bom_temp = j; |
|
311 |
} |
|
312 |
|
|
313 |
} |
|
314 |
usb_puts("\n\r"); |
|
315 |
//Restart loop now that we are done using analog8 |
|
316 |
analog_start_loop(); |
|
317 |
|
|
318 |
//threshold on the bom analog value. |
|
319 |
//defined in bom.h |
|
320 |
// if the analog value read is above the threshold, we cannot see a robot |
|
321 |
// (remember, low means higher intensity). |
|
322 |
if(h < BOM_VALUE_THRESHOLD) { |
|
323 |
return max_bom_temp; |
|
324 |
} |
|
325 |
else |
|
326 |
return -1; |
|
269 |
bom_refresh(BOM_ALL); |
|
270 |
return bom_get_max(); |
|
327 | 271 |
} |
328 | 272 |
|
329 | 273 |
/** |
... | ... | |
333 | 277 |
**/ |
334 | 278 |
void bom_on(void) |
335 | 279 |
{ |
336 |
output_high(MONKL);
|
|
280 |
bom_leds_on(BOM_ALL);
|
|
337 | 281 |
} |
338 | 282 |
|
339 | 283 |
/** |
... | ... | |
343 | 287 |
**/ |
344 | 288 |
void bom_off(void) |
345 | 289 |
{ |
346 |
output_low(MONKL);
|
|
290 |
bom_leds_off(BOM_ALL);
|
|
347 | 291 |
} |
348 | 292 |
|
349 | 293 |
/** @} **/ //end group |
350 |
|
|
351 |
void output_high(int which) { |
|
352 |
digital_output(which, 1); |
|
353 |
} |
|
354 |
|
|
355 |
void output_low(int which) { |
|
356 |
digital_output(which, 0); |
|
357 |
} |
|
358 | 294 |
static void bom_select(char which) { |
359 | 295 |
if (which&8) |
Also available in: Unified diff