mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
♻️ refactor: unify UI notification methods into single notify() function
Consolidates soundBuzzer() and triggerVibration() into a unified notify() method that handles both audio and haptic feedback based on UIEventType.
This commit is contained in:
parent
2da50882c0
commit
043f37a08e
6 changed files with 26 additions and 40 deletions
|
|
@ -348,9 +348,7 @@ public:
|
|||
return true;
|
||||
}
|
||||
if (c == KEY_ENTER && _page == HomePage::ADVERT) {
|
||||
#ifdef PIN_BUZZER
|
||||
_task->soundBuzzer(UIEventType::ack);
|
||||
#endif
|
||||
_task->notify(UIEventType::ack);
|
||||
if (the_mesh.advert()) {
|
||||
_task->showAlert("Advert sent!", 1000);
|
||||
} else {
|
||||
|
|
@ -501,9 +499,9 @@ void UITask::showAlert(const char* text, int duration_millis) {
|
|||
_alert_expiry = millis() + duration_millis;
|
||||
}
|
||||
|
||||
void UITask::soundBuzzer(UIEventType bet) {
|
||||
void UITask::notify(UIEventType t) {
|
||||
#if defined(PIN_BUZZER)
|
||||
switch(bet){
|
||||
switch(t){
|
||||
case UIEventType::contactMessage:
|
||||
// gemini's pick
|
||||
buzzer.play("MsgRcv3:d=4,o=6,b=200:32e,32g,32b,16c7");
|
||||
|
|
@ -521,13 +519,15 @@ switch(bet){
|
|||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PIN_VIBRATION
|
||||
void UITask::triggerVibration() {
|
||||
vibration.trigger();
|
||||
}
|
||||
// Trigger vibration for all UI events except none
|
||||
if (t != UIEventType::none) {
|
||||
vibration.trigger();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void UITask::msgRead(int msgcount) {
|
||||
_msgcount = msgcount;
|
||||
|
|
@ -542,9 +542,6 @@ void UITask::newMsg(uint8_t path_len, const char* from_name, const char* text, i
|
|||
((MsgPreviewScreen *) msg_preview)->addPreview(path_len, from_name, text);
|
||||
setCurrScreen(msg_preview);
|
||||
|
||||
#ifdef PIN_VIBRATION
|
||||
triggerVibration();
|
||||
#endif
|
||||
|
||||
if (_display != NULL) {
|
||||
if (!_display->isOn()) _display->turnOn();
|
||||
|
|
@ -773,11 +770,11 @@ void UITask::toggleGPS() {
|
|||
if (strcmp(_sensors->getSettingName(i), "gps") == 0) {
|
||||
if (strcmp(_sensors->getSettingValue(i), "1") == 0) {
|
||||
_sensors->setSettingValue("gps", "0");
|
||||
soundBuzzer(UIEventType::ack);
|
||||
notify(UIEventType::ack);
|
||||
showAlert("GPS: Disabled", 800);
|
||||
} else {
|
||||
_sensors->setSettingValue("gps", "1");
|
||||
soundBuzzer(UIEventType::ack);
|
||||
notify(UIEventType::ack);
|
||||
showAlert("GPS: Enabled", 800);
|
||||
}
|
||||
_next_refresh = 0;
|
||||
|
|
@ -792,7 +789,7 @@ void UITask::toggleBuzzer() {
|
|||
#ifdef PIN_BUZZER
|
||||
if (buzzer.isQuiet()) {
|
||||
buzzer.quiet(false);
|
||||
soundBuzzer(UIEventType::ack);
|
||||
notify(UIEventType::ack);
|
||||
showAlert("Buzzer: ON", 800);
|
||||
} else {
|
||||
buzzer.quiet(true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue