Hopperpop / Sgp4-Library

Library for calculating satellites positions and predicting overpasses.
MIT License
56 stars 21 forks source link

Fix compiler errors and ESP32 crash. Add minimumElevation to nextpass. #5

Closed PaulZC closed 2 years ago

PaulZC commented 2 years ago

Hello @Hopperpop ,

I know this library is a few years old, but thank you for sharing it. It is a really nice piece of work!

I had some problems running the code on an ESP32 using Arduino 1.8.13 and esp32 by Espressif Systems (version 2.0.2). The code was crashing when I ran your Sgp4Predictor example. I traced the cause to a missing return statement in the overloaded copy of nextpass. This Pull Request corrects that.

I was also seeing two compiler errors while using a different version of the ESP32 compiler. It was complaining about missing parentheses and code ambiguity. So I fixed those too.

To be able to use this code to predict communication satellite passes, it is useful (actually essential) to be able to set a "minimum elevation" for a successful satellite pass. So I've added minimumElevation as a parameter for nextpass and have included an extra overload. The change is backward-compatible, it defaults to 0.0.

I have tested the code on ESP32, SAMD51, nRF52840 (Arduino Nano), Apollo3 (SparkFun Artemis) and STM32F4. It appears to work well on all platforms.

Thank you again for sharing, and I hope you like this Pull Request.

Very best wishes, Paul

Hopperpop commented 2 years ago

Thanks Paul for the fixes. It's all a bit rusty for me, that's why it took some time.