Project

General

Profile

Statistics
| Revision:

root / branches / charging_station / code / projects / recharging / charging_station / main.c @ 85

History | View | Annotate | Download (1.22 KB)

1

    
2
#include "firefly+_lib.h"
3

    
4
#include <wireless.h>
5
#include <wl_token_ring.h>
6

    
7
#include "bays.h"
8

    
9
int main(void) {
10
    
11
  //lcd, orb, all that good stuff
12
        
13
    analog_init();
14
    led_init();
15
    orb_init();
16
    buzzer_init();
17
        
18
    usb_init(BAUD115200);
19
    xbee_init(BAUD9600);
20
  
21
    usb_puts("Beginning.\n");
22
    wl_init();
23
    usb_puts("Done initializing.\n");
24
    wl_token_ring_register();
25
    wl_token_ring_join();
26
    bays_init();
27
        
28
    orb_set_color(GREEN);
29
    
30
        lbom_off();
31
    
32
        while(1)
33
        {
34
                //this needs to happen continuously -- it handles the packet
35
                wl_do();
36
                do_consistency_checks();
37
                
38
                if(button1_click())
39
                {
40
                        print_bays_debug();
41
                }
42
        if(button2_click())
43
                {
44
                        if(bayStates[1] == 255)
45
      {
46
        bayStates[1] = 50;
47
        usb_puts("\n**filled bay 1 with bogus robot (50)**\n");
48
        print_bays_debug();
49
        orb_set_color(RED);
50
      }
51
      else if(bayStates[1] == 50)
52
      {
53
        bayStates[1] = 255;
54
               usb_puts("\n**freed bogus robot (50) from bay 1 bay 1**\n");
55
        print_bays_debug();
56
        orb_set_color(BLUE);
57
      }
58
      else
59
      {
60
        usb_puts("\n**bay 1 already in use by legitimate robot**\n");
61
        print_bays_debug();
62
        orb_set_color(GREEN);
63
      }
64
                }
65
        }
66
  return 0;
67
}