Merge branch 'main' into theAlexes/cleanup
This commit is contained in:
commit
d7369cd00d
@ -21,12 +21,12 @@ do
|
|||||||
for color in "${colors[@]}"
|
for color in "${colors[@]}"
|
||||||
do
|
do
|
||||||
COLOR=$(echo "$color" | tr '[:lower:]' '[:upper:]')
|
COLOR=$(echo "$color" | tr '[:lower:]' '[:upper:]')
|
||||||
make clean
|
make COLOR=$COLOR clean
|
||||||
make COLOR=$COLOR FIRMWARE=$VARIANT
|
make COLOR=$COLOR FIRMWARE=$VARIANT
|
||||||
mv "build/watch.uf2" "$fw_dir/$variant-$color.uf2"
|
mv "build/watch.uf2" "$fw_dir/$variant-$color.uf2"
|
||||||
done
|
done
|
||||||
rm -rf ./build-sim
|
rm -rf ./build-sim
|
||||||
emmake make FIRMWARE=$VARIANT
|
emmake make COLOR=GREEN FIRMWARE=$VARIANT
|
||||||
mkdir "$sim_dir/$variant/"
|
mkdir "$sim_dir/$variant/"
|
||||||
mv "build-sim/watch.wasm" "$sim_dir/$variant/"
|
mv "build-sim/watch.wasm" "$sim_dir/$variant/"
|
||||||
mv "build-sim/watch.js" "$sim_dir/$variant/"
|
mv "build-sim/watch.js" "$sim_dir/$variant/"
|
||||||
|
@ -294,25 +294,31 @@ void movement_request_wake() {
|
|||||||
_movement_reset_inactivity_countdown();
|
_movement_reset_inactivity_countdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
void movement_play_signal(void) {
|
void end_buzzing() {
|
||||||
bool buzzer_enabled = watch_is_buzzer_or_led_enabled();
|
movement_state.is_buzzing = false;
|
||||||
if (!buzzer_enabled) {
|
|
||||||
watch_enable_buzzer();
|
|
||||||
}
|
|
||||||
watch_buzzer_play_note(BUZZER_NOTE_C8, 75);
|
|
||||||
watch_buzzer_play_note(BUZZER_NOTE_REST, 100);
|
|
||||||
watch_buzzer_play_note(BUZZER_NOTE_C8, 100);
|
|
||||||
if (!buzzer_enabled) {
|
|
||||||
watch_disable_buzzer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void movement_play_tune(void) {
|
void end_buzzing_and_disable_buzzer(void) {
|
||||||
if (!watch_is_buzzer_or_led_enabled()) {
|
end_buzzing();
|
||||||
watch_enable_buzzer();
|
watch_disable_buzzer();
|
||||||
watch_buzzer_play_sequence(signal_tune, watch_disable_buzzer);
|
}
|
||||||
|
|
||||||
|
void movement_play_signal(void) {
|
||||||
|
void *maybe_disable_buzzer = end_buzzing_and_disable_buzzer;
|
||||||
|
if (watch_is_buzzer_or_led_enabled()) {
|
||||||
|
maybe_disable_buzzer = end_buzzing;
|
||||||
} else {
|
} else {
|
||||||
watch_buzzer_play_sequence(signal_tune, NULL);
|
watch_enable_buzzer();
|
||||||
|
}
|
||||||
|
movement_state.is_buzzing = true;
|
||||||
|
watch_buzzer_play_sequence(signal_tune, maybe_disable_buzzer);
|
||||||
|
if (movement_state.le_mode_ticks == -1) {
|
||||||
|
// the watch is asleep. wake it up for "1" round through the main loop.
|
||||||
|
// the sleep_mode_app_loop will notice the is_buzzing and note that it
|
||||||
|
// only woke up to beep and then it will spinlock until the callback
|
||||||
|
// turns off the is_buzzing flag.
|
||||||
|
movement_state.needs_wake = true;
|
||||||
|
movement_state.le_mode_ticks = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,6 +452,7 @@ static void _sleep_mode_app_loop(void) {
|
|||||||
|
|
||||||
bool app_loop(void) {
|
bool app_loop(void) {
|
||||||
wf = &watch_faces[movement_state.current_face_idx];
|
wf = &watch_faces[movement_state.current_face_idx];
|
||||||
|
bool woke_up_for_buzzer = false;
|
||||||
if (movement_state.watch_face_changed) {
|
if (movement_state.watch_face_changed) {
|
||||||
if (movement_state.settings.bit.button_should_sound) {
|
if (movement_state.settings.bit.button_should_sound) {
|
||||||
// low note for nonzero case, high note for return to watch_face 0
|
// low note for nonzero case, high note for return to watch_face 0
|
||||||
@ -491,7 +498,11 @@ bool app_loop(void) {
|
|||||||
// _sleep_mode_app_loop takes over at this point and loops until le_mode_ticks is reset by the extwake handler,
|
// _sleep_mode_app_loop takes over at this point and loops until le_mode_ticks is reset by the extwake handler,
|
||||||
// or wake is requested using the movement_request_wake function.
|
// or wake is requested using the movement_request_wake function.
|
||||||
_sleep_mode_app_loop();
|
_sleep_mode_app_loop();
|
||||||
// as soon as _sleep_mode_app_loop returns, we reactivate ourselves.
|
// as soon as _sleep_mode_app_loop returns, we prepare to reactivate
|
||||||
|
// ourselves, but first, we check to see if we woke up for the buzzer:
|
||||||
|
if (movement_state.is_buzzing) {
|
||||||
|
woke_up_for_buzzer = true;
|
||||||
|
}
|
||||||
event.event_type = EVENT_ACTIVATE;
|
event.event_type = EVENT_ACTIVATE;
|
||||||
// this is a hack tho: waking from sleep mode, app_setup does get called, but it happens before we have reset our ticks.
|
// this is a hack tho: waking from sleep mode, app_setup does get called, but it happens before we have reset our ticks.
|
||||||
// need to figure out if there's a better heuristic for determining how we woke up.
|
// need to figure out if there's a better heuristic for determining how we woke up.
|
||||||
@ -582,8 +593,13 @@ bool app_loop(void) {
|
|||||||
// if the watch face changed, we can't sleep because we need to update the display.
|
// if the watch face changed, we can't sleep because we need to update the display.
|
||||||
if (movement_state.watch_face_changed) can_sleep = false;
|
if (movement_state.watch_face_changed) can_sleep = false;
|
||||||
|
|
||||||
// if the buzzer or the LED is on, we need to stay awake to keep the TCC running.
|
// if we woke up for the buzzer, stay awake until it's finished.
|
||||||
if (movement_state.is_buzzing || movement_state.light_ticks != -1) can_sleep = false;
|
if (woke_up_for_buzzer) {
|
||||||
|
while(watch_is_buzzer_or_led_enabled());
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the LED is on, we need to stay awake to keep the TCC running.
|
||||||
|
if (movement_state.light_ticks != -1) can_sleep = false;
|
||||||
|
|
||||||
return can_sleep;
|
return can_sleep;
|
||||||
}
|
}
|
||||||
|
@ -307,7 +307,6 @@ void movement_cancel_background_task_for_face(uint8_t watch_face_index);
|
|||||||
void movement_request_wake(void);
|
void movement_request_wake(void);
|
||||||
|
|
||||||
void movement_play_signal(void);
|
void movement_play_signal(void);
|
||||||
void movement_play_tune(void);
|
|
||||||
void movement_play_alarm(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, BuzzerNote alarm_note);
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ const watch_face_t watch_faces[] = {
|
|||||||
*/
|
*/
|
||||||
#define MOVEMENT_SECONDARY_FACE_INDEX (MOVEMENT_NUM_FACES - 2) // or (0)
|
#define MOVEMENT_SECONDARY_FACE_INDEX (MOVEMENT_NUM_FACES - 2) // or (0)
|
||||||
|
|
||||||
/* Custom hourly chime tune. Check movement_custom_signal_tunes.h for options */
|
/* Custom hourly chime tune. Check movement_custom_signal_tunes.h for options. */
|
||||||
#define SIGNAL_TUNE_DEFAULT
|
#define SIGNAL_TUNE_DEFAULT
|
||||||
|
|
||||||
#endif // MOVEMENT_CONFIG_H_
|
#endif // MOVEMENT_CONFIG_H_
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
void <#watch_face_name#>_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
void <#watch_face_name#>_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr) {
|
||||||
(void) settings;
|
(void) settings;
|
||||||
|
(void) watch_face_index;
|
||||||
if (*context_ptr == NULL) {
|
if (*context_ptr == NULL) {
|
||||||
*context_ptr = malloc(sizeof(<#watch_face_name#>_state_t));
|
*context_ptr = malloc(sizeof(<#watch_face_name#>_state_t));
|
||||||
memset(*context_ptr, 0, sizeof(<#watch_face_name#>_state_t));
|
memset(*context_ptr, 0, sizeof(<#watch_face_name#>_state_t));
|
||||||
|
@ -151,6 +151,8 @@ bool repetition_minute_face_loop(movement_event_t event, movement_settings_t *se
|
|||||||
else watch_clear_indicator(WATCH_INDICATOR_BELL);
|
else watch_clear_indicator(WATCH_INDICATOR_BELL);
|
||||||
break;
|
break;
|
||||||
case EVENT_BACKGROUND_TASK:
|
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();
|
movement_play_signal();
|
||||||
break;
|
break;
|
||||||
case EVENT_LIGHT_LONG_UP:
|
case EVENT_LIGHT_LONG_UP:
|
||||||
|
@ -136,11 +136,7 @@ bool simple_clock_face_loop(movement_event_t event, movement_settings_t *setting
|
|||||||
case EVENT_BACKGROUND_TASK:
|
case EVENT_BACKGROUND_TASK:
|
||||||
// uncomment this line to snap back to the clock face when the hour signal sounds:
|
// uncomment this line to snap back to the clock face when the hour signal sounds:
|
||||||
// movement_move_to_face(state->watch_face_index);
|
// movement_move_to_face(state->watch_face_index);
|
||||||
#ifdef SIGNAL_TUNE_DEFAULT
|
|
||||||
movement_play_signal();
|
movement_play_signal();
|
||||||
#else
|
|
||||||
movement_play_tune();
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return movement_default_loop_handler(event, settings);
|
return movement_default_loop_handler(event, settings);
|
||||||
|
@ -84,8 +84,10 @@ static void tomato_draw(tomato_state_t *state) {
|
|||||||
sec = 0;
|
sec = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sprintf(buf, "TO %c%2d%02d%2d", kind, min, sec, state->done_count);
|
if (state->visible) {
|
||||||
watch_display_string(buf, 0);
|
sprintf(buf, "TO %c%2d%02d%2d", kind, min, sec, state->done_count);
|
||||||
|
watch_display_string(buf, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tomato_reset(tomato_state_t *state) {
|
static void tomato_reset(tomato_state_t *state) {
|
||||||
@ -116,6 +118,7 @@ void tomato_face_setup(movement_settings_t *settings, uint8_t watch_face_index,
|
|||||||
state->mode=tomato_ready;
|
state->mode=tomato_ready;
|
||||||
state->kind= tomato_focus;
|
state->kind= tomato_focus;
|
||||||
state->done_count = 0;
|
state->done_count = 0;
|
||||||
|
state->visible = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,6 +130,7 @@ void tomato_face_activate(movement_settings_t *settings, void *context) {
|
|||||||
watch_set_indicator(WATCH_INDICATOR_BELL);
|
watch_set_indicator(WATCH_INDICATOR_BELL);
|
||||||
}
|
}
|
||||||
watch_set_colon();
|
watch_set_colon();
|
||||||
|
state->visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tomato_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
bool tomato_face_loop(movement_event_t event, movement_settings_t *settings, void *context) {
|
||||||
@ -184,6 +188,8 @@ bool tomato_face_loop(movement_event_t event, movement_settings_t *settings, voi
|
|||||||
}
|
}
|
||||||
|
|
||||||
void tomato_face_resign(movement_settings_t *settings, void *context) {
|
void tomato_face_resign(movement_settings_t *settings, void *context) {
|
||||||
|
tomato_state_t *state = (tomato_state_t *)context;
|
||||||
|
state->visible = false;
|
||||||
(void) settings;
|
(void) settings;
|
||||||
(void) context;
|
(void) context;
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,7 @@ typedef struct {
|
|||||||
tomato_mode mode;
|
tomato_mode mode;
|
||||||
tomato_kind kind;
|
tomato_kind kind;
|
||||||
uint8_t done_count;
|
uint8_t done_count;
|
||||||
|
bool visible;
|
||||||
} tomato_state_t;
|
} tomato_state_t;
|
||||||
|
|
||||||
void tomato_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
void tomato_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void ** context_ptr);
|
||||||
|
@ -245,7 +245,6 @@ static void value_increase(int16_t delta) {
|
|||||||
nanosec_state.correction_cadence = (delta > 0) ? 1 : 20;
|
nanosec_state.correction_cadence = (delta > 0) ? 1 : 20;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
nanosec_state.correction_profile = (nanosec_state.correction_profile + delta) % nanosec_profile_count;
|
|
||||||
break;
|
break;
|
||||||
case 6: // Aging
|
case 6: // Aging
|
||||||
nanosec_state.aging_ppm_pa += delta;
|
nanosec_state.aging_ppm_pa += delta;
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "watch_buzzer.h"
|
#include "watch_buzzer.h"
|
||||||
|
#include "watch_private_buzzer.h"
|
||||||
#include "../../../watch-library/hardware/include/saml22j18a.h"
|
#include "../../../watch-library/hardware/include/saml22j18a.h"
|
||||||
#include "../../../watch-library/hardware/include/component/tc.h"
|
#include "../../../watch-library/hardware/include/component/tc.h"
|
||||||
#include "../../../watch-library/hardware/hri/hri_tc_l22.h"
|
#include "../../../watch-library/hardware/hri/hri_tc_l22.h"
|
||||||
|
@ -175,6 +175,8 @@ extern const uint16_t NotePeriods[108];
|
|||||||
*/
|
*/
|
||||||
void watch_buzzer_play_sequence(int8_t *note_sequence, void (*callback_on_end)(void));
|
void watch_buzzer_play_sequence(int8_t *note_sequence, void (*callback_on_end)(void));
|
||||||
|
|
||||||
|
uint16_t sequence_length(int8_t *sequence);
|
||||||
|
|
||||||
/** @brief Aborts a playing sequence.
|
/** @brief Aborts a playing sequence.
|
||||||
*/
|
*/
|
||||||
void watch_buzzer_abort_sequence(void);
|
void watch_buzzer_abort_sequence(void);
|
||||||
|
@ -23,6 +23,13 @@
|
|||||||
*/
|
*/
|
||||||
#include "driver_init.h"
|
#include "driver_init.h"
|
||||||
|
|
||||||
// note: the buzzer uses a 1 MHz clock. these values were determined by dividing 1,000,000 by the target frequency.
|
uint16_t sequence_length(int8_t *sequence) {
|
||||||
// i.e. for a 440 Hz tone (A4 on the piano), 1MHz/440Hz = 2273
|
uint16_t result = 0;
|
||||||
const uint16_t NotePeriods[108] = {18182,17161,16197,15288,14430,13620,12857,12134,11453,10811,10204,9631,9091,8581,8099,7645,7216,6811,6428,6068,5727,5405,5102,4816,4545,4290,4050,3822,3608,3405,3214,3034,2863,2703,2551,2408,2273,2145,2025,1911,1804,1703,1607,1517,1432,1351,1276,1204,1136,1073,1012,956,902,851,804,758,716,676,638,602,568,536,506,478,451,426,402,379,358,338,319,301,284,268,253,239,225,213,201,190,179,169,159,150,142,134,127};
|
|
||||||
|
while (*sequence != 0){
|
||||||
|
result += *(sequence + 1);
|
||||||
|
sequence += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
33
watch-library/shared/watch/watch_private_buzzer.h
Normal file
33
watch-library/shared/watch/watch_private_buzzer.h
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* MIT License
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 Wesley Aptekar-Cassels
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
#ifndef _WATCH_PRIVATE_BUZZER_H_INCLUDED
|
||||||
|
#define _WATCH_PRIVATE_BUZZER_H_INCLUDED
|
||||||
|
|
||||||
|
// note: the buzzer uses a 1 MHz clock. these values were determined by dividing 1,000,000 by the target frequency.
|
||||||
|
// i.e. for a 440 Hz tone (A4 on the piano), 1MHz/440Hz = 2273
|
||||||
|
const uint16_t NotePeriods[108] = {18182,17161,16197,15288,14430,13620,12857,12134,11453,10811,10204,9631,9091,8581,8099,7645,7216,6811,6428,6068,5727,5405,5102,4816,4545,4290,4050,3822,3608,3405,3214,3034,2863,2703,2551,2408,2273,2145,2025,1911,1804,1703,1607,1517,1432,1351,1276,1204,1136,1073,1012,956,902,851,804,758,716,676,638,602,568,536,506,478,451,426,402,379,358,338,319,301,284,268,253,239,225,213,201,190,179,169,159,150,142,134,127};
|
||||||
|
|
||||||
|
uint16_t sequence_length(int8_t *sequence);
|
||||||
|
|
||||||
|
#endif
|
@ -23,6 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "watch_buzzer.h"
|
#include "watch_buzzer.h"
|
||||||
|
#include "watch_private_buzzer.h"
|
||||||
#include "watch_main_loop.h"
|
#include "watch_main_loop.h"
|
||||||
|
|
||||||
#include <emscripten.h>
|
#include <emscripten.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user