Skip to content

Commit

Permalink
Add on / off check bypass preon / postoff (#628)
Browse files Browse the repository at this point in the history
  • Loading branch information
NoSloppy authored Mar 6, 2024
1 parent 946b6c5 commit 74ce55a
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions props/saber_BC_buttons.h
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,23 @@ class SaberBCButtons : public PROP_INHERIT_PREFIX PropBase {
return false;
}

void TurnOnHelper() {
if (is_pointing_up()) {
FastOn();
} else {
On();
}
}

void TurnOffHelper() {
if (is_pointing_up()) {
Off(OFF_FAST);
} else {
Off();
}
saber_off_time_ = millis();
}

RefPtr<BufferedWavPlayer> wav_player;

bool Event2(enum BUTTON button, EVENT event, uint32_t modifiers) override {
Expand Down Expand Up @@ -663,12 +680,7 @@ class SaberBCButtons : public PROP_INHERIT_PREFIX PropBase {
last_twist_ = millis();
saber_off_time_ = millis();
battle_mode_ = false;
// Bypass postoff if pointing up
if (fusor.angle1() > M_PI / 3) {
Off(OFF_FAST);
} else {
Off();
}
TurnOffHelper();
}
return true;
#endif // BC_TWIST_OFF
Expand Down Expand Up @@ -721,19 +733,13 @@ class SaberBCButtons : public PROP_INHERIT_PREFIX PropBase {
return true;
#endif // BC_FORCE_PUSH

// Turns Saber ON
// Turn Saber ON
case EVENTID(BUTTON_POWER, EVENT_FIRST_SAVED_CLICK_SHORT, MODE_OFF):
// No power on without exiting Vol Menu first
if (!mode_volume_) {
// Bypass preon if pointing up
if (fusor.angle1() > M_PI / 3) {
FastOn();
} else {
On();
scroll_presets_ = false;
}
} else {
if (mode_volume_) {
QuickMaxVolume();
} else {
TurnOnHelper();
}
return true;

Expand Down Expand Up @@ -1093,15 +1099,9 @@ class SaberBCButtons : public PROP_INHERIT_PREFIX PropBase {
}
#endif
if (!battle_mode_) {
// Bypass postoff if pointing up
if (fusor.angle1() > M_PI / 3) {
Off(OFF_FAST);
} else {
Off();
}
TurnOffHelper();
}
}
saber_off_time_ = millis();
return true;

// Blade Detect
Expand Down

0 comments on commit 74ce55a

Please sign in to comment.