8000 Screensaver while playing option / blank screen instead of clock options by trip5 · Pull Request #129 · e2002/yoradio · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Screensaver while playing option / blank screen instead of clock options #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified yoRadio/data/www/script.js.gz
Binary file not shown.
24 changes: 21 additions & 3 deletions yoRadio/data/www/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,30 @@ <h2 class="pagetitle">SёTTINGS</h2>
<div class="row-title"><span>screensaver</span></div>
<div class="flex-row group group_tft group_oled group_nextion hidden" style="margin-top:20px;">
<div class="inputwrap">
<span class="inputtitle">screensaver enabled</span>
<span class="inputtitle">while not playing</span>
<div class="checkbox off nous" id="screensaverenabled" style="padding-top:16px;"></div>
</div>
<div class="inputwrap">
<span class="inputtitle">screensaver timeout (sec)</span>
<input type="number" id="screensavertimeout" class="textinput inputchange" name="screensavertimeout" value="" maxlength="3" min="0" max="65520" />
<span class="inputtitle">blank screen</span>
<div class="checkbox off nous" id="screensaverblank"></div>
</div>
<div class="inputwrap">
<span class="inputtitle">timeout (sec)</span>
<input type="number" id="screensavertimeout" class="textinput inputchange" name="screensavertimeout" value="" maxlength="3" min="5" max="65520" />
</div>
</div>
<div class="flex-row group group_tft group_oled group_nextion hidden">
<div class="inputwrap">
<span class="inputtitle">while playing</span>
<div class="checkbox off nous" id="screensaverplayingenabled"></div>
</div>
<div class="inputwrap">
<span class="inputtitle">blank screen</span>
<div class="checkbox off nous" id="screensaverplayingblank"></div>
</div>
<div class="inputwrap">
<span class="inputtitle">timeout (min)</span>
<input type="number" id="screensaverplayingtimeout" class="textinput inputchange" name="screensaverplayingtimeout" value="" maxlength="3" min="1" max="1080" />
</div>
</div>
</section>
Expand Down
2 changes: 1 addition & 1 deletion yoRadio/src/core/common.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef COMMON_H
#define COMMON_H

enum displayMode_e { PLAYER, VOL, STATIONS, NUMBERS, LOST, UPDATING, INFO, SETTINGS, TIMEZONE, WIFI, CLEAR, SLEEPING, SDCHANGE, SCREENSAVER };
enum displayMode_e { PLAYER, VOL, STATIONS, NUMBERS, LOST, UPDATING, INFO, SETTINGS, TIMEZONE, WIFI, CLEAR, SLEEPING, SDCHANGE, SCREENSAVER, SCREENBLANK };
enum pages_e : uint8_t { PG_PLAYER=0, PG_DIALOG=1, PG_PLAYLIST=2, PG_SCREENSAVER=3 };

enum displayRequestType_e { BOOTSTRING, NEWMODE, CLOCK, NEWTITLE, NEWSTATION, NEXTSTATION, DRAWPLAYLIST, DRAWVOL, DBITRATE, AUDIOINFO, SHOWVUMETER, DSPRSSI, SHOWWEATHER, NEWWEATHER, PSTOP, PSTART, DSP_START, WAITFORSD, SDFILEINDEX, NEWIP, NOPE };
Expand Down
9 changes: 9 additions & 0 deletions yoRadio/src/core/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void Config::init() {
EEPROM.begin(EEPROM_SIZE);
sdResumePos = 0;
screensaverTicks = 0;
screensaverPlayingTicks = 0;
isScreensaver = false;
bootInfo();
#if RTCSUPPORTED
Expand Down Expand Up @@ -97,6 +98,12 @@ void Config::_setupVersion(){
saveValue(store.mdnsname, buf, MDNS_LENGTH);
saveValue(&store.skipPlaylistUpDown, false);
break;
case 3:
saveValue(&store.screensaverBlank, false);
saveValue(&store.screensaverPlayingEnabled, false);
saveValue(&store.screensaverPlayingTimeout, (uint16_t)5);
saveValue(&store.screensaverPlayingBlank, false);
break;
default:
break;
}
Expand Down Expand Up @@ -353,6 +360,8 @@ void Config::setDefaults() {
store.screensaverTimeout = 20;
snprintf(store.mdnsname, MDNS_LENGTH, "yoradio-%x", getChipId());
store.skipPlaylistUpDown = false;
store.screensaverPlayingEnabled = false;
store.screensaverPlayingTimeout = 5;
eepromWrite(EEPROM_START, store);
}

Expand Down
7 changes: 6 additions & 1 deletion yoRadio/src/core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0)
#define ESP_ARDUINO_3 1
#endif
#define CONFIG_VERSION 3
#define CONFIG_VERSION 4

