Skip to content

Commit b9aab54

Browse files
Merge remote-tracking branch 'origin/sunset' into HEAD
2 parents 22fc368 + 589e8c4 commit b9aab54

File tree

7 files changed

+52
-42
lines changed

7 files changed

+52
-42
lines changed

lib/obp60task/OBP60Extensions.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,18 @@ SensorData calcSunsetSunrise(double time, double date, double latitude, double l
233233
int intminSR = 0;
234234
int inthrSS = 0;
235235
int intminSS = 0;
236+
bool sunDown = true;
236237

237-
// Calculate local time
238-
time_t t = (date * secPerYear) + (time + int(timezone * secPerHour));
239238

239+
<<<<<<< HEAD
240240
if (!isnan(time) && !isnan(date) && !isnan(latitude) && !isnan(longitude) && !isnan(timezone)) {
241+
=======
242+
// api->getLogger()->logDebug(GwLog::DEBUG,"... calcSun: Lat %f, Lon %f, at: %d, next SR: %d (%s), next SS: %d (%s)", latitude, longitude, t, sunR, sSunR, sunS, sSunS);
243+
244+
if (!isnan(time) && !isnan(date) && !isnan(latitude) && !isnan(longitude) && !isnan(timezone)) {
245+
// Calculate local time
246+
time_t t = (date * secPerYear) + (time + int(timezone * secPerHour));
247+
>>>>>>> sunset
241248
sr.calculate(latitude, longitude, t); // LAT, LON, EPOCH
242249
// Sunrise
243250
if (sr.hasRise) {
@@ -251,13 +258,23 @@ SensorData calcSunsetSunrise(double time, double date, double latitude, double l
251258
inthrSS = int (sunS / secPerHour);
252259
intminSS = int((sunS - inthrSS * secPerHour)/60);
253260
}
261+
// Sun control (return value by sun on sky = false, sun down = true)
262+
if ((t >= (sr.riseTime + int(timezone * secPerHour))) && (t <= (sr.setTime + int(timezone * secPerHour))))
263+
sunDown = false;
264+
else sunDown = true;
254265
}
255266
// Return values
256267
returnset.sunsetHour = inthrSS;
257268
returnset.sunsetMinute = intminSS;
258269
returnset.sunriseHour = inthrSR;
259270
returnset.sunriseMinute = intminSR;
271+
<<<<<<< HEAD
260272
returnset.sunControl = false;
273+
=======
274+
returnset.sunDown = sunDown;
275+
276+
// api->getLogger()->logDebug(GwLog::DEBUG,"... calcSun: 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);
277+
>>>>>>> sunset
261278
return returnset;
262279
}
263280

lib/obp60task/OBP60Extensions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,9 @@ 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+
<<<<<<< HEAD
47+
=======
48+
//bool sunControl(double time, double date, double latitude, double longitude, double timezone); // Control bit for sun
49+
>>>>>>> sunset
4650

4751
#endif

lib/obp60task/OBP60Formater.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
1414
static int dayoffset = 0;
1515

1616
// Load configuration values
17-
int timeZone = commondata.config->getInt(commondata.config->timeZone); // [UTC -12...+14]
17+
18+
String stimeZone = commondata.config->getString(commondata.config->timeZone); // [UTC -14.00...+12.00]
19+
double timeZone = stimeZone.toDouble();
1820
String lengthFormat = commondata.config->getString(commondata.config->lengthFormat); // [m|ft]
1921
String distanceFormat = commondata.config->getString(commondata.config->distanceFormat); // [m|km|nm]
2022
String speedFormat = commondata.config->getString(commondata.config->speedFormat); // [m/s|km/h|kn]
@@ -28,6 +30,8 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
2830
result.svalue = "---";
2931
return result;
3032
}
33+
34+
LOG_DEBUG(GwLog::DEBUG,"formatValue init: getFormat: %s date->value: %f time->value: %f", value->getFormat(), commondata.date->value, commondata.time->value);
3135
static const int bsize = 30;
3236
char buffer[bsize+1];
3337
buffer[0]=0;

lib/obp60task/PageClock.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,11 @@ bool keylock = false; // Keylock
147147
}
148148

