mirror of
https://github.com/tbnobody/OpenDTU.git
synced 2025-12-13 02:09:58 +01:00
Added methods to calculate and show sunrise and sunset times
This commit is contained in:
30
include/SunPosition.h
Normal file
30
include/SunPosition.h
Normal file
@@ -0,0 +1,30 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#pragma once
|
||||
|
||||
#include <sunset.h>
|
||||
|
||||
#define SUNPOS_UPDATE_INTERVAL 60000l
|
||||
|
||||
class SunPositionClass {
|
||||
public:
|
||||
SunPositionClass();
|
||||
void init();
|
||||
void loop();
|
||||
|
||||
bool isDayPeriod();
|
||||
bool sunsetTime(struct tm* info);
|
||||
bool sunriseTime(struct tm* info);
|
||||
|
||||
private:
|
||||
void updateSunData();
|
||||
|
||||
SunSet _sun;
|
||||
bool _isDayPeriod = true;
|
||||
uint _sunriseMinutes = 0;
|
||||
uint _sunsetMinutes = 0;
|
||||
|
||||
uint32_t _lastUpdate = 0;
|
||||
bool _isValidInfo = false;
|
||||
};
|
||||
|
||||
extern SunPositionClass SunPosition;
|
||||
Reference in New Issue
Block a user