Backup
This commit is contained in:
parent
dca9d96957
commit
40b7daad16
|
@ -264,4 +264,37 @@ SensorData calcSunsetSunrise(double time, double date, double latitude, double l
|
||||||
return returnset;
|
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
|
#endif
|
|
@ -43,5 +43,6 @@ 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(double time, double date, double latitude, double longitude, double timezone); // Calulate sunset and sunrise
|
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
|
#endif
|
|
@ -391,6 +391,13 @@ void OBP60Task(GwApi *api){
|
||||||
setPortPin(OBP_FLASH_LED, true);
|
setPortPin(OBP_FLASH_LED, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check the keyboard message
|
// Check the keyboard message
|
||||||
int keyboardMessage=0;
|
int keyboardMessage=0;
|
||||||
while (xQueueReceive(allParameters.queue,&keyboardMessage,0)){
|
while (xQueueReceive(allParameters.queue,&keyboardMessage,0)){
|
||||||
|
@ -441,11 +448,17 @@ void OBP60Task(GwApi *api){
|
||||||
LOG_DEBUG(GwLog::LOG,"set pagenumber to %d",pageNumber);
|
LOG_DEBUG(GwLog::LOG,"set pagenumber to %d",pageNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate sunrise and sunset all 1s
|
// Calculate sunrise, sunset and backlight control with sun status all 1s
|
||||||
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(time->value , date->value, lat->value, lon->value, tz.toDouble());
|
commonData.data = calcSunsetSunrise(time->value , date->value, lat->value, lon->value, tz.toDouble());
|
||||||
|
// 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()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue