From: Matheus Afonso Martins Moreira Date: Wed, 21 Feb 2024 02:12:53 +0000 (-0300) Subject: faces/totp: define TOTP struct initializer macro X-Git-Url: https://git.earman.xyz/?a=commitdiff_plain;h=8a7d9326cf274003a6e92c9ca800173ec7292fec;p=sensor-watch.git faces/totp: define TOTP struct initializer macro Generates a compound initializer for the given TOTP parameters. Lessens repetition and allows functional definitions of TOTP records. --- diff --git a/movement/watch_faces/complication/totp_face.c b/movement/watch_faces/complication/totp_face.c index d634baa..8961920 100644 --- a/movement/watch_faces/complication/totp_face.c +++ b/movement/watch_faces/complication/totp_face.c @@ -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;