restore platformio.ini and implement logger function

This commit is contained in:
norbert-walter 2022-04-02 17:45:43 +02:00
parent b9aab54279
commit 78a71169a8
5 changed files with 37 additions and 44 deletions

View File

@ -220,31 +220,28 @@ void displayHeader(CommonData &commonData, GwApi::BoatValue *date, GwApi::BoatVa
}
// 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;
SunRise sr;
int secPerHour = 3600;
int secPerYear = 86400;
sr.hasRise = false;
sr.hasSet = false;
time_t t = 0;
time_t sunR = 0;
time_t sunS = 0;
int inthrSR = 0;
int intminSR = 0;
int inthrSS = 0;
int intminSS = 0;
bool sunDown = true;
bool sunDown = false;
<<<<<<< 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);
api->getLogger()->logDebug(GwLog::DEBUG,"... calcSun: Lat %f, Lon %f, at: %d, next SR: %d, next SS: %d", latitude, longitude, t, sunR, sunS);
if (!isnan(time) && !isnan(date) && !isnan(latitude) && !isnan(longitude) && !isnan(timezone)) {
// Calculate local time
time_t t = (date * secPerYear) + (time + int(timezone * secPerHour));
>>>>>>> sunset
t = (date * secPerYear) + (time + int(timezone * secPerHour));
sr.calculate(latitude, longitude, t); // LAT, LON, EPOCH
// Sunrise
if (sr.hasRise) {
@ -268,13 +265,9 @@ SensorData calcSunsetSunrise(double time, double date, double latitude, double l
returnset.sunsetMinute = intminSS;
returnset.sunriseHour = inthrSR;
returnset.sunriseMinute = intminSR;
<<<<<<< HEAD
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
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);
return returnset;
}

View File

@ -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
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
SensorData calcSunsetSunrise(GwApi *api, double time, double date, double latitude, double longitude, double timezone); // Calulate sunset and sunrise
#endif

View File

@ -47,11 +47,7 @@ typedef struct{
int sunsetMinute = 0;
int sunriseHour = 0;
int sunriseMinute = 0;
<<<<<<< HEAD
bool sunControl = false; // (sun on sky = false, sun down = true)
=======
bool sunDown = true;
>>>>>>> sunset
} SensorData;
typedef struct{

View File

@ -390,19 +390,7 @@ void OBP60Task(GwApi *api){
if(String(gpsFix) == "GPS Fix Lost" && date->valid == false){
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
int keyboardMessage=0;
while (xQueueReceive(allParameters.queue,&keyboardMessage,0)){
@ -457,17 +445,10 @@ void OBP60Task(GwApi *api){
if(millis() > starttime5 + 1000){
starttime5 = millis();
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
<<<<<<< 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"){
setPortPin(OBP_BACKLIGHT_LED, commonData.data.sunDown);
>>>>>>> sunset
}
}
}

View File

@ -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