Project

General

Profile

Revision 0c80370b

ID0c80370b0079003faff138131a7f8eca80a9f6e2
Parent 6b9a71b0
Child e6c4b5e0

Added by Matthew Sebek about 10 years ago

Added struct filter_state, so we can filter multiple signals

View differences:

arduino/RadioBuggyMega/RadioBuggyMega.ino
32 32
static char data; // used to pass things into xbee
33 33
static unsigned long last_time;
34 34

  
35
// Initialize filter for 
36
struct filter_state ail_state;
37
struct filter_state thr_state;
35 38

  
36 39
#define LED_DANGER_PIN 12
37 40

  
......
45 48
 digitalWrite(LED_DANGER_PIN, HIGH);
46 49
}
47 50

  
51

  
52

  
48 53
void setup()  {
49 54
  Serial.begin(9600);
50 55
  Serial1.begin(9600);
......
54 59
  // Initialize Buggy
55 60
  // Pins 2 and 3: pin 2 is thr, pin 3 is ail
56 61
  receiver_init();
62
  filter_init(&ail_state);
63
  filter_init(&thr_state);
57 64
  watchdog_init(TIME_THRESH, &watchdog_fail);
58 65
  brake_init(BRAKE_PIN, BRAKE_INDICATOR_PIN);
59 66
  steering_init(STEERING_PIN, 120, 133, 145);
......
85 92

  
86 93
void loop() {
87 94

  
88
  if(filter(rc_available[THR_INDEX])) {
95
  if(filter_loop(&thr_state, rc_available[THR_INDEX])) {
89 96
    watchdog_feed();
90 97
    rc_angle = receiver_get_angle(THR_INDEX);
91 98
    steer_angle = convert_rc_to_steering(rc_angle);
92 99
    steering_set(steer_angle);
93 100
  }
94 101
  
95
  if(filter(rc_available[AIL_INDEX])) {
102
  if(filter_loop(&ail_state, rc_available[AIL_INDEX])) {
96 103
    watchdog_feed();
97 104
    rc_thr = receiver_get_angle(AIL_INDEX);
98 105
    // TODO make this code...less...something

Also available in: Unified diff