From 22fc368dd2a07f556dfc660120f9dd58db9dbebd Mon Sep 17 00:00:00 2001 From: norbert-walter Date: Fri, 1 Apr 2022 18:56:33 +0200 Subject: [PATCH] Backup --- lib/obp60task/OBP60Extensions.cpp | 38 +------------------------------ lib/obp60task/OBP60Extensions.h | 1 - lib/obp60task/Pagedata.h | 1 + lib/obp60task/obp60task.cpp | 4 ++-- 4 files changed, 4 insertions(+), 40 deletions(-) diff --git a/lib/obp60task/OBP60Extensions.cpp b/lib/obp60task/OBP60Extensions.cpp index c33a6d5..ff24c4d 100644 --- a/lib/obp60task/OBP60Extensions.cpp +++ b/lib/obp60task/OBP60Extensions.cpp @@ -237,8 +237,6 @@ SensorData calcSunsetSunrise(double time, double date, double latitude, double l // Calculate local time time_t t = (date * secPerYear) + (time + int(timezone * secPerHour)); -// api->getLogger()->logDebug(GwLog::DEBUG,"... PageClock: Lat %f, Lon %f, at: %d, next SR: %d (%s), next SS: %d (%s)", latitude, longitude, t, sunR, sSunR, sunS, sSunS); - if (!isnan(time) && !isnan(date) && !isnan(latitude) && !isnan(longitude) && !isnan(timezone)) { sr.calculate(latitude, longitude, t); // LAT, LON, EPOCH // Sunrise @@ -259,42 +257,8 @@ SensorData calcSunsetSunrise(double time, double date, double latitude, double l returnset.sunsetMinute = intminSS; returnset.sunriseHour = inthrSR; returnset.sunriseMinute = intminSR; - -// api->getLogger()->logDebug(GwLog::DEBUG,"... PageClock: at t: %d, hasRise: %d, next SR: %d '%s', hasSet: %d, next SS: %d '%s'\n", t, sr.hasRise, sr.riseTime, sSunR, sr.hasSet, sr.setTime, sSunS); + returnset.sunControl = false; return returnset; } -// Sun control (return valu by sun on sky = false, sun down = true) -bool sunControl(double time, double date, double latitude, double longitude, double timezone){ - SunRise sr; - int secPerHour = 3600; - int secPerYear = 86400; - sr.hasRise = false; - sr.hasSet = false; - time_t sunR = 0; - time_t sunS = 0; - - // Calculate local time - time_t t = (date * secPerYear) + (time + int(timezone * secPerHour)); - - if (!isnan(time) && !isnan(date) && !isnan(latitude) && !isnan(longitude) && !isnan(timezone)) { - sr.calculate(latitude, longitude, t); // LAT, LON, EPOCH - // Sunrise - if (sr.hasRise) { - sunR = (sr.riseTime + int(timezone * secPerHour) + 30); // add 30 seconds: round to minutes - } - // Sunset - if (sr.hasSet) { - sunS = (sr.setTime + int(timezone * secPerHour) + 30); // add 30 seconds: round to minutes - } - } - // Return values (sun on sky = false, sun down = true) - if(t > sunR && t < sunS){ - return false; - } - else{ - return true; - } -} - #endif \ No newline at end of file diff --git a/lib/obp60task/OBP60Extensions.h b/lib/obp60task/OBP60Extensions.h index 525ca28..c6a30b6 100644 --- a/lib/obp60task/OBP60Extensions.h +++ b/lib/obp60task/OBP60Extensions.h @@ -43,6 +43,5 @@ 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(double time, double date, double latitude, double longitude, double timezone); // Calulate sunset and sunrise -bool sunControl(double time, double date, double latitude, double longitude, double timezone); // Control bit for sun #endif \ No newline at end of file diff --git a/lib/obp60task/Pagedata.h b/lib/obp60task/Pagedata.h index 892f725..401621d 100644 --- a/lib/obp60task/Pagedata.h +++ b/lib/obp60task/Pagedata.h @@ -47,6 +47,7 @@ typedef struct{ int sunsetMinute = 0; int sunriseHour = 0; int sunriseMinute = 0; + bool sunControl = false; // (sun on sky = false, sun down = true) } SensorData; typedef struct{ diff --git a/lib/obp60task/obp60task.cpp b/lib/obp60task/obp60task.cpp index 4352f09..e09d809 100644 --- a/lib/obp60task/obp60task.cpp +++ b/lib/obp60task/obp60task.cpp @@ -394,7 +394,7 @@ void OBP60Task(GwApi *api){ // Back light with sun control if(String(backlight) == "Control by Sun"){ if(time->valid == true && date->valid == true && lat->valid == true && lon->valid == true){ - setPortPin(OBP_BACKLIGHT_LED, sunControl(time->value, date->value, lat->value, lon->value, tz.toDouble())); + setPortPin(OBP_BACKLIGHT_LED, commonData.data.sunControl); } } @@ -456,7 +456,7 @@ void OBP60Task(GwApi *api){ // Backlight with sun control if(String(backlight) == "Control by Sun"){ if(time->valid == true && date->valid == true && lat->valid == true && lon->valid == true){ - setPortPin(OBP_BACKLIGHT_LED, sunControl(time->value, date->value, lat->value, lon->value, tz.toDouble())); + setPortPin(OBP_BACKLIGHT_LED, commonData.data.sunControl); } } }