Skip to content

Commit

Permalink
allow setting alarm presets at compile time
Browse files Browse the repository at this point in the history
  • Loading branch information
mcguirepr89 committed Sep 19, 2024
1 parent e8f31be commit be682a2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
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

0 comments on commit be682a2

Please sign in to comment.