Guest User

Untitled

a guest
Mar 17th, 2025
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. // Battery level
  2. #if NUM_BUTTONS == 1
  3. // 1 button
  4. case EVENTID(BUTTON_POWER, EVENT_THIRD_SAVED_CLICK_SHORT, MODE_OFF):
  5. #else
  6. // 2 and 3 button
  7. case EVENTID(BUTTON_AUX, EVENT_FIRST_HELD_LONG, MODE_OFF):
  8. #endif
  9. talkie.SayDigit((int)floorf(battery_monitor.battery()));
  10. talkie.Say(spPOINT);
  11. talkie.SayDigit(((int)floorf(battery_monitor.battery() * 10)) % 10);
  12. talkie.SayDigit(((int)floorf(battery_monitor.battery() * 100)) % 10);
  13. talkie.Say(spVOLTS);
  14. return true;
  15.  
  16. #ifdef BLADE_DETECT_PIN
  17. case EVENTID(BUTTON_BLADE_DETECT, EVENT_LATCH_ON, MODE_ANY_BUTTON | MODE_ON):
  18. case EVENTID(BUTTON_BLADE_DETECT, EVENT_LATCH_ON, MODE_ANY_BUTTON | MODE_OFF):
  19. // Might need to do something cleaner, but let's try this for now.
  20. blade_detected_ = true;
  21. FindBladeAgain();
  22. SaberBase::DoBladeDetect(true);
  23. return true;
  24.  
  25. case EVENTID(BUTTON_BLADE_DETECT, EVENT_LATCH_OFF, MODE_ANY_BUTTON | MODE_ON):
  26. case EVENTID(BUTTON_BLADE_DETECT, EVENT_LATCH_OFF, MODE_ANY_BUTTON | MODE_OFF):
  27. // Might need to do something cleaner, but let's try this for now.
  28. blade_detected_ = false;
  29. FindBladeAgain();
  30. SaberBase::DoBladeDetect(false);
  31. return true;
  32. #endif
  33.  
  34. // Events that needs to be handled regardless of what other buttons
  35. // are pressed.
  36. case EVENTID(BUTTON_POWER, EVENT_RELEASED, MODE_ANY_BUTTON | MODE_ON):
  37. case EVENTID(BUTTON_AUX, EVENT_RELEASED, MODE_ANY_BUTTON | MODE_ON):
  38. case EVENTID(BUTTON_AUX2, EVENT_RELEASED, MODE_ANY_BUTTON | MODE_ON):
  39. if (SaberBase::Lockup()) {
  40. SaberBase::DoEndLockup();
  41. SaberBase::SetLockup(SaberBase::LOCKUP_NONE);
  42. return true;
  43. }
  44. }
  45. return false;
  46. }
  47.  
  48. void SB_Effect(EffectType effect, float location) override {
  49. switch (effect) {
  50. case EFFECT_POWERSAVE:
  51. if (SFX_dim) {
  52. hybrid_font.PlayCommon(&SFX_dim);
  53. } else {
  54. beeper.Beep(0.5, 3000);
  55. }
  56. return;
  57. case EFFECT_BATTERY_LEVEL:
  58. if (SFX_battery) {
  59. hybrid_font.PlayCommon(&SFX_battery);
  60. } else {
  61. beeper.Beep(0.5, 3000);
  62. }
  63. return;
  64. case EFFECT_FAST_ON:
  65. if (SFX_faston) {
  66. hybrid_font.PlayCommon(&SFX_faston);
  67. }
  68. return;
  69.  
  70. default: break; // avoids compiler warning
  71. }
  72. }
  73.  
Advertisement
Add Comment
Please, Sign In to add comment