Keith Packard [Mon, 21 Feb 2022 17:43:54 +0000 (09:43 -0800)]
altos: Document how delay_done is used in ao_pyro.c
delay_done is the time at which the delay finishes, but non-zero
values also indicate that some delay is pending. Add a comment about
why the value is set to 1 when it is zero, and switch the tests of
this value to comparisons against zero.
Keith Packard [Thu, 17 Feb 2022 05:44:52 +0000 (21:44 -0800)]
ao_lco_v2: Use int32_t for temporary box value in step_box
Stepping to the next box will generate negative values and values
beyond the highest box number. Use a type capable of holding all of
those values, instead of int16_t.
Keith Packard [Thu, 17 Feb 2022 01:49:42 +0000 (17:49 -0800)]
altos/lpc: Add casts to reduce -Wconversion warnings
Most of these were caused by int/long mixes as uint32_t is 'long' on
arm for reasons, meaning that bare int constants need to be cast to
avoid a warning.
Keith Packard [Thu, 17 Feb 2022 01:34:41 +0000 (17:34 -0800)]
ao_telemetry: Use int16_t types for telemetry packet intervals
This avoids concerns about overflow from int8_t types when computing
long intervals between packets as the base interface type was an
int16_t. This should help deal with higher sample rate sensors when
that occurs.
Keith Packard [Fri, 28 Jan 2022 23:44:03 +0000 (15:44 -0800)]
ao_task: Task ids are 8-bits, fix type in struct ao_task
These are densely allocated and should never be larger than the
maximum number of task slots, so fix the type to be 8-bits just like
all other places where a task_id is used.
Keith Packard [Fri, 28 Jan 2022 23:11:07 +0000 (15:11 -0800)]
ao_log: Fix sensor time triggers to use AO_TICK_TYPE
These values were used to determine when various log information would
be recorded. Using the wrong type meant that they would always
trigger, causing the log to fill up rapidly with data that should be
sampled at a lower rate.
Keith Packard [Fri, 28 Jan 2022 23:06:18 +0000 (15:06 -0800)]
ao_log: Change flight type to uint16_t, widen APIs dealing with flight numbers to int32_t
Real Flight numbers are 16-bit unsigned values, but APIs using them
pass values that areoverloaded to also represent broken log slots
using negative numbers. This means that these APIs need to be able to
represent all 65535 possible flight numbers *and* all possible log
slots as negative values. Switch the variables holding only flight
numbers to uint16_t and those holding either a flight number or log
slot to int32_t.
Keith Packard [Fri, 28 Jan 2022 22:50:58 +0000 (14:50 -0800)]
ao_flight: ao_interval_end type was too small, could cause premature landing state
ao_interval_end is used to provide a window of time during which the
max/min values for sensors are measured. After that time expires,
those bounds are compared to see if the airframe has been stable and
should be moved to landing state. With a type that is too small, that
could happen immediately after transitioning to main (for baro-enabled
devices) or coast (for accel-only devices). For baro devices, this
would disable any redundant main firing events. For accel-only
devices, this could disable all events occuring after coast, including
firing separation charges or motor igniters.
There are also a couple of additional changes to reduce -Wconversion
messages.
Keith Packard [Fri, 28 Jan 2022 22:06:25 +0000 (14:06 -0800)]
drivers/ao_pad: Convert from/to 16-bit times over the air
The radio protocol sends only 16 bits of time, make sure we translate
from/to those correctly. No bugs detected, just casts added to
clarify. Also fix other -Wconversion warnings.
Keith Packard [Fri, 28 Jan 2022 17:33:17 +0000 (09:33 -0800)]
drivers/ao_lco: Fix box types to be uint16_t. Also clean other -Wconversion messages
Old LCO code uses 0x1000 as magic value for "DRAG" box, so we need 16
bits. Switch all box variables to 16 bits, use int32_t when switching
box numbers to deal with negative values and still hold the whole
possible range (even though 16 bits "should" be plenty).
Keith Packard [Thu, 17 Feb 2022 01:00:59 +0000 (17:00 -0800)]
altos: Re-enable apogee delay
When the igniter code was changed to support booster mode, the code
which delayed apogee firing based on the configure apogee delay value
was lost. Re-enable that by sticking a delay before firing the drogue
charge when the ignite mode is not redundant apogee.
Keith Packard [Fri, 28 Jan 2022 23:27:02 +0000 (15:27 -0800)]
ao_pyro: Move delay_done out of pyro structure
The pyro structure should be read-only in flight operations. Move the
'delay_done' element to a parallel array as that gets written. Change
types to pointers to const structs to enforce this in the future.
Keith Packard [Thu, 27 Jan 2022 23:49:15 +0000 (15:49 -0800)]
altos: AES code was storing bytes in an int array
The only operations using these values are logic using bytes, not
arithmetic, so shrinking the size of the elements should have no
effect on operation.
This saves space *and* eliminates a type conversion warning from
-Wconversion.
Keith Packard [Tue, 11 Jan 2022 22:32:55 +0000 (14:32 -0800)]
altosdroid: Add BLUETOOTH_CONNECT permission, handle its lack
Android 12 switched how bluetooth permissions work, so now we need a
new one to talk to devices. Also deal with a lack of that by not
crashing when we can't get the name of a BT device.
Keith Packard [Thu, 16 Dec 2021 21:39:33 +0000 (13:39 -0800)]
altos: Switch all tick variables to AO_TICK_TYPE/AO_TICK_SIGNED
Instead of trying to pick and choose which work as 16-bit values,
change everything that doesn't affect external values (log, companion,
radio) to AO_TICK_TYPE.
Keith Packard [Sat, 16 Oct 2021 22:48:22 +0000 (15:48 -0700)]
altosdroid: Fix tab updates on Android 11 after rotate
Android 11 appears to have "optimized" application rotation by
regenerating fragments automatically. This means the tab fragments
aren't getting created by TabsAdapter.getItem, so that code didn't
know about them, which caused it to not know which tab was active so
all of the application state wasn't getting updated in the tabs after
rotation.
Fix this by telling TabsAdapter about fragments that are already
created -- altosdroid hears about them in the registerTab hook.