Skip to content

Commit

Permalink
BC_buttons - Spoken battery fix #2 (#600)
Browse files Browse the repository at this point in the history
* fix execution condition and order

* remove comment
  • Loading branch information
NoSloppy authored Dec 8, 2023
1 parent 49d98c5 commit 267be7c
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions props/saber_BC_buttons.h
Original file line number Diff line number Diff line change
Expand Up @@ -803,12 +803,13 @@ class SaberBCButtons : public PROP_INHERIT_PREFIX PropBase {

// Spoken Battery Level in volts
case EVENTID(BUTTON_POWER, EVENT_THIRD_SAVED_CLICK_SHORT, MODE_OFF):
// Avoid weird battery readings when using USB
if (battery_monitor.battery() < 0.5) {
sound_library_.SayTheBatteryLevelIs();
sound_library_.SayDisabled();
}
if (!mode_volume_) {
// Avoid weird battery readings when using USB
if (battery_monitor.battery() < 0.5) {
sound_library_.SayTheBatteryLevelIs();
sound_library_.SayDisabled();
return true;
}
sound_library_.SayTheBatteryLevelIs();
sound_library_.SayNumber(battery_monitor.battery(), SAY_DECIMAL);
sound_library_.SayVolts();
Expand All @@ -820,15 +821,16 @@ class SaberBCButtons : public PROP_INHERIT_PREFIX PropBase {

// Spoken Battery Level in percentage
case EVENTID(BUTTON_POWER, EVENT_THIRD_HELD, MODE_OFF):
if (battery_monitor.battery() < 0.5) {
sound_library_.SayTheBatteryLevelIs();
sound_library_.SayDisabled();
}
if (!mode_volume_) {
if (battery_monitor.battery() < 0.5) {
sound_library_.SayTheBatteryLevelIs();
sound_library_.SayDisabled();
return true;
}
sound_library_.SayTheBatteryLevelIs();
sound_library_.SayNumber(battery_monitor.battery_percent(), SAY_WHOLE);
sound_library_.SayPercent();
PVLOG_NORMAL << "Battery Percentage: " <<battery_monitor.battery_percent() << "\n";
PVLOG_NORMAL << "Battery Percentage: " <<battery_monitor.battery_percent() << "%\n";
speaking_ = true;
SaberBase::DoEffect(EFFECT_BATTERY_LEVEL, 0);
}
Expand Down

0 comments on commit 267be7c

Please sign in to comment.