diff options
| author | Joey Castillo <joeycastillo@utexas.edu> | 2021-12-10 11:33:07 -0500 | 
|---|---|---|
| committer | Joey Castillo <joeycastillo@utexas.edu> | 2021-12-10 11:33:07 -0500 | 
| commit | 616587a2030be054277ef74fdbf0be626684db3c (patch) | |
| tree | dc46e22572fc2c174d084e798d256589d0cd4476 | |
| parent | 8e06100b81c0218e09d97ae09b0feea20bc3d460 (diff) | |
| download | Sensor-Watch-616587a2030be054277ef74fdbf0be626684db3c.tar.gz Sensor-Watch-616587a2030be054277ef74fdbf0be626684db3c.tar.bz2 Sensor-Watch-616587a2030be054277ef74fdbf0be626684db3c.zip  | |
add demo watch face
| -rwxr-xr-x | movement/make/Makefile | 1 | ||||
| -rw-r--r-- | movement/movement_config.h | 1 | ||||
| -rw-r--r-- | movement/watch_faces/demos/demo_face.c | 91 | ||||
| -rw-r--r-- | movement/watch_faces/demos/demo_face.h | 19 | 
4 files changed, 112 insertions, 0 deletions
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 <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  | 
