Fix for sunset/sunrise
This commit is contained in:
parent
79b0e9ab9e
commit
ff76620329
|
@ -220,10 +220,9 @@ void displayHeader(CommonData &commonData, GwApi::BoatValue *date, GwApi::BoatVa
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sunset und sunrise calculation
|
// 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();
|
GwLog *logger=api->getLogger();
|
||||||
SensorData returnset;
|
SunData returnset;
|
||||||
SunRise sr;
|
SunRise sr;
|
||||||
int secPerHour = 3600;
|
int secPerHour = 3600;
|
||||||
int secPerYear = 86400;
|
int secPerYear = 86400;
|
||||||
|
@ -268,7 +267,6 @@ SensorData calcSunsetSunrise(GwApi *api, double time, double date, double latitu
|
||||||
returnset.sunriseMinute = intminSR;
|
returnset.sunriseMinute = intminSR;
|
||||||
returnset.sunDown = sunDown;
|
returnset.sunDown = sunDown;
|
||||||
return returnset;
|
return returnset;
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Battery graphic with fill level
|
// Battery graphic with fill level
|
||||||
|
|
|
@ -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
|
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
|
void batteryGraphic(uint x, uint y, float percent, int pcolor, int bcolor); // Battery graphic with fill level
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ public:
|
||||||
// Show values sunrise
|
// Show values sunrise
|
||||||
String sunrise = "---";
|
String sunrise = "---";
|
||||||
if(valid1 == true && valid2 == true){
|
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);
|
display.setTextColor(textcolor);
|
||||||
|
@ -166,7 +166,7 @@ public:
|
||||||
// Show values sunset
|
// Show values sunset
|
||||||
String sunset = "---";
|
String sunset = "---";
|
||||||
if(valid1 == true && valid2 == true){
|
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);
|
display.setTextColor(textcolor);
|
||||||
|
|
|
@ -50,11 +50,20 @@ typedef struct{
|
||||||
bool sunDown = true;
|
bool sunDown = true;
|
||||||
} SensorData;
|
} SensorData;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
int sunsetHour = 0;
|
||||||
|
int sunsetMinute = 0;
|
||||||
|
int sunriseHour = 0;
|
||||||
|
int sunriseMinute = 0;
|
||||||
|
bool sunDown = true;
|
||||||
|
} SunData;
|
||||||
|
|
||||||
typedef struct{
|
typedef struct{
|
||||||
GwApi::Status status;
|
GwApi::Status status;
|
||||||
GwLog *logger=NULL;
|
GwLog *logger=NULL;
|
||||||
GwConfigHandler *config=NULL;
|
GwConfigHandler *config=NULL;
|
||||||
SensorData data;
|
SensorData data;
|
||||||
|
SunData sundata;
|
||||||
GwApi::BoatValue *time=NULL;
|
GwApi::BoatValue *time=NULL;
|
||||||
GwApi::BoatValue *date=NULL;
|
GwApi::BoatValue *date=NULL;
|
||||||
} CommonData;
|
} CommonData;
|
||||||
|
|
|
@ -445,10 +445,11 @@ void OBP60Task(GwApi *api){
|
||||||
if(millis() > starttime5 + 1000){
|
if(millis() > starttime5 + 1000){
|
||||||
starttime5 = millis();
|
starttime5 = millis();
|
||||||
if(time->valid == true && date->valid == true && lat->valid == true && lon->valid == true){
|
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
|
// Backlight with sun control
|
||||||
if(String(backlight) == "Control by Sun"){
|
if(String(backlight) == "Control by Sun"){
|
||||||
setPortPin(OBP_BACKLIGHT_LED, commonData.data.sunDown);
|
setPortPin(OBP_BACKLIGHT_LED, commonData.sundata.sunDown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue