NoSloppy

modified fett263VolumeSection

Mar 17th, 2021 (edited)
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. // SA22C Volume Menu
  2. void VolumeUp() {
  3. STDOUT.println("Volume up");
  4. if (dynamic_mixer.get_volume() < VOLUME) {
  5. dynamic_mixer.set_volume(std::min<int>(VOLUME + VOLUME * 0.1,
  6. dynamic_mixer.get_volume() + VOLUME * 0.10));
  7. //beeper.Beep(0.5, 2000);
  8. ::CommandParser::DoParse("play", "volchangeup.wav"); // BC Custom Spoken Volume menu
  9. STDOUT.print("Current Volume: ");
  10. STDOUT.println(dynamic_mixer.get_volume());
  11. } else {
  12. #ifdef VOLUME_MENU_CYCLE // BC Cycle through Volume Menu option
  13. if (!max_vol_) {
  14. //beeper.Beep(0.5, 3000);
  15. ::CommandParser::DoParse("play", "volmax.wav");
  16. STDOUT.print("Current Volume: ");
  17. max_vol_ = true;
  18. } else {
  19. dynamic_mixer.set_volume(std::max<int>(VOLUME * 0.1,
  20. dynamic_mixer.get_volume() - VOLUME * 0.90));
  21. ::CommandParser::DoParse("play", "volmin.wav");
  22. STDOUT.print("Current Volume: ");
  23. max_vol_ = false;
  24. }
  25. #else
  26. ::CommandParser::DoParse("play", "volmax.wav");
  27. STDOUT.print("Current Volume: ");
  28. #endif
  29. }
  30. }
  31.  
  32. void VolumeDown() {
  33. STDOUT.println("Volume Down");
  34. if (dynamic_mixer.get_volume() > (0.10 * VOLUME)) {
  35. dynamic_mixer.set_volume(std::max<int>(VOLUME * 0.1,
  36. dynamic_mixer.get_volume() - VOLUME * 0.10));
  37. //beeper.Beep(0.5, 2000);
  38. ::CommandParser::DoParse("play", "volchangedown.wav");
  39. STDOUT.print("Current Volume: ");
  40. STDOUT.println(dynamic_mixer.get_volume());
  41. } else {
  42. #ifdef VOLUME_MENU_CYCLE
  43. if (!min_vol_) {
  44. //beeper.Beep(0.5, 3000);
  45. ::CommandParser::DoParse("play", "volmin.wav");
  46. STDOUT.print("Current Volume: ");
  47. min_vol_ = true;
  48. } else {
  49. dynamic_mixer.set_volume(VOLUME);
  50. ::CommandParser::DoParse("play", "volmax.wav");
  51. STDOUT.print("Current Volume: ");
  52. min_vol_ = false;
  53. }
  54. #else
  55. ::CommandParser::DoParse("play", "volmin.wav");
  56. STDOUT.print("Current Volume: ");
  57. #endif
  58.  
  59. }
  60. }
  61.  
  62. //-------------------
  63. // add to private:
  64. //--------------------
  65.  
  66. bool max_vol_ = false;
  67. bool min_vol_ = false;
Advertisement
Add Comment
Please, Sign In to add comment