@@ -356,9 +356,7 @@ class HomeScreen : public UIScreen {
356356 return true ;
357357 }
358358 if (c == KEY_ENTER && _page == HomePage::ADVERT) {
359- #ifdef PIN_BUZZER
360- _task->soundBuzzer (UIEventType::ack);
361- #endif
359+ _task->notify (UIEventType::ack);
362360 if (the_mesh.advert ()) {
363361 _task->showAlert (" Advert sent!" , 1000 );
364362 } else {
@@ -495,6 +493,10 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no
495493 buzzer.begin ();
496494#endif
497495
496+ #ifdef PIN_VIBRATION
497+ vibration.begin ();
498+ #endif
499+
498500 ui_started_at = millis ();
499501 _alert_expiry = 0 ;
500502
@@ -509,9 +511,9 @@ void UITask::showAlert(const char* text, int duration_millis) {
509511 _alert_expiry = millis () + duration_millis;
510512}
511513
512- void UITask::soundBuzzer (UIEventType bet ) {
514+ void UITask::notify (UIEventType t ) {
513515#if defined(PIN_BUZZER)
514- switch (bet ){
516+ switch (t ){
515517 case UIEventType::contactMessage:
516518 // gemini's pick
517519 buzzer.play (" MsgRcv3:d=4,o=6,b=200:32e,32g,32b,16c7" );
@@ -529,8 +531,16 @@ switch(bet){
529531 break ;
530532}
531533#endif
534+
535+ #ifdef PIN_VIBRATION
536+ // Trigger vibration for all UI events except none
537+ if (t != UIEventType::none) {
538+ vibration.trigger ();
539+ }
540+ #endif
532541}
533542
543+
534544void UITask::msgRead (int msgcount) {
535545 _msgcount = msgcount;
536546 if (msgcount == 0 ) {
@@ -699,6 +709,10 @@ void UITask::loop() {
699709#endif
700710 }
701711
712+ #ifdef PIN_VIBRATION
713+ vibration.loop ();
714+ #endif
715+
702716#ifdef AUTO_SHUTDOWN_MILLIVOLTS
703717 if (millis () > next_batt_chck) {
704718 uint16_t milliVolts = getBattMilliVolts ();
@@ -767,11 +781,11 @@ void UITask::toggleGPS() {
767781 if (strcmp (_sensors->getSettingName (i), " gps" ) == 0 ) {
768782 if (strcmp (_sensors->getSettingValue (i), " 1" ) == 0 ) {
769783 _sensors->setSettingValue (" gps" , " 0" );
770- soundBuzzer (UIEventType::ack);
784+ notify (UIEventType::ack);
771785 showAlert (" GPS: Disabled" , 800 );
772786 } else {
773787 _sensors->setSettingValue (" gps" , " 1" );
774- soundBuzzer (UIEventType::ack);
788+ notify (UIEventType::ack);
775789 showAlert (" GPS: Enabled" , 800 );
776790 }
777791 _next_refresh = 0 ;
@@ -786,7 +800,7 @@ void UITask::toggleBuzzer() {
786800 #ifdef PIN_BUZZER
787801 if (buzzer.isQuiet ()) {
788802 buzzer.quiet (false );
789- soundBuzzer (UIEventType::ack);
803+ notify (UIEventType::ack);
790804 showAlert (" Buzzer: ON" , 800 );
791805 } else {
792806 buzzer.quiet (true );
0 commit comments