Browse Source
Enhances buzzer audibility on small piezos
Adjusts the duration and tempo of several buzzer melodies to make them more perceptible. Specifically, the advert sent and generic toggle sounds are modified with longer note durations and slower tempos, improving their clarity on typical small piezo speakers.
pull/2665/head
Mark Jocas
2 months ago
No known key found for this signature in database
GPG Key ID: F75EF1C43FC564B4
4 changed files with
5 additions and
4 deletions
examples/companion_radio/ui-new/UITask.cpp
examples/companion_radio/ui-orig/UITask.cpp
examples/companion_radio/ui-tiny/UITask.cpp
src/helpers/ui/buzzer.cpp
@ -610,7 +610,7 @@ switch(t){
buzzer . play ( " ack:d=32,o=8,b=120:c " ) ;
buzzer . play ( " ack:d=32,o=8,b=120:c " ) ;
break ;
break ;
case UIEventType : : advertSent :
case UIEventType : : advertSent :
buzzer . play ( " Advert:d=16,o=6,b=24 0:c,e,g,c7 " ) ;
buzzer . play ( " Advert:d=8,o=6,b=18 0:c,e,g,c7 " ) ;
break ;
break ;
case UIEventType : : roomMessage :
case UIEventType : : roomMessage :
case UIEventType : : newContactMessage :
case UIEventType : : newContactMessage :
@ -104,7 +104,7 @@ switch(t){
buzzer . play ( " ack:d=32,o=8,b=120:c " ) ;
buzzer . play ( " ack:d=32,o=8,b=120:c " ) ;
break ;
break ;
case UIEventType : : advertSent :
case UIEventType : : advertSent :
buzzer . play ( " Advert:d=16,o=6,b=24 0:c,e,g,c7 " ) ;
buzzer . play ( " Advert:d=8,o=6,b=18 0:c,e,g,c7 " ) ;
break ;
break ;
case UIEventType : : roomMessage :
case UIEventType : : roomMessage :
case UIEventType : : newContactMessage :
case UIEventType : : newContactMessage :
@ -482,7 +482,7 @@ switch(t){
buzzer . play ( " ack:d=32,o=8,b=120:c " ) ;
buzzer . play ( " ack:d=32,o=8,b=120:c " ) ;
break ;
break ;
case UIEventType : : advertSent :
case UIEventType : : advertSent :
buzzer . play ( " Advert:d=16,o=6,b=24 0:c,e,g,c7 " ) ;
buzzer . play ( " Advert:d=8,o=6,b=18 0:c,e,g,c7 " ) ;
break ;
break ;
case UIEventType : : roomMessage :
case UIEventType : : roomMessage :
case UIEventType : : newContactMessage :
case UIEventType : : newContactMessage :
@ -50,7 +50,8 @@ void genericBuzzer::playToggle(int count, bool enabled) {
if ( count < 1 ) count = 1 ;
if ( count < 1 ) count = 1 ;
if ( count > max_notes ) count = max_notes ;
if ( count > max_notes ) count = max_notes ;
char melody [ 64 ] ;
char melody [ 64 ] ;
int n = snprintf ( melody , sizeof ( melody ) , " Tg:d=16,o=6,b=200: " ) ;
// d=8 (eighths) at b=180 -> ~166 ms per note, audible on small piezos.
int n = snprintf ( melody , sizeof ( melody ) , " Tg:d=8,o=6,b=180: " ) ;
for ( int i = 0 ; i < count & & n < ( int ) sizeof ( melody ) ; i + + ) {
for ( int i = 0 ; i < count & & n < ( int ) sizeof ( melody ) ; i + + ) {
int idx = enabled ? i : ( count - 1 - i ) ;
int idx = enabled ? i : ( count - 1 - i ) ;
n + = snprintf ( melody + n , sizeof ( melody ) - n , " %s%s " , i ? " , " : " " , notes [ idx ] ) ;
n + = snprintf ( melody + n , sizeof ( melody ) - n , " %s%s " , i ? " , " : " " , notes [ idx ] ) ;