Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow setting alarm presets at compile time #477

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions movement/watch_faces/complication/alarm_face.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,23 @@ void alarm_face_setup(movement_settings_t *settings, uint8_t watch_face_index, v
*context_ptr = malloc(sizeof(alarm_state_t));
alarm_state_t *state = (alarm_state_t *)*context_ptr;
memset(*context_ptr, 0, sizeof(alarm_state_t));
// initialize the default alarm values
uint8_t num_presets = sizeof(alarm_presets) / sizeof(alarm_presets[0]);
for (uint8_t i = 0; i < ALARM_ALARMS; i++) {
state->alarm[i].day = ALARM_DAY_EACH_DAY;
state->alarm[i].beeps = 5;
state->alarm[i].pitch = 1;
if (i < num_presets) {
state->alarm[i].day = alarm_presets[i].day;
state->alarm[i].hour = alarm_presets[i].hour;
state->alarm[i].minute = alarm_presets[i].minute;
state->alarm[i].beeps = alarm_presets[i].beeps;
state->alarm[i].pitch = alarm_presets[i].pitch;
state->alarm[i].enabled = alarm_presets[i].enabled;
} else {
// Default values for alarms without presets
state->alarm[i].day = ALARM_DAY_EACH_DAY;
state->alarm[i].beeps = 5;
state->alarm[i].pitch = 1;
}
}

state->alarm_handled_minute = -1;
_wait_ticks = -1;
}
Expand Down
5 changes: 5 additions & 0 deletions movement/watch_faces/complication/alarm_face.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ typedef struct {
bool enabled : 1;
} alarm_setting_t;

static const alarm_setting_t alarm_presets[] = {
//{ ALARM_DAY_WORKDAY, 6, 0, 5, 1, true },
//{ ALARM_DAY_WORKDAY, 16, 30, 5, 1, true },
};

typedef struct {
uint8_t alarm_idx : 4;
uint8_t alarm_playing_idx : 4;
Expand Down
Loading