diff options
Diffstat (limited to 'movement/watch_faces')
-rw-r--r-- | movement/watch_faces/clock/world_clock_face.c | 6 | ||||
-rw-r--r-- | movement/watch_faces/complications/day_one_face.c | 4 | ||||
-rw-r--r-- | movement/watch_faces/demos/demo_face.c | 91 | ||||
-rw-r--r-- | movement/watch_faces/demos/demo_face.h | 19 | ||||
-rw-r--r-- | movement/watch_faces/demos/lis2dh_logging_face.c | 4 | ||||
-rw-r--r-- | movement/watch_faces/demos/voltage_face.c | 2 | ||||
-rw-r--r-- | movement/watch_faces/thermistor/thermistor_driver.c | 6 | ||||
-rw-r--r-- | movement/watch_faces/thermistor/thermistor_driver.h | 6 | ||||
-rw-r--r-- | movement/watch_faces/thermistor/thermistor_logging_face.c | 4 | ||||
-rw-r--r-- | movement/watch_faces/thermistor/thermistor_readout_face.c | 2 |
10 files changed, 127 insertions, 17 deletions
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/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 <stdlib.h> +#include <string.h> +#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 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]; |