Skip to content

Commit

Permalink
play newfont/bladein/bladeout when blade id scanning detects a change
Browse files Browse the repository at this point in the history
  • Loading branch information
profezzorn committed Dec 9, 2023
1 parent e6706eb commit deb54f0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 1 addition & 3 deletions props/dual_prop.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ Give the BladeConfig 2 sets of descriptions, and
*/


#ifndef DUAL_PROP_CONDITION
#define DUAL_PROP_CONDITION blade_detected_
#endif
#define DUAL_PROP_CONDITION blade_present()

#ifdef PROP_INHERIT_PREFIX
#error dual_prop.h must be included first
Expand Down
14 changes: 14 additions & 0 deletions props/prop_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,13 @@ class PropBase : CommandParser, Looper, protected SaberBase {
bool blade_detected_ = false;
#endif

// Use this helper function, not the bool above.
// This function changes when we're properly initialized
// the blade, the bool is an internal to blade detect.
bool blade_present() {
return current_config->ohm < NO_BLADE;
}

// Measure and return the blade identifier resistor.
float id() {
EnableBooster();
Expand Down Expand Up @@ -609,7 +616,14 @@ class PropBase : CommandParser, Looper, protected SaberBase {
void PollScanId() {
if (find_blade_again_pending_) {
find_blade_again_pending_ = false;
bool blade_present_before = blade_present();
FindBladeAgain();
bool blade_present_after = blade_present();
if (blade_present_before != blade_present_after) {
SaberBase::DoBladeDetect(blade_present_after);
} else {
SaberBase::DoNewFont();
}
}
}
#else
Expand Down

0 comments on commit deb54f0

Please sign in to comment.