multiple blades use blade detect:
Add this to events.h
BUTTON_BLADE_DETECT = 256,
BUTTON_BLADE_DETECT2 = 2048,
BUTTON_BLADE_DETECT3 = 4096,
Add this to your config header
#define BLADE_DETECT_PIN 8
#define BLADE_DETECT_PIN2 9
#define BLADE_DETECT_PIN3 22
Add this to your props file
#ifdef BLADE_DETECT_PIN
case EVENTID(BUTTON_BLADE_DETECT, EVENT_LATCH_ON, MODE_ANY_BUTTON | MODE_ON):
case EVENTID(BUTTON_BLADE_DETECT, EVENT_LATCH_ON, MODE_ANY_BUTTON | MODE_OFF):
// Might need to do something cleaner, but let's try this for now.
blade_detected_ = true;
FindBladeAgain();
SaberBase::DoBladeDetect(true);
return true;
case EVENTID(BUTTON_BLADE_DETECT, EVENT_LATCH_OFF, MODE_ANY_BUTTON | MODE_ON):
case EVENTID(BUTTON_BLADE_DETECT, EVENT_LATCH_OFF, MODE_ANY_BUTTON | MODE_OFF):
// Might need to do something cleaner, but let's try this for now.
blade_detected_ = false;
FindBladeAgain();
SaberBase::DoBladeDetect(false);
return true;
#endif
#ifdef BLADE_DETECT_PIN2
case EVENTID(BUTTON_BLADE_DETECT2, EVENT_LATCH_ON, MODE_ANY_BUTTON | MODE_ON):
case EVENTID(BUTTON_BLADE_DETECT2, EVENT_LATCH_ON, MODE_ANY_BUTTON | MODE_OFF):
// Might need to do something cleaner, but let's try this for now.
blade2_detected_ = true;
FindBladeAgain();
SaberBase::DoBladeDetect(true);
return true;
case EVENTID(BUTTON_BLADE_DETECT2, EVENT_LATCH_OFF, MODE_ANY_BUTTON | MODE_ON):
case EVENTID(BUTTON_BLADE_DETECT2, EVENT_LATCH_OFF, MODE_ANY_BUTTON | MODE_OFF):
// Might need to do something cleaner, but let's try this for now.
blade2_detected_ = false;
FindBladeAgain();
SaberBase::DoBladeDetect(false);
return true;
#endif
#ifdef BLADE_DETECT_PIN3
case EVENTID(BUTTON_BLADE_DETECT3, EVENT_LATCH_ON, MODE_ANY_BUTTON | MODE_ON):
case EVENTID(BUTTON_BLADE_DETECT3, EVENT_LATCH_ON, MODE_ANY_BUTTON | MODE_OFF):
// Might need to do something cleaner, but let's try this for now.
blade3_detected_ = true;
FindBladeAgain();
SaberBase::DoBladeDetect(true);
return true;
case EVENTID(BUTTON_BLADE_DETECT3, EVENT_LATCH_OFF, MODE_ANY_BUTTON | MODE_ON):
case EVENTID(BUTTON_BLADE_DETECT3, EVENT_LATCH_OFF, MODE_ANY_BUTTON | MODE_OFF):
// Might need to do something cleaner, but let's try this for now.
blade3_detected_ = false;
FindBladeAgain();
SaberBase::DoBladeDetect(false);
return true;
#endif
private:
#ifdef BLADE_DETECT_PIN2
bool blade2_detected_ = false;
#endif
#ifdef BLADE_DETECT_PIN3
bool blade3_detected_ = false;
#endif
Add this to ProffieOS.ino
#ifdef BLADE_DETECT_PIN
LatchingButtonTemplate<FloatingButtonBase<BLADE_DETECT_PIN>>
BladeDetect(BUTTON_BLADE_DETECT, BLADE_DETECT_PIN, "blade_detect");
#endif
#ifdef BLADE_DETECT_PIN2
LatchingButtonTemplate<FloatingButtonBase<BLADE_DETECT_PIN2>>
BladeDetect2(BUTTON_BLADE_DETECT2, BLADE_DETECT_PIN2, "blade_detect");
#endif
#ifdef BLADE_DETECT_PIN3
LatchingButtonTemplate<FloatingButtonBase<BLADE_DETECT_PIN3>>
BladeDetect3(BUTTON_BLADE_DETECT3, BLADE_DETECT_PIN3, "blade_detect");
#endif