From f1a706792e995f45b6b6f2ef70b2318253002249 Mon Sep 17 00:00:00 2001 From: Joey Castillo Date: Thu, 21 Oct 2021 17:28:59 -0400 Subject: movement: add character set demo --- movement/watch_faces/demos/character_set_face.c | 51 +++++++++++++++++++++++++ movement/watch_faces/demos/character_set_face.h | 19 +++++++++ 2 files changed, 70 insertions(+) create mode 100644 movement/watch_faces/demos/character_set_face.c create mode 100644 movement/watch_faces/demos/character_set_face.h (limited to 'movement/watch_faces') diff --git a/movement/watch_faces/demos/character_set_face.c b/movement/watch_faces/demos/character_set_face.c new file mode 100644 index 00000000..7daea5a9 --- /dev/null +++ b/movement/watch_faces/demos/character_set_face.c @@ -0,0 +1,51 @@ +#include +#include +#include "character_set_face.h" +#include "watch.h" + +void character_set_face_setup(movement_settings_t *settings, void ** context_ptr) { + (void) settings; + if (*context_ptr == NULL) *context_ptr = malloc(sizeof(char)); +} + +void character_set_face_activate(movement_settings_t *settings, void *context) { + (void) settings; + char *c = (char *)context; + *c = '@'; +} + +bool character_set_face_loop(movement_event_t event, movement_settings_t *settings, void *context) { + (void) settings; + char *c = (char *)context; + char buf[11]; + 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: + *c = (*c) + 1; + if (*c & 0x80) *c = ' '; + // fall through + case EVENT_ACTIVATE: + 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; + default: + break; + } + + return true; +} + +void character_set_face_resign(movement_settings_t *settings, void *context) { + (void) settings; + (void) context; +} diff --git a/movement/watch_faces/demos/character_set_face.h b/movement/watch_faces/demos/character_set_face.h new file mode 100644 index 00000000..b27a8359 --- /dev/null +++ b/movement/watch_faces/demos/character_set_face.h @@ -0,0 +1,19 @@ +#ifndef CHARACTER_SET_FACE_H_ +#define CHARACTER_SET_FACE_H_ + +#include "movement.h" + +void character_set_face_setup(movement_settings_t *settings, void ** context_ptr); +void character_set_face_activate(movement_settings_t *settings, void *context); +bool character_set_face_loop(movement_event_t event, movement_settings_t *settings, void *context); +void character_set_face_resign(movement_settings_t *settings, void *context); + +static const watch_face_t character_set_face = { + character_set_face_setup, + character_set_face_activate, + character_set_face_loop, + character_set_face_resign, + NULL +}; + +#endif // CHARACTER_SET_FACE_H_ \ No newline at end of file -- cgit v1.2.3