♻️ 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:
csrutil 2025-09-17 08:53:50 +08:00
parent 2da50882c0
commit 043f37a08e
6 changed files with 26 additions and 40 deletions

View file

@ -243,12 +243,7 @@ void MyMesh::onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path
}
} else {
#ifdef DISPLAY_CLASS
if (_ui) _ui->soundBuzzer(UIEventType::newContactMessage);
if (_ui) {
#ifdef PIN_VIBRATION
if (is_new) _ui->triggerVibration();
#endif
}
if (_ui) _ui->notify(UIEventType::newContactMessage);
#endif
}
@ -358,7 +353,7 @@ void MyMesh::queueMessage(const ContactInfo &from, uint8_t txt_type, mesh::Packe
if (should_display && _ui) {
_ui->newMsg(path_len, from.name, text, offline_queue_len);
if (!_serial->isConnected()) {
_ui->soundBuzzer(UIEventType::contactMessage);
_ui->notify(UIEventType::contactMessage);
}
}
#endif
@ -417,7 +412,7 @@ void MyMesh::onChannelMessageRecv(const mesh::GroupChannel &channel, mesh::Packe
_serial->writeFrame(frame, 1);
} else {
#ifdef DISPLAY_CLASS
if (_ui) _ui->soundBuzzer(UIEventType::channelMessage);
if (_ui) _ui->notify(UIEventType::channelMessage);
#endif
}
#ifdef DISPLAY_CLASS