gps-watch.git
2 months agoAdd README. master
Tilman Sauerbeck [Sun, 13 Sep 2020 10:44:22 +0000 (12:44 +0200)]
Add README.

2 months agobuild: Generate gps-watch-bootloader-intermediate.frm.
Tilman Sauerbeck [Sun, 13 Sep 2020 10:36:40 +0000 (12:36 +0200)]
build: Generate gps-watch-bootloader-intermediate.frm.

This file can be installed on a GPS watch running the vendor firmware.

2 months agoAdd LICENSE.
Tilman Sauerbeck [Sun, 13 Sep 2020 10:36:24 +0000 (12:36 +0200)]
Add LICENSE.

2 months agoapplication: Store pace in the model and show it in its own view.
Tilman Sauerbeck [Sun, 5 Jul 2020 16:37:42 +0000 (18:37 +0200)]
application: Store pace in the model and show it in its own view.

2 months agocommon: Make Logger calculate and publish pace.
Tilman Sauerbeck [Sun, 5 Jul 2020 16:35:09 +0000 (18:35 +0200)]
common: Make Logger calculate and publish pace.

Every 1000m, pace is set to the time in seconds it took to travel
that distance.

2 months agocommon: Add beginnings of tests for the fmt module.
Tilman Sauerbeck [Sun, 5 Jul 2020 15:42:22 +0000 (17:42 +0200)]
common: Add beginnings of tests for the fmt module.

2 months agocommon: Use the correct magic number in Fixed15_49::pi_div_two().
Tilman Sauerbeck [Sun, 26 Apr 2020 10:36:45 +0000 (12:36 +0200)]
common: Use the correct magic number in Fixed15_49::pi_div_two().

This change should fix the display of current distance travelled
during a workout. It does not affect recordings.

8 months agoapplication: Only reset the model when starting a new recording.
Tilman Sauerbeck [Wed, 25 Mar 2020 16:22:22 +0000 (17:22 +0100)]
application: Only reset the model when starting a new recording.

Do not reset it when stopping a recording. This lets us view the
recording's data (distance only for now) after it has been stopped.

8 months agoapplication: Use the previous/next buttons to cycle the current view.
Tilman Sauerbeck [Mon, 23 Mar 2020 11:52:21 +0000 (12:52 +0100)]
application: Use the previous/next buttons to cycle the current view.

8 months agoapplication: Introduce data model struct and view structs.
Tilman Sauerbeck [Sun, 22 Mar 2020 16:08:55 +0000 (17:08 +0100)]
application: Introduce data model struct and view structs.

This improves the structure of our UI code.

8 months agocommon: Store distance travelled in Logger instance.
Tilman Sauerbeck [Sat, 28 Mar 2020 16:30:49 +0000 (17:30 +0100)]
common: Store distance travelled in Logger instance.

8 months agoapplication: Fix indentation broken by previous changeset.
Tilman Sauerbeck [Sun, 22 Mar 2020 14:43:08 +0000 (15:43 +0100)]
application: Fix indentation broken by previous changeset.

8 months agoapplication: Use the Button struct to handle the play button.
Tilman Sauerbeck [Sun, 22 Mar 2020 14:27:34 +0000 (15:27 +0100)]
application: Use the Button struct to handle the play button.

8 months agoapplication: Add the button module.
Tilman Sauerbeck [Sun, 22 Mar 2020 14:26:39 +0000 (15:26 +0100)]
application: Add the button module.

Provides debouncing for GPIOs.

9 months agobuild: Adjustments for scons running in Python 3.
Tilman Sauerbeck [Thu, 13 Feb 2020 19:16:09 +0000 (20:16 +0100)]
build: Adjustments for scons running in Python 3.

9 months agocommon: Implement the "rm" shell command.
Tilman Sauerbeck [Tue, 11 Feb 2020 18:57:21 +0000 (19:57 +0100)]
common: Implement the "rm" shell command.

Removes a recording.

9 months agocommon: Implement Logger::remove_recording().
Tilman Sauerbeck [Tue, 11 Feb 2020 18:56:37 +0000 (19:56 +0100)]
common: Implement Logger::remove_recording().

