From 24299980fc7c1b59af9c8f17e5cff9cf6d6c13e9 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Tue, 29 Nov 2022 20:02:00 +0100 Subject: [PATCH] - glcd/weather: split temperature and weather icon --- data/locale/deutsch.locale | 12 ++++-- data/locale/english.locale | 12 ++++-- src/driver/glcd/weather.cpp | 76 +++++++++++++++++++++++++++---------- src/driver/glcd/weather.h | 2 +- src/gui/glcdsetup.cpp | 24 ++++++++++-- src/gui/glcdthemes.cpp | 24 ++++++++---- src/neutrino.cpp | 5 +++ src/system/locals.h | 12 ++++-- src/system/locals_intern.h | 12 ++++-- src/system/settings.h | 12 ++++-- version_pseudo.h | 2 +- 11 files changed, 138 insertions(+), 55 deletions(-) diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 8cae50f89..1a9be565b 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -947,8 +947,10 @@ glcd.standby_clock_led LED-Uhr glcd.standby_clock_simple Einfache Uhr glcd.standby_settings Standby-Einstellungen glcd.standby_weather Wetter im Standby -glcd.standby_weather_curr_x_position Wetter im Standby heute x-Position -glcd.standby_weather_next_x_position Wetter im Standby morgen x-Position +glcd.standby_weather_curr_icon_x_position Wetter-Icon heute x-Position +glcd.standby_weather_curr_temp_x_position Temperatur heute x-Position +glcd.standby_weather_next_icon_x_position Wetter-Icon morgen x-Position +glcd.standby_weather_next_temp_x_position Temperatur morgen x-Position glcd.standby_weather_percent Wetter Höhe glcd.standby_weather_y_position Wetter im Standby y-Position glcd.start_align Sendungsstart ausrichten @@ -965,8 +967,10 @@ glcd.time_size_standby Uhrzeit Höhe im Standby glcd.time_x_position Uhrzeit x-Position glcd.time_y_position Uhrzeit y-Position glcd.volume Lautstärke -glcd.weather_curr_x_position Wetter heute x-Position -glcd.weather_next_x_position Wetter morgen x-Position +glcd.weather_curr_icon_x_position Wetter-Icon heute x-Position +glcd.weather_curr_temp_x_position Temperatur heute x-Position +glcd.weather_next_icon_x_position Wetter-Icon morgen x-Position +glcd.weather_next_temp_x_position Temperatur morgen x-Position glcd.weather_percent Wetter Höhe glcd.weather_show Wetter anzeigen glcd.weather_y_position Wetter y-Position diff --git a/data/locale/english.locale b/data/locale/english.locale index 4257da2d8..b747719cd 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -947,8 +947,10 @@ glcd.standby_clock_led LED-clock glcd.standby_clock_simple Simple clock glcd.standby_settings Standby-settings glcd.standby_weather Weather in standby mode -glcd.standby_weather_curr_x_position Weather in standby mode current x-position -glcd.standby_weather_next_x_position Weather in standby mode next x-position +glcd.standby_weather_curr_icon_x_position Weather icon current x-position +glcd.standby_weather_curr_temp_x_position Temperature current x-position +glcd.standby_weather_next_icon_x_position Weather icon next x-position +glcd.standby_weather_next_temp_x_position Temperature next x-position glcd.standby_weather_percent Weather height glcd.standby_weather_y_position Weather in standby mode y-position glcd.start_align Event start arrangement @@ -965,8 +967,10 @@ glcd.time_size_standby Standby time height glcd.time_x_position Time x-position glcd.time_y_position Time y-position glcd.volume Volume -glcd.weather_curr_x_position Weather current x-position -glcd.weather_next_x_position Weather next x-position +glcd.weather_curr_icon_x_position Weather icon current x-position +glcd.weather_curr_temp_x_position Temperature current x-position +glcd.weather_next_icon_x_position Weather icon next x-position +glcd.weather_next_temp_x_position Temperature next x-position glcd.weather_percent Weather height glcd.weather_show Weather display glcd.weather_y_position Weather y-position diff --git a/src/driver/glcd/weather.cpp b/src/driver/glcd/weather.cpp index 16852eecd..0dc9b8e58 100644 --- a/src/driver/glcd/weather.cpp +++ b/src/driver/glcd/weather.cpp @@ -79,8 +79,29 @@ void WeatherUpdateFonts() fonts_initialized = true; } -void RenderWeather(int cx, int cy, int nx, int ny, bool standby) +void RenderWeather(bool standby) { + SNeutrinoGlcdTheme &t = g_settings.glcd_theme; + + int ctx, cix, ntx, nix, y; + + if (!standby) + { + ctx = t.glcd_weather_curr_temp_x_position; + cix = t.glcd_weather_curr_icon_x_position; + ntx = t.glcd_weather_next_temp_x_position; + nix = t.glcd_weather_next_icon_x_position; + y = t.glcd_weather_y_position; + } + else + { + ctx = t.glcd_standby_weather_curr_temp_x_position; + cix = t.glcd_standby_weather_curr_icon_x_position; + ntx = t.glcd_standby_weather_next_temp_x_position; + nix = t.glcd_standby_weather_next_icon_x_position; + y = t.glcd_standby_weather_y_position; + } + int forecast = 0; // 0 is current day std::string current_wcity = ""; @@ -96,7 +117,7 @@ void RenderWeather(int cx, int cy, int nx, int ny, bool standby) std::string next_wicon = ""; cGLCD *cglcd = cGLCD::getInstance(); - SNeutrinoGlcdTheme &t = g_settings.glcd_theme; + if (g_settings.weather_enabled) { if (CWeather::getInstance()->checkUpdate(ForceUpdate)) @@ -130,50 +151,63 @@ void RenderWeather(int cx, int cy, int nx, int ny, bool standby) next_wicon = st_next_wicon; } - if (current_wicon != "") { + if ((current_wicon != "") && cix) + { if (!standby) - cglcd->imageShow(current_wicon, cx, cy, weather_fontsize, weather_fontsize, false, false, false, false, false); + cglcd->imageShow(current_wicon, cix, y, weather_fontsize, weather_fontsize, false, false, false, false, false); else - cglcd->imageShow(current_wicon, cx, cy, standby_weather_fontsize, standby_weather_fontsize, false, false, false, false, false); + cglcd->imageShow(current_wicon, cix, y, standby_weather_fontsize, standby_weather_fontsize, false, false, false, false, false); } - if (current_wtemp != "") { + if ((current_wtemp != "") && ctx) + { //current_wtemp += "°"; + int current_width; WeatherUpdateFonts(); if (!standby) - cglcd->bitmap->DrawText(cx + 5 + weather_fontsize, cy + ((weather_fontsize - font_temperature.TotalHeight()) / 2 ), cglcd->bitmap->Width() - 1, current_wtemp, + { + current_width = font_temperature.Width(current_wtemp); + cglcd->bitmap->DrawText(ctx, y, cglcd->bitmap->Width() - 1, current_wtemp, &font_temperature, cglcd->ColorConvert3to1(t.glcd_foreground_color_red, t.glcd_foreground_color_green, t.glcd_foreground_color_blue), GLCD::cColor::Transparent); + } else - cglcd->bitmap->DrawText(cx + 5 + standby_weather_fontsize, cy + ((standby_weather_fontsize - font_temperature_standby.TotalHeight()) / 2 ), cglcd->bitmap->Width() - 1, current_wtemp, + { + current_width = font_temperature_standby.Width(current_wtemp); + cglcd->bitmap->DrawText(ctx, y, cglcd->bitmap->Width() - 1, current_wtemp, &font_temperature_standby, cglcd->ColorConvert3to1(t.glcd_foreground_color_red, t.glcd_foreground_color_green, t.glcd_foreground_color_blue), GLCD::cColor::Transparent); + } } - if (next_wicon != "") { + + if ((next_wicon != "") && nix) + { if (!standby) - cglcd->imageShow(next_wicon, nx, ny, weather_fontsize, weather_fontsize, false, false, false, false, false); + cglcd->imageShow(next_wicon, nix, y, weather_fontsize, weather_fontsize, false, false, false, false, false); else - cglcd->imageShow(next_wicon, nx, ny, standby_weather_fontsize, standby_weather_fontsize, false, false, false, false, false); + cglcd->imageShow(next_wicon, nix, y, standby_weather_fontsize, standby_weather_fontsize, false, false, false, false, false); } - if (next_wtemp != "") { + if ((next_wtemp != "") && ntx) + { //next_wtemp += "°"; + int next_width; WeatherUpdateFonts(); if (!standby) - cglcd->bitmap->DrawText(nx + 5 + weather_fontsize, ny + ((weather_fontsize - font_temperature.TotalHeight()) / 2 ), cglcd->bitmap->Width() - 1, next_wtemp, + { + next_width = font_temperature.Width(next_wtemp); + cglcd->bitmap->DrawText(ntx, y, cglcd->bitmap->Width() - 1, next_wtemp, &font_temperature, cglcd->ColorConvert3to1(t.glcd_foreground_color_red, t.glcd_foreground_color_green, t.glcd_foreground_color_blue), GLCD::cColor::Transparent); + } else - cglcd->bitmap->DrawText(nx + 5 + standby_weather_fontsize, ny + ((standby_weather_fontsize - font_temperature_standby.TotalHeight()) / 2 ), cglcd->bitmap->Width() - 1, next_wtemp, + { + next_width = font_temperature_standby.Width(next_wtemp); + cglcd->bitmap->DrawText(ntx, y, cglcd->bitmap->Width() - 1, next_wtemp, &font_temperature_standby, cglcd->ColorConvert3to1(t.glcd_foreground_color_red, t.glcd_foreground_color_green, t.glcd_foreground_color_blue), GLCD::cColor::Transparent); + } } } } void ShowWeather(bool standby) { - SNeutrinoGlcdTheme &t = g_settings.glcd_theme; - - if (!standby) { - RenderWeather(t.glcd_weather_curr_x_position, t.glcd_weather_y_position, t.glcd_weather_next_x_position, t.glcd_weather_y_position, standby); - } else { - RenderWeather(t.glcd_standby_weather_curr_x_position, t.glcd_standby_weather_y_position, t.glcd_standby_weather_next_x_position, t.glcd_standby_weather_y_position, standby); - } + RenderWeather(standby); if (ForceUpdate) ForceUpdate = false; diff --git a/src/driver/glcd/weather.h b/src/driver/glcd/weather.h index 94e26bf6f..fe968d6e5 100644 --- a/src/driver/glcd/weather.h +++ b/src/driver/glcd/weather.h @@ -29,5 +29,5 @@ #include "glcd.h" void WeatherUpdateFonts(); -void RenderWeather(int cx, int cy, int nx, int ny, bool standby); +void RenderWeather(bool standby); void ShowWeather(bool standby); diff --git a/src/gui/glcdsetup.cpp b/src/gui/glcdsetup.cpp index cf13ef3d7..92b05e843 100644 --- a/src/gui/glcdsetup.cpp +++ b/src/gui/glcdsetup.cpp @@ -371,11 +371,19 @@ int GLCD_Menu::GLCD_Standby_Settings() gss->addItem(nc); WeatherSBActivate.Add(nc); - nc = new CMenuOptionNumberChooser(LOCALE_GLCD_STANDBY_WEATHER_CURR_X_POSITION, &t.glcd_standby_weather_curr_x_position, t.glcd_standby_weather, 0, oled_width, this); + nc = new CMenuOptionNumberChooser(LOCALE_GLCD_STANDBY_WEATHER_CURR_TEMP_X_POSITION, &t.glcd_standby_weather_curr_temp_x_position, t.glcd_standby_weather, 0, oled_width, this); gss->addItem(nc); WeatherSBActivate.Add(nc); - nc = new CMenuOptionNumberChooser(LOCALE_GLCD_STANDBY_WEATHER_NEXT_X_POSITION, &t.glcd_standby_weather_next_x_position, t.glcd_standby_weather, 0, oled_width, this); + nc = new CMenuOptionNumberChooser(LOCALE_GLCD_STANDBY_WEATHER_CURR_ICON_X_POSITION, &t.glcd_standby_weather_curr_icon_x_position, t.glcd_standby_weather, 0, oled_width, this); + gss->addItem(nc); + WeatherSBActivate.Add(nc); + + nc = new CMenuOptionNumberChooser(LOCALE_GLCD_STANDBY_WEATHER_NEXT_TEMP_X_POSITION, &t.glcd_standby_weather_next_temp_x_position, t.glcd_standby_weather, 0, oled_width, this); + gss->addItem(nc); + WeatherSBActivate.Add(nc); + + nc = new CMenuOptionNumberChooser(LOCALE_GLCD_STANDBY_WEATHER_NEXT_ICON_X_POSITION, &t.glcd_standby_weather_next_icon_x_position, t.glcd_standby_weather, 0, oled_width, this); gss->addItem(nc); WeatherSBActivate.Add(nc); @@ -652,11 +660,19 @@ int GLCD_Menu::GLCD_Theme_Settings() gts->addItem(nc); WeatherActivate.Add(nc); - nc = new CMenuOptionNumberChooser(LOCALE_GLCD_WEATHER_CURR_X_POSITION, &t.glcd_weather_curr_x_position, t.glcd_weather, 0, oled_width, this); + nc = new CMenuOptionNumberChooser(LOCALE_GLCD_WEATHER_CURR_TEMP_X_POSITION, &t.glcd_weather_curr_temp_x_position, t.glcd_weather, 0, oled_width, this); gts->addItem(nc); WeatherActivate.Add(nc); - nc = new CMenuOptionNumberChooser(LOCALE_GLCD_WEATHER_NEXT_X_POSITION, &t.glcd_weather_next_x_position, t.glcd_weather, 0, oled_width, this); + nc = new CMenuOptionNumberChooser(LOCALE_GLCD_WEATHER_CURR_ICON_X_POSITION, &t.glcd_weather_curr_icon_x_position, t.glcd_weather, 0, oled_width, this); + gts->addItem(nc); + WeatherActivate.Add(nc); + + nc = new CMenuOptionNumberChooser(LOCALE_GLCD_WEATHER_NEXT_TEMP_X_POSITION, &t.glcd_weather_next_temp_x_position, t.glcd_weather, 0, oled_width, this); + gts->addItem(nc); + WeatherActivate.Add(nc); + + nc = new CMenuOptionNumberChooser(LOCALE_GLCD_WEATHER_NEXT_ICON_X_POSITION, &t.glcd_weather_next_icon_x_position, t.glcd_weather, 0, oled_width, this); gts->addItem(nc); WeatherActivate.Add(nc); diff --git a/src/gui/glcdthemes.cpp b/src/gui/glcdthemes.cpp index 4c1a09f3c..75c33d5f1 100644 --- a/src/gui/glcdthemes.cpp +++ b/src/gui/glcdthemes.cpp @@ -349,13 +349,17 @@ void CGLCDThemes::setTheme(CConfigFile &configfile) configfile.setInt32("glcd_standby_clock_simple_y_position", t.glcd_standby_clock_simple_y_position); configfile.setBool("glcd_weather", t.glcd_weather); configfile.setInt32("glcd_weather_percent", t.glcd_weather_percent); - configfile.setInt32("glcd_weather_curr_x_position", t.glcd_weather_curr_x_position); - configfile.setInt32("glcd_weather_next_x_position", t.glcd_weather_next_x_position); + configfile.setInt32("glcd_weather_curr_temp_x_position", t.glcd_weather_curr_temp_x_position); + configfile.setInt32("glcd_weather_curr_icon_x_position", t.glcd_weather_curr_icon_x_position); + configfile.setInt32("glcd_weather_next_temp_x_position", t.glcd_weather_next_temp_x_position); + configfile.setInt32("glcd_weather_next_icon_x_position", t.glcd_weather_next_icon_x_position); configfile.setInt32("glcd_weather_y_position", t.glcd_weather_y_position); configfile.setInt32("glcd_standby_weather", t.glcd_standby_weather); configfile.setInt32("glcd_standby_weather_percent", t.glcd_standby_weather_percent); - configfile.setInt32("glcd_standby_weather_curr_x_position", t.glcd_standby_weather_curr_x_position); - configfile.setInt32("glcd_standby_weather_next_x_position", t.glcd_standby_weather_next_x_position); + configfile.setInt32("glcd_standby_weather_curr_temp_x_position", t.glcd_standby_weather_curr_temp_x_position); + configfile.setInt32("glcd_standby_weather_curr_icon_x_position", t.glcd_standby_weather_curr_icon_x_position); + configfile.setInt32("glcd_standby_weather_next_temp_x_position", t.glcd_standby_weather_next_temp_x_position); + configfile.setInt32("glcd_standby_weather_next_icon_x_position", t.glcd_standby_weather_next_icon_x_position); configfile.setInt32("glcd_standby_weather_y_position", t.glcd_standby_weather_y_position); configfile.setInt32("glcd_position_settings", t.glcd_position_settings); } @@ -427,13 +431,17 @@ void CGLCDThemes::getTheme(CConfigFile &configfile) t.glcd_standby_clock_simple_y_position = configfile.getInt32("glcd_standby_clock_simple_y_position", 0); t.glcd_weather = configfile.getBool("glcd_weather", false); t.glcd_weather_percent = configfile.getInt32("glcd_weather_percent", 15); - t.glcd_weather_curr_x_position = configfile.getInt32("glcd_weather_curr_x_position", 0); - t.glcd_weather_next_x_position = configfile.getInt32("glcd_weather_next_x_position", 0); + t.glcd_weather_curr_temp_x_position = configfile.getInt32("glcd_weather_curr_temp_x_position", 0); + t.glcd_weather_curr_icon_x_position = configfile.getInt32("glcd_weather_curr_icon_x_position", 0); + t.glcd_weather_next_temp_x_position = configfile.getInt32("glcd_weather_next_temp_x_position", 0); + t.glcd_weather_next_icon_x_position = configfile.getInt32("glcd_weather_next_icon_x_position", 0); t.glcd_weather_y_position = configfile.getInt32("glcd_weather_y_position", 0); t.glcd_standby_weather = configfile.getInt32("glcd_standby_weather", 1); t.glcd_standby_weather_percent = configfile.getInt32("glcd_standby_weather_percent", 40); - t.glcd_standby_weather_curr_x_position = configfile.getInt32("glcd_standby_weather_curr_x_position", 0); - t.glcd_standby_weather_next_x_position = configfile.getInt32("glcd_standby_weather_next_x_position", 0); + t.glcd_standby_weather_curr_temp_x_position = configfile.getInt32("glcd_standby_weather_curr_temp_x_position", 0); + t.glcd_standby_weather_curr_icon_x_position = configfile.getInt32("glcd_standby_weather_curr_icon_x_position", 0); + t.glcd_standby_weather_next_temp_x_position = configfile.getInt32("glcd_standby_weather_next_temp_x_position", 0); + t.glcd_standby_weather_next_icon_x_position = configfile.getInt32("glcd_standby_weather_next_icon_x_position", 0); t.glcd_standby_weather_y_position = configfile.getInt32("glcd_standby_weather_y_position", 0); t.glcd_position_settings = configfile.getInt32("glcd_position_settings", 1); diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 88da25df2..4294dfe35 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -1485,6 +1485,11 @@ void CNeutrinoApp::upgradeSetup(const char * fname) g_settings.channellist_epgtext_alignment = EPGTEXT_ALIGN_RIGHT_MIDDLE; configfile.deleteKey("channellist_epgtext_align_right"); } + if (g_settings.version_pseudo < "20221129210000") + { + configfile.deleteKey("glcd_weather_curr_x_position"); + configfile.deleteKey("glcd_weather_next_x_position"); + } g_settings.version_pseudo = NEUTRINO_VERSION_PSEUDO; configfile.setString("version_pseudo", g_settings.version_pseudo); diff --git a/src/system/locals.h b/src/system/locals.h index a7dfae410..89f69176e 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -974,8 +974,10 @@ typedef enum LOCALE_GLCD_STANDBY_CLOCK_SIMPLE, LOCALE_GLCD_STANDBY_SETTINGS, LOCALE_GLCD_STANDBY_WEATHER, - LOCALE_GLCD_STANDBY_WEATHER_CURR_X_POSITION, - LOCALE_GLCD_STANDBY_WEATHER_NEXT_X_POSITION, + LOCALE_GLCD_STANDBY_WEATHER_CURR_ICON_X_POSITION, + LOCALE_GLCD_STANDBY_WEATHER_CURR_TEMP_X_POSITION, + LOCALE_GLCD_STANDBY_WEATHER_NEXT_ICON_X_POSITION, + LOCALE_GLCD_STANDBY_WEATHER_NEXT_TEMP_X_POSITION, LOCALE_GLCD_STANDBY_WEATHER_PERCENT, LOCALE_GLCD_STANDBY_WEATHER_Y_POSITION, LOCALE_GLCD_START_ALIGN, @@ -992,8 +994,10 @@ typedef enum LOCALE_GLCD_TIME_X_POSITION, LOCALE_GLCD_TIME_Y_POSITION, LOCALE_GLCD_VOLUME, - LOCALE_GLCD_WEATHER_CURR_X_POSITION, - LOCALE_GLCD_WEATHER_NEXT_X_POSITION, + LOCALE_GLCD_WEATHER_CURR_ICON_X_POSITION, + LOCALE_GLCD_WEATHER_CURR_TEMP_X_POSITION, + LOCALE_GLCD_WEATHER_NEXT_ICON_X_POSITION, + LOCALE_GLCD_WEATHER_NEXT_TEMP_X_POSITION, LOCALE_GLCD_WEATHER_PERCENT, LOCALE_GLCD_WEATHER_SHOW, LOCALE_GLCD_WEATHER_Y_POSITION, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 7ca238997..426fdd289 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -974,8 +974,10 @@ const char * locale_real_names[] = "glcd.standby_clock_simple", "glcd.standby_settings", "glcd.standby_weather", - "glcd.standby_weather_curr_x_position", - "glcd.standby_weather_next_x_position", + "glcd.standby_weather_curr_icon_x_position", + "glcd.standby_weather_curr_temp_x_position", + "glcd.standby_weather_next_icon_x_position", + "glcd.standby_weather_next_temp_x_position", "glcd.standby_weather_percent", "glcd.standby_weather_y_position", "glcd.start_align", @@ -992,8 +994,10 @@ const char * locale_real_names[] = "glcd.time_x_position", "glcd.time_y_position", "glcd.volume", - "glcd.weather_curr_x_position", - "glcd.weather_next_x_position", + "glcd.weather_curr_icon_x_position", + "glcd.weather_curr_temp_x_position", + "glcd.weather_next_icon_x_position", + "glcd.weather_next_temp_x_position", "glcd.weather_percent", "glcd.weather_show", "glcd.weather_y_position", diff --git a/src/system/settings.h b/src/system/settings.h index 09ea165c6..e9eecca8a 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -293,14 +293,18 @@ struct SNeutrinoGlcdTheme int glcd_weather; int glcd_weather_percent; - int glcd_weather_curr_x_position; - int glcd_weather_next_x_position; + int glcd_weather_curr_temp_x_position; + int glcd_weather_curr_icon_x_position; + int glcd_weather_next_temp_x_position; + int glcd_weather_next_icon_x_position; int glcd_weather_y_position; int glcd_standby_weather; int glcd_standby_weather_percent; - int glcd_standby_weather_curr_x_position; - int glcd_standby_weather_next_x_position; + int glcd_standby_weather_curr_temp_x_position; + int glcd_standby_weather_curr_icon_x_position; + int glcd_standby_weather_next_temp_x_position; + int glcd_standby_weather_next_icon_x_position; int glcd_standby_weather_y_position; int glcd_position_settings; diff --git a/version_pseudo.h b/version_pseudo.h index c0cc11586..21cf0ec6b 100644 --- a/version_pseudo.h +++ b/version_pseudo.h @@ -1 +1 @@ -#define NEUTRINO_VERSION_PSEUDO "20220506230000" +#define NEUTRINO_VERSION_PSEUDO "20221129210000"