]> git.earman.xyz Git - sensor-watch.git/commitdiff
faces/totp: define TOTP struct initializer macro
authorMatheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Wed, 21 Feb 2024 02:12:53 +0000 (23:12 -0300)
committerMatheus Afonso Martins Moreira <matheus.a.m.moreira@gmail.com>
Wed, 21 Feb 2024 02:12:53 +0000 (23:12 -0300)
Generates a compound initializer for the given TOTP parameters.
Lessens repetition and allows functional definitions of TOTP records.

movement/watch_faces/complication/totp_face.c

index d634baa30de3966ed8ff46a15ce5f3366d5b176c..89619208686cf1885771110c95ad967209110ed8 100644 (file)
@@ -37,6 +37,15 @@ typedef struct {
     uint8_t *key;
 } totp_t;
 
+#define TOTP_INITIALIZER(label_1, label_2, key_array, algo, timestep) \
+    (const totp_t) { \
+        .key = (key_array), \
+        .key_length = sizeof(key_array), \
+        .period = (timestep), \
+        .labels = { (label_1), (label_2) }, \
+        .algorithm = (algo), \
+    }
+
 ////////////////////////////////////////////////////////////////////////////////
 // Enter your TOTP key data below
 static const uint8_t num_keys = 2;