Skip to content

Commit

Permalink
Merge branch 'main' into accel-interrupt-counter
Browse files Browse the repository at this point in the history
  • Loading branch information
joeycastillo committed Sep 18, 2024
2 parents ecb05a4 + bf4d461 commit 178ef85
Show file tree
Hide file tree
Showing 66 changed files with 7,997 additions and 170 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
env:
COLOR: BLUE

jobs:
jobs:
build:
container:
image: ghcr.io/armmbed/mbed-os-env:latest
Expand All @@ -29,7 +29,7 @@ jobs:
run: make
working-directory: 'movement/make'
- name: Upload UF2
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: watch.uf2
path: movement/make/build/watch.uf2
Expand All @@ -52,7 +52,7 @@ jobs:
cp watch.html index.html
tar -czf simulator.tar.gz index.html watch.wasm watch.js
- name: Upload simulator build
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: simulator.tar.gz
path: movement/make/build-sim/simulator.tar.gz
9 changes: 3 additions & 6 deletions apps/beats-time/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <string.h>
#include <math.h>
#include "watch.h"
#include "watch_utility.h"

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

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

switch (application_state.page) {
case 0: // hour
Expand All @@ -224,13 +224,10 @@ void set_time_mode_handle_secondary_button(void) {
break;
case 5: // day
date_time.unit.day = date_time.unit.day + 1;
// can't set to the 29th on a leap year. if it's february 29, set to 11:59 on the 28th.
// and it should roll over.
if (date_time.unit.day > days_in_month[date_time.unit.month - 1]) {
date_time.unit.day = 1;
}
break;
}
if (date_time.unit.day > days_in_month(date_time.unit.month, date_time.unit.year + WATCH_RTC_REFERENCE_YEAR))
date_time.unit.day = 1;
watch_rtc_set_date_time(date_time);
}

Expand Down
14 changes: 14 additions & 0 deletions make.mk
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,20 @@ SRCS += \

endif

ifeq ($(LED), BLUE)
CFLAGS += -DWATCH_IS_BLUE_BOARD
endif

ifndef COLOR
$(error Set the COLOR variable to RED, BLUE, or GREEN depending on what board you have.)
endif

COLOR_VALID := $(filter $(COLOR),RED BLUE GREEN)

ifeq ($(COLOR_VALID),)
$(error COLOR must be RED, BLUE, or GREEN)
endif

ifeq ($(COLOR), BLUE)
CFLAGS += -DWATCH_IS_BLUE_BOARD
endif
Expand Down
12 changes: 12 additions & 0 deletions movement/make/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ SRCS += \
../shell.c \
../shell_cmd_list.c \
../watch_faces/clock/simple_clock_face.c \
../watch_faces/clock/close_enough_clock_face.c \
../watch_faces/clock/clock_face.c \
../watch_faces/clock/world_clock_face.c \
../watch_faces/clock/beats_face.c \
Expand Down Expand Up @@ -129,6 +130,17 @@ SRCS += \
../watch_faces/clock/minute_repeater_decimal_face.c \
../watch_faces/complication/tuning_tones_face.c \
../watch_faces/complication/kitchen_conversions_face.c \
../watch_faces/complication/wordle_face.c \
../watch_faces/complication/endless_runner_face.c \
../watch_faces/complication/periodic_face.c \
../watch_faces/complication/deadline_face.c \
../watch_faces/complication/higher_lower_game_face.c \
../watch_faces/clock/french_revolutionary_face.c \
../watch_faces/clock/minimal_clock_face.c \
../watch_faces/complication/simon_face.c \
../watch_faces/complication/simple_calculator_face.c \
../watch_faces/sensor/alarm_thermometer_face.c \
../watch_faces/demo/beeps_face.c \
../watch_faces/sensor/accel_interrupt_count_face.c \
# New watch faces go above this line.

