@@ -15,7 +15,7 @@ bool lastButtonState = HIGH; // To find when the button changes state
1515
1616KerbalSimpit mySimpit (Serial); // Declare a KerbalSimpit object that will communicate using the "Serial" device.
1717
18- const int NUMBER_OF_STEPS = 52 ; // The selectionIndex will be reset to 0 after reaching NUMBER_OF_STEPS-1
18+ const int NUMBER_OF_STEPS = 54 ; // The selectionIndex will be reset to 0 after reaching NUMBER_OF_STEPS-1
1919int selectionIndex = 0 ; // increased when pushing the continue button to display different Values
2020unsigned long timestampLastSent; // When was the last time something was sent to print on screen
2121const int SENDING_INTERVAL = 1000 ; // in milliseconds. How often to print data to screen
@@ -25,8 +25,8 @@ const int SENDING_INTERVAL = 1000; // in milliseconds. How often to print data
2525bool echoReceived = false ;
2626float myAltitudeSeaLevel;
2727float myAltitudeSurface;
28- int32_t myTimeToApoapsis ;
29- int32_t myTimeToPeriapsis ;
28+ int32_t myTime1 ;
29+ int32_t myTime2 ;
3030byte myCurrentSASMode;
3131int16_t mySASModeAvailability;
3232bool myCustomActionGroups[10 ];
@@ -156,6 +156,7 @@ void setup() {
156156 mySimpit.registerChannel (ATMO_CONDITIONS_MESSAGE );
157157 mySimpit.registerChannel (VESSEL_NAME_MESSAGE );
158158 mySimpit.registerChannel (VESSEL_CHANGE_MESSAGE );
159+ mySimpit.registerChannel (INTERSECTS_MESSAGE );
159160
160161 // |---------------------|
161162 // | Echo & Echo Request |
@@ -231,7 +232,7 @@ void loop()
231232 mySimpit.printToKSP (" Apoapsis " + String (myFloatStorage2, 0 ) + " Periapsis " + String (myFloatStorage1, 0 ), PRINT_TO_SCREEN );
232233 } break ;
233234 case 13 : { // Apsides Times
234- mySimpit.printToKSP (" Time to Ap " + String (myTimeToApoapsis ) + " Time to Pe " + String (myTimeToPeriapsis ), PRINT_TO_SCREEN );
235+ mySimpit.printToKSP (" Time to Ap " + String (myTime1 ) + " Time to Pe " + String (myTime2 ), PRINT_TO_SCREEN );
235236 } break ;
236237 case 14 : { // Maneuver part 1
237238 mySimpit.printToKSP (" Mnv Time " + String (myFloatStorage1, 0 ) + " dvNxt " + String (myFloatStorage2, 0 ) + " dur " + String (myFloatStorage3, 0 ), PRINT_TO_SCREEN );
@@ -456,6 +457,12 @@ void loop()
456457 " 5:" + String ((int )myAdvancedActionGroups[4 ]), PRINT_TO_SCREEN );
457458 // And so on for all 10 action groups
458459 } break ;
460+ case 52 : { // Intersect info first intersect
461+ mySimpit.printToKSP (" Intsct1 d " + String (myFloatStorage1, 0 ) + " v " + String (myFloatStorage2, 0 ) + " t " + String (myTime1), PRINT_TO_SCREEN );
462+ } break ;
463+ case 53 : { // Intersect info second intersect
464+ mySimpit.printToKSP (" Intsct2 d " + String (myFloatStorage3, 0 ) + " v " + String (myFloatStorage4, 0 ) + " t " + String (myTime2), PRINT_TO_SCREEN );
465+ } break ;
459466 default : {
460467 // mySimpit.printToKSP(F("Unknown selectionIndex"), PRINT_TO_SCREEN);
461468 } break ;
@@ -640,9 +647,6 @@ void loop()
640647 case 46 :
641648 mySimpit.requestMessageOnChannel (VESSEL_NAME_MESSAGE );
642649 break ;
643-
644-
645-
646650 case 47 :
647651 mySimpit.requestMessageOnChannel (INTAKE_AIR_MESSAGE );
648652 break ;
@@ -659,6 +663,10 @@ void loop()
659663 case 51 :
660664 mySimpit.requestMessageOnChannel (ADVANCED_CAGSTATUS_MESSAGE );
661665 break ;
666+ case 52 :
667+ case 53 :
668+ mySimpit.requestMessageOnChannel (INTERSECTS_MESSAGE );
669+ break ;
662670 }
663671 }
664672 }
@@ -905,8 +913,8 @@ void messageHandler(byte messageType, byte msg[], byte msgSize) {
905913 if (msgSize == sizeof (apsidesTimeMessage) && selectionIndex == 13 )
906914 {
907915 apsidesTimeMessage apsidesTimeMsg = parseMessage<apsidesTimeMessage>(msg);
908- myTimeToPeriapsis = apsidesTimeMsg.periapsis ;
909- myTimeToApoapsis = apsidesTimeMsg.apoapsis ;
916+ myTime1 = apsidesTimeMsg.apoapsis ;
917+ myTime2 = apsidesTimeMsg.periapsis ;
910918 }
911919 } break ;
912920 case MANEUVER_MESSAGE : {
@@ -1143,6 +1151,18 @@ void messageHandler(byte messageType, byte msg[], byte msgSize) {
11431151 myBool2 = true ;
11441152 }
11451153 } break ;
1154+ case INTERSECTS_MESSAGE : {
1155+ if (msgSize == sizeof (intersectsMessage) && (selectionIndex == 52 || selectionIndex == 53 ))
1156+ {
1157+ intersectsMessage intersectsMsg = parseMessage<intersectsMessage>(msg);
1158+ myFloatStorage1 = intersectsMsg.distanceAtIntersect1 ;
1159+ myFloatStorage2 = intersectsMsg.velocityAtIntersect1 ;
1160+ myTime1 = intersectsMsg.timeToIntersect1 ;
1161+ myFloatStorage3 = intersectsMsg.distanceAtIntersect2 ;
1162+ myFloatStorage4 = intersectsMsg.velocityAtIntersect2 ;
1163+ myTime2 = intersectsMsg.timeToIntersect2 ;
1164+ }
1165+ } break ;
11461166 default : {
11471167
11481168 } break ;
0 commit comments