diff options
author | Joey Castillo <joeycastillo@utexas.edu> | 2021-12-10 15:55:54 -0500 |
---|---|---|
committer | Joey Castillo <joeycastillo@utexas.edu> | 2021-12-10 15:55:54 -0500 |
commit | e4f9737e21b6489be04e43f0af23aa968dba9ac2 (patch) | |
tree | 17475ccb72febde21425530eddce606f0176e23a /movement/watch_faces/demos/demo_face.c | |
parent | 8571bfa74f4de75fbb55b37e97de80351f5e92fe (diff) | |
parent | 762af872d2f2c977e51d6e51b8c3ad622485cc05 (diff) | |
download | Sensor-Watch-e4f9737e21b6489be04e43f0af23aa968dba9ac2.tar.gz Sensor-Watch-e4f9737e21b6489be04e43f0af23aa968dba9ac2.tar.bz2 Sensor-Watch-e4f9737e21b6489be04e43f0af23aa968dba9ac2.zip |
Merge branch 'main' into movement-timer-stuff
Diffstat (limited to 'movement/watch_faces/demos/demo_face.c')
-rw-r--r-- | movement/watch_faces/demos/demo_face.c | 91 |
1 files changed, 91 insertions, 0 deletions
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); +} |