[sun] Implements is_above_horizon() (#7754)

This commit is contained in:
Edward Firmo 2024-11-12 19:23:00 +01:00 committed by GitHub
parent 1e80c4807e
commit e6a1254e65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -59,6 +59,9 @@ class Sun {
void set_latitude(double latitude) { location_.latitude = latitude; } void set_latitude(double latitude) { location_.latitude = latitude; }
void set_longitude(double longitude) { location_.longitude = longitude; } void set_longitude(double longitude) { location_.longitude = longitude; }
// Check if the sun is above the horizon, with a default elevation angle of -0.83333 (standard for sunrise/set).
bool is_above_horizon(double elevation = -0.83333) { return this->elevation() > elevation; }
optional<ESPTime> sunrise(double elevation); optional<ESPTime> sunrise(double elevation);
optional<ESPTime> sunset(double elevation); optional<ESPTime> sunset(double elevation);
optional<ESPTime> sunrise(ESPTime date, double elevation); optional<ESPTime> sunrise(ESPTime date, double elevation);