Skip to content

Commit a5a4dd1

Browse files
committed
Tally face sound now uses the preference's beep so decrementing fast can happen immedietly
1 parent 002f5bc commit a5a4dd1

File tree

2 files changed

+26
-36
lines changed

2 files changed

+26
-36
lines changed

movement/watch_faces/complication/tally_face.c

Lines changed: 24 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ void tally_face_setup(movement_settings_t *settings, uint8_t watch_face_index, v
4343
memset(*context_ptr, 0, sizeof(tally_state_t));
4444
tally_state_t *state = (tally_state_t *)*context_ptr;
4545
state->tally_default_idx = 0;
46-
state->soundOff = true;
4746
state->tally_idx = _tally_default[state->tally_default_idx];
4847
_init_val = true;
4948
}
@@ -65,34 +64,33 @@ static void stop_quick_cyc(void){
6564
movement_request_tick_frequency(1);
6665
}
6766

68-
static void tally_face_increment(tally_state_t *state) {
69-
bool soundOn = !_quick_ticks_running && !state->soundOff;
67+
static void tally_face_increment(tally_state_t *state, bool sound_on) {
68+
bool soundOn = !_quick_ticks_running && sound_on;
7069
_init_val = false;
7170
if (state->tally_idx >= TALLY_FACE_MAX){
7271
if (soundOn) watch_buzzer_play_note(BUZZER_NOTE_E7, 30);
7372
}
7473
else {
7574
state->tally_idx++;
76-
print_tally(state);
75+
print_tally(state, sound_on);
7776
if (soundOn) watch_buzzer_play_note(BUZZER_NOTE_E6, 30);
7877
}
7978
}
8079

81-
static void tally_face_decrement(tally_state_t *state) {
82-
bool soundOn = !_quick_ticks_running && !state->soundOff;
80+
static void tally_face_decrement(tally_state_t *state, bool sound_on) {
81+
bool soundOn = !_quick_ticks_running && sound_on;
8382
_init_val = false;
8483
if (state->tally_idx <= TALLY_FACE_MIN){
8584
if (soundOn) watch_buzzer_play_note(BUZZER_NOTE_C5SHARP_D5FLAT, 30);
8685
}
8786
else {
8887
state->tally_idx--;
89-
print_tally(state);
88+
print_tally(state, sound_on);
9089
if (soundOn) watch_buzzer_play_note(BUZZER_NOTE_C6SHARP_D6FLAT, 30);
9190
}
9291
}
9392

9493
bool tally_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
95-
(void) settings;
9694
tally_state_t *state = (tally_state_t *)context;
9795
static bool using_led = false;
9896

@@ -112,24 +110,17 @@ bool tally_face_loop(movement_event_t event, movement_settings_t *settings, void
112110
bool light_pressed = watch_get_pin_level(BTN_LIGHT);
113111
bool alarm_pressed = watch_get_pin_level(BTN_ALARM);
114112
if (light_pressed && alarm_pressed) stop_quick_cyc();
115-
else if (light_pressed) tally_face_increment(state);
116-
else if (alarm_pressed) tally_face_decrement(state);
113+
else if (light_pressed) tally_face_increment(state, settings->bit.button_should_sound);
114+
else if (alarm_pressed) tally_face_decrement(state, settings->bit.button_should_sound);
117115
else stop_quick_cyc();
118116
}
119117
break;
120118
case EVENT_ALARM_BUTTON_UP:
121-
tally_face_decrement(state);
119+
tally_face_decrement(state, settings->bit.button_should_sound);
122120
break;
123121
case EVENT_ALARM_LONG_PRESS:
124-
if (_init_val) {
125-
state->soundOff = !state->soundOff;
126-
if (!state->soundOff) watch_buzzer_play_note(BUZZER_NOTE_E6, 30);
127-
print_tally(state);
128-
}
129-
else{
130-
tally_face_decrement(state);
131-
start_quick_cyc();
132-
}
122+
tally_face_decrement(state, settings->bit.button_should_sound);
123+
start_quick_cyc();
133124
break;
134125
case EVENT_MODE_LONG_PRESS:
135126
if (state->tally_idx == _tally_default[state->tally_default_idx]) {
@@ -140,14 +131,14 @@ bool tally_face_loop(movement_event_t event, movement_settings_t *settings, void
140131
state->tally_idx = _tally_default[state->tally_default_idx]; // reset tally index
141132
_init_val = true;
142133
//play a reset tune
143-
if (!state->soundOff) watch_buzzer_play_note(BUZZER_NOTE_G6, 30);
144-
if (!state->soundOff) watch_buzzer_play_note(BUZZER_NOTE_REST, 30);
145-
if (!state->soundOff) watch_buzzer_play_note(BUZZER_NOTE_E6, 30);
146-
print_tally(state);
134+
if (settings->bit.button_should_sound) watch_buzzer_play_note(BUZZER_NOTE_G6, 30);
135+
if (settings->bit.button_should_sound) watch_buzzer_play_note(BUZZER_NOTE_REST, 30);
136+
if (settings->bit.button_should_sound) watch_buzzer_play_note(BUZZER_NOTE_E6, 30);
137+
print_tally(state, settings->bit.button_should_sound);
147138
}
148139
break;
149140
case EVENT_LIGHT_BUTTON_UP:
150-
tally_face_increment(state);
141+
tally_face_increment(state, settings->bit.button_should_sound);
151142
break;
152143
case EVENT_LIGHT_BUTTON_DOWN:
153144
case EVENT_ALARM_BUTTON_DOWN:
@@ -160,18 +151,18 @@ bool tally_face_loop(movement_event_t event, movement_settings_t *settings, void
160151
if (_init_val){
161152
state->tally_default_idx = (state->tally_default_idx + 1) % _tally_default_size;
162153
state->tally_idx = _tally_default[state->tally_default_idx];
163-
if (!state->soundOff) watch_buzzer_play_note(BUZZER_NOTE_E6, 30);
164-
if (!state->soundOff) watch_buzzer_play_note(BUZZER_NOTE_REST, 30);
165-
if (!state->soundOff) watch_buzzer_play_note(BUZZER_NOTE_G6, 30);
166-
print_tally(state);
154+
if (settings->bit.button_should_sound) watch_buzzer_play_note(BUZZER_NOTE_E6, 30);
155+
if (settings->bit.button_should_sound) watch_buzzer_play_note(BUZZER_NOTE_REST, 30);
156+
if (settings->bit.button_should_sound) watch_buzzer_play_note(BUZZER_NOTE_G6, 30);
157+
print_tally(state, settings->bit.button_should_sound);
167158
}
168159
else{
169-
tally_face_increment(state);
160+
tally_face_increment(state, settings->bit.button_should_sound);
170161
start_quick_cyc();
171162
}
172163
break;
173164
case EVENT_ACTIVATE:
174-
print_tally(state);
165+
print_tally(state, settings->bit.button_should_sound);
175166
break;
176167
case EVENT_TIMEOUT:
177168
// ignore timeout
@@ -185,9 +176,9 @@ bool tally_face_loop(movement_event_t event, movement_settings_t *settings, void
185176
}
186177

187178
// print tally index at the center of display.
188-
void print_tally(tally_state_t *state) {
179+
void print_tally(tally_state_t *state, bool sound_on) {
189180
char buf[14];
190-
if (!state->soundOff)
181+
if (sound_on)
191182
watch_set_indicator(WATCH_INDICATOR_BELL);
192183
else
193184
watch_clear_indicator(WATCH_INDICATOR_BELL);

movement/watch_faces/complication/tally_face.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@
5050

5151
typedef struct {
5252
int16_t tally_idx;
53-
uint8_t tally_default_idx : 7;
54-
bool soundOff;
53+
uint8_t tally_default_idx;
5554
} tally_state_t;
5655

5756

@@ -60,7 +59,7 @@ void tally_face_activate(movement_settings_t *settings, void *context);
6059
bool tally_face_loop(movement_event_t event, movement_settings_t *settings, void *context);
6160
void tally_face_resign(movement_settings_t *settings, void *context);
6261

63-
void print_tally(tally_state_t *state);
62+
void print_tally(tally_state_t *state, bool sound_on);
6463

6564
#define tally_face ((const watch_face_t){ \
6665
tally_face_setup, \

0 commit comments

Comments
 (0)