KerbalSimpitRevamped
KerbalSimpitRevamped copied to clipboard
[BUG]: CAG not behaving consistently when empty
Tested on latest version of Simpit, KSP1.12 w/ AGExt. Reported by @CodapopKSP
Using the logging, you can see the difference in behavior between AG1-10 and AG11+.
If you put a craft on the pad and a craft on the runway, both with nothing assigned to action groups, and then run that code and have it activate the CAG in the setup, then switch between the two, you'll see a few things:
- AG 1-10 cannot be activated using the arduino if they're empty, but they can be activated using the keyboard. But when switching to the other craft, they turn OFF appropriately, and when returning to the first craft, they turn back ON appropriately. The issue here is they can only be activated by the controller if they are populated.
- The bigger issue is that turning on AG 11+ on one craft and then switching to the other craft reveals them to still be turned on, but only if they're empty. If they're populated, then I believe they all function properly.
So all AGs function properly when populated on both crafts. AG 1-10 are unable to be activated by controller if unpopulated (maybe a feature more than a bug) AG 11+ can be activated but don't change state when switching craft if unpopulated AG 11+ also automatically turn off when exiting flight even if there is no scene change message.
Here is a script to reproduce it
#include "KerbalSimpit.h"
KerbalSimpit mySimpit(Serial);
unsigned long lastDebounceTime_w = 0;
bool Action_Dspl_b[10] = {};
bool Action2_Dspl_b[10] = {};
void setup() {
Serial.begin(115200);
while (!mySimpit.init()) {delay(100);}
mySimpit.printToKSP("Connected", PRINT_TO_SCREEN);
mySimpit.inboundHandler(messageHandler);
mySimpit.registerChannel(CAGSTATUS_MESSAGE);
delay(1000);
mySimpit.toggleCAG(2);
mySimpit.toggleCAG(3);
mySimpit.toggleCAG(12);
mySimpit.toggleCAG(13);
}
void loop() {
mySimpit.update();
if ((millis() - lastDebounceTime_w) > 1000) {
for (int i = 0; i < 4; i++) {
mySimpit.printToKSP("AG" + String(i) + ": " + String(Action_Dspl_b[i]), PRINT_TO_SCREEN);
//mySimpit.printToKSP("AG2" + String(i+10) + ": " + String(Action2_Dspl_b[i]), PRINT_TO_SCREEN);
}
lastDebounceTime_w = millis();
}
}
void messageHandler(byte messageType, byte msg[], byte msgSize) {
switch(messageType) {
case CAGSTATUS_MESSAGE:
if (msgSize == sizeof(cagStatusMessage)) {
cagStatusMessage myAG;
myAG = parseCAGStatusMessage(msg);
for (int i = 1; i < 11; i++) {
Action_Dspl_b[i] = (myAG.is_action_activated(i));
Action2_Dspl_b[i] = (myAG.is_action_activated(i+10));
}
}
break;
}
}