Thanks guys.
Though I’m slightly confused. Based on this thread, by default, the motion chip times out after 20 seconds with props other than yours Fernando, and Dmitry’s:
So MOTION_TIMEOUT is only really overriding a default time of 20 seconds with a custom time instead.
It is only used in the prop for SWING_ON so that you can still swing to turn on if more than 20 seconds has expired since turning off the blade, up to your custom defined time.
Regardless, a 20 second timeout minimum still exists in saber base in the following code block.
However, if NUM_BUTTONS == 0, I don’t think it should ever time out in the first place?
static bool MotionRequested() {
#if NUM_BUTTONS == 0
return true;
#else
return IsOn() || (millis() - last_motion_request_) < 20000;
#endif
}
Anyway, if you really wanted to, you could just remove the MOTION_TIMEOUT check all together by taking away the outer most condition here:
if (millis() - saber_off_time_ < MOTION_TIMEOUT) {
SaberBase::RequestMotion();
if (swinging_ && fusor.swing_speed() < 100) {
swinging_ = false;
}
if (!swinging_ && fusor.swing_speed() > 500) {
swinging_ = true;
Event(BUTTON_NONE, EVENT_SWING);
}
}
so that it’s just
SaberBase::RequestMotion();
if (swinging_ && fusor.swing_speed() < 100) {
swinging_ = false;
}
if (!swinging_ && fusor.swing_speed() > 500) {
swinging_ = true;
Event(BUTTON_NONE, EVENT_SWING);
}
This would effectively be constantly setting last_motion_request_ = millis();, so you’d never reach the default 20000ms, not use any MOTION_TIMEOUT, and the saber would just always respond to motion as long as there is power available.
-or-
as pointed out above, just set the MOTION_TIMEOUT to something ridiculously high and be done.
Surely that means that by default, after just 20 seconds of inactivity, any gesture ignition won’t work? But that doesn’t appear to be the case…?
What am I missing here?