summaryrefslogtreecommitdiffstats
path: root/watch-library/watch/watch.c
diff options
context:
space:
mode:
Diffstat (limited to 'watch-library/watch/watch.c')
-rw-r--r--watch-library/watch/watch.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/watch-library/watch/watch.c b/watch-library/watch/watch.c
index 170c4747..d3e32d5c 100644
--- a/watch-library/watch/watch.c
+++ b/watch-library/watch/watch.c
@@ -172,6 +172,9 @@ inline void watch_clear_pixel(uint8_t com, uint8_t seg) {
}
void watch_display_character(uint8_t character, uint8_t position) {
+ // handle lowercase 7 if needed
+ if (character == '7' && (position == 4 || position == 6)) character = '&';
+
uint64_t segmap = Segment_Map[position];
uint64_t segdata = Character_Set[character - 0x20];
@@ -319,6 +322,39 @@ void watch_set_led_off() {
}
}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// Buzzer
+
+inline void watch_enable_buzzer() {
+ PWM_1_init();
+}
+
+inline void watch_set_buzzer_period(uint32_t period) {
+ pwm_set_parameters(&PWM_1, period, period / 2);
+}
+
+inline void watch_set_buzzer_on() {
+ pwm_enable(&PWM_1);
+}
+
+inline void watch_set_buzzer_off() {
+ pwm_disable(&PWM_1);
+}
+
+const uint16_t NotePeriods[108] = {31047, 29301, 27649, 26079, 24617, 23224, 21923, 20683, 19515, 18418, 17377, 16399, 15477, 14603, 13780, 13004, 12272, 11580, 10926, 10311, 9730, 9181, 8664, 8175, 7714, 7280, 6869, 6483, 6117, 5772, 5447, 5140, 4850, 4577, 4319, 4076, 3846, 3629, 3425, 3232, 3050, 2878, 2715, 2562, 2418, 2282, 2153, 2032, 1917, 1809, 1707, 1611, 1520, 1435, 1354, 1277, 1205, 1137, 1073, 1013, 956, 902, 851, 803, 758, 715, 675, 637, 601, 567, 535, 505, 476, 450, 424, 400, 378, 357, 336, 317, 300, 283, 267, 252, 238, 224, 212, 200, 188, 178, 168, 158, 149, 141, 133, 125, 118, 112, 105, 99, 94, 89, 84, 79, 74, 70, 66, 63};
+
+void watch_buzzer_play_note(BuzzerNote note, uint16_t duration_ms) {
+ if (note == BUZZER_NOTE_REST) {
+ watch_set_buzzer_off();
+ } else {
+ pwm_set_parameters(&PWM_1, NotePeriods[note], NotePeriods[note] / 2);
+ watch_set_buzzer_on();
+ }
+ delay_ms(duration_ms);
+ watch_set_buzzer_off();
+}
+
//////////////////////////////////////////////////////////////////////////////////////////
// Real-time Clock