public static async Task Aggregator(
            FPGA.InputSignal <bool> RXD,
            FPGA.OutputSignal <bool> TXD
            )
        {
            Sequential handler = () =>
            {
                FPU.FPUScopeNoSync();

                while (true)
                {
                    FPGA.Optimizations.AddOptimizer <DefaultOptimizer>();
                    const uint baud = 115200;
                    float[]    buff = new float[4];
                    for (byte i = 0; i < 4; i++)
                    {
                        UART.ReadFloat(baud, RXD, out float tmp);
                        buff[i] = tmp;
                    }

                    var deltaV = FPGAOrbitalCalc.DeltaVInclinationOrbitOptimized(
                        buff[0],
                        buff[1],
                        buff[2],
                        buff[3]
                        );

                    UART.WriteFloat(baud, deltaV, TXD);
                }
            };

            FPGA.Config.OnStartup(handler);
        }
        public void VInclination()
        {
            var R            = 6371e+3f;
            var M            = 5.972e+24f;
            var Inc          = 0.4974188f;
            var nonOptimized = FPGAOrbitalCalc.DeltaVInclinationOrbit(M, R + 100e+3f, R + 1000e3f, Inc);
            var optimized    = FPGAOrbitalCalc.DeltaVInclinationOrbitOptimized(M, R + 100e+3f, R + 1000e3f, Inc);

            Assert.AreEqual(nonOptimized, optimized);
        }
        public void Quokka_DeltaVInclinationOrbitOptimized()
        {
            using (var port = new QuokkaPort())
            {
                var r0 = 6371e+3f;

                // http://www.satsig.net/orbit-research/delta-v-geo-injection-calculator.htm
                var cases = new[]
                {
                    // low orbit to GSO from Kennedy
                    new
                    {
                        R1  = r0 + 200e+3f,
                        R2  = r0 + 35786e+3f,
                        M   = 5.972e+24f,
                        Inc = 0.4974188f, // ~28.5*
                        DV  = 1836.49f
                    },
                };

                foreach (var testCase in cases)
                {
                    float calculated = FPGAOrbitalCalc.DeltaVInclinationOrbitOptimized(testCase.M, testCase.R1, testCase.R2, testCase.Inc);

                    var err = Math.Abs((calculated - testCase.DV) / testCase.DV);
                    Assert.IsTrue(err < 0.01);

                    port.WriteFloat(testCase.M);
                    port.WriteFloat(testCase.R1);
                    port.WriteFloat(testCase.R2);
                    port.WriteFloat(testCase.Inc);

                    var actualBytes = port.Read(4, true, port.DefaultTimeout);
                    var actual      = TestConverters.FloatFromByteArray(actualBytes);

                    Assert.AreEqual(calculated, actual, $"Failed for {testCase}");
                }
            }
        }