This commit is contained in:
e2002
2022-08-23 15:50:56 +03:00
parent 223bae1923
commit de9753058d
6 changed files with 34 additions and 30 deletions

View File

@@ -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);
}
}

View File

@@ -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() {

View File

@@ -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;

View File

@@ -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() {

View File

@@ -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.