enum playMode_e : uint8_t { PM_WEB=0, PM_SDCARD=1 };
enum BitrateFormat { BF_UNCNOWN, BF_MP3, BF_AAC, BF_FLAC, BF_OGG, BF_WAV };
Expand Down Expand Up @@ -136,6 +136,10 @@ struct config_t
bool rotate90;
bool screensaverEnabled;
uint16_t screensaverTimeout;
bool screensaverBlank;
bool screensaverPlayingEnabled;
uint16_t screensaverPlayingTimeout;
bool screensaverPlayingBlank;
char mdnsname[24];
bool skipPlaylistUpDown;
};
Expand Down Expand Up @@ -181,6 +185,7 @@ class Config {
bool emptyFS;
uint16_t vuThreshold;
uint16_t screensaverTicks;
uint16_t screensaverPlayingTicks;
bool isScreensaver;
public:
Config() {};
Expand Down
6 changes: 4 additions & 2 deletions yoRadio/src/core/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,13 @@ void Display::_swichMode(displayMode_e newmode) {
_pager.setPage( pages[PG_PLAYER]);
pm.on_display_player();
}
if (newmode == SCREENSAVER) {
if (newmode == SCREENSAVER || newmode == SCREENBLANK) {
config.isScreensaver = true;
_pager.setPage( pages[PG_SCREENSAVER]);
if (newmode == SCREENBLANK) dsp.clearClock();
}else{
config.screensaverTicks=SCREENSAVERSTARTUPDELAY;
config.screensaverPlayingTicks=SCREENSAVERSTARTUPDELAY;
config.isScreensaver = false;
}
if (newmode == VOL) {
Expand Down Expand Up @@ -533,7 +535,7 @@ void Display::_time(bool redraw) {
}
#endif
if(config.isScreensaver && network.timeinfo.tm_sec % 60 == 0)
_clock.moveTo({clockConf.left, random(TFT_FRAMEWDT+clockConf.textsize, (dsp.height()-TFT_FRAMEWDT*2)), 0});
_clock.moveTo({clockConf.left, static_cast<uint16_t>(random(TFT_FRAMEWDT+clockConf.textsize, (dsp.height()-dsp.plItemHeight-TFT_FRAMEWDT*2))), 0});
_clock.draw();
/*#ifdef USE_NEXTION
nextion.printClock(network.timeinfo);
Expand Down
47 changes: 44 additions & 3 deletions yoRadio/src/core/netserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ void NetServer::processQueue(){
config.vuThreshold,
config.store.mdnsname);
break;
case GETSCREEN: sprintf (wsbuf, "{\"flip\":%d,\"inv\":%d,\"nump\":%d,\"tsf\":%d,\"tsd\":%d,\"dspon\":%d,\"br\":%d,\"con\":%d,\"scre\":%d,\"scrt\":%d}",
case GETSCREEN: sprintf (wsbuf, "{\"flip\":%d,\"inv\":%d,\"nump\":%d,\"tsf\":%d,\"tsd\":%d,\"dspon\":%d,\"br\":%d,\"con\":%d,\"scre\":%d,\"scrt\":%d,\"scrb\":%d,\"scrpe\":%d,\"scrpt\":%d,\"scrpb\":%d}",
config.store.flipscreen,
config.store.invertdisplay,
config.store.numplaylist,
Expand All @@ -308,7 +308,11 @@ void NetServer::processQueue(){
config.store.brightness,
config.store.contrast,
config.store.screensaverEnabled,
config.store.screensaverTimeout);
config.store.screensaverTimeout,
config.store.screensaverBlank,
config.store.screensaverPlayingEnabled,
config.store.screensaverPlayingTimeout,
config.store.screensaverPlayingBlank);
break;
case GETTIMEZONE: sprintf (wsbuf, "{\"tzh\":%d,\"tzm\":%d,\"sntp1\":\"%s\",\"sntp2\":\"%s\"}",
config.store.tzHour,
Expand Down Expand Up @@ -507,13 +511,46 @@ void NetServer::onWsMessage(void *arg, uint8_t *data, size_t len, uint8_t client
}
if (strcmp(cmd, "screensavertimeout") == 0) {
uint16_t valb = atoi(val);
valb = constrain(valb,0,65520);
valb = constrain(valb,5,65520);
config.saveValue(&config.store.screensaverTimeout, valb);
#ifndef DSP_LCD
display.putRequest(NEWMODE, PLAYER);
#endif
return;
}
if (strcmp(cmd, "screensaverblank") == 0) {
bool valb = static_cast<bool>(atoi(val));
config.saveValue(&config.store.screensaverBlank, valb);
#ifndef DSP_LCD
display.putRequest(NEWMODE, PLAYER);
#endif
return;
}
if (strcmp(cmd, "screensaverplayingenabled") == 0) {
bool valb = static_cast<bool>(atoi(val));
config.saveValue(&config.store.screensaverPlayingEnabled, valb);
#ifndef DSP_LCD
display.putRequest(NEWMODE, PLAYER);
#endif
return;
}
if (strcmp(cmd, "screensaverplayingtimeout") == 0) {
uint16_t valb = atoi(val);
valb = constrain(valb,1,1080);
config.saveValue(&config.store.screensaverPlayingTimeout, valb);
#ifndef DSP_LCD
display.putRequest(NEWMODE, PLAYER);
#endif
return;
}
if (strcmp(cmd, "screensaverplayingblank") == 0) {
bool valb = static_cast<bool>(atoi(val));
config.saveValue(&config.store.screensaverPlayingBlank, valb);
#ifndef DSP_LCD
display.putRequest(NEWMODE, PLAYER);
#endif
return;
}
if (strcmp(cmd, "tzh") == 0) {
int8_t vali = atoi(val);
config.saveValue(&config.store.tzHour, vali);
Expand Down Expand Up @@ -613,6 +650,10 @@ void NetServer::onWsMessage(void *arg, uint8_t *data, size_t len, uint8_t client
config.saveValue(&config.store.numplaylist, false);
config.saveValue(&config.store.screensaverEnabled, false);
config.saveValue(&config.store.screensaverTimeout, (uint16_t)20);
config.saveValue(&config.store.screensaverBlank, f F438 alse);
config.saveValue(&config.store.screensaverPlayingEnabled, false);
config.saveValue(&config.store.screensaverPlayingTimeout, (uint16_t)5);
config.saveValue(&config.store.screensaverPlayingBlank, false);
display.putRequest(NEWMODE, CLEAR); display.putRequest(NEWMODE, PLAYER);
requestOnChange(GETSCREEN, clientId);
return;
Expand Down
19 changes: 18 additions & 1 deletion yoRadio/src/core/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,24 @@ void ticks() {
}
#ifndef DSP_LCD
if(config.store.screensaverEnabled && display.mode()==PLAYER && !player.isRunning()){
if(config.screensaverTicks++ > config.store.screensaverTimeout+SCREENSAVERSTARTUPDELAY) display.putRequest(NEWMODE, SCREENSAVER);
config.screensaverTicks++;
if(config.screensaverTicks > config.store.screensaverTimeout+SCREENSAVERSTARTUPDELAY){
if(config.store.screensaverBlank){
display.putRequest(NEWMODE, SCREENBLANK);
}else{
display.putRequest(NEWMODE, SCREENSAVER);
}
}
}
if(config.store.screensaverPlayingEnabled && display.mode()==PLAYER && player.isRunning()){
config.screensaverPlayingTicks++;
if(config.screensaverPlayingTicks > config.store.screensaverPlayingTimeout*60+SCREENSAVERSTARTUPDELAY){
if(config.store.screensaverPlayingBlank){
display.putRequest(NEWMODE, SCREENBLANK);
}else{
display.putRequest(NEWMODE, SCREENSAVER);
}
}
}
#endif
#if RTCSUPPORTED
Expand Down
1 change: 1 addition & 0 deletions yoRadio/src/core/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ void Player::_play(uint16_t stationId) {
config.vuThreshold = 0;
//display.putRequest(PSTOP);
config.screensaverTicks=SCREENSAVERSTARTUPDELAY;
config.screensaverPlayingTicks=SCREENSAVERSTARTUPDELAY;
if(config.getMode()!=PM_SDCARD) {
display.putRequest(PSTOP);
}
Expand Down
0