X-Git-Url: http://git.droids-corp.org/?p=protos%2Fxbee-avr.git;a=blobdiff_plain;f=rc_proto.c;fp=rc_proto.c;h=8ea3767b26b7fc54d8ba8bfcb57e6b78a2849406;hp=d8c4727e6497bee7f122eb16a0d4f3b45d436dbe;hb=6811941dc02f68dd0305a30f3c1cf72a23566b6b;hpb=d8ce6478238b8e6093c9c0a18325d51d6dcf7e06 diff --git a/rc_proto.c b/rc_proto.c index d8c4727..8ea3767 100644 --- a/rc_proto.c +++ b/rc_proto.c @@ -51,13 +51,13 @@ #define RX_DB_THRESHOLD 65 /* mean -65 dB */ -/* XXX make it configurable */ -/* min time between 2 servo_send */ -#define SEND_SERVO_MIN_TIME_MS 50 -/* max time between 2 servo_send */ -#define SEND_SERVO_MAX_TIME_MS 300 -/* time before switching into bypass mode when no servo command received */ -#define AUTO_BYPASS_TIME_MS 500 +/* default values */ +struct rc_proto_timers rc_proto_timers = { + .send_servo_min_ms = 50, + .send_servo_max_ms = 300, + .send_power_probe_ms = 500, + .autobypass_ms = 500, +}; /* rc_proto statistics, accessed with sched_prio=XBEE_PRIO */ struct rc_proto_stats_data { @@ -368,7 +368,7 @@ static int8_t rc_proto_send_servos(void) /* if we transmitted servos values recently, nothing to do */ ms = get_time_ms(); diff = ms - servo_tx.time; - if (diff < SEND_SERVO_MIN_TIME_MS) + if (diff < rc_proto_timers.send_servo_min_ms) return 0; /* prepare values to send */ @@ -401,7 +401,7 @@ static int8_t rc_proto_send_servos(void) /* if no value changed and last message is acknowledged, don't transmit * if we already transmitted quite recently */ if (updated == 0 && ack == servo_tx.seq && - diff < SEND_SERVO_MAX_TIME_MS) + diff < rc_proto_timers.send_servo_max_ms) return 0; /* ok, we need to transmit */ @@ -711,7 +711,7 @@ static void rc_proto_cb(struct callout_mgr *cm, struct callout *tim, void *arg) /* send power probe periodically */ if (rc_proto_flags & RC_PROTO_FLAGS_TX_POW_PROBE) { diff = t - prev_power_probe; - if (diff > AUTO_BYPASS_TIME_MS) { + if (diff > rc_proto_timers.send_power_probe_ms) { pow_probe++; if (pow_probe > 4) pow_probe = 0; @@ -723,7 +723,7 @@ static void rc_proto_cb(struct callout_mgr *cm, struct callout *tim, void *arg) /* on wing, auto bypass servos if no commands since some time */ if (rc_proto_flags & RC_PROTO_FLAGS_RX_AUTOBYPASS) { diff = t - servo_rx.time; - if (diff > AUTO_BYPASS_TIME_MS) + if (diff > rc_proto_timers.autobypass_ms) spi_servo_set_bypass(1); }