From 9a20b8bab61598a9704cbb69c7490e8d235ecdd0 Mon Sep 17 00:00:00 2001 From: Tetopia Date: Sun, 11 Feb 2024 02:20:54 +0100 Subject: [PATCH] Add Science Action Group --- .../KerbalSimpitAllCommandDemo.ino | 3 +++ .../KerbalSimpitAllFeedbackDemo.ino | 13 +++++++------ src/KerbalSimpitMessageTypes.h | 10 ++++++++-- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/examples/KerbalSimpitAllCommandDemo/KerbalSimpitAllCommandDemo.ino b/examples/KerbalSimpitAllCommandDemo/KerbalSimpitAllCommandDemo.ino index 34a7ce0..1c02fef 100644 --- a/examples/KerbalSimpitAllCommandDemo/KerbalSimpitAllCommandDemo.ino +++ b/examples/KerbalSimpitAllCommandDemo/KerbalSimpitAllCommandDemo.ino @@ -280,6 +280,9 @@ void setup() { TestActionGroup("SAS", ADVANCED_SAS_ACTION); TestActionGroup("RCS", ADVANCED_RCS_ACTION); TestActionGroup("Brakes", ADVANCED_BRAKES_ACTION); + TestActionGroup("Solar", ADVANCED_SOLAR_ACTION); + TestActionGroup("Radiators", ADVANCED_RADIATOR_ACTION); + TestActionGroup("Science", ADVANCED_SCIENCE_ACTION); // |----------| // | Rotation | diff --git a/examples/KerbalSimpitAllFeedbackDemo/KerbalSimpitAllFeedbackDemo.ino b/examples/KerbalSimpitAllFeedbackDemo/KerbalSimpitAllFeedbackDemo.ino index 7bc309c..69ef55f 100644 --- a/examples/KerbalSimpitAllFeedbackDemo/KerbalSimpitAllFeedbackDemo.ino +++ b/examples/KerbalSimpitAllFeedbackDemo/KerbalSimpitAllFeedbackDemo.ino @@ -16,7 +16,7 @@ bool lastButtonState = HIGH; // To find when the button changes state KerbalSimpit mySimpit(Serial); // Declare a KerbalSimpit object that will communicate using the "Serial" device. const int NUMBER_OF_STEPS = 52; //The selectionIndex will be reset to 0 after reaching NUMBER_OF_STEPS-1 -int selectionIndex = 14; // increased when pushing the continue button to display different Values +int selectionIndex = 0; // increased when pushing the continue button to display different Values unsigned long timestampLastSent; // When was the last time something was sent to print on screen const int SENDING_INTERVAL = 1000; // in milliseconds. How often to print data to screen @@ -418,10 +418,10 @@ void loop() mySimpit.printToKSP("Signal:" + String((int)myByte6) + "% Stg:" + String((int)myByte7) + " Typ:" + String((int)myByte8), PRINT_TO_SCREEN); } break; case 44: { //Athmospheric Conditions - mySimpit.printToKSP("Athmo:" + String(myBool1) + " Ox:" + String(myBool2) + " In:" + String(myBool3), PRINT_TO_SCREEN); + mySimpit.printToKSP("Athmo:" + String(myBool1) + " Ox:" + String(myBool2) + " InAtm:" + String(myBool3), PRINT_TO_SCREEN); } break; case 45: { //Athmospheric Conditions - mySimpit.printToKSP("Dens:" + String(myFloatStorage1, 0) + " Temp:" + String(myFloatStorage2, 0) + " Press" + String(myFloatStorage3, 0), PRINT_TO_SCREEN); + mySimpit.printToKSP("Dens:" + String(myFloatStorage1, 2) + " Temp:" + String(myFloatStorage2, 0) + " Pres:" + String(myFloatStorage3, 0), PRINT_TO_SCREEN); } break; case 46: { //Vessel Name mySimpit.printToKSP("Vessel Name: '" + myString + "'", PRINT_TO_SCREEN); @@ -443,8 +443,9 @@ void loop() " S" + String((int)myAdvancedActionGroups[ADVANCED_SOLAR_ACTION]) + " A" + String((int)myAdvancedActionGroups[ADVANCED_ABORT_ACTION]) + " R" + String((int)myAdvancedActionGroups[ADVANCED_RADIATOR_ACTION]) + - " Sas" + String((int)myAdvancedActionGroups[ADVANCED_SAS_ACTION]) + - " Rcs" + String((int)myAdvancedActionGroups[ADVANCED_RCS_ACTION]), PRINT_TO_SCREEN); + " SA" + String((int)myAdvancedActionGroups[ADVANCED_SAS_ACTION]) + + " RC" + String((int)myAdvancedActionGroups[ADVANCED_RCS_ACTION]) + + " Sc" + String((int)myAdvancedActionGroups[ADVANCED_SCIENCE_ACTION]), PRINT_TO_SCREEN); } break; case 51: { //Advanced Custom Action Group State Info mySimpit.printToKSP( @@ -959,7 +960,7 @@ void messageHandler(byte messageType, byte msg[], byte msgSize) { if (msgSize == sizeof(advancedActionStatusMessage) && selectionIndex == 50) { advancedActionStatusMessage actionStatusMsg = parseMessage(msg); - for(int i = 0; i < 9; i++) //There are 9 action groups (stage, gear, ...), they are listed in the AdvancedActionGroupIndexes enum. Some are only available for KSP2 + for(int i = 0; i < 10; i++) //There are 9 action groups (stage, gear, ...), they are listed in the AdvancedActionGroupIndexes enum. Some are only available for KSP2 { myAdvancedActionGroups[i] = actionStatusMsg.getActionStatus(i); } diff --git a/src/KerbalSimpitMessageTypes.h b/src/KerbalSimpitMessageTypes.h index 37c03fa..e6595a4 100644 --- a/src/KerbalSimpitMessageTypes.h +++ b/src/KerbalSimpitMessageTypes.h @@ -423,7 +423,9 @@ enum AdvancedActionGroupIndexes /** Index for the Solar action group. Only for KSP2. */ ADVANCED_SOLAR_ACTION = 7, /** Index for the Radiator action group. Only for KSP2. */ - ADVANCED_RADIATOR_ACTION = 8 + ADVANCED_RADIATOR_ACTION = 8, + /** Index for the Science action group. Only for KSP2. */ + ADVANCED_SCIENCE_ACTION = 9 }; /** Action Group Settings for single action groups @@ -451,7 +453,11 @@ enum AdvancedActionGroupStates /** Value if the action group is off. */ ADVANCED_AG_STATE_OFF = 2, /** Value if the action group is mixed, meaning some parts associated with it are on and others are off. */ - ADVANCED_AG_STATE_MIXED = 3 + ADVANCED_AG_STATE_MIXED = 3, + /** Value if the action group is mixed, meaning some parts associated with it are on and others are off. */ + ADVANCED_AG_STATE_BITMASK_SCIENCE_AVAILABLE = 1, + /** Value if the action group is mixed, meaning some parts associated with it are on and others are off. */ + ADVANCED_AG_STATE_BITMASK_EXPERIMENTS_IN_PROGRESS = 2 };