diff options
author | Keith Packard <keithp@keithp.com> | 2018-08-05 11:09:34 +0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2018-08-05 11:13:42 +0800 |
commit | 0d57c78dde3c6e61576a4769b0e0fae7e88c107d (patch) | |
tree | 55b15b996575fe8c934ebfb16426c8e95425e2cf /src | |
parent | 9dfbf0103a649816e98d5511b1d6bbbfc93f6632 (diff) |
altos: Add separate 'ao_launch_tick'. Use in pyro and lockout.
Prior to this, there was only ao_boost_tick, which got reset at each
motor burn start. That meant there wasn't any way to measure total
flight time for pyro channels and 'apogee lockout' was based on time
since most recent motor start instead of total flight time.
Now pyro channels and apogee lockout both use total flight time, while
motor burn length still uses time since most recent motor burn start
(as it should).
Docs and UI updated to use 'launch' instead of 'boost' to try and make
the change clear.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/kernel/ao_flight.c | 7 | ||||
-rw-r--r-- | src/kernel/ao_flight.h | 1 | ||||
-rw-r--r-- | src/kernel/ao_pyro.c | 8 |
3 files changed, 9 insertions, 7 deletions
diff --git a/src/kernel/ao_flight.c b/src/kernel/ao_flight.c index 7b3cb9fa..c2700d20 100644 --- a/src/kernel/ao_flight.c +++ b/src/kernel/ao_flight.c @@ -48,7 +48,8 @@ /* Main flight thread. */ __pdata enum ao_flight_state ao_flight_state; /* current flight state */ -__pdata uint16_t ao_boost_tick; /* time of launch detect */ +__pdata uint16_t ao_boost_tick; /* time of most recent boost detect */ +__pdata uint16_t ao_launch_tick; /* time of first boost detect */ __pdata uint16_t ao_motor_number; /* number of motors burned so far */ #if HAS_SENSOR_ERRORS @@ -199,7 +200,7 @@ ao_flight(void) ) { ao_flight_state = ao_flight_boost; - ao_boost_tick = ao_sample_tick; + ao_launch_tick = ao_boost_tick = ao_sample_tick; /* start logging data */ ao_log_start(); @@ -269,7 +270,7 @@ ao_flight(void) * number of seconds. */ if (ao_config.apogee_lockout) { - if ((int16_t) (ao_sample_tick - ao_boost_tick) < + if ((int16_t) (ao_sample_tick - ao_launch_tick) < AO_SEC_TO_TICKS(ao_config.apogee_lockout)) break; } diff --git a/src/kernel/ao_flight.h b/src/kernel/ao_flight.h index 6894fe59..005c7e84 100644 --- a/src/kernel/ao_flight.h +++ b/src/kernel/ao_flight.h @@ -40,6 +40,7 @@ enum ao_flight_state { extern __pdata enum ao_flight_state ao_flight_state; extern __pdata uint16_t ao_boost_tick; +extern __pdata uint16_t ao_launch_tick; extern __pdata uint16_t ao_motor_number; #if HAS_IMU || HAS_MMA655X diff --git a/src/kernel/ao_pyro.c b/src/kernel/ao_pyro.c index 3c872354..527112ac 100644 --- a/src/kernel/ao_pyro.c +++ b/src/kernel/ao_pyro.c @@ -160,14 +160,14 @@ ao_pyro_ready(struct ao_pyro *pyro) #endif case ao_pyro_time_less: - if ((int16_t) (ao_time() - ao_boost_tick) <= pyro->time_less) + if ((int16_t) (ao_time() - ao_launch_tick) <= pyro->time_less) continue; - DBG("time %d > %d\n", (int16_t)(ao_time() - ao_boost_tick), pyro->time_less); + DBG("time %d > %d\n", (int16_t)(ao_time() - ao_launch_tick), pyro->time_less); break; case ao_pyro_time_greater: - if ((int16_t) (ao_time() - ao_boost_tick) >= pyro->time_greater) + if ((int16_t) (ao_time() - ao_launch_tick) >= pyro->time_greater) continue; - DBG("time %d < %d\n", (int16_t)(ao_time() - ao_boost_tick), pyro->time_greater); + DBG("time %d < %d\n", (int16_t)(ao_time() - ao_launch_tick), pyro->time_greater); break; case ao_pyro_ascending: |