diff --git a/README.md b/README.md index e97908e..f9f703b 100644 --- a/README.md +++ b/README.md @@ -317,6 +317,9 @@ Work is in progress... --- ## Version history +#### v0.7.414 +- fixed non latin long titles of songs error + #### v0.7.402 **!!! a [full update](#update-over-web-interface) with Sketch data upload is required. After updating please press CTRL+F5 in browser !!!** \ **Please backup playlist.csv and wifi.csv before updating.** diff --git a/yoRadio/audiohandlers.ino b/yoRadio/audiohandlers.ino index 41bd408..18139c4 100644 --- a/yoRadio/audiohandlers.ino +++ b/yoRadio/audiohandlers.ino @@ -57,7 +57,11 @@ void audio_showstation(const char *info) { void audio_showstreamtitle(const char *info) { if (strlen(info) > 0) { bool p = printable(info); +#ifdef DEBUG_TITLES + config.setTitle(DEBUG_TITLES); +#else config.setTitle(p?info:"*****"); +#endif netserver.requestOnChange(TITLE, 0); } } diff --git a/yoRadio/config.cpp b/yoRadio/config.cpp index 4fae0dd..ea8ace8 100644 --- a/yoRadio/config.cpp +++ b/yoRadio/config.cpp @@ -17,6 +17,11 @@ void DBGVB(const char *format, ...) { #endif } +void u8fix(char *src){ + char last = src[strlen(src)-1]; + if ((uint8_t)last >= 0xC2) src[strlen(src)-1]='\0'; +} + void Config::init() { EEPROM.begin(EEPROM_SIZE); #if IR_PIN!=255 @@ -223,12 +228,14 @@ byte Config::setLastSSID(byte val) { void Config::setTitle(const char* title) { memset(config.station.title, 0, BUFLEN); strlcpy(config.station.title, title, BUFLEN); + u8fix(config.station.title); display.putRequest({NEWTITLE, 0}); } void Config::setStation(const char* station) { memset(config.station.name, 0, BUFLEN); strlcpy(config.station.name, station, BUFLEN); + u8fix(config.station.title); } void Config::indexPlaylist() { diff --git a/yoRadio/config.h b/yoRadio/config.h index a073d20..4c3e599 100644 --- a/yoRadio/config.h +++ b/yoRadio/config.h @@ -14,6 +14,7 @@ #define INDEX_PATH "/data/index.dat" void DBGVB(const char *format, ...); +void u8fix(char *src); struct theme_t { uint16_t background; diff --git a/yoRadio/display.cpp b/yoRadio/display.cpp index 87265d2..ef16f8b 100644 --- a/yoRadio/display.cpp +++ b/yoRadio/display.cpp @@ -558,9 +558,6 @@ void Display::station() { nextion.newNameset(config.station.name); nextion.bitrate(config.station.bitrate); nextion.bitratePic(ICON_NA); -#endif -#ifdef DEBUG_TITLES - meta.setText(dsp.utf8Rus("Utenim adminim veniam FM", true)); #endif //dsp.loop(true); //netserver.requestOnChange(STATION, 0); @@ -570,44 +567,36 @@ void Display::returnTile() { meta.setText(dsp.utf8Rus(config.station.name, true)); #ifdef USE_NEXTION nextion.newNameset(config.station.name); -#endif -#ifdef DEBUG_TITLES - meta.setText(dsp.utf8Rus("Utenim adminim veniam FM", true)); #endif meta.reset(); //dsp.loop(true); } -void Display::title() { - /* - memset(config.station.title, 0, BUFLEN); - strlcpy(config.station.title, str, BUFLEN); - */ - char ttl[BUFLEN / 2] = { 0 }; - char sng[BUFLEN / 2] = { 0 }; - if (strlen(config.station.title) > 0) { - char* ici; - if ((ici = strstr(config.station.title, " - ")) != NULL && TITLE_SIZE2 != 0) { - strlcpy(sng, ici + 3, BUFLEN / 2); - strlcpy(ttl, config.station.title, strlen(config.station.title) - strlen(ici) + 1); +char *split(char *str, const char *delim) { + char *dmp = strstr(str, delim); + if (dmp == NULL) return NULL; + *dmp = '\0'; + return dmp + strlen(delim); +} - } else { - strlcpy(ttl, config.station.title, BUFLEN / 2); - sng[0] = '\0'; +void Display::title() { + DBGVB("call of %s(), config.station.title=%s", __func__, config.station.title); + if (strlen(config.station.title) > 0) { + char tmpbuf[strlen(config.station.title)+1]; + strlcpy(tmpbuf, config.station.title, strlen(config.station.title)+1); + char *stitle = split(tmpbuf, " - "); + if(stitle && TITLE_SIZE2 != 0){ + title1.setText(dsp.utf8Rus(tmpbuf, true)); + title2.setText(dsp.utf8Rus(stitle, true)); + }else{ + title1.setText(dsp.utf8Rus(tmpbuf, true)); + title2.setText(dsp.utf8Rus("", true)); } -#ifdef DEBUG_TITLES - strlcpy(ttl, "Duis aute irure dolor in reprehenderit in voluptate velit", BUFLEN / 2); - strlcpy(sng, "Excepteur sint occaecat cupidatat non proident", BUFLEN / 2); -#endif - title1.setText(dsp.utf8Rus(ttl, true)); - if (TITLE_SIZE2 != 0) title2.setText(dsp.utf8Rus(sng, true)); #ifdef USE_NEXTION nextion.newTitle(config.station.title); #endif - //dsp.loop(true); if (player_on_track_change) player_on_track_change(); } - //netserver.requestOnChange(TITLE, 0); } void Display::heap() { diff --git a/yoRadio/options.h b/yoRadio/options.h index a13db40..a216f1f 100644 --- a/yoRadio/options.h +++ b/yoRadio/options.h @@ -1,7 +1,7 @@ #ifndef options_h #define options_h -#define VERSION "0.7.402" +#define VERSION "0.7.414" /******************************************************* DO NOT EDIT THIS FILE.