Merge remote-tracking branch 'origin/sunset' into HEAD
This commit is contained in:
commit
b9aab54279
|
@ -233,11 +233,18 @@ SensorData calcSunsetSunrise(double time, double date, double latitude, double l
|
||||||
int intminSR = 0;
|
int intminSR = 0;
|
||||||
int inthrSS = 0;
|
int inthrSS = 0;
|
||||||
int intminSS = 0;
|
int intminSS = 0;
|
||||||
|
bool sunDown = true;
|
||||||
|
|
||||||
// Calculate local time
|
|
||||||
time_t t = (date * secPerYear) + (time + int(timezone * secPerHour));
|
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
if (!isnan(time) && !isnan(date) && !isnan(latitude) && !isnan(longitude) && !isnan(timezone)) {
|
if (!isnan(time) && !isnan(date) && !isnan(latitude) && !isnan(longitude) && !isnan(timezone)) {
|
||||||
|
=======
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
if (!isnan(time) && !isnan(date) && !isnan(latitude) && !isnan(longitude) && !isnan(timezone)) {
|
||||||
|
// Calculate local time
|
||||||
|
time_t t = (date * secPerYear) + (time + int(timezone * secPerHour));
|
||||||
|
>>>>>>> sunset
|
||||||
sr.calculate(latitude, longitude, t); // LAT, LON, EPOCH
|
sr.calculate(latitude, longitude, t); // LAT, LON, EPOCH
|
||||||
// Sunrise
|
// Sunrise
|
||||||
if (sr.hasRise) {
|
if (sr.hasRise) {
|
||||||
|
@ -251,13 +258,23 @@ SensorData calcSunsetSunrise(double time, double date, double latitude, double l
|
||||||
inthrSS = int (sunS / secPerHour);
|
inthrSS = int (sunS / secPerHour);
|
||||||
intminSS = int((sunS - inthrSS * secPerHour)/60);
|
intminSS = int((sunS - inthrSS * secPerHour)/60);
|
||||||
}
|
}
|
||||||
|
// Sun control (return value by sun on sky = false, sun down = true)
|
||||||
|
if ((t >= (sr.riseTime + int(timezone * secPerHour))) && (t <= (sr.setTime + int(timezone * secPerHour))))
|
||||||
|
sunDown = false;
|
||||||
|
else sunDown = true;
|
||||||
}
|
}
|
||||||
// Return values
|
// Return values
|
||||||
returnset.sunsetHour = inthrSS;
|
returnset.sunsetHour = inthrSS;
|
||||||
returnset.sunsetMinute = intminSS;
|
returnset.sunsetMinute = intminSS;
|
||||||
returnset.sunriseHour = inthrSR;
|
returnset.sunriseHour = inthrSR;
|
||||||
returnset.sunriseMinute = intminSR;
|
returnset.sunriseMinute = intminSR;
|
||||||
|
<<<<<<< HEAD
|
||||||
returnset.sunControl = false;
|
returnset.sunControl = false;
|
||||||
|
=======
|
||||||
|
returnset.sunDown = sunDown;
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
>>>>>>> sunset
|
||||||
return returnset;
|
return returnset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,5 +43,9 @@ 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
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
//bool sunControl(double time, double date, double latitude, double longitude, double timezone); // Control bit for sun
|
||||||
|
>>>>>>> sunset
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -14,7 +14,9 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
|
||||||
static int dayoffset = 0;
|
static int dayoffset = 0;
|
||||||
|
|
||||||
// Load configuration values
|
// Load configuration values
|
||||||
int timeZone = commondata.config->getInt(commondata.config->timeZone); // [UTC -12...+14]
|
|
||||||
|
String stimeZone = commondata.config->getString(commondata.config->timeZone); // [UTC -14.00...+12.00]
|
||||||
|
double timeZone = stimeZone.toDouble();
|
||||||
String lengthFormat = commondata.config->getString(commondata.config->lengthFormat); // [m|ft]
|
String lengthFormat = commondata.config->getString(commondata.config->lengthFormat); // [m|ft]
|
||||||
String distanceFormat = commondata.config->getString(commondata.config->distanceFormat); // [m|km|nm]
|
String distanceFormat = commondata.config->getString(commondata.config->distanceFormat); // [m|km|nm]
|
||||||
String speedFormat = commondata.config->getString(commondata.config->speedFormat); // [m/s|km/h|kn]
|
String speedFormat = commondata.config->getString(commondata.config->speedFormat); // [m/s|km/h|kn]
|
||||||
|
@ -28,6 +30,8 @@ FormatedData formatValue(GwApi::BoatValue *value, CommonData &commondata){
|
||||||
result.svalue = "---";
|
result.svalue = "---";
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG_DEBUG(GwLog::DEBUG,"formatValue init: getFormat: %s date->value: %f time->value: %f", value->getFormat(), commondata.date->value, commondata.time->value);
|
||||||
static const int bsize = 30;
|
static const int bsize = 30;
|
||||||
char buffer[bsize+1];
|
char buffer[bsize+1];
|
||||||
buffer[0]=0;
|
buffer[0]=0;
|
||||||
|
|
|
@ -147,13 +147,11 @@ 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);
|
sunrise = String(commonData.data.sunriseHour) + ":" + String(commonData.data.sunriseMinute + 100).substring(1);
|
||||||
}
|
|
||||||
else{
|
|
||||||
sunrise = "---";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
display.setTextColor(textcolor);
|
display.setTextColor(textcolor);
|
||||||
display.setFont(&Ubuntu_Bold8pt7b);
|
display.setFont(&Ubuntu_Bold8pt7b);
|
||||||
display.setCursor(335, 65);
|
display.setCursor(335, 65);
|
||||||
|
@ -166,13 +164,13 @@ public:
|
||||||
display.fillRect(340, 149, 80, 3, pixelcolor);
|
display.fillRect(340, 149, 80, 3, pixelcolor);
|
||||||
|
|
||||||
// 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);
|
sunset = String(commonData.data.sunsetHour) + ":" + String(commonData.data.sunsetMinute + 100).substring(1);
|
||||||
}
|
|
||||||
else{
|
|
||||||
sunset = "---";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG_DEBUG(GwLog::LOG,"sunrise: .%s., sunset: .%s.", String(commonData.data.sunriseMinute + 100), String(commonData.data.sunsetMinute + 100));
|
||||||
|
|
||||||
display.setTextColor(textcolor);
|
display.setTextColor(textcolor);
|
||||||
display.setFont(&Ubuntu_Bold8pt7b);
|
display.setFont(&Ubuntu_Bold8pt7b);
|
||||||
display.setCursor(335, 250);
|
display.setCursor(335, 250);
|
||||||
|
|
|
@ -47,7 +47,11 @@ typedef struct{
|
||||||
int sunsetMinute = 0;
|
int sunsetMinute = 0;
|
||||||
int sunriseHour = 0;
|
int sunriseHour = 0;
|
||||||
int sunriseMinute = 0;
|
int sunriseMinute = 0;
|
||||||
|
<<<<<<< HEAD
|
||||||
bool sunControl = false; // (sun on sky = false, sun down = true)
|
bool sunControl = false; // (sun on sky = false, sun down = true)
|
||||||
|
=======
|
||||||
|
bool sunDown = true;
|
||||||
|
>>>>>>> sunset
|
||||||
} SensorData;
|
} SensorData;
|
||||||
|
|
||||||
typedef struct{
|
typedef struct{
|
||||||
|
|
|
@ -391,13 +391,18 @@ void OBP60Task(GwApi *api){
|
||||||
setPortPin(OBP_FLASH_LED, true);
|
setPortPin(OBP_FLASH_LED, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Back light with sun control
|
// Back light with sun control: turn on if no valid data for safety reasons
|
||||||
if(String(backlight) == "Control by Sun"){
|
if(String(backlight) == "Control by Sun"){
|
||||||
|
<<<<<<< HEAD
|
||||||
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){
|
||||||
setPortPin(OBP_BACKLIGHT_LED, commonData.data.sunControl);
|
setPortPin(OBP_BACKLIGHT_LED, commonData.data.sunControl);
|
||||||
|
=======
|
||||||
|
if(time->valid == false || date->valid == false || lat->valid == false || lon->valid == false){
|
||||||
|
setPortPin(OBP_BACKLIGHT_LED, true);
|
||||||
|
>>>>>>> sunset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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)){
|
||||||
|
@ -454,10 +459,15 @@ void OBP60Task(GwApi *api){
|
||||||
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
|
// Backlight with sun control
|
||||||
|
<<<<<<< HEAD
|
||||||
if(String(backlight) == "Control by Sun"){
|
if(String(backlight) == "Control by Sun"){
|
||||||
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){
|
||||||
setPortPin(OBP_BACKLIGHT_LED, commonData.data.sunControl);
|
setPortPin(OBP_BACKLIGHT_LED, commonData.data.sunControl);
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
if(String(backlight) == "Control by Sun"){
|
||||||
|
setPortPin(OBP_BACKLIGHT_LED, commonData.data.sunDown);
|
||||||
|
>>>>>>> sunset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
[platformio]
|
|
||||||
#if you want a pio run to only build
|
|
||||||
#your special environments you can set this here
|
|
||||||
#by uncommenting the next line
|
|
||||||
default_envs = nodemcu32s_obp60
|
|
||||||
[env:nodemcu32s_obp60]
|
|
||||||
board_build.partitions = lib/obp60task/partitions_obp60.csv
|
|
||||||
board = nodemcu-32s
|
|
||||||
lib_deps =
|
|
||||||
${env.lib_deps}
|
|
||||||
lib_deps =
|
|
||||||
blemasle/MCP23017@2.0.0
|
|
||||||
adafruit/Adafruit BusIO@1.5.0
|
|
||||||
zinggjm/GxEPD@3.1.0
|
|
||||||
sstaub/Ticker@4.4.0
|
|
||||||
adafruit/Adafruit BMP280 Library@2.6.2
|
|
||||||
adafruit/Adafruit BME280 Library@2.2.2
|
|
||||||
adafruit/Adafruit BMP085 Library@1.2.1
|
|
||||||
enjoyneering/HTU21D@1.2.1
|
|
||||||
robtillaart/INA226@0.2.0
|
|
||||||
signetica/SunRise@2.0.2
|
|
||||||
build_flags=
|
|
||||||
-D BOARD_NODEMCU32S_OBP60
|
|
||||||
${env.build_flags}
|
|
||||||
upload_port = COM3
|
|
||||||
upload_protocol = esptool
|
|
||||||
monitor_speed = 115200
|
|
Loading…
Reference in New Issue