You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to Omar at CTRE each api call to a joystick can take ~0.3ms. With the hope of running at 100hz this can be problematic given everything else that is going on.
It would be relatively easy to cache the value of the JoystickButtons and only update the cache every nth loop. The buttons would be staggered to avoid everything nth loop being slower.
The text was updated successfully, but these errors were encountered:
Using a wrapper like this around all our buttons should work.
class JoystickButton2481 {
private:
class Button* m_button;
static int s_buttonCount;
int m_loopCounter;
bool m_cachedState;
public:
JoystickButton2481(Button* button) {
m_button = button;
m_loopCounter = s_buttonCount++ % 5; //Offset the loop counter by 1 to 5 so not all the buttons update on the loop.
m_cachedState = false;
}
bool Get() {
if (m_loopCounter++ % 5 == 0) {
m_cachedState = m_button->Get();
}
return m_cachedState;
}
};
According to Omar at CTRE each api call to a joystick can take ~0.3ms. With the hope of running at 100hz this can be problematic given everything else that is going on.
It would be relatively easy to cache the value of the JoystickButtons and only update the cache every nth loop. The buttons would be staggered to avoid everything nth loop being slower.
The text was updated successfully, but these errors were encountered: