diff options
Diffstat (limited to 'movement')
-rw-r--r-- | movement/watch_faces/clock/simple_clock_face.c | 12 | ||||
-rw-r--r-- | movement/watch_faces/clock/weeknumber_clock_face.c | 12 | ||||
-rw-r--r-- | movement/watch_faces/complication/alarm_face.c | 10 | ||||
-rw-r--r-- | movement/watch_faces/complication/rpn_calculator_face.c | 30 |
4 files changed, 47 insertions, 17 deletions
diff --git a/movement/watch_faces/clock/simple_clock_face.c b/movement/watch_faces/clock/simple_clock_face.c index fbc2c4b3..91400b6c 100644 --- a/movement/watch_faces/clock/simple_clock_face.c +++ b/movement/watch_faces/clock/simple_clock_face.c @@ -136,7 +136,17 @@ bool simple_clock_face_loop(movement_event_t event, movement_settings_t *setting case EVENT_BACKGROUND_TASK: // uncomment this line to snap back to the clock face when the hour signal sounds: // movement_move_to_face(state->watch_face_index); - movement_play_signal(); + if (watch_is_buzzer_or_led_enabled()) { + // if we are in the foreground, we can just beep. + movement_play_signal(); + } else { + // if we were in the background, we need to enable the buzzer peripheral first, + watch_enable_buzzer(); + // beep quickly (this call blocks for 275 ms), + movement_play_signal(); + // and then turn the buzzer peripheral off again. + watch_disable_buzzer(); + } break; default: return movement_default_loop_handler(event, settings); diff --git a/movement/watch_faces/clock/weeknumber_clock_face.c b/movement/watch_faces/clock/weeknumber_clock_face.c index 45d751af..e49e5abf 100644 --- a/movement/watch_faces/clock/weeknumber_clock_face.c +++ b/movement/watch_faces/clock/weeknumber_clock_face.c @@ -136,7 +136,17 @@ bool weeknumber_clock_face_loop(movement_event_t event, movement_settings_t *set case EVENT_BACKGROUND_TASK: // uncomment this line to snap back to the clock face when the hour signal sounds: // movement_move_to_face(state->watch_face_index); - movement_play_signal(); + if (watch_is_buzzer_or_led_enabled()) { + // if we are in the foreground, we can just beep. + movement_play_signal(); + } else { + // if we were in the background, we need to enable the buzzer peripheral first, + watch_enable_buzzer(); + // beep quickly (this call blocks for 275 ms), + movement_play_signal(); + // and then turn the buzzer peripheral off again. + watch_disable_buzzer(); + } break; default: break; diff --git a/movement/watch_faces/complication/alarm_face.c b/movement/watch_faces/complication/alarm_face.c index 9acf5899..5ad3976c 100644 --- a/movement/watch_faces/complication/alarm_face.c +++ b/movement/watch_faces/complication/alarm_face.c @@ -417,7 +417,15 @@ bool alarm_face_loop(movement_event_t event, movement_settings_t *settings, void case EVENT_BACKGROUND_TASK: // play alarm if (state->alarm[state->alarm_playing_idx].beeps == 0) { - _alarm_play_short_beep(state->alarm[state->alarm_playing_idx].pitch); + // short beep + if (watch_is_buzzer_or_led_enabled()) { + _alarm_play_short_beep(state->alarm[state->alarm_playing_idx].pitch); + } else { + // enable, play beep and disable buzzer again + watch_enable_buzzer(); + _alarm_play_short_beep(state->alarm[state->alarm_playing_idx].pitch); + watch_disable_buzzer(); + } } else { // regular alarm beeps movement_play_alarm_beeps((state->alarm[state->alarm_playing_idx].beeps == (ALARM_MAX_BEEP_ROUNDS - 1) ? 20 : state->alarm[state->alarm_playing_idx].beeps), diff --git a/movement/watch_faces/complication/rpn_calculator_face.c b/movement/watch_faces/complication/rpn_calculator_face.c index 5ba5e559..9271a101 100644 --- a/movement/watch_faces/complication/rpn_calculator_face.c +++ b/movement/watch_faces/complication/rpn_calculator_face.c @@ -79,7 +79,7 @@ static void next_op(rpn_calculator_state_t *state) { // FIXME: this converts the number to string and back, there might // be better ways to do this static float inc_digit(float num, uint8_t position) { - char buf[7]; + char buf[8]; if (position > 5) { return 0.0; } @@ -203,7 +203,7 @@ static void run_op(rpn_calculator_state_t *state) { state->mode = rpn_calculator_err; } -static void draw(rpn_calculator_state_t *state, uint8_t subsecond, movement_settings_t *settings) { +static void draw(rpn_calculator_state_t *state, uint8_t subsecond) { char buf[16]; switch (state->mode) { case rpn_calculator_err: @@ -234,6 +234,7 @@ static void draw(rpn_calculator_state_t *state, uint8_t subsecond, movement_sett void rpn_calculator_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) { (void) settings; + (void) watch_face_index; if (*context_ptr == NULL) { *context_ptr = malloc(sizeof(rpn_calculator_state_t)); memset(*context_ptr, 0, sizeof(rpn_calculator_state_t)); @@ -246,29 +247,30 @@ void rpn_calculator_face_setup(movement_settings_t *settings, uint8_t watch_face void rpn_calculator_face_activate(movement_settings_t *settings, void *context) { (void) settings; - rpn_calculator_state_t *state = (rpn_calculator_state_t *)context; - (void) state; + (void) context; // Handle any tasks related to your watch face coming on screen. } bool rpn_calculator_face_loop(movement_event_t event, movement_settings_t *settings, void *context) { + (void) settings; + rpn_calculator_state_t *state = (rpn_calculator_state_t *)context; switch (event.event_type) { case EVENT_ACTIVATE: - draw(state, event.subsecond, settings); + draw(state, event.subsecond); break; case EVENT_TICK: if (state->mode == rpn_calculator_number) { - draw(state, event.subsecond, settings); + draw(state, event.subsecond); } break; case EVENT_MODE_BUTTON_UP: switch (state->mode) { case rpn_calculator_number: state->mode = rpn_calculator_waiting; - draw(state, event.subsecond, settings); + draw(state, event.subsecond); movement_request_tick_frequency(1); break; default: @@ -282,15 +284,15 @@ bool rpn_calculator_face_loop(movement_event_t event, movement_settings_t *setti switch (state->mode) { case rpn_calculator_waiting: state->mode = rpn_calculator_op; - draw(state, event.subsecond, settings); + draw(state, event.subsecond); break; case rpn_calculator_number: state->selection = (state->selection + 1) % 6; - draw(state, event.subsecond, settings); + draw(state, event.subsecond); break; case rpn_calculator_op: next_op(state); - draw(state, event.subsecond, settings); + draw(state, event.subsecond); break; default: movement_illuminate_led(); @@ -303,21 +305,21 @@ bool rpn_calculator_face_loop(movement_event_t event, movement_settings_t *setti state->mode = rpn_calculator_number; state->selection = 2; stack_push(state, 0); - draw(state, event.subsecond, settings); + draw(state, event.subsecond); movement_request_tick_frequency(4); break; case rpn_calculator_number: state->stack[state->top] = inc_digit(state->stack[state->top], state->selection); printf_stack(state); - draw(state, event.subsecond, settings); + draw(state, event.subsecond); break; case rpn_calculator_err: state->mode = rpn_calculator_waiting; - draw(state, event.subsecond, settings); + draw(state, event.subsecond); break; case rpn_calculator_op: run_op(state); - draw(state, event.subsecond, settings); + draw(state, event.subsecond); break; default: break; |