restore platformio.ini and implement logger function
This commit is contained in:
parent
b9aab54279
commit
78a71169a8
|
@ -220,31 +220,28 @@ void displayHeader(CommonData &commonData, GwApi::BoatValue *date, GwApi::BoatVa
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sunset und sunrise calculation
|
// Sunset und sunrise calculation
|
||||||
SensorData calcSunsetSunrise(double time, double date, double latitude, double longitude, double timezone){
|
SensorData calcSunsetSunrise(GwApi *api, double time, double date, double latitude, double longitude, double timezone){
|
||||||
|
GwLog *logger=api->getLogger();
|
||||||
SensorData returnset;
|
SensorData returnset;
|
||||||
SunRise sr;
|
SunRise sr;
|
||||||
int secPerHour = 3600;
|
int secPerHour = 3600;
|
||||||
int secPerYear = 86400;
|
int secPerYear = 86400;
|
||||||
sr.hasRise = false;
|
sr.hasRise = false;
|
||||||
sr.hasSet = false;
|
sr.hasSet = false;
|
||||||
|
time_t t = 0;
|
||||||
time_t sunR = 0;
|
time_t sunR = 0;
|
||||||
time_t sunS = 0;
|
time_t sunS = 0;
|
||||||
int inthrSR = 0;
|
int inthrSR = 0;
|
||||||
int intminSR = 0;
|
int intminSR = 0;
|
||||||
int inthrSS = 0;
|
int inthrSS = 0;
|
||||||
int intminSS = 0;
|
int intminSS = 0;
|
||||||
bool sunDown = true;
|
bool sunDown = false;
|
||||||
|
|
||||||
|
api->getLogger()->logDebug(GwLog::DEBUG,"... calcSun: Lat %f, Lon %f, at: %d, next SR: %d, next SS: %d", latitude, longitude, t, sunR, sunS);
|
||||||
<<<<<<< HEAD
|
|
||||||
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)) {
|
if (!isnan(time) && !isnan(date) && !isnan(latitude) && !isnan(longitude) && !isnan(timezone)) {
|
||||||
// Calculate local time
|
// Calculate local time
|
||||||
time_t t = (date * secPerYear) + (time + int(timezone * secPerHour));
|
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) {
|
||||||
|
@ -268,13 +265,9 @@ SensorData calcSunsetSunrise(double time, double date, double latitude, double l
|
||||||
returnset.sunsetMinute = intminSS;
|
returnset.sunsetMinute = intminSS;
|
||||||
returnset.sunriseHour = inthrSR;
|
returnset.sunriseHour = inthrSR;
|
||||||
returnset.sunriseMinute = intminSR;
|
returnset.sunriseMinute = intminSR;
|
||||||
<<<<<<< HEAD
|
|
||||||
returnset.sunControl = false;
|
|
||||||
=======
|
|
||||||
returnset.sunDown = sunDown;
|
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);
|
api->getLogger()->logDebug(GwLog::DEBUG,"... calcSun: at t: %d, hasRise: %d, next SR: %d, hasSet: %d, next SS: %d\n", t, sr.hasRise, sr.riseTime, sr.hasSet, sr.setTime);
|
||||||
>>>>>>> sunset
|
|
||||||
return returnset;
|
return returnset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,10 +42,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(GwApi *api, 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
|
|
@ -47,11 +47,7 @@ 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 sunDown = true;
|
bool sunDown = true;
|
||||||
>>>>>>> sunset
|
|
||||||
} SensorData;
|
} SensorData;
|
||||||
|
|
||||||
typedef struct{
|
typedef struct{
|
||||||
|
|
|
@ -391,18 +391,6 @@ void OBP60Task(GwApi *api){
|
||||||
setPortPin(OBP_FLASH_LED, true);
|
setPortPin(OBP_FLASH_LED, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Back light with sun control: turn on if no valid data for safety reasons
|
|
||||||
if(String(backlight) == "Control by Sun"){
|
|
||||||
<<<<<<< HEAD
|
|
||||||
if(time->valid == true && date->valid == true && lat->valid == true && lon->valid == true){
|
|
||||||
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)){
|
||||||
|
@ -457,17 +445,10 @@ void OBP60Task(GwApi *api){
|
||||||
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(api, 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(time->valid == true && date->valid == true && lat->valid == true && lon->valid == true){
|
|
||||||
setPortPin(OBP_BACKLIGHT_LED, commonData.data.sunControl);
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
if(String(backlight) == "Control by Sun"){
|
if(String(backlight) == "Control by Sun"){
|
||||||
setPortPin(OBP_BACKLIGHT_LED, commonData.data.sunDown);
|
setPortPin(OBP_BACKLIGHT_LED, commonData.data.sunDown);
|
||||||
>>>>>>> sunset
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
[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