Commit graph

1006 commits

Author SHA1 Message Date
David Volovskiy 4a4fce428e Removed some dead code 2024-07-29 18:24:58 -04:00
David Volovskiy df2dac5a07 debouince now uses cb_fast_tick and holding the button now also gets debounced 2024-07-29 18:12:46 -04:00
David Volovskiy 7d5aaf60ca Leaving sleep with alarm button up doesn't trigger alarm button 2024-07-29 07:44:31 -04:00
David Volovskiy 4375ca37e0 Added debouncing 2024-07-29 07:39:51 -04:00
atax1a 42c14c2e5b
Merge pull request #420 from voloved/sunrise_sunset_presets
Added ability to add presets to the sunrise and sunset face
2024-07-24 04:49:03 +00:00
Wesley Ellis 8aa1a3f8fa
Merge pull request #422 from wryun/fix-totp-lfs-error-params
Fix TOTP LFS printf string
2024-07-21 08:43:05 -04:00
James Haggerty 222c60b072 Fix TOTP LFS printf string 2024-07-21 09:10:28 +10:00
David Volovskiy a13c8c35b8 Code review commit 2024-07-20 15:59:42 -04:00
David Volovskiy 9ee319c888 Typo in comment 2024-07-20 14:48:32 -04:00
David Volovskiy a3d23ab45e Long press of Alarm goes back to default 2024-07-20 14:46:42 -04:00
David Volovskiy a7c0fb7dfd Added ability to add presets to the sunrise and sunset face 2024-07-20 14:35:37 -04:00
joeycastillo 5ec3dca9e4 documentation fix 2024-07-10 06:56:49 -04:00
joeycastillo ac5fb40730 remove dead code 2024-07-10 06:49:56 -04:00
atax1a 5f5d86353f
Merge pull request #397 from madhogs/wyrun-totp-lfs-fix
Reduce totp_face_lfs memory usage
2024-07-08 21:10:46 +00:00
Jose Castillo d98d14d236
Add support for Sensor Watch Pro (#412)
* Sensor Watch Pro board definition

* Disable hot-plugging on SWCLK

* Add rainbow test

* Move interrupt mapping to board config

* New color definition for Pro boards in makefile
2024-07-06 11:07:02 -04:00
joeycastillo 89a2af92ef silence warnings 2024-07-06 08:52:41 -04:00
Wesley Ellis 226cda748c
Merge pull request #408 from tahnok/sanity-check-color
Check that color is valid
2024-06-26 11:40:28 -04:00
Wesley Ellis 96fdf64c4c Check that color is valid
Instead of merely checking that COLOR is set, check that it is one of
RED, BLUE or GREEN
2024-06-26 11:30:31 -04:00
James Haggerty 77ea1b8965 Reduce totp_face_lfs memory usage 2024-04-26 16:05:35 +01:00
atax1a 439843f56b
Merge pull request #388 from TheOnePerson/fix-compile-errors
Fix compile errors and warnings in movement.c and shell.c
2024-04-09 22:24:19 +00:00
atax1a 45beca19e8
Merge pull request #389 from joeycastillo/theAlexes/add-openocd
add an openocd.cfg for openocd 0.12.0
2024-04-09 22:23:21 +00:00
madhogs 524098b925 add the ability to set location and birthdate in movement config 2024-03-31 13:27:54 +01:00
atax1a d2b5ed7155
Merge pull request #383 from theAlexes/theAlexes/fix-uf2conv
uf2conv: argument to `re.split` should be a rawstring
2024-03-31 00:40:05 +00:00
atax1a 1e29fe85e5
Merge pull request #385 from matheusmoreira/totp-hot-patch
TOTP hotfix: reduce memory usage
2024-03-31 00:39:43 +00:00
Alex Maestas f28209b290 add an openocd.cfg for openocd 0.12.0 2024-03-31 00:37:35 +00:00
TheOnePerson c22123961f Fix compile errors and warnings in movement.c and shell.c 2024-03-29 11:49:48 +01:00
Matheus Afonso Martins Moreira 10701f3d50 faces/totp: avoid displaying when key is invalid
Fixes a division by zero bug caused by calling getCodeFromTimestamp
without having initialized the TOTP library with a secret first.
This was happening because the face calls totp_display on activation,
meaning the validity of the secret was not checked since this is
done in the generate function.

Now the validity of the key is determined solely by the size
of the current decoded key. A general display function checks it
and decides whether to display the code or just the error message.

The size of the current decoded key is initialized to zero
on watch face activation, ensuring fail safe operation.

Tested-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Tested-on-hardware-by: madhogs <59648482+madhogs@users.noreply.github.com>
Signed-off-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/385
2024-03-20 12:54:20 -03:00
Matheus Afonso Martins Moreira 7e5c34773a faces/totp: fix error message not displayed bug
Forgot to call watch_display_string on the error message.
Of course the message isn't going to be displayed.

Also, increase the buffer size to 10 characters
and output a space to the last position.
This ensures the segments are cleared.

Tested-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Tested-on-hardware-by: madhogs <59648482+madhogs@users.noreply.github.com>
Signed-off-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/385
2024-03-20 12:54:10 -03:00
Matheus Afonso Martins Moreira 3f850d79c8 faces/totp: remove dynamic memory allocation
Allocate an unlimited extent 128 byte buffer once during setup
instead of allocating and deallocating repeatedly. A static buffer
was not used because it fails to be reentrant and prevents multiple
instances of the watch face to be compiled by the user.

The advantage is the complete prevention of memory management errors,
improving the reliability of the watch. It also eliminates the overhead
of the memory allocator itself since malloc is not free.
The disadvantage is a worst case default size of 128 bytes was required,
meaning about 90 bytes will be wasted in the common case since most keys
are not that big. This can be overridden by the user via preprocessor.

The key lengths are checked on TOTP watch face initialization
and if any key is found to be too large to fit the buffer
it is turned off and the label and ERROR is displayed instead.

The base32 encoded secrets are decoded dynamically to the buffer
at the following times:

 - Face enters the foreground
 - User switches TOTP code

Therefore, there is still some extra runtime overhead
that can still be eliminated by code generation.
This will be addressed in future commits.

Tested-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Tested-on-hardware-by: madhogs <59648482+madhogs@users.noreply.github.com>
Signed-off-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/385
2024-03-18 11:40:55 -03:00
Matheus Afonso Martins Moreira df38c262b8 faces/totp: improve memory usage
The TOTP face is working in the simulator but fails on the real hardware
when loaded with lots of codes, just like the LFS version.
This is likely caused by the recent refactoring of the TOTP face
which introduced a declarative credential interface for ease of use.
That's accomplished by decoding the secrets at runtime which increases
the RAM requirements. Users are likely hitting memory limits.

In order to mitigate this, the algorithm is changed from decoding
all of the secrets only once during initialization to on the fly
decoding of the secret for the current TOTP credential only.
This converts this face's dynamic memory usage from O(N) to O(1)
at the cost of memory management when switching faces and credentials
which could impact power consumption. Issue is confirmed fixed by
author of issue who has tested it on real hardware. Fixes #384.

Due to variable key sizes, the memory cannot be statically allocated.
Perhaps there's a maximum key size that can serve as worst case?

Also took this opportunity to restructure the code a bit.
Also added code to check for memory allocation failure.

Reported-by: madhogs <59648482+madhogs@users.noreply.github.com>
Fixed-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Tested-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Tested-on-hardware-by: madhogs <59648482+madhogs@users.noreply.github.com>
Signed-off-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
GitHub-Issue: https://github.com/joeycastillo/Sensor-Watch/issues/384
2024-03-17 20:48:54 -03:00
Matheus Afonso Martins Moreira 955ac94de3 faces: restore simple_clock_face
Restore the original simple clock face as requested.
2024-03-16 20:04:08 -03:00
Alex Maestas 40b71400c5 uf2conv: argument to re.split should be a rawstring 2024-03-16 16:50:55 +00:00
Matheus Afonso Martins Moreira 8bf652f213 Merge branch 'timeout-event-and-sleep-logic'
Currently, movement drops timeout events in case the previous loop
indicates that sleep is not possible. This is due to unintended
short circuiting behavior of && and is fixed with a temporary variable.

The static qualifier of can_sleep is also removed.

Helped-by: Alex Maestas <git@se30.xyz>
Tested-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Tested-on-hardware-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Signed-off-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/376
2024-03-08 06:56:55 -03:00
Matheus Afonso Martins Moreira ca40d101d3 Merge branch 'structured-totp+maxz' into advanced
Aggregates the TOTP credentials into a data structure,
making it easier to define and use the credentials.
Also incorporate backwards movement code from another branch.

Co-authored-by: Max Zettlmeißl <max@zettlmeissl.de>
Tested-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Tested-on-hardware-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Signed-off-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/369
GitHub-Related-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/356
2024-03-08 06:56:31 -03:00
Matheus Afonso Martins Moreira 66796805ac Merge branch 'advanced-pulsometer' into advanced
Implements an advanced pulsometer that can be calibrated by the user.
Also features a streamlined and responsive user interface,
new documentation and generally improved code.

Tested-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Tested-on-hardware-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Signed-off-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/371
2024-03-08 06:54:50 -03:00
Matheus Afonso Martins Moreira 4b269c5063 Merge branch 'advanced-clock+24h' into advanced
Completely refactors the simple clock face
and lays the foundations for new features.

Also adds a compile time 24 hour mode only feature.

Tested-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Tested-on-hardware-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Signed-off-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/373
2024-03-08 06:54:22 -03:00
Matheus Afonso Martins Moreira 7208df1dfb Merge branch 'moon-phase-face-long-press-reset'
Makes a long press of the ALARM button reset the face to current day.

Reviewed-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Tested-by: Wesley Aptekar-Cassels <me@wesleyac.com>
Tested-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Tested-on-hardware-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Signed-off-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/316
2024-03-08 06:52:49 -03:00
Matheus Afonso Martins Moreira f35cb849de Merge branch 'compile-time-preferences'
Adds overridable C preprocessor definitions for every user preference.
Enables the user to set defaults and omit the preferences face.

The default behavior of the watch is preserved.

Suggested-by: Wesley Aptekar-Cassels <me@wesleyac.com>
Implemented-by: madhogs <x3dh4vhf@duck.com>
Reviewed-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Tested-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Tested-on-hardware-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Signed-off-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/295
GitHub-Related-Issue: https://github.com/joeycastillo/Sensor-Watch/issues/291
2024-03-08 06:52:22 -03:00
Matheus Afonso Martins Moreira 35c0a4be87 Merge branch 'usb-improvements' into advanced
- Change newline prints to also send carriage return
 - Introduce shell module for serial shell with argument parsing
 - Introduce shell command list for compile time command registration
 - Refactor file system commands for shell subsystem
 - Introduce new shell commands:
   - 'help' command
   - 'flash' command to reset into bootloader
   - 'stress' tests CDC serial writes of various lengths
     - optional delay parameter
 - Harden USB handling
   - Hangs less
   - Drops fewer inputs
 - Circular buffers for both reads and writes

Reported-by: Edward Shin <contact@edwardsh.in>
Tested-by: Edward Shin <contact@edwardsh.in>
Tested-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Tested-on-hardware-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Reviewed-by: James Haggerty <james@gruemail.com>
Reviewed-by: Wesley Aptekar-Cassels <me@wesleyac.com>
Reviewed-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Signed-off-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/344
2024-03-08 06:51:34 -03:00
Matheus Afonso Martins Moreira 592e18bf0e Merge branch 'silicon-errata' into advanced
Implements the recommended workarounds for numerous silicon errata,
reducing power consumption and preventing freezes and hard faults.

Tested-by: Alex Maestas <git@se30.xyz>
Tested-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Tested-on-hardware-by: Alex Maestas <git@se30.xyz>
Tested-on-hardware-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Reviewed-by: Wesley Aptekar-Cassels <me@wesleyac.com>
Reviewed-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Signed-off-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/340
GitHub-Related-Issue: https://github.com/joeycastillo/Sensor-Watch/issues/361
GitHub-Related-Issue: https://github.com/joeycastillo/Sensor-Watch/issues/359
Reference: https://ww1.microchip.com/downloads/aemDocuments/documents/MCU32/ProductDocuments/Errata/SAM-L22-Family-Silicon-Errata-and-Data-Sheet-Clarification-DS80000782.pdf
2024-03-08 06:50:16 -03:00
Matheus Afonso Martins Moreira a4ee7dd7fc Merge 'fix-sunrise-sunset-uninitialized'
Fixes a crash due to use of uninitialized buffer when setting location.

Reported-by: eshrh <esrh@gatech.edu>
Fixed-by: Wesley Aptekar-Cassels <me@wesleyac.com>
Reviewed-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Tested-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Tested-on-hardware-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Signed-off-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/329
GitHub-Issue: https://github.com/joeycastillo/Sensor-Watch/issues/198
Fixes: https://github.com/joeycastillo/Sensor-Watch/issues/198
2024-03-08 06:49:18 -03:00
Matheus Afonso Martins Moreira b1adbd548e movement: fix unintended timeout short circuiting
Currently, movement drops time out events in case the previous loop
indicates that sleep is not possible due to short circuiting behavior
of logical and in C: if the left-hand side is false, the right hand
side is not evaluated at all, which means the loop is not called.
This was not intended to happen.

Fix it by storing the result in a second boolean variable
and working out the logic after the fact.
2024-03-05 21:49:32 -03:00
Matheus Afonso Martins Moreira 6ca553e648 movement: convert can_sleep an automatic variable
It is a simple boolean value and its scope is limited to the function.
There is no reason that I can think of for it to be a static variable.
2024-03-05 21:08:10 -03:00
Matheus Afonso Martins Moreira fb3b96c8b7 faces/pulsometer: remember pulsometer measurement
Avoid resetting it to zero when the face is activated.
Initialize the variables once when the face is first set up.

This makes it remember the last measurement taken by the user.
It will no longer be overwritten when the watch face activates.
2024-03-05 04:41:58 -03:00
Matheus Afonso Martins Moreira e1b1493894 faces/pulsometer: remember pulsometer calibration
Avoid resetting it to default when the face is activated.
Set the default pulsometer calibration once,
only when the face is first set up.

This makes it remember the calibration set by the user.
It will no longer overwrite it.
2024-03-05 04:14:10 -03:00
Matheus Afonso Martins Moreira 92baa2200f faces/totp: update copyrights
Update the copyrights to include full name attribution
to Max Zettlmeißl whose code I've incorporated and who
has explicitly licensed it as MIT.

Max Zettlmeißl (@maxz) commented on 2024-01-20:

> I provide all my changes under the MIT license

GitHub-Comment: https://github.com/joeycastillo/Sensor-Watch/pull/356#issuecomment-1902114306
2024-03-05 03:58:09 -03:00
Max Zettlmeißl 26e1b7bdc4 faces/totp: allow moving backwards through codes
Adds the ability to cycle back to the previous credential with LIGHT.
Long pressing LIGHT activates the LED.

Co-authored-by: Matheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
2024-03-05 03:58:09 -03:00
Matheus Afonso Martins Moreira 4a66035f77 faces/clock: add 24h only feature
The clock watch face can now be configured at build time
to only display the time in 24h mode. Also enabled in forced 24h mode.

This should result in smaller code size due to dead code elimination.
2024-03-05 00:46:27 -03:00
Matheus Afonso Martins Moreira 4cca3a0fac faces/clock: update copyrights and credits
Update the copyrights to include full name attribution to all
who contributed to the clock watch face, including myself.

Also add an SPDX license identifier header comment to the files.
2024-03-05 00:46:27 -03:00
Matheus Afonso Martins Moreira 4633be0845 faces/totp: delete leading underscores
Makes for cleaner symbols.
2024-02-25 22:57:47 -03:00