Skip to content

Commit 178ef85

Browse files
committed
Merge branch 'main' into accel-interrupt-counter
2 parents ecb05a4 + bf4d461 commit 178ef85

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+7997
-170
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
env:
1010
COLOR: BLUE
1111

12-
jobs:
12+
jobs:
1313
build:
1414
container:
1515
image: ghcr.io/armmbed/mbed-os-env:latest
@@ -29,7 +29,7 @@ jobs:
2929
run: make
3030
working-directory: 'movement/make'
3131
- name: Upload UF2
32-
uses: actions/upload-artifact@v2
32+
uses: actions/upload-artifact@v4
3333
with:
3434
name: watch.uf2
3535
path: movement/make/build/watch.uf2
@@ -52,7 +52,7 @@ jobs:
5252
cp watch.html index.html
5353
tar -czf simulator.tar.gz index.html watch.wasm watch.js
5454
- name: Upload simulator build
55-
uses: actions/upload-artifact@v2
55+
uses: actions/upload-artifact@v4
5656
with:
5757
name: simulator.tar.gz
5858
path: movement/make/build-sim/simulator.tar.gz

apps/beats-time/app.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <string.h>
33
#include <math.h>
44
#include "watch.h"
5+
#include "watch_utility.h"
56

67
const int8_t UTC_OFFSET = 4; // set to your current UTC offset to see correct beats time
78
const uint8_t BEAT_REFRESH_FREQUENCY = 8;
@@ -203,7 +204,6 @@ void set_time_mode_handle_primary_button(void) {
203204

204205
void set_time_mode_handle_secondary_button(void) {
205206
watch_date_time date_time = watch_rtc_get_date_time();
206-
const uint8_t days_in_month[12] = {31, 28, 31, 30, 31, 30, 30, 31, 30, 31, 30, 31};
207207

208208
switch (application_state.page) {
209209
case 0: // hour
@@ -224,13 +224,10 @@ void set_time_mode_handle_secondary_button(void) {
224224
break;
225225
case 5: // day
226226
date_time.unit.day = date_time.unit.day + 1;
227-
// can't set to the 29th on a leap year. if it's february 29, set to 11:59 on the 28th.
228-
// and it should roll over.
229-
if (date_time.unit.day > days_in_month[date_time.unit.month - 1]) {
230-
date_time.unit.day = 1;
231-
}
232227
break;
233228
}
229+
if (date_time.unit.day > days_in_month(date_time.unit.month, date_time.unit.year + WATCH_RTC_REFERENCE_YEAR))
230+
date_time.unit.day = 1;
234231
watch_rtc_set_date_time(date_time);
235232
}
236233

make.mk

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,20 @@ SRCS += \
215215

216216
endif
217217

218+
ifeq ($(LED), BLUE)
219+
CFLAGS += -DWATCH_IS_BLUE_BOARD
220+
endif
221+
222+
ifndef COLOR
223+
$(error Set the COLOR variable to RED, BLUE, or GREEN depending on what board you have.)
224+
endif
225+
226+
COLOR_VALID := $(filter $(COLOR),RED BLUE GREEN)
227+
228+
ifeq ($(COLOR_VALID),)
229+
$(error COLOR must be RED, BLUE, or GREEN)
230+
endif
231+
218232
ifeq ($(COLOR), BLUE)
219233
CFLAGS += -DWATCH_IS_BLUE_BOARD
220234
endif

movement/make/Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ SRCS += \
5252
../shell.c \
5353
../shell_cmd_list.c \
5454
../watch_faces/clock/simple_clock_face.c \
55+
../watch_faces/clock/close_enough_clock_face.c \
5556
../watch_faces/clock/clock_face.c \
5657
../watch_faces/clock/world_clock_face.c \
5758
../watch_faces/clock/beats_face.c \
@@ -129,6 +130,17 @@ SRCS += \
129130
../watch_faces/clock/minute_repeater_decimal_face.c \
130131
../watch_faces/complication/tuning_tones_face.c \
131132
../watch_faces/complication/kitchen_conversions_face.c \
133+
../watch_faces/complication/wordle_face.c \
134+
../watch_faces/complication/endless_runner_face.c \
135+
../watch_faces/complication/periodic_face.c \
136+
../watch_faces/complication/deadline_face.c \
137+
../watch_faces/complication/higher_lower_game_face.c \
138+
../watch_faces/clock/french_revolutionary_face.c \
139+
../watch_faces/clock/minimal_clock_face.c \
140+
../watch_faces/complication/simon_face.c \
141+
../watch_faces/complication/simple_calculator_face.c \
142+
../watch_faces/sensor/alarm_thermometer_face.c \
143+
../watch_faces/demo/beeps_face.c \
132144
../watch_faces/sensor/accel_interrupt_count_face.c \
133145
# New watch faces go above this line.
134146

movement/movement.c

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ static void _movement_handle_scheduled_tasks(void) {
201201

202202
for(uint8_t i = 0; i < MOVEMENT_NUM_FACES; i++) {
203203
if (scheduled_tasks[i].reg) {
204-
if (scheduled_tasks[i].reg == date_time.reg) {
204+
if (scheduled_tasks[i].reg <= date_time.reg) {
205205
scheduled_tasks[i].reg = 0;
206206
movement_event_t background_event = { EVENT_BACKGROUND_TASK, 0 };
207207
watch_faces[i].loop(background_event, &movement_state.settings, watch_face_contexts[i]);
@@ -239,14 +239,24 @@ void movement_request_tick_frequency(uint8_t freq) {
239239
}
240240

241241
void movement_illuminate_led(void) {
242-
if (movement_state.settings.bit.led_duration) {
242+
if (movement_state.settings.bit.led_duration != 0b111) {
243243
watch_set_led_color(movement_state.settings.bit.led_red_color ? (0xF | movement_state.settings.bit.led_red_color << 4) : 0,
244244
movement_state.settings.bit.led_green_color ? (0xF | movement_state.settings.bit.led_green_color << 4) : 0);
245-
movement_state.light_ticks = (movement_state.settings.bit.led_duration * 2 - 1) * 128;
245+
if (movement_state.settings.bit.led_duration == 0) {
246+
movement_state.light_ticks = 1;
247+
} else {
248+
movement_state.light_ticks = (movement_state.settings.bit.led_duration * 2 - 1) * 128;
249+
}
246250
_movement_enable_fast_tick_if_needed();
247251
}
248252
}
249253

254+
static void _movement_led_off(void) {
255+
watch_set_led_off();
256+
movement_state.light_ticks = -1;
257+
_movement_disable_fast_tick_if_possible();
258+
}
259+
250260
bool movement_default_loop_handler(movement_event_t event, movement_settings_t *settings) {
251261
(void)settings;
252262

@@ -257,6 +267,11 @@ bool movement_default_loop_handler(movement_event_t event, movement_settings_t *
257267
case EVENT_LIGHT_BUTTON_DOWN:
258268
movement_illuminate_led();
259269
break;
270+
case EVENT_LIGHT_BUTTON_UP:
271+
if (movement_state.settings.bit.led_duration == 0) {
272+
_movement_led_off();
273+
}
274+
break;
260275
case EVENT_MODE_LONG_PRESS:
261276
if (MOVEMENT_SECONDARY_FACE_INDEX && movement_state.current_face_idx == 0) {
262277
movement_move_to_face(MOVEMENT_SECONDARY_FACE_INDEX);
@@ -328,6 +343,14 @@ static void end_buzzing_and_disable_buzzer(void) {
328343
watch_disable_buzzer();
329344
}
330345

346+
static void set_initial_clock_mode(void) {
347+
#ifdef CLOCK_FACE_24H_ONLY
348+
movement_state.settings.bit.clock_mode_24h = true;
349+
#else
350+
movement_state.settings.bit.clock_mode_24h = MOVEMENT_DEFAULT_24H_MODE;
351+
#endif
352+
}
353+
331354
void movement_play_signal(void) {
332355
void *maybe_disable_buzzer = end_buzzing_and_disable_buzzer;
333356
if (watch_is_buzzer_or_led_enabled()) {
@@ -376,14 +399,14 @@ void app_init(void) {
376399
#endif
377400

378401
memset(&movement_state, 0, sizeof(movement_state));
379-
380-
movement_state.settings.bit.clock_mode_24h = MOVEMENT_DEFAULT_24H_MODE;
402+
set_initial_clock_mode();
381403
movement_state.settings.bit.led_red_color = MOVEMENT_DEFAULT_RED_COLOR;
382404
movement_state.settings.bit.led_green_color = MOVEMENT_DEFAULT_GREEN_COLOR;
383405
movement_state.settings.bit.button_should_sound = MOVEMENT_DEFAULT_BUTTON_SOUND;
384406
movement_state.settings.bit.to_interval = MOVEMENT_DEFAULT_TIMEOUT_INTERVAL;
385407
movement_state.settings.bit.le_interval = MOVEMENT_DEFAULT_LOW_ENERGY_INTERVAL;
386408
movement_state.settings.bit.led_duration = MOVEMENT_DEFAULT_LED_DURATION;
409+
387410
movement_state.light_ticks = -1;
388411
movement_state.alarm_ticks = -1;
389412
movement_state.next_available_backup_register = 4;
@@ -503,9 +526,7 @@ bool app_loop(void) {
503526
if (watch_get_pin_level(BTN_LIGHT)) {
504527
movement_state.light_ticks = 1;
505528
} else {
506-
watch_set_led_off();
507-
movement_state.light_ticks = -1;
508-
_movement_disable_fast_tick_if_possible();
529+
_movement_led_off();
509530
}
510531
}
511532

@@ -543,6 +564,17 @@ bool app_loop(void) {
543564
event.subsecond = movement_state.subsecond;
544565
// the first trip through the loop overrides the can_sleep state
545566
can_sleep = wf->loop(event, &movement_state.settings, watch_face_contexts[movement_state.current_face_idx]);
567+
568+
// Keep light on if user is still interacting with the watch.
569+
if (movement_state.light_ticks > 0) {
570+
switch (event.event_type) {
571+
case EVENT_LIGHT_BUTTON_DOWN:
572+
case EVENT_MODE_BUTTON_DOWN:
573+
case EVENT_ALARM_BUTTON_DOWN:
574+
movement_illuminate_led();
575+
}
576+
}
577+
546578
event.event_type = EVENT_NONE;
547579
}
548580

movement/movement.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ typedef union {
5050
uint8_t to_interval : 2; // an inactivity interval for asking the active face to resign.
5151
bool to_always : 1; // if true, always time out from the active face to face 0. otherwise only faces that time out will resign (the default).
5252
uint8_t le_interval : 3; // 0 to disable low energy mode, or an inactivity interval for going into low energy mode.
53-
uint8_t led_duration : 2; // how many seconds to shine the LED for (x2), or 0 to disable it.
53+
uint8_t led_duration : 3; // how many seconds to shine the LED for (x2), 0 to shine only while the button is depressed, or all bits set to disable the LED altogether.
5454
uint8_t led_red_color : 4; // for general purpose illumination, the red LED value (0-15)
5555
uint8_t led_green_color : 4; // for general purpose illumination, the green LED value (0-15)
5656
uint8_t time_zone : 6; // an integer representing an index in the time zone table.
@@ -60,9 +60,10 @@ typedef union {
6060
// time-oriented complication like a sunrise/sunset timer, and a simple locale preference could tell an
6161
// altimeter to display feet or meters as easily as it tells a thermometer to display degrees in F or C.
6262
bool clock_mode_24h : 1; // indicates whether clock should use 12 or 24 hour mode.
63+
bool clock_24h_leading_zero : 1; // indicates whether clock should leading zero to indicate 24 hour mode.
6364
bool use_imperial_units : 1; // indicates whether to use metric units (the default) or imperial.
6465
bool alarm_enabled : 1; // indicates whether there is at least one alarm enabled.
65-
uint8_t reserved : 6; // room for more preferences if needed.
66+
uint8_t reserved : 5; // room for more preferences if needed.
6667
} bit;
6768
uint32_t reg;
6869
} movement_settings_t;

movement/movement_custom_signal_tunes.h

Lines changed: 122 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,21 +67,139 @@ int8_t signal_tune[] = {
6767
};
6868
#endif // SIGNAL_TUNE_MARIO_THEME
6969

70+
#ifdef SIGNAL_TUNE_MGS_CODEC
71+
int8_t signal_tune[] = {
72+
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
73+
BUZZER_NOTE_C6, 1,
74+
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
75+
BUZZER_NOTE_C6, 1,
76+
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
77+
BUZZER_NOTE_C6, 1,
78+
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
79+
BUZZER_NOTE_C6, 1,
80+
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
81+
BUZZER_NOTE_C6, 1,
82+
BUZZER_NOTE_REST, 6,
83+
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
84+
BUZZER_NOTE_C6, 1,
85+
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
86+
BUZZER_NOTE_C6, 1,
87+
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
88+
BUZZER_NOTE_C6, 1,
89+
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
90+
BUZZER_NOTE_C6, 1,
91+
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
92+
BUZZER_NOTE_C6, 1,
93+
0
94+
};
95+
#endif // SIGNAL_TUNE_MGS_CODEC
96+
7097
#ifdef SIGNAL_TUNE_KIM_POSSIBLE
7198
int8_t signal_tune[] = {
7299
BUZZER_NOTE_G7, 6,
73-
BUZZER_NOTE_REST, 1,
74-
BUZZER_NOTE_G4, 3,
100+
BUZZER_NOTE_G4, 2,
75101
BUZZER_NOTE_REST, 5,
76102
BUZZER_NOTE_G7, 6,
77-
BUZZER_NOTE_REST, 1,
78-
BUZZER_NOTE_G4, 3,
103+
BUZZER_NOTE_G4, 2,
79104
BUZZER_NOTE_REST, 5,
80105
BUZZER_NOTE_A7SHARP_B7FLAT, 6,
81106
BUZZER_NOTE_REST, 2,
82107
BUZZER_NOTE_G7, 6,
108+
BUZZER_NOTE_G4, 2,
83109
0
84110
};
85111
#endif // SIGNAL_TUNE_KIM_POSSIBLE
86112

113+
#ifdef SIGNAL_TUNE_POWER_RANGERS
114+
int8_t signal_tune[] = {
115+
BUZZER_NOTE_D8, 6,
116+
BUZZER_NOTE_REST, 8,
117+
BUZZER_NOTE_D8, 6,
118+
BUZZER_NOTE_REST, 8,
119+
BUZZER_NOTE_C8, 6,
120+
BUZZER_NOTE_REST, 2,
121+
BUZZER_NOTE_D8, 6,
122+
BUZZER_NOTE_REST, 8,
123+
BUZZER_NOTE_F8, 6,
124+
BUZZER_NOTE_REST, 8,
125+
BUZZER_NOTE_D8, 6,
126+
0
127+
};
128+
#endif // SIGNAL_TUNE_POWER_RANGERS
129+
130+
#ifdef SIGNAL_TUNE_LAYLA
131+
int8_t signal_tune[] = {
132+
BUZZER_NOTE_A6, 5,
133+
BUZZER_NOTE_REST, 1,
134+
BUZZER_NOTE_C7, 5,
135+
BUZZER_NOTE_REST, 1,
136+
BUZZER_NOTE_D7, 5,
137+
BUZZER_NOTE_REST, 1,
138+
BUZZER_NOTE_F7, 5,
139+
BUZZER_NOTE_REST, 1,
140+
BUZZER_NOTE_D7, 5,
141+
BUZZER_NOTE_REST, 1,
142+
BUZZER_NOTE_C7, 5,
143+
BUZZER_NOTE_REST, 1,
144+
BUZZER_NOTE_D7, 20,
145+
0
146+
};
147+
#endif // SIGNAL_TUNE_LAYLA
148+
149+
#ifdef SIGNAL_TUNE_HARRY_POTTER_SHORT
150+
int8_t signal_tune[] = {
151+
BUZZER_NOTE_B5, 12,
152+
BUZZER_NOTE_REST, 1,
153+
BUZZER_NOTE_E6, 12,
154+
BUZZER_NOTE_REST, 1,
155+
BUZZER_NOTE_G6, 6,
156+
BUZZER_NOTE_REST, 1,
157+
BUZZER_NOTE_F6SHARP_G6FLAT, 6,
158+
BUZZER_NOTE_REST, 1,
159+
BUZZER_NOTE_E6, 16,
160+
BUZZER_NOTE_REST, 1,
161+
BUZZER_NOTE_B6, 8,
162+
BUZZER_NOTE_REST, 1,
163+
BUZZER_NOTE_A6, 24,
164+
BUZZER_NOTE_REST, 1,
165+
BUZZER_NOTE_F6SHARP_G6FLAT, 24,
166+
0
167+
};
168+
#endif // SIGNAL_TUNE_HARRY_POTTER_SHORT
169+
170+
#ifdef SIGNAL_TUNE_HARRY_POTTER_LONG
171+
int8_t signal_tune[] = {
172+
BUZZER_NOTE_B5, 12,
173+
BUZZER_NOTE_REST, 1,
174+
BUZZER_NOTE_E6, 12,
175+
BUZZER_NOTE_REST, 1,
176+
BUZZER_NOTE_G6, 6,
177+
BUZZER_NOTE_REST, 1,
178+
BUZZER_NOTE_F6SHARP_G6FLAT, 6,
179+
BUZZER_NOTE_REST, 1,
180+
BUZZER_NOTE_E6, 16,
181+
BUZZER_NOTE_REST, 1,
182+
BUZZER_NOTE_B6, 8,
183+
BUZZER_NOTE_REST, 1,
184+
BUZZER_NOTE_A6, 24,
185+
BUZZER_NOTE_REST, 1,
186+
BUZZER_NOTE_F6SHARP_G6FLAT, 24,
187+
BUZZER_NOTE_REST, 1,
188+
189+
BUZZER_NOTE_E6, 12,
190+
BUZZER_NOTE_REST, 1,
191+
BUZZER_NOTE_G6, 6,
192+
BUZZER_NOTE_REST, 1,
193+
BUZZER_NOTE_F6SHARP_G6FLAT, 6,
194+
BUZZER_NOTE_REST, 1,
195+
BUZZER_NOTE_D6SHARP_E6FLAT, 16,
196+
BUZZER_NOTE_REST, 1,
197+
BUZZER_NOTE_F6, 8,
198+
BUZZER_NOTE_REST, 1,
199+
BUZZER_NOTE_B5, 24,
200+
201+
0
202+
};
203+
#endif // SIGNAL_TUNE_HARRY_POTTER_LONG
204+
87205
#endif // MOVEMENT_CUSTOM_SIGNAL_TUNES_H_

0 commit comments

Comments
 (0)