9 months agocommon: Implement Storage::erase() in Mx25l.
Tilman Sauerbeck [Tue, 11 Feb 2020 18:54:06 +0000 (19:54 +0100)]
common: Implement Storage::erase() in Mx25l.

10 months agocommon: Rename TimeAndPos::latitude to latitude_deg.
Tilman Sauerbeck [Sun, 19 Jan 2020 20:11:29 +0000 (21:11 +0100)]
common: Rename TimeAndPos::latitude to latitude_deg.

Same for longitude.

10 months agoapplication: Show distance travelled while recording.
Tilman Sauerbeck [Sun, 19 Jan 2020 11:16:48 +0000 (12:16 +0100)]
application: Show distance travelled while recording.

10 months agocommon: Implement TimeAndPos::distance_cm().
Tilman Sauerbeck [Sun, 19 Jan 2020 18:57:42 +0000 (19:57 +0100)]
common: Implement TimeAndPos::distance_cm().

Calculates the distance between two points in cm.

10 months agocommon: Store GPS coordinates in radians, too.
Tilman Sauerbeck [Sun, 19 Jan 2020 11:20:16 +0000 (12:20 +0100)]
common: Store GPS coordinates in radians, too.

Use the Q15.49 fixed point format to store those values.

10 months agocommon: Add the fixed15_49 module.
Tilman Sauerbeck [Sun, 19 Jan 2020 11:24:07 +0000 (12:24 +0100)]
common: Add the fixed15_49 module.

Implements Q15.49 fixed point math.

10 months agotest: Order arguments to assert_eq!() consistently.
Tilman Sauerbeck [Sat, 18 Jan 2020 18:51:02 +0000 (19:51 +0100)]
test: Order arguments to assert_eq!() consistently.

The expected value comes first.

10 months agocommon: Include the recordings' size in the listing.
Tilman Sauerbeck [Mon, 13 Jan 2020 07:27:02 +0000 (08:27 +0100)]
common: Include the recordings' size in the listing.

The size is only approximate (i.e. multiples of sectors used).

10 months agocommon: Avoid duplicated recordings shown in Logger::list_recordings().
Tilman Sauerbeck [Sun, 12 Jan 2020 11:56:56 +0000 (12:56 +0100)]
common: Avoid duplicated recordings shown in Logger::list_recordings().

This is achieved by simplifying the way we sort our sector indices,
which unfortunately also comes with a performance hit.

10 months agocommon: Use slice.swap() to clean up SectorHeaderIter::sort().
Tilman Sauerbeck [Sun, 12 Jan 2020 09:41:40 +0000 (10:41 +0100)]
common: Use slice.swap() to clean up SectorHeaderIter::sort().

10 months agocommon: Factor out the SectorHeaderIter::sort() method.
Tilman Sauerbeck [Sun, 12 Jan 2020 09:28:58 +0000 (10:28 +0100)]
common: Factor out the SectorHeaderIter::sort() method.

10 months agotest: Verify Logger::list_recordings()'s behavior with empty storage.
Tilman Sauerbeck [Sat, 11 Jan 2020 13:18:53 +0000 (14:18 +0100)]
test: Verify Logger::list_recordings()'s behavior with empty storage.

We expect no output in that case.

10 months agotest: Make Logger test's pipe non-blocking.
Tilman Sauerbeck [Sat, 11 Jan 2020 10:33:22 +0000 (11:33 +0100)]
test: Make Logger test's pipe non-blocking.

There are cases where we need to verify that the pipe is empty.

10 months agotest: Add a first test for Logger::list_recordings().
Tilman Sauerbeck [Sat, 11 Jan 2020 09:43:51 +0000 (10:43 +0100)]
test: Add a first test for Logger::list_recordings().

10 months agotools: Import the gpxify program.
Tilman Sauerbeck [Fri, 10 Jan 2020 10:31:34 +0000 (11:31 +0100)]
tools: Import the gpxify program.

gpxify takes as input an recording retrieved from the GPS watch
and converts it to GPX format.

10 months agotools: Add license header to update-firmware.
Tilman Sauerbeck [Fri, 10 Jan 2020 09:11:51 +0000 (10:11 +0100)]
tools: Add license header to update-firmware.

10 months agocommon: Implement the "ls" shell command.
Tilman Sauerbeck [Thu, 9 Jan 2020 22:40:50 +0000 (23:40 +0100)]
common: Implement the "ls" shell command.

