Commit graph

141 commits

Author SHA1 Message Date
Matheus Afonso Martins Moreira fe9a0a693d Revert PR #268 - add daylight savings time toggle
The DST code has not yet been fully tested, the upcoming movement
refactor is upon us and it will integrate with the micro timezone
library anyway. Revert it so that next can be merged into main.

This reverts commit 5a8a49a8c7, reversing
changes made to bfadb81e82.
2024-09-17 17:28:41 -03:00
Matheus Afonso Martins Moreira a9d503b807 Revert PR #470 - implement automatic DST toggling
The DST code has not yet been fully tested, the upcoming movement
refactor is upon us and it will integrate with the micro timezone
library anyway. Revert it so that next can be merged into main.

This reverts commit ac5bf8cfce, reversing
changes made to 5a8a49a8c7.
2024-09-17 17:28:32 -03:00
Matheus Afonso Martins Moreira c9cbb82163 Revert merge of PR #437 - debouncing logic
This reverts commit a715265af6, reversing
changes made to 9c093f9540.

Insidious issues were found in the course of long term testing
by the community, and further reviews of the code were not enough
to pinpoint the issue and fix it. So for now the appropriate action
is to revert these changes while development continues, and possibly
merge them back in once they have been stabilized.

Tested-on-hardware-by: David Volovskiy <devolov@gmail.com>
Tested-on-hardware-by: CarpeNoctem <cryptomax@pm.me>
Tested-on-hardware-by: Krzysztof Gałka <@kshysztof@Discord>
2024-09-15 21:00:22 -03:00
Matheus Afonso Martins Moreira be969c4deb Revert PR #387 - fixes LE state restoration
This commit caused state restored from backup registers
to be overwritten. It is thereby reverted until a better
solution is found or movement is refactored.

This reverts commit 524098b925.

Reviewed-by: Matheus Afonso Martins Moreira <matheus@matheusmoreira.com>
References: https://github.com/joeycastillo/Sensor-Watch/pull/474
2024-09-10 12:10:48 -03:00
Matheus Afonso Martins Moreira ac5bf8cfce Merge PR #470 - implement automatic DST toggling
Implements logic to automatically offset daylight saving time settings
when calculating timezone offsets. This should make the DST functions
work automatically with no need for user input in most cases.

Reviewed-by: Matheus Afonso Martins Moreira <matheus@matheusmoreira.com>
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/470
2024-09-08 13:41:52 -03:00
David Volovskiy 5ae88e438d Minot cleanup 2024-09-08 10:50:09 -04:00
Matheus Afonso Martins Moreira 5a8a49a8c7 Merge PR #268 - add daylight savings time toggle
Adds a toggle in the preferences face that allows the user
to enable or disable the daylight savings time.

Should help produce the correct results with the sunrise/sunset presets.

A proper solution would be to integrate the tzinfo database
but it's too big for the watch at the time of this writing.
Can't be done unless it can be shrunk down into a subset
the user would be interested. Even then it's a stopgap
since the database is likely to keep growing over time.

Reviewed-by: Matheus Afonso Martins Moreira <matheus@matheusmoreira.com>
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/268
2024-09-08 11:09:10 -03:00
Matheus Afonso Martins Moreira 99586f8442 Merge PR #394 - keep LED lit while buttons held
Keeps the LED turned on while the user is interacting with the watch.

Reviewed-by: Matheus Afonso Martins Moreira <matheus@matheusmoreira.com>
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/394
2024-09-07 20:31:46 -03:00
Matheus Afonso Martins Moreira 014ef32576 Merge PR #293 - add instant LED duration
Adds an instant LED duration preference that only keeps the LED lit
while the LIGHT button remains held down.

Matches the behavior of the original watch.

Reviewed-by: Matheus Afonso Martins Moreira <matheus@matheusmoreira.com>
Tested-on-hardware-by: Wesley Aptekar-Cassels <me@wesleyac.com>
Tested-on-hardware-by: 814d3 (GitHub)
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/293
2024-09-03 19:06:40 -03:00
Matheus Afonso Martins Moreira 879c48ce4d Merge PR #417 - improve 24h only mode
Enhances 24 hour only mode by setting defaults properly
and skipping past the 12/24 hour settings page in the
preferences watch face.

Reviewed-by: Matheus Afonso Martins Moreira <matheus@matheusmoreira.com>
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/417
2024-08-30 16:47:47 -03:00
Matheus Afonso Martins Moreira a715265af6 Merge PR #437 - debouncing logic
Mechanical switches exhibit temporary voltage fluctuations
when electrical contact is made, which manifest as "bouncing"
between the logical high and low states. Sampling the switch's
state during this period of stability produces invalid results.

The switch must be debounced by ignoring the generated interrupts
until the switch's state has stabilized. This is implemented by delaying
the input events until an empirically determined time has elapsed.
As such this pull request introduces customizable high resolution timers
for debouncing button down and up events.

This software debouncing unfortunately increases the sensor watch's
input latency. This is an acceptable tradeoff due to better usability:
watch faces which require holding down buttons such as the pulsometer
should work much more reliably after this patch.

Reviewed-by: Matheus Afonso Martins Moreira <matheus@matheusmoreira.com>
Tested-on-hardware-by: Krzysztof Gałka <@kshysztof@Discord>
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/437
References: https://en.wikipedia.org/wiki/Switch#Contact_bounce
2024-08-30 16:44:38 -03:00
Matheus Moreira 9c093f9540 Merge PR #387 - configurable default birthdate/location
Adds the ability to configure at compilation time
the movement's default birth date and location.

