From 8e2bf8591a70742addfd169832f03aa76210961c Mon Sep 17 00:00:00 2001 From: Joey Castillo Date: Fri, 3 Dec 2021 11:30:36 -0500 Subject: movement: allow watch faces to request zero ticks --- movement/movement.c | 2 +- movement/movement_config.h | 1 + movement/watch_faces/demos/character_set_face.c | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'movement') diff --git a/movement/movement.c b/movement/movement.c index b41700b0..f627dbf5 100644 --- a/movement/movement.c +++ b/movement/movement.c @@ -104,7 +104,7 @@ void movement_request_tick_frequency(uint8_t freq) { RTC->MODE2.INTENCLR.reg = 0xFE; // disable all callbacks except the 128 Hz one movement_state.subsecond = 0; movement_state.tick_frequency = freq; - watch_rtc_register_periodic_callback(cb_tick, freq); + if (freq) watch_rtc_register_periodic_callback(cb_tick, freq); } void movement_illuminate_led() { diff --git a/movement/movement_config.h b/movement/movement_config.h index 2ef43ef0..b6b3c350 100644 --- a/movement/movement_config.h +++ b/movement/movement_config.h @@ -18,6 +18,7 @@ const watch_face_t watch_faces[] = { simple_clock_face, + character_set_face, preferences_face, set_time_face, }; diff --git a/movement/watch_faces/demos/character_set_face.c b/movement/watch_faces/demos/character_set_face.c index 7daea5a9..eabb133f 100644 --- a/movement/watch_faces/demos/character_set_face.c +++ b/movement/watch_faces/demos/character_set_face.c @@ -12,6 +12,7 @@ void character_set_face_activate(movement_settings_t *settings, void *context) { (void) settings; char *c = (char *)context; *c = '@'; + movement_request_tick_frequency(0); } bool character_set_face_loop(movement_event_t event, movement_settings_t *settings, void *context) { @@ -33,8 +34,6 @@ bool character_set_face_loop(movement_event_t event, movement_settings_t *settin sprintf(buf, "%c%c%c%c%c%c%c%c%c%c", *c, *c, *c, *c, *c, *c, *c, *c, *c, *c); watch_display_string(buf, 0); break; - case EVENT_TICK: - break; case EVENT_TIMEOUT: movement_move_to_face(0); break; @@ -48,4 +47,5 @@ bool character_set_face_loop(movement_event_t event, movement_settings_t *settin void character_set_face_resign(movement_settings_t *settings, void *context) { (void) settings; (void) context; + movement_request_tick_frequency(1); } -- cgit v1.2.3 From 5a6bf6bfe24c4631a02e53b06f352b654b147dba Mon Sep 17 00:00:00 2001 From: Joey Castillo Date: Fri, 3 Dec 2021 19:06:25 -0500 Subject: movement: remove testing watch face from config --- movement/movement_config.h | 1 - 1 file changed, 1 deletion(-) (limited to 'movement') diff --git a/movement/movement_config.h b/movement/movement_config.h index b6b3c350..2ef43ef0 100644 --- a/movement/movement_config.h +++ b/movement/movement_config.h @@ -18,7 +18,6 @@ const watch_face_t watch_faces[] = { simple_clock_face, - character_set_face, preferences_face, set_time_face, }; -- cgit v1.2.3 From eb66b67e8ea37f841105c31243c641a7382465d2 Mon Sep 17 00:00:00 2001 From: Joey Castillo Date: Sun, 5 Dec 2021 16:24:17 -0600 Subject: more accelerometer tests: track interrupts on each axis, log on the quarter hour --- movement/watch_faces/demos/lis2dh_logging_face.c | 138 +++++++++++++++-------- movement/watch_faces/demos/lis2dh_logging_face.h | 11 +- 2 files changed, 96 insertions(+), 53 deletions(-) (limited to 'movement') diff --git a/movement/watch_faces/demos/lis2dh_logging_face.c b/movement/watch_faces/demos/lis2dh_logging_face.c index 0e4383cd..12387a0b 100644 --- a/movement/watch_faces/demos/lis2dh_logging_face.c +++ b/movement/watch_faces/demos/lis2dh_logging_face.c @@ -12,14 +12,78 @@ // Pressing the alarm button enters the log mode, where the main display shows the number of interrupts detected in each of the last // 24 hours (the hour is shown in the top right digit and AM/PM indicator, if the clock is set to 12 hour mode) +void _lis2dh_logging_face_update_display(movement_settings_t *settings, lis2dh_logger_state_t *logger_state, lis2dh_interrupt_state interrupt_state, watch_date_time date_time) { + char buf[14]; + char time_indication_character; + int8_t pos; + + if (logger_state->log_ticks) { + pos = (logger_state->data_points - 1 - logger_state->display_index) % LIS2DH_LOGGING_NUM_DATA_POINTS; + if (pos < 0) { + watch_clear_colon(); + sprintf(buf, "NO data "); + } else { + date_time = logger_state->data[pos].timestamp; + watch_set_colon(); + if (settings->bit.clock_mode_24h) { + watch_set_indicator(WATCH_INDICATOR_24H); + } else { + if (date_time.unit.hour > 11) watch_set_indicator(WATCH_INDICATOR_PM); + date_time.unit.hour %= 12; + if (date_time.unit.hour == 0) date_time.unit.hour = 12; + } + switch (logger_state->axis_index) { + case 0: + sprintf(buf, "3A%2d%02d%4ld", date_time.unit.hour, date_time.unit.minute, logger_state->data[pos].x_interrupts + logger_state->data[pos].y_interrupts + logger_state->data[pos].z_interrupts); + break; + case 1: + sprintf(buf, "XA%2d%02d%4ld", date_time.unit.hour, date_time.unit.minute, logger_state->data[pos].x_interrupts); + break; + case 2: + sprintf(buf, "YA%2d%02d%4ld", date_time.unit.hour, date_time.unit.minute, logger_state->data[pos].y_interrupts); + break; + case 3: + sprintf(buf, "ZA%2d%02d%4ld", date_time.unit.hour, date_time.unit.minute, logger_state->data[pos].z_interrupts); + break; + } + } + } else { + date_time = watch_rtc_get_date_time(); + watch_clear_colon(); + watch_clear_indicator(WATCH_INDICATOR_PM); + watch_clear_indicator(WATCH_INDICATOR_24H); + if ((59 - date_time.unit.second) < 10) time_indication_character = '0' + (59 - date_time.unit.second); + else time_indication_character = (date_time.unit.second % 2) ? 'i' : '_'; + sprintf(buf, "%c%c%c%c%2d%2d%2d", + (interrupt_state & LIS2DH_INTERRUPT_STATE_Y_HIGH) ? 'Y' : ' ', + (interrupt_state & LIS2DH_INTERRUPT_STATE_X_HIGH) ? 'X' : ' ', + (interrupt_state & LIS2DH_INTERRUPT_STATE_Z_HIGH) ? 'Z' : ' ', + time_indication_character, + logger_state->interrupts[0], + logger_state->interrupts[1], + logger_state->interrupts[2]); + } + watch_display_string(buf, 0); +} + void _lis2dh_logging_face_log_data(lis2dh_logger_state_t *logger_state) { watch_date_time date_time = watch_rtc_get_date_time(); - date_time.unit.hour = (date_time.unit.hour + 23) % 24; // log this as the number of events in the previous hour + // we get this call 15 minutes late; i.e. at 6:15 we're logging events for 6:00. + // so: if we're at the top of the hour, roll the hour back too (7:00 task logs data for 6:45) + if (date_time.unit.minute == 0) date_time.unit.hour = (date_time.unit.hour + 23) % 24; + + // // then roll the minute back. + date_time.unit.minute = (date_time.unit.minute + 45) % 60; + size_t pos = logger_state->data_points % LIS2DH_LOGGING_NUM_DATA_POINTS; logger_state->data[pos].timestamp.reg = date_time.reg; - logger_state->data[pos].interrupts = logger_state->interrupts_this_hour; + logger_state->data[pos].x_interrupts = logger_state->x_interrupts_this_hour; + logger_state->data[pos].y_interrupts = logger_state->y_interrupts_this_hour; + logger_state->data[pos].z_interrupts = logger_state->z_interrupts_this_hour; logger_state->data_points++; - logger_state->interrupts_this_hour = 0; + logger_state->x_interrupts_this_hour = 0; + logger_state->y_interrupts_this_hour = 0; + logger_state->z_interrupts_this_hour = 0; } void lis2dh_logging_face_setup(movement_settings_t *settings, void ** context_ptr) { @@ -49,74 +113,47 @@ void lis2dh_logging_face_activate(movement_settings_t *settings, void *context) watch_enable_digital_input(A1); } -bool tick = false; - bool lis2dh_logging_face_loop(movement_event_t event, movement_settings_t *settings, void *context) { lis2dh_logger_state_t *logger_state = (lis2dh_logger_state_t *)context; lis2dh_interrupt_state interrupt_state = 0; watch_date_time date_time; - char buf[14]; - char time_indication_character; - int8_t pos; switch (event.event_type) { case EVENT_MODE_BUTTON_UP: movement_move_to_next_face(); break; case EVENT_LIGHT_LONG_PRESS: + movement_illuminate_led(); break; case EVENT_LIGHT_BUTTON_DOWN: + logger_state->axis_index = (logger_state->axis_index + 1) % 4; + logger_state->log_ticks = 255; + _lis2dh_logging_face_update_display(settings, logger_state, interrupt_state, date_time); break; case EVENT_ALARM_BUTTON_UP: - if (logger_state->log_ticks) { - logger_state->display_index = (logger_state->display_index + 1) % LIS2DH_LOGGING_NUM_DATA_POINTS; - } - logger_state->log_ticks = 60; - // fall through + if (logger_state->log_ticks) logger_state->display_index = (logger_state->display_index + 1) % LIS2DH_LOGGING_NUM_DATA_POINTS; + logger_state->log_ticks = 255; + logger_state->axis_index = 0; + _lis2dh_logging_face_update_display(settings, logger_state, interrupt_state, date_time); + break; case EVENT_ACTIVATE: case EVENT_TICK: - tick = !tick; + if (logger_state->log_ticks > 0) { + logger_state->log_ticks--; + } else { + logger_state->display_index = 0; + } if (watch_get_pin_level(A1)) { watch_set_indicator(WATCH_INDICATOR_SIGNAL); interrupt_state = lis2dh_get_int1_state(); logger_state->interrupts[0]++; - logger_state->interrupts_this_hour++; + if (interrupt_state & LIS2DH_INTERRUPT_STATE_X_HIGH) logger_state->x_interrupts_this_hour++; + if (interrupt_state & LIS2DH_INTERRUPT_STATE_Y_HIGH) logger_state->y_interrupts_this_hour++; + if (interrupt_state & LIS2DH_INTERRUPT_STATE_Z_HIGH) logger_state->z_interrupts_this_hour++; } else { watch_clear_indicator(WATCH_INDICATOR_SIGNAL); } - if (logger_state->log_ticks) { - pos = (logger_state->data_points - 1 - logger_state->display_index) % LIS2DH_LOGGING_NUM_DATA_POINTS; - if (pos < 0) { - watch_clear_colon(); - sprintf(buf, "NO data "); - } else { - date_time = logger_state->data[pos].timestamp; - watch_set_colon(); - if (settings->bit.clock_mode_24h) { - watch_set_indicator(WATCH_INDICATOR_24H); - } else { - if (date_time.unit.hour > 11) watch_set_indicator(WATCH_INDICATOR_PM); - date_time.unit.hour %= 12; - if (date_time.unit.hour == 0) date_time.unit.hour = 12; - } - sprintf(buf, "AT%2d1n%4ld", date_time.unit.hour, logger_state->data[pos].interrupts); - } - } else { - date_time = watch_rtc_get_date_time(); - watch_clear_colon(); - if ((59 - date_time.unit.second) < 10) time_indication_character = '0' + (59 - date_time.unit.second); - else time_indication_character = (date_time.unit.second % 2) ? 'i' : '_'; - sprintf(buf, "%c%c%c%c%2d%2d%2d", - (interrupt_state & LIS2DH_INTERRUPT_STATE_Y_HIGH) ? 'Y' : ' ', - (interrupt_state & LIS2DH_INTERRUPT_STATE_X_HIGH) ? 'X' : ' ', - (interrupt_state & LIS2DH_INTERRUPT_STATE_Z_HIGH) ? '2' : ' ', - time_indication_character, - logger_state->interrupts[0], - logger_state->interrupts[1], - logger_state->interrupts[2]); - } - - watch_display_string(buf, 0); + _lis2dh_logging_face_update_display(settings, logger_state, interrupt_state, date_time); break; case EVENT_BACKGROUND_TASK: _lis2dh_logging_face_log_data(logger_state); @@ -137,12 +174,13 @@ void lis2dh_logging_face_resign(movement_settings_t *settings, void *context) { bool lis2dh_logging_face_wants_background_task(movement_settings_t *settings, void *context) { (void) settings; lis2dh_logger_state_t *logger_state = (lis2dh_logger_state_t *)context; + watch_date_time date_time = watch_rtc_get_date_time(); // this is kind of an abuse of the API, but, let's use the 1 minute tick to shift all our data over. logger_state->interrupts[2] = logger_state->interrupts[1]; logger_state->interrupts[1] = logger_state->interrupts[0]; logger_state->interrupts[0] = 0; - // and do our logging task at the top of the hour - return watch_rtc_get_date_time().unit.minute == 0; + // and do our logging task every 15 minutes + return (date_time.unit.minute % 15) == 0; } diff --git a/movement/watch_faces/demos/lis2dh_logging_face.h b/movement/watch_faces/demos/lis2dh_logging_face.h index d8ab0e24..b0faeca5 100644 --- a/movement/watch_faces/demos/lis2dh_logging_face.h +++ b/movement/watch_faces/demos/lis2dh_logging_face.h @@ -4,19 +4,24 @@ #include "movement.h" #include "watch.h" -#define LIS2DH_LOGGING_NUM_DATA_POINTS (24) +#define LIS2DH_LOGGING_NUM_DATA_POINTS (96) typedef struct { watch_date_time timestamp; - uint32_t interrupts; + uint32_t x_interrupts; + uint32_t y_interrupts; + uint32_t z_interrupts; } lis2dh_logger_data_point_t; typedef struct { uint8_t display_index; // the index we are displaying on screen + uint8_t axis_index; // the index we are displaying on screen uint8_t log_ticks; // when the user taps the ALARM button, we enter log mode int32_t data_points; // the absolute number of data points logged uint8_t interrupts[3]; // the number of interrupts we have logged in each of the last 3 minutes - uint32_t interrupts_this_hour; // the number of interrupts we have logged in the last hour + uint32_t x_interrupts_this_hour; // the number of interrupts we have logged in the last hour + uint32_t y_interrupts_this_hour; // the number of interrupts we have logged in the last hour + uint32_t z_interrupts_this_hour; // the number of interrupts we have logged in the last hour lis2dh_logger_data_point_t data[LIS2DH_LOGGING_NUM_DATA_POINTS]; } lis2dh_logger_state_t; -- cgit v1.2.3 From c5400e437f919843e0235ed66f7840fd3ddf6ea0 Mon Sep 17 00:00:00 2001 From: Joey Castillo Date: Sun, 5 Dec 2021 22:56:09 -0600 Subject: ensure accelerometer test face always stays active --- movement/watch_faces/demos/lis2dh_logging_face.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'movement') diff --git a/movement/watch_faces/demos/lis2dh_logging_face.c b/movement/watch_faces/demos/lis2dh_logging_face.c index 12387a0b..af82a004 100644 --- a/movement/watch_faces/demos/lis2dh_logging_face.c +++ b/movement/watch_faces/demos/lis2dh_logging_face.c @@ -106,8 +106,12 @@ void lis2dh_logging_face_setup(movement_settings_t *settings, void ** context_pt } void lis2dh_logging_face_activate(movement_settings_t *settings, void *context) { - (void) settings; lis2dh_logger_state_t *logger_state = (lis2dh_logger_state_t *)context; + // force two settings: never enter low energy mode, and always snap back to screen 0. + // this assumes the accelerometer face is first in the watch_faces list. + settings->bit.le_interval = 0; + settings->bit.to_always = true; + logger_state->display_index = 0; logger_state->log_ticks = 0; watch_enable_digital_input(A1); -- cgit v1.2.3 From 616587a2030be054277ef74fdbf0be626684db3c Mon Sep 17 00:00:00 2001 From: Joey Castillo Date: Fri, 10 Dec 2021 11:33:07 -0500 Subject: add demo watch face --- movement/make/Makefile | 1 + movement/movement_config.h | 1 + movement/watch_faces/demos/demo_face.c | 91 ++++++++++++++++++++++++++++++++++ movement/watch_faces/demos/demo_face.h | 19 +++++++ 4 files changed, 112 insertions(+) create mode 100644 movement/watch_faces/demos/demo_face.c create mode 100644 movement/watch_faces/demos/demo_face.h (limited to 'movement') diff --git a/movement/make/Makefile b/movement/make/Makefile index 7a3e85ec..b7a0e6e2 100755 --- a/movement/make/Makefile +++ b/movement/make/Makefile @@ -39,6 +39,7 @@ SRCS += \ ../watch_faces/demos/character_set_face.c \ ../watch_faces/demos/voltage_face.c \ ../watch_faces/demos/lis2dh_logging_face.c \ + ../watch_faces/demos/demo_face.c \ ../watch_faces/complications/beats_face.c \ ../watch_faces/complications/day_one_face.c \ ../watch_faces/complications/stopwatch_face.c \ diff --git a/movement/movement_config.h b/movement/movement_config.h index 2ef43ef0..6aeb0b83 100644 --- a/movement/movement_config.h +++ b/movement/movement_config.h @@ -15,6 +15,7 @@ #include "stopwatch_face.h" #include "totp_face.h" #include "lis2dh_logging_face.h" +#include "demo_face.h" const watch_face_t watch_faces[] = { simple_clock_face, diff --git a/movement/watch_faces/demos/demo_face.c b/movement/watch_faces/demos/demo_face.c new file mode 100644 index 00000000..82256767 --- /dev/null +++ b/movement/watch_faces/demos/demo_face.c @@ -0,0 +1,91 @@ +#include +#include +#include "demo_face.h" +#include "watch.h" + +typedef enum { + DEMO_FACE_HELLO = 0, + DEMO_FACE_TIME, + DEMO_FACE_WORLD_TIME, + DEMO_FACE_BEATS, + DEMO_FACE_TEMP_F, + DEMO_FACE_TEMP_C, + DEMO_FACE_BATTERY_VOLTAGE, + DEMO_FACE_NUM_FACES +} demo_face_index_t; + +void demo_face_setup(movement_settings_t *settings, void ** context_ptr) { + (void) settings; + if (*context_ptr == NULL) { + *context_ptr = malloc(sizeof(demo_face_index_t)); + memset(*context_ptr, 0, sizeof(demo_face_index_t)); + } +} + +void demo_face_activate(movement_settings_t *settings, void *context) { + (void) settings; + (void) context; + movement_request_tick_frequency(0); + // ensure the watch never enters low energy mode + settings->bit.le_interval = 0; +} + +bool demo_face_loop(movement_event_t event, movement_settings_t *settings, void *context) { + (void) settings; + demo_face_index_t *screen = (demo_face_index_t *)context; + switch (event.event_type) { + case EVENT_MODE_BUTTON_UP: + movement_move_to_next_face(); + break; + case EVENT_LIGHT_BUTTON_DOWN: + movement_illuminate_led(); + break; + case EVENT_ALARM_BUTTON_UP: + *screen = ((*screen) + 1) % DEMO_FACE_NUM_FACES; + // fall through + case EVENT_ACTIVATE: + switch (*screen) { + case DEMO_FACE_HELLO: + watch_display_string(" Hello ", 0); + watch_clear_colon(); + break; + case DEMO_FACE_TIME: + watch_display_string("TH 6101036", 0); + watch_set_colon(); + break; + case DEMO_FACE_WORLD_TIME: + watch_display_string("MT 6 81036", 0); + break; + case DEMO_FACE_BEATS: + watch_display_string("bt 64125", 0); + watch_clear_colon(); + break; + case DEMO_FACE_TEMP_F: + watch_display_string("TE 72.1#F", 0); + break; + case DEMO_FACE_TEMP_C: + watch_display_string("TE 22.3#C", 0); + break; + case DEMO_FACE_BATTERY_VOLTAGE: + watch_display_string("BA 2.97 V", 0); + break; + case DEMO_FACE_NUM_FACES: + // we won't get here, but silence the warning + break; + } + break; + case EVENT_TIMEOUT: + // ignore timeout + break; + default: + break; + } + + return true; +} + +void demo_face_resign(movement_settings_t *settings, void *context) { + (void) settings; + (void) context; + movement_request_tick_frequency(1); +} diff --git a/movement/watch_faces/demos/demo_face.h b/movement/watch_faces/demos/demo_face.h new file mode 100644 index 00000000..b9e36ffc --- /dev/null +++ b/movement/watch_faces/demos/demo_face.h @@ -0,0 +1,19 @@ +#ifndef DEMO_FACE_H_ +#define DEMO_FACE_H_ + +#include "movement.h" + +void demo_face_setup(movement_settings_t *settings, void ** context_ptr); +void demo_face_activate(movement_settings_t *settings, void *context); +bool demo_face_loop(movement_event_t event, movement_settings_t *settings, void *context); +void demo_face_resign(movement_settings_t *settings, void *context); + +static const watch_face_t demo_face = { + demo_face_setup, + demo_face_activate, + demo_face_loop, + demo_face_resign, + NULL +}; + +#endif // DEMO_FACE_H_ \ No newline at end of file -- cgit v1.2.3 From 762af872d2f2c977e51d6e51b8c3ad622485cc05 Mon Sep 17 00:00:00 2001 From: Joey Castillo Date: Sun, 5 Dec 2021 23:49:26 -0600 Subject: fix missing prototype warnings --- movement/lib/TOTP-MCU/sha1.c | 4 +- movement/movement.c | 60 +++++++++++----------- movement/movement.h | 8 +-- movement/watch_faces/clock/world_clock_face.c | 6 +-- movement/watch_faces/complications/day_one_face.c | 4 +- movement/watch_faces/demos/lis2dh_logging_face.c | 4 +- movement/watch_faces/demos/voltage_face.c | 2 +- .../watch_faces/thermistor/thermistor_driver.c | 6 +-- .../watch_faces/thermistor/thermistor_driver.h | 6 +-- .../thermistor/thermistor_logging_face.c | 4 +- .../thermistor/thermistor_readout_face.c | 2 +- 11 files changed, 53 insertions(+), 53 deletions(-) (limited to 'movement') diff --git a/movement/lib/TOTP-MCU/sha1.c b/movement/lib/TOTP-MCU/sha1.c index 8e918e64..3ac14856 100644 --- a/movement/lib/TOTP-MCU/sha1.c +++ b/movement/lib/TOTP-MCU/sha1.c @@ -38,7 +38,7 @@ uint32_t rol32(uint32_t number, uint8_t bits) { return ((number << bits) | (uint32_t)(number >> (32-bits))); } -void hashBlock() { +void hashBlock(void) { uint8_t i; uint32_t a,b,c,d,e,t; @@ -97,7 +97,7 @@ void writeArray(uint8_t *buffer, uint8_t size){ } } -void pad() { +void pad(void) { // Implement SHA-1 padding (fips180-2 ��5.1.1) // Pad with 0x80 followed by 0x00 until the end of the block diff --git a/movement/movement.c b/movement/movement.c index f627dbf5..cdd4ff06 100644 --- a/movement/movement.c +++ b/movement/movement.c @@ -58,27 +58,27 @@ const int16_t movement_timezone_offsets[] = { const char movement_valid_position_0_chars[] = " AaBbCcDdEeFGgHhIiJKLMNnOoPQrSTtUuWXYZ-='+\\/0123456789"; const char movement_valid_position_1_chars[] = " ABCDEFHlJLNORTtUX-='01378"; -void cb_mode_btn_interrupt(); -void cb_light_btn_interrupt(); -void cb_alarm_btn_interrupt(); -void cb_alarm_btn_extwake(); -void cb_alarm_fired(); -void cb_fast_tick(); -void cb_tick(); - -static inline void _movement_reset_inactivity_countdown() { +void cb_mode_btn_interrupt(void); +void cb_light_btn_interrupt(void); +void cb_alarm_btn_interrupt(void); +void cb_alarm_btn_extwake(void); +void cb_alarm_fired(void); +void cb_fast_tick(void); +void cb_tick(void); + +static inline void _movement_reset_inactivity_countdown(void) { movement_state.le_mode_ticks = movement_le_inactivity_deadlines[movement_state.settings.bit.le_interval]; movement_state.timeout_ticks = movement_timeout_inactivity_deadlines[movement_state.settings.bit.to_interval]; } -static inline void _movement_enable_fast_tick_if_needed() { +static inline void _movement_enable_fast_tick_if_needed(void) { if (!movement_state.fast_tick_enabled) { movement_state.fast_ticks = 0; watch_rtc_register_periodic_callback(cb_fast_tick, 128); } } -static inline void _movement_disable_fast_tick_if_possible() { +static inline void _movement_disable_fast_tick_if_possible(void) { if ((movement_state.light_ticks == -1) && (movement_state.alarm_ticks == -1) && ((movement_state.light_down_timestamp + movement_state.mode_down_timestamp + movement_state.alarm_down_timestamp) == 0)) { @@ -87,7 +87,7 @@ static inline void _movement_disable_fast_tick_if_possible() { } } -void _movement_handle_background_tasks() { +static void _movement_handle_background_tasks(void) { for(uint8_t i = 0; i < MOVEMENT_NUM_FACES; i++) { // For each face, if the watch face wants a background task... if (watch_faces[i].wants_background_task != NULL && watch_faces[i].wants_background_task(&movement_state.settings, watch_face_contexts[i])) { @@ -107,7 +107,7 @@ void movement_request_tick_frequency(uint8_t freq) { if (freq) watch_rtc_register_periodic_callback(cb_tick, freq); } -void movement_illuminate_led() { +void movement_illuminate_led(void) { if (movement_state.settings.bit.led_duration) { watch_set_led_color(movement_state.settings.bit.led_red_color ? (0xF | movement_state.settings.bit.led_red_color << 4) : 0, movement_state.settings.bit.led_green_color ? (0xF | movement_state.settings.bit.led_green_color << 4) : 0); @@ -121,22 +121,22 @@ void movement_move_to_face(uint8_t watch_face_index) { movement_state.next_watch_face = watch_face_index; } -void movement_move_to_next_face() { +void movement_move_to_next_face(void) { movement_move_to_face((movement_state.current_watch_face + 1) % MOVEMENT_NUM_FACES); } -void movement_play_signal() { +void movement_play_signal(void) { watch_buzzer_play_note(BUZZER_NOTE_C8, 75); watch_buzzer_play_note(BUZZER_NOTE_REST, 100); watch_buzzer_play_note(BUZZER_NOTE_C8, 100); } -void movement_play_alarm() { +void movement_play_alarm(void) { movement_state.alarm_ticks = 128 * 5 - 80; // 80 ticks short of 5 seconds, or 4.375 seconds (our beep is 0.375 seconds) _movement_enable_fast_tick_if_needed(); } -void app_init() { +void app_init(void) { memset(&movement_state, 0, sizeof(movement_state)); movement_state.settings.bit.led_green_color = 0xF; @@ -149,11 +149,11 @@ void app_init() { _movement_reset_inactivity_countdown(); } -void app_wake_from_backup() { +void app_wake_from_backup(void) { movement_state.settings.reg = watch_get_backup_data(0); } -void app_setup() { +void app_setup(void) { watch_store_backup_data(movement_state.settings.reg, 0); static bool is_first_launch = true; @@ -194,13 +194,13 @@ void app_setup() { } } -void app_prepare_for_standby() { +void app_prepare_for_standby(void) { } -void app_wake_from_standby() { +void app_wake_from_standby(void) { } -bool app_loop() { +bool app_loop(void) { if (movement_state.watch_face_changed) { if (movement_state.settings.bit.button_should_sound) { // low note for nonzero case, high note for return to watch_face 0 @@ -300,7 +300,7 @@ bool app_loop() { return can_sleep && (movement_state.light_ticks == -1) && !movement_state.is_buzzing; } -movement_event_type_t _figure_out_button_event(bool pin_level, movement_event_type_t button_down_event_type, uint8_t *down_timestamp) { +static movement_event_type_t _figure_out_button_event(bool pin_level, movement_event_type_t button_down_event_type, uint8_t *down_timestamp) { // force alarm off if the user pressed a button. if (movement_state.alarm_ticks) movement_state.alarm_ticks = 0; @@ -323,34 +323,34 @@ movement_event_type_t _figure_out_button_event(bool pin_level, movement_event_ty } } -void cb_light_btn_interrupt() { +void cb_light_btn_interrupt(void) { bool pin_level = watch_get_pin_level(BTN_LIGHT); _movement_reset_inactivity_countdown(); event.event_type = _figure_out_button_event(pin_level, EVENT_LIGHT_BUTTON_DOWN, &movement_state.light_down_timestamp); } -void cb_mode_btn_interrupt() { +void cb_mode_btn_interrupt(void) { bool pin_level = watch_get_pin_level(BTN_MODE); _movement_reset_inactivity_countdown(); event.event_type = _figure_out_button_event(pin_level, EVENT_MODE_BUTTON_DOWN, &movement_state.mode_down_timestamp); } -void cb_alarm_btn_interrupt() { +void cb_alarm_btn_interrupt(void) { bool pin_level = watch_get_pin_level(BTN_ALARM); _movement_reset_inactivity_countdown(); event.event_type = _figure_out_button_event(pin_level, EVENT_ALARM_BUTTON_DOWN, &movement_state.alarm_down_timestamp); } -void cb_alarm_btn_extwake() { +void cb_alarm_btn_extwake(void) { // wake up! _movement_reset_inactivity_countdown(); } -void cb_alarm_fired() { +void cb_alarm_fired(void) { movement_state.needs_background_tasks_handled = true; } -void cb_fast_tick() { +void cb_fast_tick(void) { movement_state.fast_ticks++; if (movement_state.light_ticks > 0) movement_state.light_ticks--; if (movement_state.alarm_ticks > 0) movement_state.alarm_ticks--; @@ -359,7 +359,7 @@ void cb_fast_tick() { if (movement_state.fast_ticks >= 1280) watch_rtc_disable_periodic_callback(128); } -void cb_tick() { +void cb_tick(void) { event.event_type = EVENT_TICK; watch_date_time date_time = watch_rtc_get_date_time(); if (date_time.unit.second != movement_state.last_second) { diff --git a/movement/movement.h b/movement/movement.h index 9edb285b..62e4120b 100644 --- a/movement/movement.h +++ b/movement/movement.h @@ -242,11 +242,11 @@ typedef struct { } movement_state_t; void movement_move_to_face(uint8_t watch_face_index); -void movement_move_to_next_face(); -void movement_illuminate_led(); +void movement_move_to_next_face(void); +void movement_illuminate_led(void); void movement_request_tick_frequency(uint8_t freq); -void movement_play_signal(); -void movement_play_alarm(); +void movement_play_signal(void); +void movement_play_alarm(void); #endif // MOVEMENT_H_ diff --git a/movement/watch_faces/clock/world_clock_face.c b/movement/watch_faces/clock/world_clock_face.c index d80cb5bc..e1d96c97 100644 --- a/movement/watch_faces/clock/world_clock_face.c +++ b/movement/watch_faces/clock/world_clock_face.c @@ -26,7 +26,7 @@ void world_clock_face_activate(movement_settings_t *settings, void *context) { watch_set_colon(); } -bool world_clock_face_do_display_mode(movement_event_t event, movement_settings_t *settings, world_clock_state_t *state) { +static bool world_clock_face_do_display_mode(movement_event_t event, movement_settings_t *settings, world_clock_state_t *state) { char buf[11]; uint8_t pos; @@ -101,7 +101,7 @@ bool world_clock_face_do_display_mode(movement_event_t event, movement_settings_ return true; } -bool world_clock_face_do_settings_mode(movement_event_t event, movement_settings_t *settings, world_clock_state_t *state) { +static bool _world_clock_face_do_settings_mode(movement_event_t event, movement_settings_t *settings, world_clock_state_t *state) { switch (event.event_type) { case EVENT_MODE_BUTTON_UP: movement_move_to_next_face(); @@ -176,7 +176,7 @@ bool world_clock_face_loop(movement_event_t event, movement_settings_t *settings if (state->current_screen == 0) { return world_clock_face_do_display_mode(event, settings, state); } else { - return world_clock_face_do_settings_mode(event, settings, state); + return _world_clock_face_do_settings_mode(event, settings, state); } } diff --git a/movement/watch_faces/complications/day_one_face.c b/movement/watch_faces/complications/day_one_face.c index 146f3f6f..3b185d04 100644 --- a/movement/watch_faces/complications/day_one_face.c +++ b/movement/watch_faces/complications/day_one_face.c @@ -3,12 +3,12 @@ #include "day_one_face.h" #include "watch.h" -uint32_t _day_one_face_juliandaynum(uint16_t year, uint16_t month, uint16_t day) { +static uint32_t _day_one_face_juliandaynum(uint16_t year, uint16_t month, uint16_t day) { // from here: https://en.wikipedia.org/wiki/Julian_day#Julian_day_number_calculation return (1461 * (year + 4800 + (month - 14) / 12)) / 4 + (367 * (month - 2 - 12 * ((month - 14) / 12))) / 12 - (3 * ((year + 4900 + (month - 14) / 12) / 100))/4 + day - 32075; } -void _day_one_face_update(day_one_state_t state) { +static void _day_one_face_update(day_one_state_t state) { char buf[14]; 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); diff --git a/movement/watch_faces/demos/lis2dh_logging_face.c b/movement/watch_faces/demos/lis2dh_logging_face.c index af82a004..9f5783fe 100644 --- a/movement/watch_faces/demos/lis2dh_logging_face.c +++ b/movement/watch_faces/demos/lis2dh_logging_face.c @@ -12,7 +12,7 @@ // Pressing the alarm button enters the log mode, where the main display shows the number of interrupts detected in each of the last // 24 hours (the hour is shown in the top right digit and AM/PM indicator, if the clock is set to 12 hour mode) -void _lis2dh_logging_face_update_display(movement_settings_t *settings, lis2dh_logger_state_t *logger_state, lis2dh_interrupt_state interrupt_state, watch_date_time date_time) { +static void _lis2dh_logging_face_update_display(movement_settings_t *settings, lis2dh_logger_state_t *logger_state, lis2dh_interrupt_state interrupt_state, watch_date_time date_time) { char buf[14]; char time_indication_character; int8_t pos; @@ -66,7 +66,7 @@ void _lis2dh_logging_face_update_display(movement_settings_t *settings, lis2dh_l watch_display_string(buf, 0); } -void _lis2dh_logging_face_log_data(lis2dh_logger_state_t *logger_state) { +static void _lis2dh_logging_face_log_data(lis2dh_logger_state_t *logger_state) { watch_date_time date_time = watch_rtc_get_date_time(); // we get this call 15 minutes late; i.e. at 6:15 we're logging events for 6:00. // so: if we're at the top of the hour, roll the hour back too (7:00 task logs data for 6:45) diff --git a/movement/watch_faces/demos/voltage_face.c b/movement/watch_faces/demos/voltage_face.c index bdc25679..fe43343f 100644 --- a/movement/watch_faces/demos/voltage_face.c +++ b/movement/watch_faces/demos/voltage_face.c @@ -3,7 +3,7 @@ #include "voltage_face.h" #include "watch.h" -void _voltage_face_update_display() { +static void _voltage_face_update_display(void) { char buf[14]; float voltage = (float)watch_get_vcc_voltage() / 1000.0; sprintf(buf, "BA %4.2f V", voltage); diff --git a/movement/watch_faces/thermistor/thermistor_driver.c b/movement/watch_faces/thermistor/thermistor_driver.c index 37b5ba3f..5659c281 100644 --- a/movement/watch_faces/thermistor/thermistor_driver.c +++ b/movement/watch_faces/thermistor/thermistor_driver.c @@ -2,7 +2,7 @@ #include "watch.h" #include "watch_utility.h" -void thermistor_driver_enable() { +void thermistor_driver_enable(void) { // Enable the ADC peripheral, which we'll use to read the thermistor value. watch_enable_adc(); // Enable analog circuitry on the sense pin, which is tied to the thermistor resistor divider. @@ -13,7 +13,7 @@ void thermistor_driver_enable() { watch_set_pin_level(THERMISTOR_ENABLE_PIN, !THERMISTOR_ENABLE_VALUE); } -void thermistor_driver_disable() { +void thermistor_driver_disable(void) { // Disable the ADC peripheral. watch_disable_adc(); // Disable analog circuitry on the sense pin to save power. @@ -22,7 +22,7 @@ void thermistor_driver_disable() { watch_disable_digital_output(THERMISTOR_ENABLE_PIN); } -float thermistor_driver_get_temperature() { +float thermistor_driver_get_temperature(void) { // set the enable pin to the level that powers the thermistor circuit. watch_set_pin_level(THERMISTOR_ENABLE_PIN, THERMISTOR_ENABLE_VALUE); // get the sense pin level diff --git a/movement/watch_faces/thermistor/thermistor_driver.h b/movement/watch_faces/thermistor/thermistor_driver.h index a0b197de..425e1154 100644 --- a/movement/watch_faces/thermistor/thermistor_driver.h +++ b/movement/watch_faces/thermistor/thermistor_driver.h @@ -12,8 +12,8 @@ #define THERMISTOR_NOMINAL_RESISTANCE (10000.0) #define THERMISTOR_SERIES_RESISTANCE (10000.0) -void thermistor_driver_enable(); -void thermistor_driver_disable(); -float thermistor_driver_get_temperature(); +void thermistor_driver_enable(void); +void thermistor_driver_disable(void); +float thermistor_driver_get_temperature(void); #endif // THERMISTOR_DRIVER_H_ diff --git a/movement/watch_faces/thermistor/thermistor_logging_face.c b/movement/watch_faces/thermistor/thermistor_logging_face.c index 3e9e62b3..0d456785 100644 --- a/movement/watch_faces/thermistor/thermistor_logging_face.c +++ b/movement/watch_faces/thermistor/thermistor_logging_face.c @@ -4,7 +4,7 @@ #include "thermistor_driver.h" #include "watch.h" -void _thermistor_logging_face_log_data(thermistor_logger_state_t *logger_state) { +static void _thermistor_logging_face_log_data(thermistor_logger_state_t *logger_state) { thermistor_driver_enable(); watch_date_time date_time = watch_rtc_get_date_time(); size_t pos = logger_state->data_points % THERMISTOR_LOGGING_NUM_DATA_POINTS; @@ -16,7 +16,7 @@ void _thermistor_logging_face_log_data(thermistor_logger_state_t *logger_state) thermistor_driver_disable(); } -void _thermistor_logging_face_update_display(thermistor_logger_state_t *logger_state, bool in_fahrenheit, bool clock_mode_24h) { +static void _thermistor_logging_face_update_display(thermistor_logger_state_t *logger_state, bool in_fahrenheit, bool clock_mode_24h) { int8_t pos = (logger_state->data_points - 1 - logger_state->display_index) % THERMISTOR_LOGGING_NUM_DATA_POINTS; char buf[14]; diff --git a/movement/watch_faces/thermistor/thermistor_readout_face.c b/movement/watch_faces/thermistor/thermistor_readout_face.c index 8c5645e2..5478f07d 100644 --- a/movement/watch_faces/thermistor/thermistor_readout_face.c +++ b/movement/watch_faces/thermistor/thermistor_readout_face.c @@ -4,7 +4,7 @@ #include "thermistor_driver.h" #include "watch.h" -void _thermistor_readout_face_update_display(bool in_fahrenheit) { +static void _thermistor_readout_face_update_display(bool in_fahrenheit) { thermistor_driver_enable(); float temperature_c = thermistor_driver_get_temperature(); char buf[14]; -- cgit v1.2.3