-
Notifications
You must be signed in to change notification settings - Fork 1
Feature request: toggle sound #2
Copy link
Copy link
Open
Description
It would be helpful to have a keyboard toggle to turn the sound on and off, this would be less distracting for people around me and draw less attention when using it. Here's the quick and dirty way I implemented it (this also has the side effect of making all the tones the same duration, which you may not want to do):
diff -r Pigtail/src/UIGrid.cpp Pigtail-nosound/src/UIGrid.cpp
63a64,67
> int tone_duration = 50;
> int tone_on = 50;
> int tone_off = 2;
>
363c367
< playSound(800, 100);
---
> playSound(800, tone_duration);
371c375
< playSound(600, 100);
---
> playSound(600, tone_duration);
382a387
> const bool sKey = kb.isKeyPressed('s') || kb.isKeyPressed('S');
391c396
< playSound(800, 100);
---
> playSound(800, tone_duration);
395,399c400,404
< if (up) { nav(0, -1); playSound(800, 50); }
< else if (down) { nav(0, +1); playSound(800, 50); }
< else if (left) { nav(-1, 0); playSound(800, 50); }
< else if (right) { nav(+1, 0); playSound(800, 50); }
< else if (enter) { openDetail(); playSound(1000, 100); }
---
> if (up) { nav(0, -1); playSound(800, tone_duration); }
> else if (down) { nav(0, +1); playSound(800, tone_duration); }
> else if (left) { nav(-1, 0); playSound(800, tone_duration); }
> else if (right) { nav(+1, 0); playSound(800, tone_duration); }
> else if (enter) { openDetail(); playSound(1000, tone_duration); }
413c418
< playSound(600, 100);
---
> playSound(600, tone_duration);
429c434
< playSound(600, 100);
---
> playSound(600, tone_duration);
434c439,442
< playSound(1000, 100);
---
> playSound(1000, tone_duration);
> }
> else if (sKey) {
> tone_duration = tone_on + tone_off - tone_duration;
436d443
<
444c451
< playSound(800, 100);
---
> playSound(800, tone_duration);
446,449c453,456
< if (up) { nav(0, -1); playSound(800, 50); }
< else if (down) { nav(0, +1); playSound(800, 50); }
< else if (left) { nav(-1, 0); playSound(800, 50); }
< else if (right) { nav(+1, 0); playSound(800, 50); }
---
> if (up) { nav(0, -1); playSound(800, tone_duration); }
> else if (down) { nav(0, +1); playSound(800, tone_duration); }
> else if (left) { nav(-1, 0); playSound(800, tone_duration); }
> else if (right) { nav(+1, 0); playSound(800, tone_duration); }
463c470
< playSound(600, 100);
---
> playSound(600, tone_duration);
479c486
< playSound(600, 100);
---
> playSound(600, tone_duration);
484c491,494
< playSound(1000, 100);
---
> playSound(1000, tone_duration);
> }
> else if (sKey) {
> tone_duration = tone_on + tone_off - tone_duration;
711c721
< M5Cardputer.Speaker.tone(frequency, duration);
---
> if (duration > 5) M5Cardputer.Speaker.tone(frequency, duration);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels