mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-08-20 06:29:02 +00:00
9067e007b6
GeoPos stored a coordinate's sign only in its degrees NumberField, which
is an int32_t and therefore has no negative zero. Any coordinate whose
integer degrees part is 0 but which is negative (i.e. strictly between
0.0 and -1.0) could not be represented at all:
- set_lat()/set_lon() passed the raw float to the degrees field, so
-0.2933 truncated to 0 and the sign was gone before it reached the
widget.
- lat()/lon() then decided the sign with `field_lon_degrees.value() < 0`,
which is false for 0, so the value came back positive.
The reporter's airport is at longitude -0.2933, which was impossible to
enter in the ADSB Tx app.
Give each coordinate an explicit hemisphere field (N/S and E/W) and make
the degrees field an unsigned magnitude:
- The hemisphere OptionsField is the single source of the sign, so
"negative with zero degrees" is now representable.
- set_lat()/set_lon() derive the hemisphere from the sign of the input
and feed the fields the magnitude.
- lat()/lon() read the hemisphere instead of inferring the sign from
the degrees value.
- The minutes on_wrap handlers no longer need to flip the carry
direction based on the degrees sign, since degrees is now a
magnitude; the carry is the same in both hemispheres.
- The degrees fields no longer loop, so carrying below 0 clamps at 0
instead of wrapping round to 90/180.
The hemisphere indicator occupies the column that the 4-wide signed
degrees field used for its minus sign, so the row layout, the degree
symbol and the decimal readout all stay where they were.
Fixes #3234