ext_weather
This commit is contained in:
@@ -22,7 +22,7 @@ static const unsigned char font[] PROGMEM = {
|
|||||||
0x18, 0x5C, 0x7F, 0x5C, 0x18,
|
0x18, 0x5C, 0x7F, 0x5C, 0x18,
|
||||||
0x00, 0x1C, 0x1C, 0x1C, 0x00,
|
0x00, 0x1C, 0x1C, 0x1C, 0x00,
|
||||||
0x7F, 0x63, 0x63, 0x63, 0x7F,
|
0x7F, 0x63, 0x63, 0x63, 0x7F,
|
||||||
0x00, 0x1C, 0x14, 0x1C, 0x00,
|
0x06, 0x09, 0x09, 0x06, 0x00,
|
||||||
0x7F, 0x63, 0x6B, 0x63, 0x7F,
|
0x7F, 0x63, 0x6B, 0x63, 0x7F,
|
||||||
0x30, 0x48, 0x4D, 0x33, 0x07,
|
0x30, 0x48, 0x4D, 0x33, 0x07,
|
||||||
0x06, 0x29, 0x79, 0x29, 0x06,
|
0x06, 0x29, 0x79, 0x29, 0x06,
|
||||||
|
|||||||
@@ -35,9 +35,27 @@ const char oct[] PROGMEM = "october";
|
|||||||
const char nov[] PROGMEM = "november";
|
const char nov[] PROGMEM = "november";
|
||||||
const char dec[] PROGMEM = "december";
|
const char dec[] PROGMEM = "december";
|
||||||
|
|
||||||
|
const char wn_N[] PROGMEM = "N";
|
||||||
|
const char wn_NNE[] PROGMEM = "NNE";
|
||||||
|
const char wn_NE[] PROGMEM = "NE";
|
||||||
|
const char wn_ENE[] PROGMEM = "ENE";
|
||||||
|
const char wn_E[] PROGMEM = "E";
|
||||||
|
const char wn_ESE[] PROGMEM = "ESE";
|
||||||
|
const char wn_SE[] PROGMEM = "SE";
|
||||||
|
const char wn_SSE[] PROGMEM = "SSE";
|
||||||
|
const char wn_S[] PROGMEM = "S";
|
||||||
|
const char wn_SSW[] PROGMEM = "SSW";
|
||||||
|
const char wn_SW[] PROGMEM = "SW";
|
||||||
|
const char wn_WSW[] PROGMEM = "WSW";
|
||||||
|
const char wn_W[] PROGMEM = "W";
|
||||||
|
const char wn_WNW[] PROGMEM = "WNW";
|
||||||
|
const char wn_NW[] PROGMEM = "NW";
|
||||||
|
const char wn_NNW[] PROGMEM = "NNW";
|
||||||
|
|
||||||
const char* const dow[] PROGMEM = { sun, mon, tue, wed, thu, fri, sat };
|
const char* const dow[] PROGMEM = { sun, mon, tue, wed, thu, fri, sat };
|
||||||
const char* const dowf[] PROGMEM = { sunf, monf, tuef, wedf, thuf, frif, satf };
|
const char* const dowf[] PROGMEM = { sunf, monf, tuef, wedf, thuf, frif, satf };
|
||||||
const char* const mnths[] PROGMEM = { jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec };
|
const char* const mnths[] PROGMEM = { jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec };
|
||||||
|
const char* const wind[] PROGMEM = { wn_N, wn_NNE, wn_NE, wn_ENE, wn_E, wn_ESE, wn_SE, wn_SSE, wn_S, wn_SSW, wn_SW, wn_WSW, wn_W, wn_WNW, wn_NW, wn_NNW, wn_N };
|
||||||
|
|
||||||
const char const_PlReady[] PROGMEM = "[ready]";
|
const char const_PlReady[] PROGMEM = "[ready]";
|
||||||
const char const_PlStopped[] PROGMEM = "[stopped]";
|
const char const_PlStopped[] PROGMEM = "[stopped]";
|
||||||
@@ -52,7 +70,7 @@ const char apNameTxt[] PROGMEM = "AP NAME";
|
|||||||
const char apPassTxt[] PROGMEM = "PASSWORD";
|
const char apPassTxt[] PROGMEM = "PASSWORD";
|
||||||
const char bootstrFmt[] PROGMEM = "Trying to %s";
|
const char bootstrFmt[] PROGMEM = "Trying to %s";
|
||||||
const char apSettFmt[] PROGMEM = "SETTINGS PAGE ON: HTTP://%s/";
|
const char apSettFmt[] PROGMEM = "SETTINGS PAGE ON: HTTP://%s/";
|
||||||
const char weatherFmt[] PROGMEM = "%s, %.1f C * pressure: %d mm * humidity: %s%%";
|
const char weatherFmt[] PROGMEM = "%s, %.1f\011C \007 feels like: %.1f\011C \007 pressure: %d мм * humidity: %s%% \007 wind: [%s] %.1f m/s";
|
||||||
const char weatherUnits[] PROGMEM = "metric"; /* standard, metric, imperial */
|
const char weatherUnits[] PROGMEM = "metric"; /* standard, metric, imperial */
|
||||||
const char weatherLang[] PROGMEM = "en"; /* https://openweathermap.org/current#multi */
|
const char weatherLang[] PROGMEM = "en"; /* https://openweathermap.org/current#multi */
|
||||||
|
|
||||||
|
|||||||
@@ -35,9 +35,27 @@ const char oct[] PROGMEM = "октября";
|
|||||||
const char nov[] PROGMEM = "ноября";
|
const char nov[] PROGMEM = "ноября";
|
||||||
const char dec[] PROGMEM = "декабря";
|
const char dec[] PROGMEM = "декабря";
|
||||||
|
|
||||||
|
const char wn_N[] PROGMEM = "С";
|
||||||
|
const char wn_NNE[] PROGMEM = "ССВ";
|
||||||
|
const char wn_NE[] PROGMEM = "СВ";
|
||||||
|
const char wn_ENE[] PROGMEM = "ВСВ";
|
||||||
|
const char wn_E[] PROGMEM = "В";
|
||||||
|
const char wn_ESE[] PROGMEM = "ВЮВ";
|
||||||
|
const char wn_SE[] PROGMEM = "ЮВ";
|
||||||
|
const char wn_SSE[] PROGMEM = "ЮЮВ";
|
||||||
|
const char wn_S[] PROGMEM = "Ю";
|
||||||
|
const char wn_SSW[] PROGMEM = "ЮЮЗ";
|
||||||
|
const char wn_SW[] PROGMEM = "ЮЗ";
|
||||||
|
const char wn_WSW[] PROGMEM = "ЗЮЗ";
|
||||||
|
const char wn_W[] PROGMEM = "З";
|
||||||
|
const char wn_WNW[] PROGMEM = "ЗСЗ";
|
||||||
|
const char wn_NW[] PROGMEM = "СЗ";
|
||||||
|
const char wn_NNW[] PROGMEM = "ССЗ";
|
||||||
|
|
||||||
const char* const dow[] PROGMEM = { sun, mon, tue, wed, thu, fri, sat };
|
const char* const dow[] PROGMEM = { sun, mon, tue, wed, thu, fri, sat };
|
||||||
const char* const dowf[] PROGMEM = { sunf, monf, tuef, wedf, thuf, frif, satf };
|
const char* const dowf[] PROGMEM = { sunf, monf, tuef, wedf, thuf, frif, satf };
|
||||||
const char* const mnths[] PROGMEM = { jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec };
|
const char* const mnths[] PROGMEM = { jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec };
|
||||||
|
const char* const wind[] PROGMEM = { wn_N, wn_NNE, wn_NE, wn_ENE, wn_E, wn_ESE, wn_SE, wn_SSE, wn_S, wn_SSW, wn_SW, wn_WSW, wn_W, wn_WNW, wn_NW, wn_NNW, wn_N };
|
||||||
|
|
||||||
const char const_PlReady[] PROGMEM = "[готов]";
|
const char const_PlReady[] PROGMEM = "[готов]";
|
||||||
const char const_PlStopped[] PROGMEM = "[остановлено]";
|
const char const_PlStopped[] PROGMEM = "[остановлено]";
|
||||||
@@ -52,7 +70,7 @@ const char apNameTxt[] PROGMEM = "ТОЧКА ДОСТУПА";
|
|||||||
const char apPassTxt[] PROGMEM = "ПАРОЛЬ";
|
const char apPassTxt[] PROGMEM = "ПАРОЛЬ";
|
||||||
const char bootstrFmt[] PROGMEM = "Соединяюсь с %s";
|
const char bootstrFmt[] PROGMEM = "Соединяюсь с %s";
|
||||||
const char apSettFmt[] PROGMEM = "НАСТРОЙКИ: HTTP://%s/";
|
const char apSettFmt[] PROGMEM = "НАСТРОЙКИ: HTTP://%s/";
|
||||||
const char weatherFmt[] PROGMEM = "%s, %.1f C * давление: %d мм * влажность: %s%%";
|
const char weatherFmt[] PROGMEM = "%s, %.1f\011C \007 ощущается: %.1f\011C \007 давление: %d мм \007 влажность: %s%% \007 ветер: %s\013%.1f м/с";
|
||||||
const char weatherUnits[] PROGMEM = "metric"; /* standard, metric, imperial */
|
const char weatherUnits[] PROGMEM = "metric"; /* standard, metric, imperial */
|
||||||
const char weatherLang[] PROGMEM = "ru"; /* https://openweathermap.org/current#multi */
|
const char weatherLang[] PROGMEM = "ru"; /* https://openweathermap.org/current#multi */
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,9 @@
|
|||||||
#define EEPROM_START 500
|
#define EEPROM_START 500
|
||||||
#define EEPROM_START_IR 0
|
#define EEPROM_START_IR 0
|
||||||
#define EEPROM_START_2 10
|
#define EEPROM_START_2 10
|
||||||
#define BUFLEN 140
|
#ifndef BUFLEN
|
||||||
|
#define BUFLEN 170
|
||||||
|
#endif
|
||||||
#define PLAYLIST_PATH "/data/playlist.csv"
|
#define PLAYLIST_PATH "/data/playlist.csv"
|
||||||
#define SSIDS_PATH "/data/wifi.csv"
|
#define SSIDS_PATH "/data/wifi.csv"
|
||||||
#define TMP_PATH "/data/tmpfile.txt"
|
#define TMP_PATH "/data/tmpfile.txt"
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ void Display::_buildPager(){
|
|||||||
#endif
|
#endif
|
||||||
_nums.init(numConf, 10, false, config.theme.digit, config.theme.background);
|
_nums.init(numConf, 10, false, config.theme.digit, config.theme.background);
|
||||||
#ifndef HIDE_WEATHER
|
#ifndef HIDE_WEATHER
|
||||||
_weather = new ScrollWidget("*", weatherConf, config.theme.weather, config.theme.background);
|
_weather = new ScrollWidget("\007", weatherConf, config.theme.weather, config.theme.background);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(_volbar) _footer.addWidget( _volbar);
|
if(_volbar) _footer.addWidget( _volbar);
|
||||||
|
|||||||
@@ -249,17 +249,17 @@ bool getWeather(char *wstr) {
|
|||||||
tmpe = strstr(tmps, ",\"");
|
tmpe = strstr(tmps, ",\"");
|
||||||
if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: temp not found !"); return false;}
|
if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: temp not found !"); return false;}
|
||||||
strlcpy(temp, tmps, tmpe - tmps + 1);
|
strlcpy(temp, tmps, tmpe - tmps + 1);
|
||||||
cursor = tmpe + 2;
|
cursor = tmpe + 1;
|
||||||
float tempf = atof(temp);
|
float tempf = atof(temp);
|
||||||
|
|
||||||
tmps = strstr(cursor, "\"pressure\":");
|
tmps = strstr(cursor, "\"feels_like\":");
|
||||||
if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: pressure not found !"); return false;}
|
if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: feels_like not found !"); return false;}
|
||||||
tmps += 11;
|
tmps += 13;
|
||||||
tmpe = strstr(tmps, ",\"");
|
tmpe = strstr(tmps, ",\"");
|
||||||
if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: pressure not found !"); return false;}
|
if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: feels_like not found !"); return false;}
|
||||||
strlcpy(press, tmps, tmpe - tmps + 1);
|
strlcpy(temp, tmps, tmpe - tmps + 1);
|
||||||
cursor = tmpe + 2;
|
cursor = tmpe + 2;
|
||||||
int pressi = (float)atoi(press) / 1.333;
|
float tempfl = atof(temp);
|
||||||
|
|
||||||
tmps = strstr(cursor, "humidity\":");
|
tmps = strstr(cursor, "humidity\":");
|
||||||
if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: humidity not found !"); return false;}
|
if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: humidity not found !"); return false;}
|
||||||
@@ -269,6 +269,35 @@ bool getWeather(char *wstr) {
|
|||||||
if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: humidity not found !"); return false;}
|
if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: humidity not found !"); return false;}
|
||||||
strlcpy(hum, tmps, tmpe - tmps + (tmpc>tmpe?1:0));
|
strlcpy(hum, tmps, tmpe - tmps + (tmpc>tmpe?1:0));
|
||||||
|
|
||||||
|
tmps = strstr(cursor, "\"grnd_level\":");
|
||||||
|
if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: pressure not found !"); return false;}
|
||||||
|
tmps += 13;
|
||||||
|
tmpe = strstr(tmps, ",\"");
|
||||||
|
if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: pressure not found !"); return false;}
|
||||||
|
strlcpy(press, tmps, tmpe - tmps + 1);
|
||||||
|
cursor = tmpe + 2;
|
||||||
|
int pressi = (float)atoi(press) / 1.333;
|
||||||
|
|
||||||
|
tmps = strstr(cursor, "\"speed\":");
|
||||||
|
if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: wind speed not found !"); return false;}
|
||||||
|
tmps += 8;
|
||||||
|
tmpe = strstr(tmps, ",\"");
|
||||||
|
if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: wind speed not found !"); return false;}
|
||||||
|
strlcpy(temp, tmps, tmpe - tmps + 1);
|
||||||
|
cursor = tmpe + 1;
|
||||||
|
float wind_speed = atof(temp);
|
||||||
|
|
||||||
|
tmps = strstr(cursor, "\"deg\":");
|
||||||
|
if (tmps == NULL) { Serial.println("## OPENWEATHERMAP ###: wind deg not found !"); return false;}
|
||||||
|
tmps += 6;
|
||||||
|
tmpe = strstr(tmps, ",\"");
|
||||||
|
if (tmpe == NULL) { Serial.println("## OPENWEATHERMAP ###: wind deg not found !"); return false;}
|
||||||
|
strlcpy(temp, tmps, tmpe - tmps + 1);
|
||||||
|
cursor = tmpe + 1;
|
||||||
|
int wind_deg = atof(temp)/22.5;
|
||||||
|
if(wind_deg<0) wind_deg = 16+wind_deg;
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_NEXTION
|
#ifdef USE_NEXTION
|
||||||
nextion.putcmdf("press_txt.txt=\"%dmm\"", pressi);
|
nextion.putcmdf("press_txt.txt=\"%dmm\"", pressi);
|
||||||
nextion.putcmdf("hum_txt.txt=\"%d%%\"", atoi(hum));
|
nextion.putcmdf("hum_txt.txt=\"%d%%\"", atoi(hum));
|
||||||
@@ -294,7 +323,7 @@ bool getWeather(char *wstr) {
|
|||||||
#ifdef WEATHER_FMT_SHORT
|
#ifdef WEATHER_FMT_SHORT
|
||||||
sprintf(wstr, weatherFmt, tempf, pressi, hum);
|
sprintf(wstr, weatherFmt, tempf, pressi, hum);
|
||||||
#else
|
#else
|
||||||
sprintf(wstr, weatherFmt, desc, tempf, pressi, hum);
|
sprintf(wstr, weatherFmt, desc, tempf, tempfl, pressi, hum, wind[wind_deg], wind_speed);
|
||||||
#endif
|
#endif
|
||||||
network.requestWeatherSync();
|
network.requestWeatherSync();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef options_h
|
#ifndef options_h
|
||||||
#define options_h
|
#define options_h
|
||||||
|
|
||||||
#define YOVERSION "0.8.962"
|
#define YOVERSION "0.8.971"
|
||||||
|
|
||||||
/*******************************************************
|
/*******************************************************
|
||||||
DO NOT EDIT THIS FILE.
|
DO NOT EDIT THIS FILE.
|
||||||
|
|||||||
Reference in New Issue
Block a user