Shows a listing of the stored recordings.

10 months agocommon: Implement Logger::list_recordings().
Tilman Sauerbeck [Thu, 9 Jan 2020 22:40:23 +0000 (23:40 +0100)]
common: Implement Logger::list_recordings().

10 months agocommon: Make Logger::read_sector_header() read the start_time field.
Tilman Sauerbeck [Fri, 10 Jan 2020 22:17:27 +0000 (23:17 +0100)]
common: Make Logger::read_sector_header() read the start_time field.

This is necessary so that we can show the date and time when a
recording was done.

10 months agotest: Use a pipe to back the write buffer for the Logger test.
Tilman Sauerbeck [Fri, 10 Jan 2020 22:20:28 +0000 (23:20 +0100)]
test: Use a pipe to back the write buffer for the Logger test.

10 months agocommon: Silence compiler warnings about ignored Result return values.
Tilman Sauerbeck [Thu, 9 Jan 2020 20:19:57 +0000 (21:19 +0100)]
common: Silence compiler warnings about ignored Result return values.

Note that we still don't handle potential errors from Storage::write().

10 months agocommon: Implement the "get" shell command.
Tilman Sauerbeck [Thu, 9 Jan 2020 14:18:25 +0000 (15:18 +0100)]
common: Implement the "get" shell command.

Retrieves a recording in yenc format.

10 months agoapplication: Start and stop recordings by pressing the play button.
Tilman Sauerbeck [Thu, 9 Jan 2020 14:14:40 +0000 (15:14 +0100)]
application: Start and stop recordings by pressing the play button.

10 months agocommon: Implement Logger::has_recording().
Tilman Sauerbeck [Thu, 9 Jan 2020 14:14:13 +0000 (15:14 +0100)]
common: Implement Logger::has_recording().

10 months agocontrib: Add udev rules file.
Tilman Sauerbeck [Thu, 9 Jan 2020 13:25:12 +0000 (14:25 +0100)]
contrib: Add udev rules file.

10 months agocommon: Add missing Write Enable command to Mx25L::program_page().
Tilman Sauerbeck [Thu, 9 Jan 2020 11:42:53 +0000 (12:42 +0100)]
common: Add missing Write Enable command to Mx25L::program_page().

Without a write enable, the flash memory doesn't take our data.

10 months agoapplication: Set up a Logger instance.
Tilman Sauerbeck [Thu, 9 Jan 2020 11:05:07 +0000 (12:05 +0100)]
application: Set up a Logger instance.

This also passes a mutable Logger reference to Shell::update()
since we no longer can pass another mutable Storage reference to it:
doing so would break the requirement of only having one
mutable reference to any instance at any time, and Logger requires
a mutable storage reference, too.

10 months agocommon: Make Logger::storage public.
Tilman Sauerbeck [Thu, 9 Jan 2020 11:03:07 +0000 (12:03 +0100)]
common: Make Logger::storage public.

This is required to avoid some multiple mutable borrow issues
in the upcoming changesets.

10 months agocommon: Implement Logger::get_recording().
Tilman Sauerbeck [Thu, 9 Jan 2020 10:39:54 +0000 (11:39 +0100)]
common: Implement Logger::get_recording().

10 months agocommon: Synchronize sector headers after a recording is finished.
Tilman Sauerbeck [Thu, 9 Jan 2020 10:02:21 +0000 (11:02 +0100)]
common: Synchronize sector headers after a recording is finished.

This is necessary to be able to retrieve the recording without
restarting the device.

10 months agocommon: Factor out Logger::read_sector_header().
Tilman Sauerbeck [Thu, 9 Jan 2020 10:00:28 +0000 (11:00 +0100)]
common: Factor out Logger::read_sector_header().

10 months agotest: Add tests for the logger module.
Tilman Sauerbeck [Wed, 8 Jan 2020 21:13:48 +0000 (22:13 +0100)]
test: Add tests for the logger module.

10 months agocommon: Add the logger module.
Tilman Sauerbeck [Sun, 5 Jan 2020 21:22:41 +0000 (22:22 +0100)]
common: Add the logger module.

