summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #383 from theAlexes/theAlexes/fix-uf2convmainatax1a2024-03-311-1/+1
|\ | | | | uf2conv: argument to `re.split` should be a rawstring
| * uf2conv: argument to `re.split` should be a rawstringAlex Maestas2024-03-161-1/+1
| |
* | Merge pull request #385 from matheusmoreira/totp-hot-patchatax1a2024-03-312-32/+95
|\ \ | | | | | | TOTP hotfix: reduce memory usage
| * | faces/totp: avoid displaying when key is invalidMatheus Afonso Martins Moreira2024-03-201-9/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | faces/totp: fix error message not displayed bugMatheus Afonso Martins Moreira2024-03-201-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | faces/totp: remove dynamic memory allocationMatheus Afonso Martins Moreira2024-03-181-39/+58
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | faces/totp: improve memory usageMatheus Afonso Martins Moreira2024-03-172-34/+73
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | faces: restore simple_clock_faceMatheus Afonso Martins Moreira2024-03-165-1/+226
| | | | | | | | Restore the original simple clock face as requested.
* | Merge branch 'timeout-event-and-sleep-logic'Matheus Afonso Martins Moreira2024-03-081-2/+3
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | movement: fix unintended timeout short circuitingMatheus Afonso Martins Moreira2024-03-051-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | movement: convert can_sleep an automatic variableMatheus Afonso Martins Moreira2024-03-051-1/+1
| |/ | | | | | | | | 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.
* | Merge branch 'structured-totp+maxz' into advancedMatheus Afonso Martins Moreira2024-03-084-36/+117
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | faces/totp: update copyrightsMatheus Afonso Martins Moreira2024-03-052-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | faces/totp: allow moving backwards through codesMax Zettlmeißl2024-03-054-2/+35
| | | | | | | | | | | | | | | | | | | | | 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>
| * | faces/totp: delete leading underscoresMatheus Afonso Martins Moreira2024-02-251-7/+7
| | | | | | | | | | | | Makes for cleaner symbols.
| * | faces/totp: rename initializer macro to credentialMatheus Afonso Martins Moreira2024-02-251-3/+3
| | | | | | | | | | | | Shorter and far more expressive.
| * | faces/totp: improve TOTP initializer labelingMatheus Afonso Martins Moreira2024-02-251-4/+4
| | | | | | | | | | | | | | | It now generates the string literal from the preprocessor token. Even warns the user if the string is too long!
| * | faces/totp: decode secrets when setting upMatheus Afonso Martins Moreira2024-02-251-19/+32
| | | | | | | | | | | | | | | | | | | | | | | | This allows the user to easily copy the base32 encoded secrets into the TOTP record initializers. They will be decoded once at runtime when the face is being set up by the movement framework. Also rename the array of TOTP records to credentials. Much better.
| * | faces/totp: update copyright and license dataMatheus Afonso Martins Moreira2024-02-212-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | Update the copyrights to include full name attribution to all who contributed to this watch face, including myself. Also add an SPDX license identifier header comment to the files. https://spdx.org/licenses/MIT.html
| * | faces/totp: delete unused structure fieldMatheus Afonso Martins Moreira2024-02-201-1/+0
| | | | | | | | | | | | | | | The TOTP watch face now keeps track of each key separately. There is no need to compute offsets at runtime.
| * | faces/totp: update watch face logic for new structMatheus Afonso Martins Moreira2024-02-201-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using the new structured TOTP record data structure allows the TOTP watch face to statically and implicitly compute the total number of defined TOTP records. Users can now simply add new keys and records in the designated area and the watch face will compile and automatically use them with no need to maintain a separate array size variable. Less chance of mistakes.
| * | faces/totp: define current TOTP data functionMatheus Afonso Martins Moreira2024-02-201-0/+4
| | | | | | | | | | | | | | | Selects the appropriate TOTP data structure given the TOTP watch face state.
| * | faces/totp: define TOTP data array size functionMatheus Afonso Martins Moreira2024-02-201-0/+4
| | | | | | | | | | | | | | | Computes the size of the array of TOTP records. The compiler will likely evaluate it at compile time.
| * | faces/totp: update example data to new structureMatheus Afonso Martins Moreira2024-02-201-17/+10
| | | | | | | | | | | | The data definitions are much shorter and easier to read now.
| * | faces/totp: define TOTP struct initializer macroMatheus Afonso Martins Moreira2024-02-201-0/+9
| | | | | | | | | | | | | | | Generates a compound initializer for the given TOTP parameters. Lessens repetition and allows functional definitions of TOTP records.
| * | faces/totp: define TOTP data structureMatheus Afonso Martins Moreira2024-02-201-0/+8
| |/ | | | | | | Aggregates all the data necessary for TOTP generation.
* | Merge branch 'advanced-pulsometer' into advancedMatheus Afonso Martins Moreira2024-03-082-74/+178
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | faces/pulsometer: remember pulsometer measurementMatheus Afonso Martins Moreira2024-03-051-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | faces/pulsometer: remember pulsometer calibrationMatheus Afonso Martins Moreira2024-03-051-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | faces/pulsometer: move structure definitionMatheus Afonso Martins Moreira2024-02-242-7/+7
| | | | | | | | | | | | | | | | | | | | | Instances of the pulsometer state structure are only passed to the pulsometer itself and only via the opaque context pointer. No other code uses it. There is no need to expose it in a header file so make it an implementation detail of the watch face.
| * | faces/pulsometer: update copyrights and creditsMatheus Afonso Martins Moreira2024-02-242-2/+11
| | | | | | | | | | | | | | | | | | | | | Update the copyrights to include full name attribution to all who contributed to the pulsometer watch face, including myself. Also add an SPDX license identifier header comment to the files.
| * | faces/pulsometer: document the advanced pulsometerMatheus Afonso Martins Moreira2024-02-241-22/+34
| | | | | | | | | | | | | | | Thoroughly document the new advanced pulsometer watch face by describing what it is and how it works.
| * | faces/pulsometer: implement advanced pulsometerMatheus Afonso Martins Moreira2024-02-242-45/+125
| |/ | | | | | | | | | | | | | | | | | | | | | | Implements an advanced pulsometer that can be recalibrated by the user. The main clock face now displays the measured pulses per minute. The day of month digits now display the pulsometer calibration. The light button now cycles through integer graduations which now range from 1 to 39 pulses per minute. Long presses of the light button cycle by 10 instead of 1. The watch face's responsiveness to input has been carefully optimized. The code has been reorganized and generally improved.
* | Merge branch 'advanced-clock+24h' into advancedMatheus Afonso Martins Moreira2024-03-087-190/+324
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | faces/clock: add 24h only featureMatheus Afonso Martins Moreira2024-03-052-2/+17
| | | | | | | | | | | | | | | | | | | | | 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.
| * | faces/clock: update copyrights and creditsMatheus Afonso Martins Moreira2024-03-052-2/+16
| | | | | | | | | | | | | | | | | | | | | 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.
| * | faces/clock: indicate low power only when neededMatheus Afonso Martins Moreira2024-02-251-5/+6
| | | | | | | | | | | | | | | There is no need to set the indicator on every clock tick. Indicate only when the battery is checked.
| * | faces/clock: indicate alarm only when necessaryMatheus Afonso Martins Moreira2024-02-251-2/+0
| | | | | | | | | | | | | | | The alarm state is not modified within the clock face. Therefore, it only needs to be set when the face is activated.
| * | faces/clock: refactor time signal toggling codeMatheus Afonso Martins Moreira2024-02-251-2/+6
| | | | | | | | | | | | Simplifies the code by defining dedicated functions for this.
| * | faces/clock: refactor clock display codeMatheus Afonso Martins Moreira2024-02-251-14/+20
| | | | | | | | | | | | Simplifies the code by defining dedicated functions for this.
| * | faces/clock: reorder periodic battery checkMatheus Afonso Martins Moreira2024-02-251-3/+2
| | | | | | | | | | | | | | | Check the battery after the time has been updated. Place all the indication code next to each other.
| * | faces/clock: refactor partial time display codeMatheus Afonso Martins Moreira2024-02-251-24/+40
| | | | | | | | | | | | Simplifies the code by defining dedicated functions for this.
| * | faces/clock: refactor full time display codeMatheus Afonso Martins Moreira2024-02-251-1/+19
| | | | | | | | | | | | Simplifies the code by defining dedicated functions for this.
| * | faces/clock: refactor tick tock animation codeMatheus Afonso Martins Moreira2024-02-251-3/+15
| | | | | | | | | | | | Simplifies the code by defining dedicated functions for this.
| * | faces/clock: refactor low power tick functionMatheus Afonso Martins Moreira2024-02-251-12/+26
| | | | | | | | | | | | | | | | | | | | | Simplifies the code by defining dedicated functions and separating the case from the main ones. Also use the snprintf function since the buffer size is known.
| * | faces/clock: simplify LAP indication functionMatheus Afonso Martins Moreira2024-02-251-3/+6
| | | | | | | | | | | | | | | Simplifies the code by adding a dedicated function for this. Also documents the meaning of the LAP indicator: Low Available Power.
| * | faces/clock: refactor daily battery checkMatheus Afonso Martins Moreira2024-02-251-11/+21
| | | | | | | | | | | | | | | Move the code in question to a dedicated function. Better organized. Add overridable preprocessor definition for the low battery threshold.
| * | faces/clock: simplify PM indication functionMatheus Afonso Martins Moreira2024-02-251-7/+21
| | | | | | | | | | | | Simplifies the code by adding dedicated functions for this.
| * | faces/clock: simplify 24h indication functionMatheus Afonso Martins Moreira2024-02-251-2/+5
| | | | | | | | | | | | Simplifies the code by adding a dedicated function for this.
| * | faces/clock: simplify signal indication functionMatheus Afonso Martins Moreira2024-02-251-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Simplifies the code and makes it use the correct indicator. For some reason it had been switched with the alarm indicator. WATCH_INDICATOR_BELL The small bell indicating that an alarm is set. WATCH_INDICATOR_SIGNAL The hourly signal indicator. Also useful for indicating that sensors are on.