Project

General

Profile

Revision 1349

Added by Chris Mar about 15 years ago

re-wrote joystick remote control code to use packets instead of single bytes over wireless. still needs to be cleaned up. TODO: figure out why robots stops responding to commands.

View differences:

joystick.c
32 32
int joystick_status (void);
33 33
int joystick_change (int old, int new);
34 34

  
35
PacketGroupHandler cntlHandler = {4, NULL, NULL, NULL, NULL};
36

  
35 37
int main (void) {
36 38
  dragonfly_init(SERIAL | USB | COMM | ORB | ANALOG);
37 39
	ADCSRA = _BV(ADEN) | _BV(ADPS2) | _BV(ADPS1) | _BV(ADPS0);
38
	xbee_init();
40
  //xbee_init();
41
  wl_init();
42
  wl_register_packet_group(&cntlHandler);
39 43

  
40 44
  orb_set_color(BLUE);
41 45
  
......
48 52
    cur_status = joystick_status();
49 53
    change = joystick_change(last_status, cur_status);
50 54
    
51
    char buf[100];
55
/*    char buf[100];
52 56
    sprintf(buf, "status: %d\n", cur_status);
53 57
    usb_puts(buf);
54
    
58
*/ 
55 59
    if (change & MOVED_UP) {
56 60
      orb_set_color(GREEN);
57
      xbee_putc('f');
61
      //xbee_putc('f');
62
      wl_send_global_packet(4, 'f', NULL, 0, 0);
63
      usb_putc('f');
58 64
    }
59 65
    if (change & MOVED_Y_CENTER) {
60 66
      orb_set_color(RED);
61
      xbee_putc('s');
67
      //xbee_putc('s');
68
      wl_send_global_packet(4, 's', NULL, 0, 0);
69
      usb_putc('s');
62 70
    }
63 71
    if (change & MOVED_DOWN) {
64 72
      orb_set_color(BLUE);
65
      xbee_putc('b');
73
      //xbee_putc('b');
74
      wl_send_global_packet(4, 'b', NULL, 0, 0);
75
      usb_putc('b');
66 76
    }
67 77
    if (change & MOVED_LEFT) {
68 78
      orb_set_color(ORANGE);
69
      xbee_putc('l');
79
      //xbee_putc('l');
80
      wl_send_global_packet(4, 'l', NULL, 0, 0);
81
      usb_putc('l');
70 82
    }
71 83
    if (change & MOVED_X_CENTER) {
72 84
      orb_set_color(RED);
73
      xbee_putc('s');
85
      //xbee_putc('s');
86
      wl_send_global_packet(4, 's', NULL, 0, 0);
87
      usb_putc('s');
74 88
    }
75 89
    if (change & MOVED_RIGHT) {
76 90
      orb_set_color(YELLOW);
77
      xbee_putc('r');
91
      //xbee_putc('r');
92
      wl_send_global_packet(4, 'r', NULL, 0, 0);
93
      usb_putc('r');
78 94
    }
79 95
    if (change & TRIGGER_PRESSED) {
80 96
      orb_set_color(PURPLE);
81
      xbee_putc('t');
97
      //xbee_putc('t');
98
      wl_send_global_packet(4, 't', NULL, 0, 0);
82 99
    }
83 100
    if (change & BUTTON_PRESSED) {
84 101
      orb_set_color(YELLOW);
85
      xbee_putc('u');
102
      //xbee_putc('u');
103
      wl_send_global_packet(4, 's', NULL, 0, 0);
86 104
    }
87 105
    delay_ms(100);
88 106
  }
......
162 180

  
163 181
  return trigger_status | button_status | x_status | y_status;
164 182
}
183

  

Also available in: Unified diff