add demo watch face
This commit is contained in:
parent
8e06100b81
commit
616587a203
@ -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 \
|
||||
|
@ -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,
|
||||
|
91
movement/watch_faces/demos/demo_face.c
Normal file
91
movement/watch_faces/demos/demo_face.c
Normal file
@ -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);
|
||||
}
|
19
movement/watch_faces/demos/demo_face.h
Normal file
19
movement/watch_faces/demos/demo_face.h
Normal file
@ -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_
|
Loading…
x
Reference in New Issue
Block a user