Skip to content

Commit 22fc368

Browse files
Backup
1 parent 40b7daa commit 22fc368

File tree

4 files changed

+4
-40
lines changed

4 files changed

+4
-40
lines changed

lib/obp60task/OBP60Extensions.cpp

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,6 @@ SensorData calcSunsetSunrise(double time, double date, double latitude, double l
237237
// Calculate local time
238238
time_t t = (date * secPerYear) + (time + int(timezone * secPerHour));
239239

240-
// 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);
241-
242240
if (!isnan(time) && !isnan(date) && !isnan(latitude) && !isnan(longitude) && !isnan(timezone)) {
243241
sr.calculate(latitude, longitude, t); // LAT, LON, EPOCH
244242
// Sunrise
@@ -259,42 +257,8 @@ SensorData calcSunsetSunrise(double time, double date, double latitude, double l
259257
returnset.sunsetMinute = intminSS;
260258
returnset.sunriseHour = inthrSR;
261259
returnset.sunriseMinute = intminSR;
262-
263-
// 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);
260+
returnset.sunControl = false;
264261
return returnset;
265262
}
266263

267-
// Sun control (return valu by sun on sky = false, sun down = true)
268-
bool sunControl(double time, double date, double latitude, double longitude, double timezone){
269-
SunRise sr;
270-
int secPerHour = 3600;
271-
int secPerYear = 86400;
272-
sr.hasRise = false;
273-
sr.hasSet = false;
274-
time_t sunR = 0;
275-
time_t sunS = 0;
276-
277-
// Calculate local time
278-
time_t t = (date * secPerYear) + (time + int(timezone * secPerHour));
279-
280-
if (!isnan(time) && !isnan(date) && !isnan(latitude) && !isnan(longitude) && !isnan(timezone)) {
281-
sr.calculate(latitude, longitude, t); // LAT, LON, EPOCH
282-
// Sunrise
283-
if (sr.hasRise) {
284-
sunR = (sr.riseTime + int(timezone * secPerHour) + 30); // add 30 seconds: round to minutes
285-
}
286-
// Sunset
287-
if (sr.hasSet) {
288-
sunS = (sr.setTime + int(timezone * secPerHour) + 30); // add 30 seconds: round to minutes
289-
}
290-
}
291-
// Return values (sun on sky = false, sun down = true)
292-
if(t > sunR && t < sunS){
293-
return false;
294-
}
295-
else{
296-
return true;
297-
}
298-
}
299-
300264
#endif

lib/obp60task/OBP60Extensions.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,5 @@ void displayTrendLow(int16_t x, int16_t y, uint16_t size, uint16_t color);
4343
void displayHeader(CommonData &commonData, GwApi::BoatValue *date, GwApi::BoatValue *time); // Draw display header
4444

4545
SensorData calcSunsetSunrise(double time, double date, double latitude, double longitude, double timezone); // Calulate sunset and sunrise
46-
bool sunControl(double time, double date, double latitude, double longitude, double timezone); // Control bit for sun
4746

4847
#endif

lib/obp60task/Pagedata.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ typedef struct{
4747
int sunsetMinute = 0;
4848
int sunriseHour = 0;
4949
int sunriseMinute = 0;
50+
bool sunControl = false; // (sun on sky = false, sun down = true)
5051
} SensorData;
5152

5253
typedef struct{

lib/obp60task/obp60task.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ void OBP60Task(GwApi *api){
394394
// Back light with sun control
395395
if(String(backlight) == "Control by Sun"){
396396
if(time->valid == true && date->valid == true && lat->valid == true && lon->valid == true){
397-
setPortPin(OBP_BACKLIGHT_LED, sunControl(time->value, date->value, lat->value, lon->value, tz.toDouble()));
397+
setPortPin(OBP_BACKLIGHT_LED, commonData.data.sunControl);
398398
}
399399
}
400400

@@ -456,7 +456,7 @@ void OBP60Task(GwApi *api){
456456
// Backlight with sun control
457457
if(String(backlight) == "Control by Sun"){
458458
if(time->valid == true && date->valid == true && lat->valid == true && lon->valid == true){
459-
setPortPin(OBP_BACKLIGHT_LED, sunControl(time->value, date->value, lat->value, lon->value, tz.toDouble()));
459+
setPortPin(OBP_BACKLIGHT_LED, commonData.data.sunControl);
460460
}
461461
}
462462
}

0 commit comments

Comments
 (0)