Expand Down
48 changes: 40 additions & 8 deletions movement/movement.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ static void _movement_handle_scheduled_tasks(void) {

for(uint8_t i = 0; i < MOVEMENT_NUM_FACES; i++) {
if (scheduled_tasks[i].reg) {
if (scheduled_tasks[i].reg == date_time.reg) {
if (scheduled_tasks[i].reg <= date_time.reg) {
scheduled_tasks[i].reg = 0;
movement_event_t background_event = { EVENT_BACKGROUND_TASK, 0 };
watch_faces[i].loop(background_event, &movement_state.settings, watch_face_contexts[i]);
Expand Down Expand Up @@ -239,14 +239,24 @@ void movement_request_tick_frequency(uint8_t freq) {
}

void movement_illuminate_led(void) {
if (movement_state.settings.bit.led_duration) {
if (movement_state.settings.bit.led_duration != 0b111) {
watch_set_led_color(movement_state.settings.bit.led_red_color ? (0xF | movement_state.settings.bit.led_red_color << 4) : 0,
movement_state.settings.bit.led_green_color ? (0xF | movement_state.settings.bit.led_green_color << 4) : 0);
movement_state.light_ticks = (movement_state.settings.bit.led_duration * 2 - 1) * 128;
if (movement_state.settings.bit.led_duration == 0) {
movement_state.light_ticks = 1;
} else {
movement_state.light_ticks = (movement_state.settings.bit.led_duration * 2 - 1) * 128;
}
_movement_enable_fast_tick_if_needed();
}
}

static void _movement_led_off(void) {
watch_set_led_off();
movement_state.light_ticks = -1;
_movement_disable_fast_tick_if_possible();
}

bool movement_default_loop_handler(movement_event_t event, movement_settings_t *settings) {
(void)settings;

Expand All @@ -257,6 +267,11 @@ bool movement_default_loop_handler(movement_event_t event, movement_settings_t *
case EVENT_LIGHT_BUTTON_DOWN:
movement_illuminate_led();
break;
case EVENT_LIGHT_BUTTON_UP:
if (movement_state.settings.bit.led_duration == 0) {
_movement_led_off();
}
break;
case EVENT_MODE_LONG_PRESS:
if (MOVEMENT_SECONDARY_FACE_INDEX && movement_state.current_face_idx == 0) {
movement_move_to_face(MOVEMENT_SECONDARY_FACE_INDEX);
Expand Down Expand Up @@ -328,6 +343,14 @@ static void end_buzzing_and_disable_buzzer(void) {
watch_disable_buzzer();
}

static void set_initial_clock_mode(void) {
#ifdef CLOCK_FACE_24H_ONLY
movement_state.settings.bit.clock_mode_24h = true;
#else
movement_state.settings.bit.clock_mode_24h = MOVEMENT_DEFAULT_24H_MODE;
#endif
}

void movement_play_signal(void) {
void *maybe_disable_buzzer = end_buzzing_and_disable_buzzer;
if (watch_is_buzzer_or_led_enabled()) {
Expand Down Expand Up @@ -376,14 +399,14 @@ void app_init(void) {
#endif

memset(&movement_state, 0, sizeof(movement_state));

movement_state.settings.bit.clock_mode_24h = MOVEMENT_DEFAULT_24H_MODE;
set_initial_clock_mode();
movement_state.settings.bit.led_red_color = MOVEMENT_DEFAULT_RED_COLOR;
movement_state.settings.bit.led_green_color = MOVEMENT_DEFAULT_GREEN_COLOR;
movement_state.settings.bit.button_should_sound = MOVEMENT_DEFAULT_BUTTON_SOUND;
movement_state.settings.bit.to_interval = MOVEMENT_DEFAULT_TIMEOUT_INTERVAL;
movement_state.settings.bit.le_interval = MOVEMENT_DEFAULT_LOW_ENERGY_INTERVAL;
movement_state.settings.bit.led_duration = MOVEMENT_DEFAULT_LED_DURATION;

movement_state.light_ticks = -1;
movement_state.alarm_ticks = -1;
movement_state.next_available_backup_register = 4;
Expand Down Expand Up @@ -503,9 +526,7 @@ bool app_loop(void) {
if (watch_get_pin_level(BTN_LIGHT)) {
movement_state.light_ticks = 1;
} else {
watch_set_led_off();
movement_state.light_ticks = -1;
_movement_disable_fast_tick_if_possible();
_movement_led_off();
}
}

Expand Down Expand Up @@ -543,6 +564,17 @@ bool app_loop(void) {
event.subsecond = movement_state.subsecond;
// the first trip through the loop overrides the can_sleep state
can_sleep = wf->loop(event, &movement_state.settings, watch_face_contexts[movement_state.current_face_idx]);

// Keep light on if user is still interacting with the watch.
if (movement_state.light_ticks > 0) {
switch (event.event_type) {
case EVENT_LIGHT_BUTTON_DOWN:
case EVENT_MODE_BUTTON_DOWN:
case EVENT_ALARM_BUTTON_DOWN:
movement_illuminate_led();
}
}

event.event_type = EVENT_NONE;
}

Expand Down
5 changes: 3 additions & 2 deletions movement/movement.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ typedef union {
uint8_t to_interval : 2; // an inactivity interval for asking the active face to resign.
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).
uint8_t le_interval : 3; // 0 to disable low energy mode, or an inactivity interval for going into low energy mode.
uint8_t led_duration : 2; // how many seconds to shine the LED for (x2), or 0 to disable it.
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.
uint8_t led_red_color : 4; // for general purpose illumination, the red LED value (0-15)
uint8_t led_green_color : 4; // for general purpose illumination, the green LED value (0-15)
uint8_t time_zone : 6; // an integer representing an index in the time zone table.
Expand All @@ -60,9 +60,10 @@ typedef union {
// time-oriented complication like a sunrise/sunset timer, and a simple locale preference could tell an
// 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 clock_24h_leading_zero : 1; // indicates whether clock should leading zero to indicate 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.
uint8_t reserved : 6; // room for more preferences if needed.
uint8_t reserved : 5; // room for more preferences if needed.
} bit;
uint32_t reg;
} movement_settings_t;
Expand Down
126 changes: 122 additions & 4 deletions movement/movement_custom_signal_tunes.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,139 @@ int8_t signal_tune[] = {
};
#endif // SIGNAL_TUNE_MARIO_THEME

#ifdef SIGNAL_TUNE_MGS_CODEC
int8_t signal_tune[] = {
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
BUZZER_NOTE_C6, 1,
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
BUZZER_NOTE_C6, 1,
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
BUZZER_NOTE_C6, 1,
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
BUZZER_NOTE_C6, 1,
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
BUZZER_NOTE_C6, 1,
BUZZER_NOTE_REST, 6,
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
BUZZER_NOTE_C6, 1,
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
BUZZER_NOTE_C6, 1,
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
BUZZER_NOTE_C6, 1,
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
BUZZER_NOTE_C6, 1,
BUZZER_NOTE_G5SHARP_A5FLAT, 1,
BUZZER_NOTE_C6, 1,
0
};
#endif // SIGNAL_TUNE_MGS_CODEC

#ifdef SIGNAL_TUNE_KIM_POSSIBLE
int8_t signal_tune[] = {
BUZZER_NOTE_G7, 6,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_G4, 3,
BUZZER_NOTE_G4, 2,
BUZZER_NOTE_REST, 5,
BUZZER_NOTE_G7, 6,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_G4, 3,
BUZZER_NOTE_G4, 2,
BUZZER_NOTE_REST, 5,
BUZZER_NOTE_A7SHARP_B7FLAT, 6,
BUZZER_NOTE_REST, 2,
BUZZER_NOTE_G7, 6,
BUZZER_NOTE_G4, 2,
0
};
#endif // SIGNAL_TUNE_KIM_POSSIBLE

#ifdef SIGNAL_TUNE_POWER_RANGERS
int8_t signal_tune[] = {
BUZZER_NOTE_D8, 6,
BUZZER_NOTE_REST, 8,
BUZZER_NOTE_D8, 6,
BUZZER_NOTE_REST, 8,
BUZZER_NOTE_C8, 6,
BUZZER_NOTE_REST, 2,
BUZZER_NOTE_D8, 6,
BUZZER_NOTE_REST, 8,
BUZZER_NOTE_F8, 6,
BUZZER_NOTE_REST, 8,
BUZZER_NOTE_D8, 6,
0
};
#endif // SIGNAL_TUNE_POWER_RANGERS

#ifdef SIGNAL_TUNE_LAYLA
int8_t signal_tune[] = {
BUZZER_NOTE_A6, 5,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_C7, 5,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_D7, 5,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_F7, 5,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_D7, 5,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_C7, 5,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_D7, 20,
0
};
#endif // SIGNAL_TUNE_LAYLA

#ifdef SIGNAL_TUNE_HARRY_POTTER_SHORT
int8_t signal_tune[] = {
BUZZER_NOTE_B5, 12,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_E6, 12,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_G6, 6,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_F6SHARP_G6FLAT, 6,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_E6, 16,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_B6, 8,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_A6, 24,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_F6SHARP_G6FLAT, 24,
0
};
#endif // SIGNAL_TUNE_HARRY_POTTER_SHORT

#ifdef SIGNAL_TUNE_HARRY_POTTER_LONG
int8_t signal_tune[] = {
BUZZER_NOTE_B5, 12,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_E6, 12,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_G6, 6,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_F6SHARP_G6FLAT, 6,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_E6, 16,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_B6, 8,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_A6, 24,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_F6SHARP_G6FLAT, 24,
BUZZER_NOTE_REST, 1,

BUZZER_NOTE_E6, 12,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_G6, 6,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_F6SHARP_G6FLAT, 6,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_D6SHARP_E6FLAT, 16,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_F6, 8,
BUZZER_NOTE_REST, 1,
BUZZER_NOTE_B5, 24,

0
};
#endif // SIGNAL_TUNE_HARRY_POTTER_LONG

#endif // MOVEMENT_CUSTOM_SIGNAL_TUNES_H_
Loading

0 comments on commit 178ef85

Please sign in to comment.