Add saved Companion sound and vibration controls

Default fresh settings to sound off and vibration on, and keep existing saved choices. Apply changes immediately across all three UIs and make custom notification patterns respect the same mute controls.

Keep the Wio Mini Companion within its existing flash boundary by storing its LED switch in a reserved preference byte and shortening CLI help without removing commands. Add coverage for live output changes, persistence, and storage failures.

Adapted from https://github.com/meshcore-dev/MeshCore/pull/3603.

Co-authored-by: R0ck <develop@hectospark.co.uk>
This commit is contained in:
mikecarperandR0ck committed 2026-10-20 09:33:43 -07:00
1 parent 9d52b1fd68
commit f57dffa2be
30 files changed
+1074 -108

No files matched your search

+1 -1
View File
@@ -77,7 +77,7 @@ void DRV2605Vibration::stop() {
void DRV2605Vibration::pulse(bool on) {
if (!_ready) return;
if (!on) {
if (!on || _quiet) {
stop();
return;
}
+1 -1
View File
@@ -27,7 +27,7 @@ public:
bool isVibrating();
void stop(); // stop vibration immediately
void pulse(bool on); // continuous RTP amplitude for scheduled ms pulses
void quiet(bool q) { _quiet = q; }
void quiet(bool q) { if (q) stop(); _quiet = q; }
bool isQuiet() const { return _quiet; }
private:
+6
View File
@@ -8,6 +8,7 @@ void GenericVibration::begin() {
}
void GenericVibration::trigger() {
if (_quiet) return;
duration = millis();
digitalWrite(PIN_VIBRATION, HIGH);
}
@@ -35,4 +36,9 @@ void GenericVibration::stop() {
digitalWrite(PIN_VIBRATION, LOW);
}
void GenericVibration::pulse(bool on) {
stop();
if (on && !_quiet) digitalWrite(PIN_VIBRATION, HIGH);
}
#endif // ifdef PIN_VIBRATION
+5 -1
View File
@@ -25,9 +25,13 @@ public:
void loop(); // non-blocking timer handling
bool isVibrating(); // returns true if currently vibrating
void stop(); // stop vibration immediately
void pulse(bool on);
void quiet(bool q) { if (q) stop(); _quiet = q; }
bool isQuiet() const { return _quiet; }
private:
unsigned long duration;
unsigned long duration = 0;
bool _quiet = false;
};
#endif // ifdef PIN_VIBRATION
+9 -9
View File
@@ -48,16 +48,14 @@ static mesh::audio::VoiceClip buttonVoiceClip(ButtonVoicePrompt prompt) {
#endif
void genericBuzzer::begin() {
// Serial.print("DBG: Setting up buzzer on pin ");
// Serial.println(PIN_BUZZER);
#ifdef PIN_BUZZER_EN
pinMode(PIN_BUZZER_EN, OUTPUT);
digitalWrite(PIN_BUZZER_EN, HIGH);
#endif
quiet(false);
digitalWrite(PIN_BUZZER, LOW);
pinMode(PIN_BUZZER, OUTPUT);
digitalWrite(PIN_BUZZER, LOW); // need to pull low by default to avoid extreme power draw
#ifdef PIN_BUZZER_EN
digitalWrite(PIN_BUZZER_EN, LOW);
pinMode(PIN_BUZZER_EN, OUTPUT);
#endif
// Start muted until the UI applies the saved preference.
quiet(_is_quiet);
}
void genericBuzzer::play(const char *melody) {
@@ -79,6 +77,8 @@ void genericBuzzer::play(const char *melody) {
}
void genericBuzzer::playNotification(const char* melody) {
// Muted background alerts must not interrupt an explicit button prompt.
if (_is_quiet) return;
stop();
#ifdef PIN_BUZZER_EN
digitalWrite(PIN_BUZZER_EN, HIGH);