10 months agotest: Add tests for the gps module.
Tilman Sauerbeck [Wed, 8 Jan 2020 17:36:47 +0000 (18:36 +0100)]
test: Add tests for the gps module.

10 months agocommon: Make Gps::update() access UART0's receive buffer via a closure.
Tilman Sauerbeck [Wed, 8 Jan 2020 17:30:19 +0000 (18:30 +0100)]
common: Make Gps::update() access UART0's receive buffer via a closure.

This will allow us to write tests for Gps without providing a fake
implementation of the UART reader function in the test.

10 months agobuild: Add infrastructure for building automated tests.
Tilman Sauerbeck [Wed, 8 Jan 2020 16:40:32 +0000 (17:40 +0100)]
build: Add infrastructure for building automated tests.

10 months agobuild: Split SConscript.libcommon in two.
Tilman Sauerbeck [Wed, 8 Jan 2020 13:32:29 +0000 (14:32 +0100)]
build: Split SConscript.libcommon in two.

Split it in SConscript.libcommon.c, dealing with the C code
that's used to build libcommon.a, and SConscript.libcommon.rs,
used to build libcommon.rlib.

This will be useful for native builds used for testing in the future.

10 months agocommon: Implement the "dump_storage" shell command.
Tilman Sauerbeck [Wed, 8 Jan 2020 11:44:09 +0000 (12:44 +0100)]
common: Implement the "dump_storage" shell command.

Lists the mx25l flash's contents in the yencode format.

10 months agocommon: Implement Storage::size() in Mx25l.
Tilman Sauerbeck [Wed, 8 Jan 2020 11:43:14 +0000 (12:43 +0100)]
common: Implement Storage::size() in Mx25l.

10 months agocommon: Implement the "clear_storage" shell command.
Tilman Sauerbeck [Wed, 8 Jan 2020 10:52:36 +0000 (11:52 +0100)]
common: Implement the "clear_storage" shell command.

Erases all of the mx25l flash's contents.

10 months agoapplication: Integrate flash storage via Mx25l.
Tilman Sauerbeck [Wed, 8 Jan 2020 10:50:50 +0000 (11:50 +0100)]
application: Integrate flash storage via Mx25l.

10 months agocommon: Implement Storage::clear() in Mx25l.
Tilman Sauerbeck [Wed, 8 Jan 2020 10:45:29 +0000 (11:45 +0100)]
common: Implement Storage::clear() in Mx25l.

10 months agoapplication: Integrate the shell.
Tilman Sauerbeck [Wed, 8 Jan 2020 10:20:32 +0000 (11:20 +0100)]
application: Integrate the shell.

10 months agocommon: Implement Mx25l::erase_all().
Tilman Sauerbeck [Wed, 8 Jan 2020 09:40:49 +0000 (10:40 +0100)]
common: Implement Mx25l::erase_all().

10 months agocommon: Implement Storage::write() in Mx25l.
Tilman Sauerbeck [Wed, 8 Jan 2020 09:48:31 +0000 (10:48 +0100)]
common: Implement Storage::write() in Mx25l.

10 months agocommon: Implement Mx25l::program_page().
Tilman Sauerbeck [Wed, 8 Jan 2020 09:46:18 +0000 (10:46 +0100)]
common: Implement Mx25l::program_page().

10 months agocommon: Implement Mx25l::erase_sector().
Tilman Sauerbeck [Wed, 8 Jan 2020 09:45:03 +0000 (10:45 +0100)]
common: Implement Mx25l::erase_sector().

10 months agocommon: Add the varint module.
Tilman Sauerbeck [Wed, 8 Jan 2020 11:05:50 +0000 (12:05 +0100)]
common: Add the varint module.

10 months agocommon: Add the yencode module.
Tilman Sauerbeck [Sun, 5 Jan 2020 14:49:55 +0000 (15:49 +0100)]
common: Add the yencode module.

10 months agocommon: Implement Time::fmt_date().
Tilman Sauerbeck [Sun, 5 Jan 2020 21:28:07 +0000 (22:28 +0100)]
common: Implement Time::fmt_date().

10 months agocommon: Add the shell module.
Tilman Sauerbeck [Wed, 8 Jan 2020 10:09:36 +0000 (11:09 +0100)]
common: Add the shell module.

