KerbalSimpitRevamped-Arduino icon indicating copy to clipboard operation
KerbalSimpitRevamped-Arduino copied to clipboard

preventative measure: Add in native debouncing for CAGs

Open LRTNZ opened this issue 5 years ago • 3 comments

When you rapidly fire a CAG, KSP seems to just crash? Or at least that is the experiance that @TheDicko has been having. The ideal solution would be for users to implement their own debouncing/rate limiting on the firing of CAG events. However, just to be sure, it would be best if this library were to implement such a thing, to avoid the need for users to worry about what may be causing such an odd issue in their controller, and consequentially spending many hours trying to hunt down a rather trivial bug.

LRTNZ avatar Nov 26 '20 15:11 LRTNZ

I could not reproduce the error to see if the debouncing corrects it.

Here is the Arduino code tested, no KSP crashed occured with KSP 1.10 and ActionGroupExtended v2.4.0.1.

The code waits for a SimPit connection and for the button connected to Arduino input 7 before spamming a toggle command for a CAG.

#include "KerbalSimpit.h"

KerbalSimpit mySimpit(Serial);

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);

  pinMode(7, INPUT_PULLUP);
  pinMode(LED_BUILTIN, OUTPUT);

  while (!mySimpit.init()) {
    delay(100);
  }

  digitalWrite(LED_BUILTIN, LOW);
  while(digitalRead(7)){
    delay(100);
  }
  digitalWrite(LED_BUILTIN, HIGH);
}

void loop() {
  // put your main code here, to run repeatedly:
  mySimpit.toggleCAG(1);
}

PBechon avatar Nov 28 '20 21:11 PBechon

Test it with toggling more than one CAG as this was only when I encountered unity crash

CallumDixon avatar Nov 29 '20 21:11 CallumDixon

Test it with toggling more than one CAG as this was only when I encountered unity crash

Was this when you were toggling more than one CAG per update cycle?

LRTNZ avatar Dec 01 '20 05:12 LRTNZ