From b8de35658ffd78ad8b22f91ccbbd3d63663afda9 Mon Sep 17 00:00:00 2001 From: Alexsander Akers Date: Tue, 25 Jan 2022 15:03:22 -0500 Subject: Sensor Watch Simulator (#35) * Put something on screen * Use the 32bit watch_date_time repr to pass from JS * Implement periodic callbacks * Clear display on enabling * Hook up watch_set_led_color() to SVG (green-only) * Make debug output full-width * Remove default Emscripten canvas * Implement sleep and button clicks * Fix time zone conversion bug in beats-time app * Clean up warnings * Fix pin levels * Set time zone to browser value (if available) * Add basic backup data saving * Silence format specifier warnings in both targets * Remove unnecessary, copied files * Use RTC pointer to clear callbacks (if available) * Use preprocessor define to avoid hardcoding MOVEMENT_NUM_FACES * Change each face to const preprocessor definition * Remove Intl.DateTimeFormat usage * Update shell.html title, header * Add touch start/end event handlers on SVG buttons * Update shell.html * Update folder structure (shared, simulator, hardware under watch-library) * Tease out shared components from watch_slcd * Clean up simulator watch_slcd.c inline JS calls * Fix missing newlines at end of file * Add simulator warnings (except format, unused-paremter) * Implement remaining watch_rtc functions * Fix button bug on mouse down then drag out * Implement remaining watch_slcd functions * Link keyboard events to buttons (for keys A, L, M) * Rewrite event handling (mouse, touch, keyboard) in C * Set explicit text UTF-8 charset in shell.html * Address PR comments * Remove unused directories from include paths --- movement/watch_faces/complications/beats_face.c | 4 ++-- movement/watch_faces/complications/beats_face.h | 14 +++++++------- movement/watch_faces/complications/blinky_face.h | 16 ++++++++-------- movement/watch_faces/complications/countdown_face.h | 14 +++++++------- movement/watch_faces/complications/day_one_face.c | 2 +- movement/watch_faces/complications/day_one_face.h | 14 +++++++------- movement/watch_faces/complications/pulsometer_face.h | 16 ++++++++-------- movement/watch_faces/complications/stopwatch_face.h | 16 ++++++++-------- movement/watch_faces/complications/sunrise_sunset_face.h | 14 +++++++------- movement/watch_faces/complications/totp_face.h | 14 +++++++------- 10 files changed, 62 insertions(+), 62 deletions(-) (limited to 'movement/watch_faces/complications') diff --git a/movement/watch_faces/complications/beats_face.c b/movement/watch_faces/complications/beats_face.c index d1466b33..df31ad1c 100644 --- a/movement/watch_faces/complications/beats_face.c +++ b/movement/watch_faces/complications/beats_face.c @@ -45,7 +45,7 @@ bool beats_face_loop(movement_event_t event, movement_settings_t *settings, void state->next_subsecond_update = (event.subsecond + 1 + (BEAT_REFRESH_FREQUENCY * 2 / 3)) % BEAT_REFRESH_FREQUENCY; state->last_centibeat_displayed = centibeats; } - sprintf(buf, "bt %6ld", centibeats); + sprintf(buf, "bt %6lu", centibeats); watch_display_string(buf, 0); break; @@ -53,7 +53,7 @@ bool beats_face_loop(movement_event_t event, movement_settings_t *settings, void if (!watch_tick_animation_is_running()) watch_start_tick_animation(432); date_time = watch_rtc_get_date_time(); centibeats = clock2beats(date_time.unit.hour, date_time.unit.minute, date_time.unit.second, event.subsecond, movement_timezone_offsets[settings->bit.time_zone]); - sprintf(buf, "bt %4ld ", centibeats / 100); + sprintf(buf, "bt %4lu ", centibeats / 100); watch_display_string(buf, 0); break; diff --git a/movement/watch_faces/complications/beats_face.h b/movement/watch_faces/complications/beats_face.h index f11126d1..2bbbc26d 100644 --- a/movement/watch_faces/complications/beats_face.h +++ b/movement/watch_faces/complications/beats_face.h @@ -14,12 +14,12 @@ void beats_face_activate(movement_settings_t *settings, void *context); bool beats_face_loop(movement_event_t event, movement_settings_t *settings, void *context); void beats_face_resign(movement_settings_t *settings, void *context); -static const watch_face_t beats_face = { - beats_face_setup, - beats_face_activate, - beats_face_loop, - beats_face_resign, - NULL -}; +#define beats_face ((const watch_face_t){ \ + beats_face_setup, \ + beats_face_activate, \ + beats_face_loop, \ + beats_face_resign, \ + NULL, \ +}) #endif // BEATS_FACE_H_ \ No newline at end of file diff --git a/movement/watch_faces/complications/blinky_face.h b/movement/watch_faces/complications/blinky_face.h index 14f0e143..e966ab1d 100644 --- a/movement/watch_faces/complications/blinky_face.h +++ b/movement/watch_faces/complications/blinky_face.h @@ -38,12 +38,12 @@ void blinky_face_activate(movement_settings_t *settings, void *context); bool blinky_face_loop(movement_event_t event, movement_settings_t *settings, void *context); void blinky_face_resign(movement_settings_t *settings, void *context); -static const watch_face_t blinky_face = { - blinky_face_setup, - blinky_face_activate, - blinky_face_loop, - blinky_face_resign, - NULL -}; +#define blinky_face ((const watch_face_t){ \ + blinky_face_setup, \ + blinky_face_activate, \ + blinky_face_loop, \ + blinky_face_resign, \ + NULL, \ +}) -#endif // BLINKY_FACE_H_ \ No newline at end of file +#endif // BLINKY_FACE_H_ diff --git a/movement/watch_faces/complications/countdown_face.h b/movement/watch_faces/complications/countdown_face.h index 1a5d2c78..657c6377 100644 --- a/movement/watch_faces/complications/countdown_face.h +++ b/movement/watch_faces/complications/countdown_face.h @@ -58,12 +58,12 @@ void countdown_face_activate(movement_settings_t *settings, void *context); bool countdown_face_loop(movement_event_t event, movement_settings_t *settings, void *context); void countdown_face_resign(movement_settings_t *settings, void *context); -static const watch_face_t countdown_face = { - countdown_face_setup, - countdown_face_activate, - countdown_face_loop, - countdown_face_resign, - NULL -}; +#define countdown_face ((const watch_face_t){ \ + countdown_face_setup, \ + countdown_face_activate, \ + countdown_face_loop, \ + countdown_face_resign, \ + NULL, \ +}) #endif // COUNTDOWN_FACE_H_ diff --git a/movement/watch_faces/complications/day_one_face.c b/movement/watch_faces/complications/day_one_face.c index 18d02d4d..99433990 100644 --- a/movement/watch_faces/complications/day_one_face.c +++ b/movement/watch_faces/complications/day_one_face.c @@ -37,7 +37,7 @@ static void _day_one_face_update(day_one_state_t state) { watch_date_time date_time = watch_rtc_get_date_time(); uint32_t julian_date = _day_one_face_juliandaynum(date_time.unit.year + WATCH_RTC_REFERENCE_YEAR, date_time.unit.month, date_time.unit.day); uint32_t julian_birthdate = _day_one_face_juliandaynum(state.birth_year, state.birth_month, state.birth_day); - sprintf(buf, "DA %6ld", julian_date - julian_birthdate); + sprintf(buf, "DA %6lu", julian_date - julian_birthdate); watch_display_string(buf, 0); } diff --git a/movement/watch_faces/complications/day_one_face.h b/movement/watch_faces/complications/day_one_face.h index f39c7927..ab8372bf 100644 --- a/movement/watch_faces/complications/day_one_face.h +++ b/movement/watch_faces/complications/day_one_face.h @@ -44,12 +44,12 @@ void day_one_face_activate(movement_settings_t *settings, void *context); bool day_one_face_loop(movement_event_t event, movement_settings_t *settings, void *context); void day_one_face_resign(movement_settings_t *settings, void *context); -static const watch_face_t day_one_face = { - day_one_face_setup, - day_one_face_activate, - day_one_face_loop, - day_one_face_resign, - NULL -}; +#define day_one_face ((const watch_face_t){ \ + day_one_face_setup, \ + day_one_face_activate, \ + day_one_face_loop, \ + day_one_face_resign, \ + NULL, \ +}) #endif // DAY_ONE_FACE_H_ diff --git a/movement/watch_faces/complications/pulsometer_face.h b/movement/watch_faces/complications/pulsometer_face.h index 65188604..600201e9 100644 --- a/movement/watch_faces/complications/pulsometer_face.h +++ b/movement/watch_faces/complications/pulsometer_face.h @@ -38,12 +38,12 @@ void pulsometer_face_activate(movement_settings_t *settings, void *context); bool pulsometer_face_loop(movement_event_t event, movement_settings_t *settings, void *context); void pulsometer_face_resign(movement_settings_t *settings, void *context); -static const watch_face_t pulsometer_face = { - pulsometer_face_setup, - pulsometer_face_activate, - pulsometer_face_loop, - pulsometer_face_resign, - NULL -}; +#define pulsometer_face ((const watch_face_t){ \ + pulsometer_face_setup, \ + pulsometer_face_activate, \ + pulsometer_face_loop, \ + pulsometer_face_resign, \ + NULL, \ +}) -#endif // PULSOMETER_FACE_H_ \ No newline at end of file +#endif // PULSOMETER_FACE_H_ diff --git a/movement/watch_faces/complications/stopwatch_face.h b/movement/watch_faces/complications/stopwatch_face.h index ff0c1796..c6e3aadb 100644 --- a/movement/watch_faces/complications/stopwatch_face.h +++ b/movement/watch_faces/complications/stopwatch_face.h @@ -15,12 +15,12 @@ void stopwatch_face_activate(movement_settings_t *settings, void *context); bool stopwatch_face_loop(movement_event_t event, movement_settings_t *settings, void *context); void stopwatch_face_resign(movement_settings_t *settings, void *context); -static const watch_face_t stopwatch_face = { - stopwatch_face_setup, - stopwatch_face_activate, - stopwatch_face_loop, - stopwatch_face_resign, - NULL -}; +#define stopwatch_face ((const watch_face_t){ \ + stopwatch_face_setup, \ + stopwatch_face_activate, \ + stopwatch_face_loop, \ + stopwatch_face_resign, \ + NULL, \ +}) -#endif // STOPWATCH_FACE_H_ \ No newline at end of file +#endif // STOPWATCH_FACE_H_ diff --git a/movement/watch_faces/complications/sunrise_sunset_face.h b/movement/watch_faces/complications/sunrise_sunset_face.h index 196b9db0..826d5e95 100644 --- a/movement/watch_faces/complications/sunrise_sunset_face.h +++ b/movement/watch_faces/complications/sunrise_sunset_face.h @@ -52,12 +52,12 @@ void sunrise_sunset_face_activate(movement_settings_t *settings, void *context); bool sunrise_sunset_face_loop(movement_event_t event, movement_settings_t *settings, void *context); void sunrise_sunset_face_resign(movement_settings_t *settings, void *context); -static const watch_face_t sunrise_sunset_face = { - sunrise_sunset_face_setup, - sunrise_sunset_face_activate, - sunrise_sunset_face_loop, - sunrise_sunset_face_resign, - NULL -}; +#define sunrise_sunset_face ((const watch_face_t){ \ + sunrise_sunset_face_setup, \ + sunrise_sunset_face_activate, \ + sunrise_sunset_face_loop, \ + sunrise_sunset_face_resign, \ + NULL, \ +}) #endif // SUNRISE_SUNSET_FACE_H_ diff --git a/movement/watch_faces/complications/totp_face.h b/movement/watch_faces/complications/totp_face.h index 1e2c5c02..dfa4a6d0 100644 --- a/movement/watch_faces/complications/totp_face.h +++ b/movement/watch_faces/complications/totp_face.h @@ -15,12 +15,12 @@ void totp_face_activate(movement_settings_t *settings, void *context); bool totp_face_loop(movement_event_t event, movement_settings_t *settings, void *context); void totp_face_resign(movement_settings_t *settings, void *context); -static const watch_face_t totp_face = { - totp_face_setup, - totp_face_activate, - totp_face_loop, - totp_face_resign, - NULL -}; +#define totp_face ((const watch_face_t){ \ + totp_face_setup, \ + totp_face_activate, \ + totp_face_loop, \ + totp_face_resign, \ + NULL, \ +}) #endif // TOTP_FACE_H_ -- cgit v1.2.3