It implements no useful functionality yet.

10 months agobootloader: Stay in bootloader when the middle left push button is held.
Tilman Sauerbeck [Sun, 5 Jan 2020 18:51:22 +0000 (19:51 +0100)]
bootloader: Stay in bootloader when the middle left push button is held.

10 months agoapplication: Make system reset less likely do be run by accident.
Tilman Sauerbeck [Sun, 5 Jan 2020 18:48:54 +0000 (19:48 +0100)]
application: Make system reset less likely do be run by accident.

System reset is now triggered by holding the upper left and the
lower right push button at the same time.

10 months agoapplication: Configure the remaining push buttons.
Tilman Sauerbeck [Sun, 5 Jan 2020 18:46:08 +0000 (19:46 +0100)]
application: Configure the remaining push buttons.

10 months agoapplication: Factor out the configure_push_buttons() function.
Tilman Sauerbeck [Sun, 5 Jan 2020 18:33:32 +0000 (19:33 +0100)]
application: Factor out the configure_push_buttons() function.

10 months agoapplication: Factor out the reset_requested() function.
Tilman Sauerbeck [Sun, 5 Jan 2020 18:23:39 +0000 (19:23 +0100)]
application: Factor out the reset_requested() function.

No change in behavior.

10 months agoapplication: Set up pins for the MX25L flash memory.
Tilman Sauerbeck [Sun, 5 Jan 2020 18:18:26 +0000 (19:18 +0100)]
application: Set up pins for the MX25L flash memory.

This configures SPI0 as well as the GPIO used as the flash's
chip select line.

10 months agocommon: Implement Storage::read() in Mx25l.
Tilman Sauerbeck [Sun, 5 Jan 2020 17:53:58 +0000 (18:53 +0100)]
common: Implement Storage::read() in Mx25l.

10 months agocommon: Add the storage module.
Tilman Sauerbeck [Mon, 6 Jan 2020 09:44:21 +0000 (10:44 +0100)]
common: Add the storage module.

10 months agoapplication: Perform system reset from panic handler if requested.
Tilman Sauerbeck [Sat, 4 Jan 2020 18:29:57 +0000 (19:29 +0100)]
application: Perform system reset from panic handler if requested.

This is untested; I'm not sure if it would work at all.

10 months agocommon: Add the mx25l module.
Tilman Sauerbeck [Sat, 4 Jan 2020 18:19:02 +0000 (19:19 +0100)]
common: Add the mx25l module.

Provides access to the status register and device ID only for now.

10 months agocommon: Accept DGPS fix information.
Tilman Sauerbeck [Sat, 4 Jan 2020 18:15:08 +0000 (19:15 +0100)]
common: Accept DGPS fix information.

We used to reject differential GPS (DGPS) fixes as invalid, but they
are actually more accurate than standard GPS fixes.

10 months agocommon: Increase size of the UART receive ringbuffer.
Tilman Sauerbeck [Sat, 4 Jan 2020 17:24:44 +0000 (18:24 +0100)]
common: Increase size of the UART receive ringbuffer.

The GPS module sends about ~380 bytes per second, which led to
overflows of our 256 byte sized ringbuffer.

10 months agocommon: Add the spi module.
Tilman Sauerbeck [Sat, 4 Jan 2020 11:00:25 +0000 (12:00 +0100)]
common: Add the spi module.

10 months agocommon: Restart NMEA message parsing when a '$' character is seen.
Tilman Sauerbeck [Fri, 3 Jan 2020 20:42:24 +0000 (21:42 +0100)]
common: Restart NMEA message parsing when a '$' character is seen.

The GPS module sometimes sends incomplete NMEA messages such as this:
  $GP$GGA...*
This changeset makes it so we'd only parse the second, complete message
in that example.

10 months agotools: Pad final chunks with 0xff if necessary.
Tilman Sauerbeck [Fri, 3 Jan 2020 15:33:15 +0000 (16:33 +0100)]
tools: Pad final chunks with 0xff if necessary.

The bootloader only accepts chunks whose size is a multiple of four.

10 months agocommon: Move panic handler out of libcommon.
Tilman Sauerbeck [Fri, 3 Jan 2020 15:09:53 +0000 (16:09 +0100)]
common: Move panic handler out of libcommon.

