summaryrefslogtreecommitdiffstats
path: root/main/fix-tuning.patch
blob: 0ad858201ea6a275edc4474be1ae94a414c25c82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
diff --git a/movement/watch_faces/complication/tuning_tones_face.c b/movement/watch_faces/complication/tuning_tones_face.c
index a139427..4ab8dfe 100644
--- a/movement/watch_faces/complication/tuning_tones_face.c
+++ b/movement/watch_faces/complication/tuning_tones_face.c
@@ -38,23 +38,23 @@
 */
 
 typedef struct Note {
-    BuzzerNote note;
+    int8_t notes[3];
     char * name;
 } Note;
 
 static Note notes[] = {
-    { .note = BUZZER_NOTE_C5, .name = "C " },
-    { .note = BUZZER_NOTE_C5SHARP_D5FLAT, .name = "Db" },
-    { .note = BUZZER_NOTE_D5, .name = "D " },
-    { .note = BUZZER_NOTE_D5SHARP_E5FLAT, .name = "Eb" },
-    { .note = BUZZER_NOTE_E5, .name = "E " },
-    { .note = BUZZER_NOTE_F5, .name = "F " },
-    { .note = BUZZER_NOTE_F5SHARP_G5FLAT, .name = "Gb" },
-    { .note = BUZZER_NOTE_G5, .name = "G " },
-    { .note = BUZZER_NOTE_G5SHARP_A5FLAT, .name = "Ab" },
-    { .note = BUZZER_NOTE_A5, .name = "A " },
-    { .note = BUZZER_NOTE_A5SHARP_B5FLAT, .name = "Bb" },
-    { .note = BUZZER_NOTE_B5, .name = "B " },
+    { .notes = { BUZZER_NOTE_C5, 64 , 0 }, .name = "C " },
+    { .notes = { BUZZER_NOTE_C5SHARP_D5FLAT, 64 , 0 }, .name = "Db" },
+    { .notes = { BUZZER_NOTE_D5, 64 , 0 }, .name = "D " },
+    { .notes = { BUZZER_NOTE_D5SHARP_E5FLAT, 64 , 0 }, .name = "Eb" },
+    { .notes = { BUZZER_NOTE_E5, 64 , 0 }, .name = "E " },
+    { .notes = { BUZZER_NOTE_F5, 64 , 0 }, .name = "F " },
+    { .notes = { BUZZER_NOTE_F5SHARP_G5FLAT, 64 , 0 }, .name = "Gb" },
+    { .notes = { BUZZER_NOTE_G5, 64 , 0 }, .name = "G " },
+    { .notes = { BUZZER_NOTE_G5SHARP_A5FLAT, 64 , 0 }, .name = "Ab" },
+    { .notes = { BUZZER_NOTE_A5, 64 , 0 }, .name = "A " },
+    { .notes = { BUZZER_NOTE_A5SHARP_B5FLAT, 64 , 0 }, .name = "Bb" },
+    { .notes = { BUZZER_NOTE_B5, 64 , 0 }, .name = "B " },
 };
 
 static size_t note_count = sizeof notes / sizeof *notes;
@@ -80,12 +80,22 @@ void tuning_tones_face_activate(movement_settings_t *settings, void *context) {
     (void) context;
 }
 
+static int8_t note;
+
+static void go_again(void) {
+    watch_buzzer_play_sequence(notes[note].notes, go_again);
+}
+
 static void update_buzzer(const tuning_tones_state_t *state)
 {
     if (state->playing) {
+        watch_enable_buzzer();
+        note = state->note_ind;
+        go_again();
+    } else {
+        watch_buzzer_abort_sequence();
         watch_set_buzzer_off();
-        watch_set_buzzer_period(NotePeriods[notes[state->note_ind].note]);
-        watch_set_buzzer_on();
+        watch_disable_buzzer();
     }
 }
 
@@ -110,11 +120,8 @@ bool tuning_tones_face_loop(movement_event_t event, movement_settings_t *setting
             break;
         case EVENT_ALARM_BUTTON_DOWN:
             state->playing = !state->playing;
-            if (!state->playing) {
-                watch_set_buzzer_off();
-            } else {
-                update_buzzer(state);
-            }
+            update_buzzer(state);
+            break;
         case EVENT_ALARM_BUTTON_UP:
             break;
         case EVENT_TIMEOUT:
@@ -135,6 +142,6 @@ void tuning_tones_face_resign(movement_settings_t *settings, void *context) {
 
     if (state->playing) {
         state->playing = false;
-        watch_set_buzzer_off();
+        update_buzzer(state);
     }
 }