]> git.earman.xyz Git - sensor-watch.git/commitdiff
rename enum, rearrange watch_tcc.h
authorjoeycastillo <joeycastillo@utexas.edu>
Sun, 22 Sep 2024 18:26:49 +0000 (14:26 -0400)
committerjoeycastillo <joeycastillo@utexas.edu>
Sun, 22 Sep 2024 18:26:49 +0000 (14:26 -0400)
movement.c
movement.h
movement/watch_faces/complication/alarm_face.c
movement/watch_faces/complication/breathing_face.c
movement/watch_faces/complication/tuning_tones_face.c
watch-library/hardware/watch/watch_tcc.c
watch-library/shared/watch/watch_tcc.h
watch-library/simulator/watch/watch_tcc.c

index 0e505b497c109db02ded433da078567c2c76c285..96e30c56d06d673f49a7da78b61170793401778f 100644 (file)
@@ -373,7 +373,7 @@ void movement_play_alarm(void) {
     movement_play_alarm_beeps(5, BUZZER_NOTE_C8);
 }
 
-void movement_play_alarm_beeps(uint8_t rounds, BuzzerNote alarm_note) {
+void movement_play_alarm_beeps(uint8_t rounds, watch_buzzer_note_t alarm_note) {
     if (rounds == 0) rounds = 1;
     if (rounds > 20) rounds = 20;
     movement_request_wake();
index 2dd53ee60d11fe2151996ead90b740d7c1f2976e..439ce625112dbb4519e717f578a92bff521f5786 100644 (file)
@@ -256,7 +256,7 @@ typedef struct {
     // alarm stuff
     int16_t alarm_ticks;
     bool is_buzzing;
-    BuzzerNote alarm_note;
+    watch_buzzer_note_t alarm_note;
 
     // button tracking for long press
     uint16_t light_down_timestamp;
@@ -308,6 +308,6 @@ void movement_request_wake(void);
 
 void movement_play_signal(void);
 void movement_play_alarm(void);
-void movement_play_alarm_beeps(uint8_t rounds, BuzzerNote alarm_note);
+void movement_play_alarm_beeps(uint8_t rounds, watch_buzzer_note_t alarm_note);
 
 uint8_t movement_claim_backup_register(void);
index 0340c08df99e6c14a693d679d3928f19d1eb7774..6a949cba8536e6e4d164ef7cd94551a61c3ec61b 100644 (file)
@@ -42,7 +42,7 @@ typedef enum {
 static const char _dow_strings[ALARM_DAY_STATES + 1][2] ={"AL", "MO", "TU", "WE", "TH", "FR", "SA", "SO", "ED", "1t", "MF", "WN"};
 static const uint8_t _blink_idx[ALARM_SETTING_STATES] = {2, 0, 4, 6, 8, 9};
 static const uint8_t _blink_idx2[ALARM_SETTING_STATES] = {3, 1, 5, 7, 8, 9};
-static const BuzzerNote _buzzer_notes[3] = {BUZZER_NOTE_B6, BUZZER_NOTE_C8, BUZZER_NOTE_A8};
+static const watch_buzzer_note_t _buzzer_notes[3] = {BUZZER_NOTE_B6, BUZZER_NOTE_C8, BUZZER_NOTE_A8};
 static const uint8_t _buzzer_segdata[3][2] = {{0, 3}, {1, 3}, {2, 2}};
 
 static int8_t _wait_ticks;
index 8c1fdec79829f53760465a53ce9ad8834221bcea..5175306950082e284a50ed56b1cae403968a4009 100644 (file)
@@ -62,7 +62,7 @@ void breathing_face_activate(movement_settings_t *settings, void *context) {
 const int NOTE_LENGTH = 80;
 
 void beep_in (void) {
-        const BuzzerNote notes[] = {
+        const watch_buzzer_note_t notes[] = {
             BUZZER_NOTE_C4,
             BUZZER_NOTE_D4,
             BUZZER_NOTE_E4,
@@ -78,7 +78,7 @@ void beep_in (void) {
 }
 
 void beep_in_hold (void) {
-        const BuzzerNote notes[] = {
+        const watch_buzzer_note_t notes[] = {
             BUZZER_NOTE_E4,
             BUZZER_NOTE_REST,
             BUZZER_NOTE_E4,
@@ -94,7 +94,7 @@ void beep_in_hold (void) {
 }
 
 void beep_out (void) {
-        const BuzzerNote notes[] = {
+        const watch_buzzer_note_t notes[] = {
             BUZZER_NOTE_E4,
             BUZZER_NOTE_D4,
             BUZZER_NOTE_C4,
@@ -110,7 +110,7 @@ void beep_out (void) {
 }
 
 void beep_out_hold (void) {
-        const BuzzerNote notes[] = {
+        const watch_buzzer_note_t notes[] = {
             BUZZER_NOTE_C4,
             BUZZER_NOTE_REST * 2,
             BUZZER_NOTE_C4,
index a12c076a49a57923ff5fece4485b72a42393ffaf..8898397aea51bb2ee487af8a7bc437f26694fa4f 100644 (file)
@@ -38,7 +38,7 @@
 */
 
 typedef struct Note {
-    BuzzerNote note;
+    watch_buzzer_note_t note;
     char * name;
 } Note;
 
index 41f8f933aeafa144ade65f722f0b62ff936bbc73..0ce0df121bac5d8505f893792f37b108081410df 100644 (file)
@@ -108,7 +108,7 @@ void cb_watch_buzzer_seq(void) {
         }
         if (_sequence[_seq_position] && _sequence[_seq_position + 1]) {
             // read note
-            BuzzerNote note = _sequence[_seq_position];
+            watch_buzzer_note_t note = _sequence[_seq_position];
             if (note != BUZZER_NOTE_REST) {
                 watch_set_buzzer_period_and_duty_cycle(NotePeriods[note], 25);
                 watch_set_buzzer_on();
@@ -167,11 +167,11 @@ inline void watch_set_buzzer_off(void) {
     HAL_GPIO_BUZZER_off();
 }
 
-void watch_buzzer_play_note(BuzzerNote note, uint16_t duration_ms) {
+void watch_buzzer_play_note(watch_buzzer_note_t note, uint16_t duration_ms) {
     watch_buzzer_play_note_with_volume(note, duration_ms, WATCH_BUZZER_VOLUME_LOUD);
 }
 
-void watch_buzzer_play_note_with_volume(BuzzerNote note, uint16_t duration_ms, watch_buzzer_volume_t volume) {
+void watch_buzzer_play_note_with_volume(watch_buzzer_note_t note, uint16_t duration_ms, watch_buzzer_volume_t volume) {
     if (note == BUZZER_NOTE_REST) {
         watch_set_buzzer_off();
     } else  {
index 7967637d3b948002c4ce80209112e573c79a9bc6..52210d3bf25c65bad3a22017a517f26985759596 100644 (file)
 
 #include "watch.h"
 
-/** @brief Returns true if either the buzzer or the LED driver is enabled.
-  * @details Both the buzzer and the LED use the TCC peripheral to drive their behavior. This function returns true if that
-  *          peripheral is enabled. You can use this function to determine whether you need to call the watch_disable_leds or
-  *          or watch_enable_buzzer functions before using these peripherals.
-  */
-bool watch_is_buzzer_or_led_enabled(void);
-
-/** @addtogroup tcc Buzzer and LED Control (via the TCC peripheral)
-  * @brief This section covers functions related to Timer Counter for Control peripheral, which drives the piezo buzzer
-  *        embedded in the F-91W's back plate as well as the LED that backlights the display.
-  */
-/// @{
-/** @brief Enables the TCC peripheral, which drives the buzzer.
-  */
-void watch_enable_buzzer(void);
-
-/** @brief Sets the period of the buzzer.
-  * @param period The period of a single cycle for the TCC peripheral. You can determine the period for
-  *               a desired frequency with the following formula: period = 1000000 / freq
-  * @param duty The duty cycle of the buzzer, from 0 to 50 (percent ON time). Do not use values over 50.
-  * @note Unless you _really_ know what you're doing, use 25% for the duty cycle. If you're just aiming
-  *       to play a tone at a given volume, use watch_buzzer_play_note_with_volume instead.
-  */
-void watch_set_buzzer_period_and_duty_cycle(uint32_t period, uint8_t duty);
-
-/** @brief Disables the TCC peripheral that drives the buzzer.
-  * @note If you are using PWM to set custom LED colors, this method will also disable the LED PWM driver,
-  *       since the buzzer and LED both make use of the same peripheral to drive their PWM behavior.
-  */
-void watch_disable_buzzer(void);
-
-/** @brief Turns the buzzer output on. It will emit a continuous sound at the given frequency.
-  * @note The TCC peripheral that drives the buzzer does not run in standby mode; if you wish for buzzer
-  *       output to continue, you should prevent your app from going to sleep.
-  */
-void watch_set_buzzer_on(void);
-
-/** @brief Turns the buzzer output off.
-  */
-void watch_set_buzzer_off(void);
-
 /// @brief An enum for controlling the volume of the buzzer.
 typedef enum {
     WATCH_BUZZER_VOLUME_SOFT = 0,
@@ -76,7 +35,7 @@ typedef enum {
 } watch_buzzer_volume_t;
 
 /// @brief 87 notes for use with watch_buzzer_play_note
-typedef enum BuzzerNote {
+typedef enum {
     BUZZER_NOTE_A1,              ///< 55.00 Hz
     BUZZER_NOTE_A1SHARP_B1FLAT,  ///< 58.27 Hz
     BUZZER_NOTE_B1,              ///< 61.74 Hz
@@ -165,7 +124,48 @@ typedef enum BuzzerNote {
     BUZZER_NOTE_A8SHARP_B8FLAT,  ///< 7458.62 Hz
     BUZZER_NOTE_B8,              ///< 7902.13 Hz
     BUZZER_NOTE_REST             ///< no sound
-} BuzzerNote;
+} watch_buzzer_note_t;
+
+/** @brief Returns true if either the buzzer or the LED driver is enabled.
+  * @details Both the buzzer and the LED use the TCC peripheral to drive their behavior. This function returns true if that
+  *          peripheral is enabled. You can use this function to determine whether you need to call the watch_disable_leds or
+  *          or watch_enable_buzzer functions before using these peripherals.
+  */
+bool watch_is_buzzer_or_led_enabled(void);
+
+/** @addtogroup tcc Buzzer and LED Control (via the TCC peripheral)
+  * @brief This section covers functions related to Timer Counter for Control peripheral, which drives the piezo buzzer
+  *        embedded in the F-91W's back plate as well as the LED that backlights the display.
+  */
+/// @{
+/** @brief Enables the TCC peripheral, which drives the buzzer.
+  */
+void watch_enable_buzzer(void);
+
+/** @brief Sets the period of the buzzer.
+  * @param period The period of a single cycle for the TCC peripheral. You can determine the period for
+  *               a desired frequency with the following formula: period = 1000000 / freq
+  * @param duty The duty cycle of the buzzer, from 0 to 50 (percent ON time). Do not use values over 50.
+  * @note Unless you _really_ know what you're doing, use 25% for the duty cycle. If you're just aiming
+  *       to play a tone at a given volume, use watch_buzzer_play_note_with_volume instead.
+  */
+void watch_set_buzzer_period_and_duty_cycle(uint32_t period, uint8_t duty);
+
+/** @brief Disables the TCC peripheral that drives the buzzer.
+  * @note If you are using PWM to set custom LED colors, this method will also disable the LED PWM driver,
+  *       since the buzzer and LED both make use of the same peripheral to drive their PWM behavior.
+  */
+void watch_disable_buzzer(void);
+
+/** @brief Turns the buzzer output on. It will emit a continuous sound at the given frequency.
+  * @note The TCC peripheral that drives the buzzer does not run in standby mode; if you wish for buzzer
+  *       output to continue, you should prevent your app from going to sleep.
+  */
+void watch_set_buzzer_on(void);
+
+/** @brief Turns the buzzer output off.
+  */
+void watch_set_buzzer_off(void);
 
 /** @brief Plays the given note for a set duration at the loudest possible volume.
   * @param note The note you wish to play, or BUZZER_NOTE_REST to disable output for the given duration.
@@ -173,7 +173,7 @@ typedef enum BuzzerNote {
   * @note Note that this will block your UI for the duration of the note's play time, and it will
   *       after this call, the buzzer period will be set to the period of this note.
   */
-void watch_buzzer_play_note(BuzzerNote note, uint16_t duration_ms);
+void watch_buzzer_play_note(watch_buzzer_note_t note, uint16_t duration_ms);
 
 /** @brief Plays the given note for a set duration.
   * @param note The note you wish to play, or BUZZER_NOTE_REST to disable output for the given duration.
@@ -182,9 +182,9 @@ void watch_buzzer_play_note(BuzzerNote note, uint16_t duration_ms);
   * @note This will block your UI for the duration of the note's play time, and after this call, the
   *       buzzer will stop sounding, but the TCC period will remain set to the period of this note.
   */
-void watch_buzzer_play_note_with_volume(BuzzerNote note, uint16_t duration_ms, watch_buzzer_volume_t volume);
+void watch_buzzer_play_note_with_volume(watch_buzzer_note_t note, uint16_t duration_ms, watch_buzzer_volume_t volume);
 
-/// @brief An array of periods for all the notes on a piano, corresponding to the names in BuzzerNote.
+/// @brief An array of periods for all the notes on a piano, corresponding to the names in watch_buzzer_note_t.
 extern const uint16_t NotePeriods[108];
 
 /** @brief Plays the given sequence of notes in a non-blocking way.
@@ -280,7 +280,7 @@ void watch_set_led_off(void);
 /** @brief Disables the TCC peripheral. Should only be called internally. */
 void _watch_disable_tcc(void);
 
-/// @brief An array of periods for all the notes on a piano, corresponding to the names in BuzzerNote.
+/// @brief An array of periods for all the notes on a piano, corresponding to the names in watch_buzzer_note_t.
 extern const uint16_t NotePeriods[108];
 
 /// @}
index fa1e1a8c9680d787d7c1473850a7d4c9d59fa0ed..63c477b71a7f49bf1b3b55000133d0af8989d4b7 100644 (file)
@@ -85,7 +85,7 @@ void cb_watch_buzzer_seq(void *userData) {
         }
         if (_sequence[_seq_position] && _sequence[_seq_position + 1]) {
             // read note
-            BuzzerNote note = _sequence[_seq_position];
+            watch_buzzer_note_t note = _sequence[_seq_position];
             if (note == BUZZER_NOTE_REST) {
                 watch_set_buzzer_off();
             } else {
@@ -171,7 +171,7 @@ void watch_set_buzzer_off(void) {
     });
 }
 
-void watch_buzzer_play_note(BuzzerNote note, uint16_t duration_ms) {
+void watch_buzzer_play_note(watch_buzzer_note_t note, uint16_t duration_ms) {
     if (note == BUZZER_NOTE_REST) {
         watch_set_buzzer_off();
     } else {