diff --git a/code/include/config.h b/code/include/config.h index 6a049f5..caff72d 100644 --- a/code/include/config.h +++ b/code/include/config.h @@ -34,6 +34,12 @@ // DST delta to apply #define TIMEZONE_DST_SEC 0 //3600 FIXME does DST work?! doesnt look like +// configure NTP +// https://github.com/nayarsystems/posix_tz_db/blob/master/zones.csv +#define MY_NTP_SERVER "de.pool.ntp.org" +#define MY_TZ "CET-1CEST,M3.5.0,M10.5.0/3" + + // How long are informational messages kept on screen #define LOG_MESSAGE_PERSISTENCE_MSEC 30000 diff --git a/code/include/version.h b/code/include/version.h index ab286a8..39bed9e 100644 --- a/code/include/version.h +++ b/code/include/version.h @@ -1,6 +1,6 @@ #ifndef _PROG_VERSION_H__ #define _PROG_VERSION_H__ -const char* PROG_VERSION = "0.1.3"; +const char* PROG_VERSION = "0.1.3b"; #endif diff --git a/code/src/clock.cpp b/code/src/clock.cpp index fbfd33a..d1d434a 100644 --- a/code/src/clock.cpp +++ b/code/src/clock.cpp @@ -28,6 +28,7 @@ void displayClock() { int hh = timeinfo.tm_hour; int mm = timeinfo.tm_min; int ss = timeinfo.tm_sec; + Serial.printf("%d:%d:%d\n", hh, mm, ss); delay(500); if (clockStartingUp) { // If we didn't have a previous time. Just draw it without morphing. diff --git a/code/src/main.cpp b/code/src/main.cpp index 8cccf69..2c51532 100644 --- a/code/src/main.cpp +++ b/code/src/main.cpp @@ -73,7 +73,11 @@ void setup(){ logStatusMessage("WiFi connected!"); logStatusMessage("NTP time..."); - configTime(TIMEZONE_DELTA_SEC, TIMEZONE_DST_SEC, NTP_SERVER); + + configTime(0, 0, MY_NTP_SERVER); // 0, 0 because we will use TZ in the next line + setenv("TZ", MY_TZ, 1); // Set environment variable with your time zone + tzset(); + lastNTPUpdate = millis(); logStatusMessage("NTP done!"); @@ -156,8 +160,15 @@ void loop() { // Periodically refresh NTP time if ((millis() - lastNTPUpdate) > (1000 * NTP_REFRESH_INTERVAL_SEC)) { - logStatusMessage("NTP Refresh"); - configTime(TIMEZONE_DELTA_SEC, TIMEZONE_DST_SEC, NTP_SERVER); + logStatusMessage("No NTP Refresh"); + //configTime(0, 0, MY_NTP_SERVER); // 0, 0 because we will use TZ in the next line + //tzset(); + + int hh = timeinfo.tm_hour; + int mm = timeinfo.tm_min; + int ss = timeinfo.tm_sec; + Serial.printf("%d:%d:%d\n", hh, mm, ss); + lastNTPUpdate = millis(); } @@ -227,7 +238,7 @@ void loop() { //drawHeartBeat(); // TODO: config option heartbeat if ((millis() - lastI2cSensorRead) > (1000 * I2C_READ_INTERVAL_SEC)) { - lightUpdate(); + //lightUpdate(); i2cSensorUpdate(); lastI2cSensorRead = millis(); } @@ -252,13 +263,13 @@ void displayUpdater() { } void i2cSensorUpdate() { - float lightData = getLightData(); - float tempdata = getTempData(); - float pressuredata = getPressureData(); - - Serial.print("temp: "); Serial.println(tempdata); - Serial.print("pressure: "); Serial.println(pressuredata); + float lightData = getLightData(); + float tempData = getTempData(); + float pressureData = getPressureData(); + Serial.print("temp: "); Serial.println(tempData); + Serial.print("pressure: "); Serial.println(pressureData); + Serial.print("light: "); Serial.println(lightData); } void lightUpdate() { diff --git a/code/src/rgb_display.cpp b/code/src/rgb_display.cpp index 5077702..e00cba7 100644 --- a/code/src/rgb_display.cpp +++ b/code/src/rgb_display.cpp @@ -94,10 +94,10 @@ void displaySensorData() { Serial.printf("[%d] value int: %d\n", i, mySensors[i].val_i); Serial.printf("[%d] value float: %f\n", i, mySensors[i].val_f); } - // - // - //mySensors[i].newData = false; - //} + // + // + //mySensors[i].newData = false; + //} } // for (int i; i = 0; ++i) { // int val = s[i].val_i; @@ -159,7 +159,7 @@ void displayLightData(float luxValue) { void displayWeatherData(const struct city_info &info) { Serial.printf("displayWeatherData: temp=%2.1f, humi=%d\n", info.forecasts[0].temp, info.forecasts[0].humidity); - +fixme ... dma_display->fillRect(SENSOR_DATA_X, SENSOR_DATA_Y, SENSOR_DATA_WIDTH, SENSOR_DATA_HEIGHT, 0); dma_display->setTextSize(1); // size 1 == 8 pixels high @@ -167,10 +167,15 @@ void displayWeatherData(const struct city_info &info) { dma_display->setTextColor(SENSOR_DATA_COLOR); //dma_display->setFont(&FreeSerifBold12pt7b); - dma_display->setCursor(SENSOR_DATA_X, SENSOR_DATA_Y); + dma_display->setCursor(SENSOR_1_DATA_X, SENSOR_1_DATA_Y); dma_display->printf("%2.1f", info.forecasts[0].temp); - dma_display->setCursor(SENSOR_DATA_X, SENSOR_DATA_Y + 8); + + dma_display->setCursor(SENSOR_2_DATA_X, SENSOR_2_DATA_Y); dma_display->printf("%3d%%", info.forecasts[0].humidity); + + dma_display->setCursor(SENSOR_3_DATA_X, SENSOR_3_DATA_Y); + dma_display->printf("%4d%", info.forecasts[0].grnd_level); + // Draw the degree symbol manually dma_display->fillRect(SENSOR_DATA_X + 25, SENSOR_DATA_Y, 2, 2, SENSOR_DATA_COLOR); diff --git a/code/src/weather.cpp b/code/src/weather.cpp index da7c4ec..cae78ed 100644 --- a/code/src/weather.cpp +++ b/code/src/weather.cpp @@ -283,23 +283,23 @@ int accuWeatherIconMapping(int icon) { if (icon <= 32) return 2; return 0; } - +// FIXME: pressure overwrite old value ... clear area. /* Start of code to get data from openweathermap - based on work by https://github.com/lefty01 */ int getOpenWeatherData(uint32_t loc_id, const char *units, const char *appid, - struct city_info *info) + struct city_info *info) { StaticJsonDocument<272> filter; filter["city"] = true; JsonObject filter_list_0 = filter["list"].createNestedObject(); filter_list_0["dt"] = true; + filter_list_0["wind"]["speed"] = true; JsonObject filter_list_0_weather_0 = filter_list_0["weather"].createNestedObject(); filter_list_0_weather_0["icon"] = true; filter_list_0_weather_0["id"] = true; - filter_list_0["wind"]["speed"] = true; JsonObject filter_list_0_main = filter_list_0.createNestedObject("main"); filter_list_0_main["temp"] = true; @@ -307,7 +307,6 @@ int getOpenWeatherData(uint32_t loc_id, const char *units, const char *appid, filter_list_0_main["temp_max"] = true; filter_list_0_main["pressure"] = true; // Atmospheric pressure on the sea level, hPa filter_list_0_main["grnd_level"] = true; // Atmospheric pressure on the ground level, hPa - filter_list_0_main["humidity"] = true; char url[128]; @@ -315,7 +314,7 @@ int getOpenWeatherData(uint32_t loc_id, const char *units, const char *appid, // sanity check units ... // strcmp(units, "standard") ... "metric", or "imperial" snprintf(url, 128, "http://api.openweathermap.org/data/2.5/forecast?id=%u&units=%s&appid=%s", - loc_id, units, appid); + loc_id, units, appid); // Allocate the largest possible document (platform dependent) // DynamicJsonDocument doc(ESP.getMaxFreeBlockSize()); @@ -327,7 +326,7 @@ int getOpenWeatherData(uint32_t loc_id, const char *units, const char *appid, http.GET(); DeserializationError error = deserializeJson(doc, http.getStream(), - DeserializationOption::Filter(filter)); + DeserializationOption::Filter(filter)); if (error) { Serial.print(F("deserializeJson() failed: ")); Serial.println(error.f_str());