Fix for sunset/sunrise

This commit is contained in:
norbert-walter 2022-04-04 17:41:55 +02:00
parent 79b0e9ab9e
commit ff76620329
5 changed files with 17 additions and 9 deletions

View File

@ -220,10 +220,9 @@ void displayHeader(CommonData &commonData, GwApi::BoatValue *date, GwApi::BoatVa
}
// Sunset und sunrise calculation
SensorData calcSunsetSunrise(GwApi *api, double time, double date, double latitude, double longitude, double timezone){
/*
SunData calcSunsetSunrise(GwApi *api, double time, double date, double latitude, double longitude, double timezone){
GwLog *logger=api->getLogger();
SensorData returnset;
SunData returnset;
SunRise sr;
int secPerHour = 3600;
int secPerYear = 86400;
@ -268,7 +267,6 @@ SensorData calcSunsetSunrise(GwApi *api, double time, double date, double latitu
returnset.sunriseMinute = intminSR;
returnset.sunDown = sunDown;
return returnset;
*/
}
// Battery graphic with fill level

View File

@ -42,7 +42,7 @@ void displayTrendLow(int16_t x, int16_t y, uint16_t size, uint16_t color);
void displayHeader(CommonData &commonData, GwApi::BoatValue *date, GwApi::BoatValue *time); // Draw display header
SensorData calcSunsetSunrise(GwApi *api, double time, double date, double latitude, double longitude, double timezone); // Calulate sunset and sunrise
SunData calcSunsetSunrise(GwApi *api, double time, double date, double latitude, double longitude, double timezone); // Calulate sunset and sunrise
void batteryGraphic(uint x, uint y, float percent, int pcolor, int bcolor); // Battery graphic with fill level

View File

@ -149,7 +149,7 @@ public:
// Show values sunrise
String sunrise = "---";
if(valid1 == true && valid2 == true){
sunrise = String(commonData.data.sunriseHour) + ":" + String(commonData.data.sunriseMinute + 100).substring(1);
sunrise = String(commonData.sundata.sunriseHour) + ":" + String(commonData.sundata.sunriseMinute + 100).substring(1);
}
display.setTextColor(textcolor);
@ -166,7 +166,7 @@ public:
// Show values sunset
String sunset = "---";
if(valid1 == true && valid2 == true){
sunset = String(commonData.data.sunsetHour) + ":" + String(commonData.data.sunsetMinute + 100).substring(1);
sunset = String(commonData.sundata.sunsetHour) + ":" + String(commonData.sundata.sunsetMinute + 100).substring(1);
}
display.setTextColor(textcolor);

View File

@ -50,11 +50,20 @@ typedef struct{
bool sunDown = true;
} SensorData;
typedef struct{
int sunsetHour = 0;
int sunsetMinute = 0;
int sunriseHour = 0;
int sunriseMinute = 0;
bool sunDown = true;
} SunData;
typedef struct{
GwApi::Status status;
GwLog *logger=NULL;
GwConfigHandler *config=NULL;
SensorData data;
SunData sundata;
GwApi::BoatValue *time=NULL;
GwApi::BoatValue *date=NULL;
} CommonData;

View File

@ -445,10 +445,11 @@ void OBP60Task(GwApi *api){
if(millis() > starttime5 + 1000){
starttime5 = millis();
if(time->valid == true && date->valid == true && lat->valid == true && lon->valid == true){
commonData.data = calcSunsetSunrise(api, time->value , date->value, lat->value, lon->value, tz.toDouble());
// Provide sundata to all pages
commonData.sundata = calcSunsetSunrise(api, time->value , date->value, lat->value, lon->value, tz.toDouble());
// Backlight with sun control
if(String(backlight) == "Control by Sun"){
setPortPin(OBP_BACKLIGHT_LED, commonData.data.sunDown);
setPortPin(OBP_BACKLIGHT_LED, commonData.sundata.sunDown);
}
}
}