@@ -43,7 +43,6 @@ void tally_face_setup(movement_settings_t *settings, uint8_t watch_face_index, v
43
43
memset (* context_ptr , 0 , sizeof (tally_state_t ));
44
44
tally_state_t * state = (tally_state_t * )* context_ptr ;
45
45
state -> tally_default_idx = 0 ;
46
- state -> soundOff = true;
47
46
state -> tally_idx = _tally_default [state -> tally_default_idx ];
48
47
_init_val = true;
49
48
}
@@ -65,34 +64,33 @@ static void stop_quick_cyc(void){
65
64
movement_request_tick_frequency (1 );
66
65
}
67
66
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 ;
70
69
_init_val = false;
71
70
if (state -> tally_idx >= TALLY_FACE_MAX ){
72
71
if (soundOn ) watch_buzzer_play_note (BUZZER_NOTE_E7 , 30 );
73
72
}
74
73
else {
75
74
state -> tally_idx ++ ;
76
- print_tally (state );
75
+ print_tally (state , sound_on );
77
76
if (soundOn ) watch_buzzer_play_note (BUZZER_NOTE_E6 , 30 );
78
77
}
79
78
}
80
79
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 ;
83
82
_init_val = false;
84
83
if (state -> tally_idx <= TALLY_FACE_MIN ){
85
84
if (soundOn ) watch_buzzer_play_note (BUZZER_NOTE_C5SHARP_D5FLAT , 30 );
86
85
}
87
86
else {
88
87
state -> tally_idx -- ;
89
- print_tally (state );
88
+ print_tally (state , sound_on );
90
89
if (soundOn ) watch_buzzer_play_note (BUZZER_NOTE_C6SHARP_D6FLAT , 30 );
91
90
}
92
91
}
93
92
94
93
bool tally_face_loop (movement_event_t event , movement_settings_t * settings , void * context ) {
95
- (void ) settings ;
96
94
tally_state_t * state = (tally_state_t * )context ;
97
95
static bool using_led = false;
98
96
@@ -112,24 +110,17 @@ bool tally_face_loop(movement_event_t event, movement_settings_t *settings, void
112
110
bool light_pressed = watch_get_pin_level (BTN_LIGHT );
113
111
bool alarm_pressed = watch_get_pin_level (BTN_ALARM );
114
112
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 );
117
115
else stop_quick_cyc ();
118
116
}
119
117
break ;
120
118
case EVENT_ALARM_BUTTON_UP :
121
- tally_face_decrement (state );
119
+ tally_face_decrement (state , settings -> bit . button_should_sound );
122
120
break ;
123
121
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 ();
133
124
break ;
134
125
case EVENT_MODE_LONG_PRESS :
135
126
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
140
131
state -> tally_idx = _tally_default [state -> tally_default_idx ]; // reset tally index
141
132
_init_val = true;
142
133
//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 );
147
138
}
148
139
break ;
149
140
case EVENT_LIGHT_BUTTON_UP :
150
- tally_face_increment (state );
141
+ tally_face_increment (state , settings -> bit . button_should_sound );
151
142
break ;
152
143
case EVENT_LIGHT_BUTTON_DOWN :
153
144
case EVENT_ALARM_BUTTON_DOWN :
@@ -160,18 +151,18 @@ bool tally_face_loop(movement_event_t event, movement_settings_t *settings, void
160
151
if (_init_val ){
161
152
state -> tally_default_idx = (state -> tally_default_idx + 1 ) % _tally_default_size ;
162
153
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 );
167
158
}
168
159
else {
169
- tally_face_increment (state );
160
+ tally_face_increment (state , settings -> bit . button_should_sound );
170
161
start_quick_cyc ();
171
162
}
172
163
break ;
173
164
case EVENT_ACTIVATE :
174
- print_tally (state );
165
+ print_tally (state , settings -> bit . button_should_sound );
175
166
break ;
176
167
case EVENT_TIMEOUT :
177
168
// ignore timeout
@@ -185,9 +176,9 @@ bool tally_face_loop(movement_event_t event, movement_settings_t *settings, void
185
176
}
186
177
187
178
// 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 ) {
189
180
char buf [14 ];
190
- if (! state -> soundOff )
181
+ if (sound_on )
191
182
watch_set_indicator (WATCH_INDICATOR_BELL );
192
183
else
193
184
watch_clear_indicator (WATCH_INDICATOR_BELL );
0 commit comments