From 67a1bfd6616ad738124753855c8edbb3426d7e06 Mon Sep 17 00:00:00 2001 From: EmilienCourt Date: Sun, 29 Jun 2025 19:25:42 +0200 Subject: [PATCH] bring totp_face into Second Movement --- Makefile | 10 ++++++++++ {legacy/lib => lib}/TOTP/LICENSE | 0 {legacy/lib => lib}/TOTP/README.md | 0 {legacy/lib => lib}/TOTP/TOTP.c | 0 {legacy/lib => lib}/TOTP/TOTP.h | 0 {legacy/lib => lib}/TOTP/example.c | 0 {legacy/lib => lib}/TOTP/sha1.c | 0 {legacy/lib => lib}/TOTP/sha1.h | 0 {legacy/lib => lib}/TOTP/sha256.c | 0 {legacy/lib => lib}/TOTP/sha256.h | 0 {legacy/lib => lib}/TOTP/sha512.c | 0 {legacy/lib => lib}/TOTP/sha512.h | 0 {legacy/lib => lib}/base32/base32.c | 0 {legacy/lib => lib}/base32/base32.h | 0 movement_faces.h | 1 + watch-faces.mk | 1 + .../complication/totp_face.c | 7 ++++--- .../complication/totp_face.h | 0 18 files changed, 16 insertions(+), 3 deletions(-) rename {legacy/lib => lib}/TOTP/LICENSE (100%) rename {legacy/lib => lib}/TOTP/README.md (100%) rename {legacy/lib => lib}/TOTP/TOTP.c (100%) rename {legacy/lib => lib}/TOTP/TOTP.h (100%) rename {legacy/lib => lib}/TOTP/example.c (100%) rename {legacy/lib => lib}/TOTP/sha1.c (100%) rename {legacy/lib => lib}/TOTP/sha1.h (100%) rename {legacy/lib => lib}/TOTP/sha256.c (100%) rename {legacy/lib => lib}/TOTP/sha256.h (100%) rename {legacy/lib => lib}/TOTP/sha512.c (100%) rename {legacy/lib => lib}/TOTP/sha512.h (100%) rename {legacy/lib => lib}/base32/base32.c (100%) rename {legacy/lib => lib}/base32/base32.h (100%) rename {legacy/watch_faces => watch-faces}/complication/totp_face.c (97%) rename {legacy/watch_faces => watch-faces}/complication/totp_face.h (100%) diff --git a/Makefile b/Makefile index cefb6988..7a469f35 100644 --- a/Makefile +++ b/Makefile @@ -67,6 +67,11 @@ INCLUDES += \ -I./filesystem \ -I./shell \ -I./lib/sunriset \ + -I./lib/sha1 \ + -I./lib/sha256 \ + -I./lib/sha512 \ + -I./lib/base32 \ + -I./lib/TOTP \ -I./lib/chirpy_tx \ -I./lib/base64 \ -I./watch-library/shared/watch \ @@ -89,6 +94,11 @@ SRCS += \ ./shell/shell.c \ ./shell/shell_cmd_list.c \ ./lib/sunriset/sunriset.c \ + ./lib/base32/base32.c \ + ./lib/TOTP/sha1.c \ + ./lib/TOTP/sha256.c \ + ./lib/TOTP/sha512.c \ + ./lib/TOTP/TOTP.c \ ./lib/chirpy_tx/chirpy_tx.c \ ./lib/base64/base64.c \ ./watch-library/shared/driver/thermistor_driver.c \ diff --git a/legacy/lib/TOTP/LICENSE b/lib/TOTP/LICENSE similarity index 100% rename from legacy/lib/TOTP/LICENSE rename to lib/TOTP/LICENSE diff --git a/legacy/lib/TOTP/README.md b/lib/TOTP/README.md similarity index 100% rename from legacy/lib/TOTP/README.md rename to lib/TOTP/README.md diff --git a/legacy/lib/TOTP/TOTP.c b/lib/TOTP/TOTP.c similarity index 100% rename from legacy/lib/TOTP/TOTP.c rename to lib/TOTP/TOTP.c diff --git a/legacy/lib/TOTP/TOTP.h b/lib/TOTP/TOTP.h similarity index 100% rename from legacy/lib/TOTP/TOTP.h rename to lib/TOTP/TOTP.h diff --git a/legacy/lib/TOTP/example.c b/lib/TOTP/example.c similarity index 100% rename from legacy/lib/TOTP/example.c rename to lib/TOTP/example.c diff --git a/legacy/lib/TOTP/sha1.c b/lib/TOTP/sha1.c similarity index 100% rename from legacy/lib/TOTP/sha1.c rename to lib/TOTP/sha1.c diff --git a/legacy/lib/TOTP/sha1.h b/lib/TOTP/sha1.h similarity index 100% rename from legacy/lib/TOTP/sha1.h rename to lib/TOTP/sha1.h diff --git a/legacy/lib/TOTP/sha256.c b/lib/TOTP/sha256.c similarity index 100% rename from legacy/lib/TOTP/sha256.c rename to lib/TOTP/sha256.c diff --git a/legacy/lib/TOTP/sha256.h b/lib/TOTP/sha256.h similarity index 100% rename from legacy/lib/TOTP/sha256.h rename to lib/TOTP/sha256.h diff --git a/legacy/lib/TOTP/sha512.c b/lib/TOTP/sha512.c similarity index 100% rename from legacy/lib/TOTP/sha512.c rename to lib/TOTP/sha512.c diff --git a/legacy/lib/TOTP/sha512.h b/lib/TOTP/sha512.h similarity index 100% rename from legacy/lib/TOTP/sha512.h rename to lib/TOTP/sha512.h diff --git a/legacy/lib/base32/base32.c b/lib/base32/base32.c similarity index 100% rename from legacy/lib/base32/base32.c rename to lib/base32/base32.c diff --git a/legacy/lib/base32/base32.h b/lib/base32/base32.h similarity index 100% rename from legacy/lib/base32/base32.h rename to lib/base32/base32.h diff --git a/movement_faces.h b/movement_faces.h index d57506fe..de97e043 100644 --- a/movement_faces.h +++ b/movement_faces.h @@ -51,4 +51,5 @@ #include "nanosec_face.h" #include "mars_time_face.h" #include "peek_memory_face.h" +#include "totp_face.h" // New includes go above this line. diff --git a/watch-faces.mk b/watch-faces.mk index b95f4220..1dd76250 100644 --- a/watch-faces.mk +++ b/watch-faces.mk @@ -11,6 +11,7 @@ SRCS += \ ./watch-faces/complication/sunrise_sunset_face.c \ ./watch-faces/complication/moon_phase_face.c \ ./watch-faces/complication/days_since_face.c \ + ./watch-faces/complication/totp_face.c \ ./watch-faces/demo/all_segments_face.c \ ./watch-faces/demo/character_set_face.c \ ./watch-faces/demo/light_sensor_face.c \ diff --git a/legacy/watch_faces/complication/totp_face.c b/watch-faces/complication/totp_face.c similarity index 97% rename from legacy/watch_faces/complication/totp_face.c rename to watch-faces/complication/totp_face.c index c159f596..b45c62f6 100644 --- a/legacy/watch_faces/complication/totp_face.c +++ b/watch-faces/complication/totp_face.c @@ -11,6 +11,7 @@ * Copyright © 2023 Jeremy O'Brien * Copyright © 2024 Matheus Afonso Martins Moreira (https://www.matheusmoreira.com/) * Copyright © 2024 Max Zettlmeißl + * Copyright © 2025 Emilien Court * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -124,7 +125,7 @@ static void totp_display_error(totp_state_t *totp_state) { totp_t *totp = totp_current(totp_state); snprintf(buf, sizeof(buf), "%c%c ERROR ", totp->labels[0], totp->labels[1]); - watch_display_string(buf, 0); + watch_display_text(0, buf); } static void totp_display_code(totp_state_t *totp_state) { @@ -141,7 +142,7 @@ static void totp_display_code(totp_state_t *totp_state) { valid_for = totp->period - result.rem; sprintf(buf, "%c%c%2d%06lu", totp->labels[0], totp->labels[1], valid_for, totp_state->current_code); - watch_display_string(buf, 0); + watch_display_text(0, buf); } static void totp_display(totp_state_t *totp_state) { @@ -158,7 +159,7 @@ static void totp_generate_and_display(totp_state_t *totp_state) { } static inline uint32_t totp_compute_base_timestamp() { - return watch_utility_date_time_to_unix_time(watch_rtc_get_date_time(), movement_get_current_timezone_offset()); + return watch_utility_date_time_to_unix_time(movement_get_utc_date_time(), 0); } void totp_face_setup(uint8_t watch_face_index, void ** context_ptr) { diff --git a/legacy/watch_faces/complication/totp_face.h b/watch-faces/complication/totp_face.h similarity index 100% rename from legacy/watch_faces/complication/totp_face.h rename to watch-faces/complication/totp_face.h