This allows us to do a native build of libcommon which is useful for
unit testing.

10 months agoapplication: Show current time on the display if we have a GPS fix.
Tilman Sauerbeck [Tue, 31 Dec 2019 12:32:48 +0000 (13:32 +0100)]
application: Show current time on the display if we have a GPS fix.

10 months agocommon: Implement Time::fmt_time().
Tilman Sauerbeck [Thu, 2 Jan 2020 12:32:26 +0000 (13:32 +0100)]
common: Implement Time::fmt_time().

Formats time as HH:MM:SS.

10 months agocommon: Add the time module.
Tilman Sauerbeck [Thu, 2 Jan 2020 12:28:59 +0000 (13:28 +0100)]
common: Add the time module.

This currently only contains the equivalent of gmtime(), which was
adapted from Rich Felker's musl.

10 months agocommon: Add the fmt module.
Tilman Sauerbeck [Tue, 31 Dec 2019 12:35:35 +0000 (13:35 +0100)]
common: Add the fmt module.

10 months agocommon: Implement screen::clear() and screen::draw_text().
Tilman Sauerbeck [Mon, 30 Dec 2019 18:51:46 +0000 (19:51 +0100)]
common: Implement screen::clear() and screen::draw_text().

This also imports (a subset of) Frederic Cambus' spleen font,
used by screen::draw_text().

10 months agocommon: Tweak bit order of screen data.
Tilman Sauerbeck [Mon, 30 Dec 2019 17:18:08 +0000 (18:18 +0100)]
common: Tweak bit order of screen data.

The left-most pixel is now defined by the most significant bit.
This is a more intuitive representation than what we had before.

10 months agoapplication: Visualize GPS fix state using the satellite icons.
Tilman Sauerbeck [Tue, 31 Dec 2019 11:03:50 +0000 (12:03 +0100)]
application: Visualize GPS fix state using the satellite icons.

As long as we are waiting for a GPS fix, we animate the satellite
icons.

10 months agoapplication: Manage whether or not we have valid GPS fix information.
Tilman Sauerbeck [Tue, 31 Dec 2019 10:28:58 +0000 (11:28 +0100)]
application: Manage whether or not we have valid GPS fix information.

Expire such information after about 1.5s.

10 months agoapplication: Blink heart icon to indicate liveness.
Tilman Sauerbeck [Tue, 31 Dec 2019 09:51:45 +0000 (10:51 +0100)]
application: Blink heart icon to indicate liveness.

10 months agocommon: Implement display::show_icon() and display::hide_icon().
Tilman Sauerbeck [Tue, 31 Dec 2019 08:17:08 +0000 (09:17 +0100)]
common: Implement display::show_icon() and display::hide_icon().

This only supports the alarm, heart and satellite icons for now,
but not the battery meter icon.

10 months agoapplication: Extract time and position from GPS NMEA messages.
Tilman Sauerbeck [Mon, 30 Dec 2019 10:39:26 +0000 (11:39 +0100)]
application: Extract time and position from GPS NMEA messages.

10 months agocommon: Add the gps module.
Tilman Sauerbeck [Mon, 30 Dec 2019 09:41:00 +0000 (10:41 +0100)]
common: Add the gps module.

10 months agoapplication: Set up pins for the GPS.
Tilman Sauerbeck [Mon, 30 Dec 2019 10:42:42 +0000 (11:42 +0100)]
application: Set up pins for the GPS.

This configures UART0 as well as the GPS' reset line.

10 months agoapplication: Define UART0_IRQHandler().
Tilman Sauerbeck [Sun, 29 Dec 2019 00:31:08 +0000 (01:31 +0100)]
application: Define UART0_IRQHandler().

Writes received data to the global uart0_rx_buf ringbuffer.

10 months agocommon: Add Rust glue for the ringbuf module.
Tilman Sauerbeck [Sat, 28 Dec 2019 22:11:09 +0000 (23:11 +0100)]
common: Add Rust glue for the ringbuf module.

For now this only allows us to access a ringbuffer from Rust
after it has been defined in C code.

10 months agocommon: Add the uart module.
Tilman Sauerbeck [Sat, 28 Dec 2019 18:54:46 +0000 (19:54 +0100)]
common: Add the uart module.