]> git.earman.xyz Git - sensor-watch.git/commitdiff
Revert "never disable buzzer output"
authorjoeycastillo <joeycastillo@utexas.edu>
Tue, 17 Jan 2023 14:52:01 +0000 (08:52 -0600)
committerjoeycastillo <joeycastillo@utexas.edu>
Tue, 17 Jan 2023 14:52:01 +0000 (08:52 -0600)
This reverts commit 851d047c818dacc30c86f4d87f33247dcfb0095c.

movement/watch_faces/clock/simple_clock_face.c
movement/watch_faces/clock/weeknumber_clock_face.c
movement/watch_faces/complication/alarm_face.c
watch-library/hardware/watch/watch_buzzer.c

index 760559986dae422f8806810e3c2ade4e16148425..179b23d60f480fb9f23ee6932b5d15c2ff7233a7 100644 (file)
@@ -142,7 +142,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:
             break;
index 45d751af086e851878260e9c39bbb7f997fdc6f6..e49e5abf743b7f6bb13da59c710dc6c065a2e841 100644 (file)
@@ -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;
index 9acf58997578ef3cf37cf7ee873f8294756ad2fb..5ad3976c24d404605a3f2feb21875bbc72dda386 100644 (file)
@@ -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), 
index b999397abb93067f616620e72782b3c858ee370c..18fb4db0c0138a8f355713b9bec97006964ff046 100644 (file)
@@ -147,7 +147,6 @@ inline void watch_enable_buzzer(void) {
     if (!hri_tcc_get_CTRLA_reg(TCC0, TCC_CTRLA_ENABLE)) {
         _watch_enable_tcc();
     }
-    gpio_set_pin_direction(BUZZER, GPIO_DIRECTION_OUT);
 }
 
 inline void watch_set_buzzer_period(uint32_t period) {
@@ -157,7 +156,6 @@ inline void watch_set_buzzer_period(uint32_t period) {
 
 void watch_disable_buzzer(void) {
     _watch_disable_tcc();
-    watch_set_buzzer_off();
 }
 
 inline void watch_set_buzzer_on(void) {
@@ -166,8 +164,8 @@ inline void watch_set_buzzer_on(void) {
 }
 
 inline void watch_set_buzzer_off(void) {
+    gpio_set_pin_direction(BUZZER, GPIO_DIRECTION_OFF);
     gpio_set_pin_function(BUZZER, GPIO_PIN_FUNCTION_OFF);
-    gpio_set_pin_level(BUZZER, true);
 }
 
 void watch_buzzer_play_note(BuzzerNote note, uint16_t duration_ms) {