Tested-by: madhogs <madhogs@protonmail.com>
Tested-by: Niehztog <niehztog@gmail.com>
Tested-on-hardware-by: madhogs <madhogs@protonmail.com>
Tested-on-hardware-by: Niehztog <niehztog@gmail.com>
Reviewed-by: Matheus Afonso Martins Moreira <matheus@matheusmoreira.com>
GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/387
2024-08-30 16:44:38 -03:00
David Volovskiy d5a8c57c82 Additional code review change 2024-08-23 22:25:02 -04:00
David Volovskiy c6f2bff75e Code review edits 2024-08-23 17:35:16 -04:00
Joseph Bryant 20b4a32835 make sure we don't miss our scheduled tasks 2024-08-18 20:09:06 +01:00
David Volovskiy e9837ff0cb Stops Running cb_fast_tick when the watch debounce timer is defined as 0 2024-08-17 02:52:30 -04:00
David Volovskiy 2cdfa2d3b3 Set the debounce tick variables to 0 to make the face work the same as stock. 2024-08-17 02:45:22 -04:00
David Volovskiy 9861da84c3 Changed debounce to ignore button presses after a press down or up rathe rthan dact after a set amount of time due to an issue of delay_ms allowing a shoft-bricking 2024-08-11 11:00:08 -04:00
David Volovskiy 598e876186 check_and_act_on_daylight_savings now only occurs in one spot 2024-08-04 10:11:33 -04:00
David Volovskiy 2824a62908 Bugfix on not registering the top of an hour 2024-08-04 09:53:04 -04:00
David Volovskiy aebea960c0 Cleanup to the default branch 2024-08-03 10:08:24 -04:00
David Volovskiy e50390b673 DST roll is now a global variable in watch_rtc 2024-08-03 10:07:57 -04:00
David Volovskiy fa2907e098 Some more cleanup 2024-08-03 09:38:00 -04:00
David Volovskiy 4c546b14dc The timezone now auto-corrects with DST (but still displays the same offset in the settings screen to the user) 2024-08-02 01:25:01 -04:00
David Volovskiy 149911e4ad Time now auto-updates with DST 2024-08-02 01:23:21 -04:00
David Volovskiy 7bbac4cd80 Brought debounce time to 8ms rather than 15 2024-07-31 07:33:25 -04:00
David Volovskiy 027e42dc58 Moved a few lines around to match main 2024-07-31 07:25:09 -04:00
David Volovskiy e297b3013e Using debounce that triggers when there's no change for Xms rather than just ignoring new presses after Xms 2024-07-31 07:22:33 -04:00
David Volovskiy 607946ed2e A little bit of clean-up 2024-07-30 07:27:47 -04:00
David Volovskiy f7d1b8f9f3 Delay for starting the debounce no loonger happens 2024-07-29 23:53:25 -04:00
David Volovskiy 7f2ac61375 Fixed stuck fast_tick 2024-07-29 21:43:32 -04:00
David Volovskiy 73c3ba3ae7 Cleaned up code 2024-07-29 21:05:19 -04:00
David Volovskiy 36117ca207 using cb_fast_tick again 2024-07-29 20:48:17 -04:00
David Volovskiy 9727dac3c3 Revert "Leaving sleep with alarm button up doesn't trigger alarm button"
This reverts commit 7d5aaf60ca.
2024-07-29 20:28:10 -04:00
David Volovskiy 947e299494 Made the debounce register rising edges rather than falling edges 2024-07-29 20:13:54 -04:00
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
James Haggerty 5f1a651732 Keep light on if interacting
This makes it possible to do a bunch of things without
having to keep touching the light button.

I don't really see any downside with this. If you want
the light to go off, just stop touching buttons.
2024-07-21 08:25:54 +10:00
David Volovskiy 2afc2c6721 isolating this bit of complexity in movement function; Add ifdefs in clock faces for DCE 2024-07-10 07:22:55 -04:00
David Volovskiy b923d50652 CLOCK_FACE_24H_ONLY hides the preference to change the setting and defaults the mode to 24Hr mode 2024-07-08 18:32:41 -04:00
R. Alex Barbieri e3d67af604 Merge remote-tracking branch 'origin/main' into manual_dst_toggle
* origin/main: (119 commits)
  add an openocd.cfg for openocd 0.12.0
  Fix compile errors and warnings in movement.c and shell.c
  faces/totp: avoid displaying when key is invalid
  faces/totp: fix error message not displayed bug
  faces/totp: remove dynamic memory allocation
  faces/totp: improve memory usage
  faces: restore simple_clock_face
  uf2conv: argument to `re.split` should be a rawstring
  movement: fix unintended timeout short circuiting
  movement: convert can_sleep an automatic variable
  faces/pulsometer: remember pulsometer measurement
  faces/pulsometer: remember pulsometer calibration
  faces/totp: update copyrights
  faces/totp: allow moving backwards through codes
  faces/clock: add 24h only feature
  faces/clock: update copyrights and credits
  faces/totp: delete leading underscores
  faces/totp: rename initializer macro to credential
  faces/totp: improve TOTP initializer labeling
  faces/totp: decode secrets when setting up
  ...
2024-04-27 13:23:53 -05:00
madhogs 524098b925 add the ability to set location and birthdate in movement config 2024-03-31 13:27:54 +01: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 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 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 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