From 63b3f21d98cc53d4af24c18b73c26d8c08d3921a Mon Sep 17 00:00:00 2001 From: vanhofen Date: Wed, 20 Mar 2019 15:27:15 +0100 Subject: [PATCH] lcd4l/weather: fix creation of data files for first run Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/ae4338d710477cf2a981f15acaedcbf398a5ee58 Author: vanhofen Date: 2019-03-20 (Wed, 20 Mar 2019) Origin message was: ------------------ - lcd4l/weather: fix creation of data files for first run ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/lcd4l.cpp | 10 +++++----- src/driver/lcd4l.h | 4 ++-- src/gui/weather.cpp | 4 ++-- src/gui/weather.h | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/driver/lcd4l.cpp b/src/driver/lcd4l.cpp index 3771baedc..0ed37d374 100644 --- a/src/driver/lcd4l.cpp +++ b/src/driver/lcd4l.cpp @@ -104,8 +104,8 @@ extern CPictureViewer *g_PicViewer; #define FCOLOR2 LCD_DATADIR "fcolor2" #define PBCOLOR LCD_DATADIR "pbcolor" -#define WEATHER_TEMP LCD_DATADIR "weather_temp" -#define WEATHER_ICON LCD_DATADIR "weather_icon" +#define WEATHER_TEMP LCD_DATADIR "weather_temp" +#define WEATHER_ICON LCD_DATADIR "weather_icon" #define FLAG_LCD4LINUX "/tmp/.lcd4linux" #define PIDFILE "/var/run/lcd4linux.pid" @@ -253,8 +253,8 @@ void CLCD4l::Init() m_Start = "00:00"; m_End = "00:00"; - m_wtemp = ""; - m_wicon = ""; + m_wtemp = ""; + m_wicon = ""; if (!access(LCD_DATADIR, F_OK) == 0) mkdir(LCD_DATADIR, 0755); @@ -1016,7 +1016,7 @@ void CLCD4l::ParseInfo(uint64_t parseID, bool newID, bool firstRun) strcpy(m_Duration, Duration); } - if (g_settings.weather_enabled && CWeather::getInstance()->checkUpdate()) + if (g_settings.weather_enabled && CWeather::getInstance()->checkUpdate(firstRun)) { std::string wtemp = CWeather::getInstance()->getActTemp(); std::string wicon = CWeather::getInstance()->getActIcon(); diff --git a/src/driver/lcd4l.h b/src/driver/lcd4l.h index dcbd83c7d..19b404a78 100644 --- a/src/driver/lcd4l.h +++ b/src/driver/lcd4l.h @@ -126,8 +126,8 @@ class CLCD4l std::string m_fcolor2; std::string m_pbcolor; - std::string m_wtemp; - std::string m_wicon; + std::string m_wtemp; + std::string m_wicon; }; #endif diff --git a/src/gui/weather.cpp b/src/gui/weather.cpp index a9ede371c..4ee1c9fc3 100644 --- a/src/gui/weather.cpp +++ b/src/gui/weather.cpp @@ -79,10 +79,10 @@ void CWeather::setCoords(std::string new_coords, std::string new_city) } } -bool CWeather::checkUpdate() +bool CWeather::checkUpdate(bool forceUpdate) { time_t current_time = time(NULL); - if (difftime(current_time,last_time) > MINUTES) + if (forceUpdate || (difftime(current_time,last_time) > MINUTES)) return GetWeatherDetails(); else return false; diff --git a/src/gui/weather.h b/src/gui/weather.h index c89d4e033..2b30b7ddc 100644 --- a/src/gui/weather.h +++ b/src/gui/weather.h @@ -61,7 +61,7 @@ public: static CWeather* getInstance(); CWeather(); ~CWeather(); - bool checkUpdate(); + bool checkUpdate(bool forceUpdate = false); void setCoords(std::string new_coords, std::string new_city = "Unknown"); void show(int x = 50, int y = 50); void hide();