summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheOnePerson <a.nebinger@web.de>2022-10-26 06:43:47 +0200
committerGitHub <noreply@github.com>2022-10-26 06:43:47 +0200
commitcb678d735a91e07e762e9f6715584ccfbeaa3fcd (patch)
tree795c1db4e70373f3134c7b3957c2162db11884d3
parent17cd90e72ff970a1cb8dda80584df16ee2e1d68f (diff)
parentcb69a2c181a3126ade2044f223b74077f48e0c77 (diff)
downloadSensor-Watch-cb678d735a91e07e762e9f6715584ccfbeaa3fcd.tar.gz
Sensor-Watch-cb678d735a91e07e762e9f6715584ccfbeaa3fcd.tar.bz2
Sensor-Watch-cb678d735a91e07e762e9f6715584ccfbeaa3fcd.zip
Merge branch 'main' into auto-fire-long-press
-rw-r--r--[-rwxr-xr-x]movement/make/Makefile1
-rw-r--r--movement/movement.c23
-rw-r--r--movement/movement.h2
-rw-r--r--movement/movement_config.h7
-rw-r--r--movement/movement_faces.h1
-rw-r--r--movement/watch_faces/clock/simple_clock_face.c20
-rw-r--r--movement/watch_faces/clock/simple_clock_face.h1
7 files changed, 47 insertions, 8 deletions
diff --git a/movement/make/Makefile b/movement/make/Makefile
index 064d289b..f0f26c3f 100755..100644
--- a/movement/make/Makefile
+++ b/movement/make/Makefile
@@ -68,6 +68,7 @@ SRCS += \
../watch_faces/complication/probability_face.c \
../watch_faces/complication/wake_face.c \
../watch_faces/demo/frequency_correction_face.c \
+ ../watch_faces/complication/alarm_face.c \
../watch_faces/complication/ratemeter_face.c \
# New watch faces go above this line.
diff --git a/movement/movement.c b/movement/movement.c
index c3b096e9..0ded11e3 100644
--- a/movement/movement.c
+++ b/movement/movement.c
@@ -52,6 +52,11 @@
#include "alt_fw/deep_space_now.h"
#endif
+// Default to no secondary face behaviour.
+#ifndef MOVEMENT_SECONDARY_FACE_INDEX
+#define MOVEMENT_SECONDARY_FACE_INDEX 0
+#endif
+
#if __EMSCRIPTEN__
#include <emscripten.h>
#endif
@@ -209,7 +214,13 @@ void movement_move_to_face(uint8_t watch_face_index) {
}
void movement_move_to_next_face(void) {
- movement_move_to_face((movement_state.current_watch_face + 1) % MOVEMENT_NUM_FACES);
+ uint16_t face_max;
+ if (MOVEMENT_SECONDARY_FACE_INDEX) {
+ face_max = (movement_state.current_watch_face < (int16_t)MOVEMENT_SECONDARY_FACE_INDEX) ? MOVEMENT_SECONDARY_FACE_INDEX : MOVEMENT_NUM_FACES;
+ } else {
+ face_max = MOVEMENT_NUM_FACES;
+ }
+ movement_move_to_face((movement_state.current_watch_face + 1) % face_max);
}
void movement_schedule_background_task(watch_date_time date_time) {
@@ -428,14 +439,18 @@ bool app_loop(void) {
can_sleep = watch_faces[movement_state.current_watch_face].loop(event, &movement_state.settings, watch_face_contexts[movement_state.current_watch_face]);
// Long-pressing MODE brings one back to the first face, provided that the watch face hasn't decided to send them elsewhere
- // (and we're not currently on the first face).
+ // (and we're not currently on the first face). If we're currently on the first face, a long press
+ // of MODE sends us to the secondary faces (if defined).
// Note that it's the face's responsibility to provide some way to get to the next face, so if EVENT_MODE_BUTTON_* is
// used for face functionality EVENT_MODE_LONG_PRESS should probably be handled and next_face() triggered in the face
// (which would effectively disable the normal 'long press to face 0' behaviour).
if (event.event_type == EVENT_MODE_LONG_PRESS
- && movement_state.current_watch_face > 0
&& !movement_state.watch_face_changed) {
- movement_move_to_face(0);
+ if (movement_state.current_watch_face != 0) {
+ movement_move_to_face(0);
+ } else if (MOVEMENT_SECONDARY_FACE_INDEX) {
+ movement_move_to_face(MOVEMENT_SECONDARY_FACE_INDEX);
+ }
}
event.event_type = EVENT_NONE;
}
diff --git a/movement/movement.h b/movement/movement.h
index 7b5c4647..9dc5fe82 100644
--- a/movement/movement.h
+++ b/movement/movement.h
@@ -61,7 +61,7 @@ typedef union {
// altimeter to display feet or meters as easily as it tells a thermometer to display degrees in F or C.
bool clock_mode_24h : 1; // indicates whether clock should use 12 or 24 hour mode.
bool use_imperial_units : 1; // indicates whether to use metric units (the default) or imperial.
- bool alarm_enabled : 1; // indicates whether there is at least one alarm enabled.
+ bool alarm_enabled : 1; // indicates wheter there is at least one alarm enabled.
uint8_t reserved : 6; // room for more preferences if needed.
} bit;
uint32_t reg;
diff --git a/movement/movement_config.h b/movement/movement_config.h
index 94456776..19a501ea 100644
--- a/movement/movement_config.h
+++ b/movement/movement_config.h
@@ -39,4 +39,11 @@ const watch_face_t watch_faces[] = {
#define MOVEMENT_NUM_FACES (sizeof(watch_faces) / sizeof(watch_face_t))
+/* Determines what face to go to from the first face if you've already set
+ * a mode long press to go to the first face in preferences, and
+ * excludes these faces from the normal rotation.
+ * Usually it makes sense to set this to the preferences face.
+ */
+#define MOVEMENT_SECONDARY_FACE_INDEX 0 // or (MOVEMENT_NUM_FACES - 2)
+
#endif // MOVEMENT_CONFIG_H_
diff --git a/movement/movement_faces.h b/movement/movement_faces.h
index 35931028..9aa5e6ca 100644
--- a/movement/movement_faces.h
+++ b/movement/movement_faces.h
@@ -55,6 +55,7 @@
#include "probability_face.h"
#include "wake_face.h"
#include "frequency_correction_face.h"
+#include "alarm_face.h"
#include "ratemeter_face.h"
// New includes go above this line.
diff --git a/movement/watch_faces/clock/simple_clock_face.c b/movement/watch_faces/clock/simple_clock_face.c
index 23f36672..7721b12a 100644
--- a/movement/watch_faces/clock/simple_clock_face.c
+++ b/movement/watch_faces/clock/simple_clock_face.c
@@ -27,6 +27,12 @@
#include "watch.h"
#include "watch_utility.h"
+static void _update_alarm_indicator(bool settings_alarm_enabled, simple_clock_state_t *state) {
+ state->alarm_enabled = settings_alarm_enabled;
+ if (state->alarm_enabled) watch_set_indicator(WATCH_INDICATOR_SIGNAL);
+ else watch_clear_indicator(WATCH_INDICATOR_SIGNAL);
+}
+
void simple_clock_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
(void) settings;
(void) watch_face_index;
@@ -45,7 +51,13 @@ void simple_clock_face_activate(movement_settings_t *settings, void *context) {
if (watch_tick_animation_is_running()) watch_stop_tick_animation();
if (settings->bit.clock_mode_24h) watch_set_indicator(WATCH_INDICATOR_24H);
- if (state->signal_enabled) watch_set_indicator(WATCH_INDICATOR_SIGNAL);
+
+ // handle chime indicator
+ if (state->signal_enabled) watch_set_indicator(WATCH_INDICATOR_BELL);
+ else watch_clear_indicator(WATCH_INDICATOR_BELL);
+
+ // show alarm indicator if there is an active alarm
+ _update_alarm_indicator(settings->bit.alarm_enabled, state);
watch_set_colon();
@@ -111,6 +123,8 @@ bool simple_clock_face_loop(movement_event_t event, movement_settings_t *setting
}
}
watch_display_string(buf, pos);
+ // handle alarm indicator
+ if (state->alarm_enabled != settings->bit.alarm_enabled) _update_alarm_indicator(settings->bit.alarm_enabled, state);
break;
case EVENT_MODE_BUTTON_UP:
movement_move_to_next_face();
@@ -120,8 +134,8 @@ bool simple_clock_face_loop(movement_event_t event, movement_settings_t *setting
break;
case EVENT_ALARM_LONG_PRESS:
state->signal_enabled = !state->signal_enabled;
- if (state->signal_enabled) watch_set_indicator(WATCH_INDICATOR_SIGNAL);
- else watch_clear_indicator(WATCH_INDICATOR_SIGNAL);
+ if (state->signal_enabled) watch_set_indicator(WATCH_INDICATOR_BELL);
+ else watch_clear_indicator(WATCH_INDICATOR_BELL);
break;
case EVENT_BACKGROUND_TASK:
// uncomment this line to snap back to the clock face when the hour signal sounds:
diff --git a/movement/watch_faces/clock/simple_clock_face.h b/movement/watch_faces/clock/simple_clock_face.h
index aa625700..1e9babad 100644
--- a/movement/watch_faces/clock/simple_clock_face.h
+++ b/movement/watch_faces/clock/simple_clock_face.h
@@ -33,6 +33,7 @@ typedef struct {
uint8_t watch_face_index;
bool signal_enabled;
bool battery_low;
+ bool alarm_enabled;
} simple_clock_state_t;
void simple_clock_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);