149149
// Show values sunrise
150-
String sunrise = "";
150+
String sunrise = "---";
151151
if(valid1 == true && valid2 == true){
152-
sunrise = String(commonData.data.sunriseHour) + ":" + String(commonData.data.sunriseMinute);
153-
}
154-
else{
155-
sunrise = "---";
152+
sunrise = String(commonData.data.sunriseHour) + ":" + String(commonData.data.sunriseMinute + 100).substring(1);
156153
}
154+
157155
display.setTextColor(textcolor);
158156
display.setFont(&Ubuntu_Bold8pt7b);
159157
display.setCursor(335, 65);
@@ -166,13 +164,13 @@ bool keylock = false; // Keylock
166164
display.fillRect(340, 149, 80, 3, pixelcolor);
167165

168166
// Show values sunset
169-
String sunset = "";
167+
String sunset = "---";
170168
if(valid1 == true && valid2 == true){
171-
sunset= String(commonData.data.sunsetHour) + ":" + String(commonData.data.sunsetMinute);
172-
}
173-
else{
174-
sunset = "---";
169+
sunset = String(commonData.data.sunsetHour) + ":" + String(commonData.data.sunsetMinute + 100).substring(1);
175170
}
171+
172+
LOG_DEBUG(GwLog::LOG,"sunrise: .%s., sunset: .%s.", String(commonData.data.sunriseMinute + 100), String(commonData.data.sunsetMinute + 100));
173+
176174
display.setTextColor(textcolor);
177175
display.setFont(&Ubuntu_Bold8pt7b);
178176
display.setCursor(335, 250);

lib/obp60task/Pagedata.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ typedef struct{
4747
int sunsetMinute = 0;
4848
int sunriseHour = 0;
4949
int sunriseMinute = 0;
50+
<<<<<<< HEAD
5051
bool sunControl = false; // (sun on sky = false, sun down = true)
52+
=======
53+
bool sunDown = true;
54+
>>>>>>> sunset
5155
} SensorData;
5256

5357
typedef struct{

lib/obp60task/obp60task.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,13 +391,18 @@ void OBP60Task(GwApi *api){
391391
setPortPin(OBP_FLASH_LED, true);
392392
}
393393

394-
// Back light with sun control
394+
// Back light with sun control: turn on if no valid data for safety reasons
395395
if(String(backlight) == "Control by Sun"){
396+
<<<<<<< HEAD
396397
if(time->valid == true && date->valid == true && lat->valid == true && lon->valid == true){
397398
setPortPin(OBP_BACKLIGHT_LED, commonData.data.sunControl);
399+
=======
400+
if(time->valid == false || date->valid == false || lat->valid == false || lon->valid == false){
401+
setPortPin(OBP_BACKLIGHT_LED, true);
402+
>>>>>>> sunset
398403
}
399404
}
400-
405+
401406
// Check the keyboard message
402407
int keyboardMessage=0;
403408
while (xQueueReceive(allParameters.queue,&keyboardMessage,0)){
@@ -454,10 +459,15 @@ void OBP60Task(GwApi *api){
454459
if(time->valid == true && date->valid == true && lat->valid == true && lon->valid == true){
455460
commonData.data = calcSunsetSunrise(time->value , date->value, lat->value, lon->value, tz.toDouble());
456461
// Backlight with sun control
462+
<<<<<<< HEAD
457463
if(String(backlight) == "Control by Sun"){
458464
if(time->valid == true && date->valid == true && lat->valid == true && lon->valid == true){
459465
setPortPin(OBP_BACKLIGHT_LED, commonData.data.sunControl);
460466
}
467+
=======
468+
if(String(backlight) == "Control by Sun"){
469+
setPortPin(OBP_BACKLIGHT_LED, commonData.data.sunDown);
470+
>>>>>>> sunset
461471
}
462472
}
463473
}

lib/obp60task/platformio.ini

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)