Skip to content

Commit c2c1908

Browse files
committed
v0.9.412
1 parent 8a3fc15 commit c2c1908

File tree

9 files changed

+107
-17
lines changed

9 files changed

+107
-17
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@ Work is in progress...
234234

235235
---
236236
## Version history
237+
### v0.9.412
238+
**!!! a [full update](#update-over-web-interface) with Sketch data upload is required. After updating please press CTRL+F5 in browser !!!**
239+
- added mDNS support, configurable via the web interface, pull[#125](https://github.com/e2002/yoradio/pull/125)
240+
- added a setting that allows you to switch stations with the UP and DOWN buttons immediately, bypassing the playlist, configurable via the web interface, pull[#125](https://github.com/e2002/yoradio/pull/125)
241+
237242
### v0.9.399
238243
**!!! a [full update](#update-over-web-interface) with Sketch data upload is required. After updating please press CTRL+F5 in browser !!!**
239244
- added a screensaver mode, configurable via the web interface.

yoRadio/data/www/script.js.gz

156 Bytes
Binary file not shown.

yoRadio/data/www/settings.html

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,14 @@ <h2 class="pagetitle">SёTTINGS</h2>
3737
<span class="inputinfo" id="slsoftapinfo">0</span>
3838
<input type="range" id="slsoftap" class="slider" data-slaveid="slsoftapinfo" name="softap" min="0" max="20" value="0">
3939
</div>
40-
</div>
40+
</div>
41+
<div class="flex-row" id="mdnsnamerow">
42+
<div class="inputwrap">
43+
<span class="inputtitle">mDNS name</span>
44+
<input type="text" id="mdnsname" class="textinput inputchange" name="mdnsname" value="" maxlength="24" />
45+
</div>
46+
<div class="button apply hlbutton" data-name="rebootmdns" style=" margin-top: 24px; height: 37px;">save</div>
47+
</div>
4148
<div class="row-title"><span>update</span></div>
4249
<div class="flex-row last">
4350
<div class="button apply" data-name="fwupdate" id="fwupdate">Firmware</div>
@@ -70,7 +77,10 @@ <h2 class="pagetitle">SёTTINGS</h2>
7077
</div>
7178
<div class="row-title"><span>screensaver</span></div>
7279
<div class="flex-row group group_tft group_oled group_nextion hidden" style="margin-top:20px;">
73-
<div class="checkbox off nous" id="screensaverenabled">screensaver enabled</div>
80+
<div class="inputwrap">
81+
<span class="inputtitle">screensaver enabled</span>
82+
<div class="checkbox off nous" id="screensaverenabled" style="padding-top:16px;"></div>
83+
</div>
7484
<div class="inputwrap">
7585
<span class="inputtitle">screensaver timeout (sec)</span>
7686
<input type="number" id="screensavertimeout" class="textinput inputchange" name="screensavertimeout" value="" maxlength="3" min="0" max="65520" />
@@ -97,6 +107,12 @@ <h2 class="pagetitle">SёTTINGS</h2>
97107
<input type="range" id="slencacceleration" class="slider" data-slaveid="slencaccelerationinfo" name="encacceleration" min="0" max="700" value="200">
98108
</div>
99109
</div>
110+
<div class="flex-row">
111+
<div class="inputwrap">
112+
<span class="inputtitle">one-click station switching</span>
113+
<div class="checkbox off nous" id="oneclickswitching"></div>
114+
</div>
115+
</div>
100116
<div class="flex-row group group_ir hidden">
101117
<div class="inputwrap">
102118
<span class="inputtitle">IR tolerance [<a href="https://crankyoldgit.github.io/IRremoteESP8266/doxygen/html/" target="_blank">docs</a>]</span>

yoRadio/src/core/config.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ void Config::_setupVersion(){
9292
saveValue(&store.screensaverTimeout, (uint16_t)20);
9393
break;
9494
case 2:
95+
char buf[MDNS_LENGTH];
96+
snprintf(buf, MDNS_LENGTH, "yoradio-%x", getChipId());
97+
saveValue(store.mdnsname, buf, MDNS_LENGTH);
98+
saveValue(&store.skipPlaylistUpDown, false);
9599
break;
96100
default:
97101
break;
@@ -347,6 +351,8 @@ void Config::setDefaults() {
347351
store.rotate90 = false;
348352
store.screensaverEnabled = false;
349353
store.screensaverTimeout = 20;
354+
snprintf(store.mdnsname, MDNS_LENGTH, "yoradio-%x", getChipId());
355+
store.skipPlaylistUpDown = false;
350356
eepromWrite(EEPROM_START, store);
351357
}
352358

@@ -626,7 +632,7 @@ bool Config::parseWsCommand(const char* line, char* cmd, char* val, uint8_t cSiz
626632
if (tmpe == NULL) return false;
627633
memset(cmd, 0, cSize);
628634
strlcpy(cmd, line, tmpe - line + 1);
629-
if (strlen(tmpe + 1) == 0) return false;
635+
//if (strlen(tmpe + 1) == 0) return false;
630636
memset(val, 0, cSize);
631637
strlcpy(val, tmpe + 1, strlen(line) - strlen(cmd) + 1);
632638
return true;

yoRadio/src/core/config.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@
3939

4040
#define MAX_PLAY_MODE 1
4141
#define WEATHERKEY_LENGTH 58
42+
#define MDNS_LENGTH 24
4243
#if SDC_CS!=255
4344
#define USE_SD
4445
#endif
4546
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0)
4647
#define ESP_ARDUINO_3 1
4748
#endif
48-
#define CONFIG_VERSION 2
49+
#define CONFIG_VERSION 3
4950

5051
enum playMode_e : uint8_t { PM_WEB=0, PM_SDCARD=1 };
5152
enum BitrateFormat { BF_UNCNOWN, BF_MP3, BF_AAC, BF_FLAC, BF_OGG, BF_WAV };
@@ -135,6 +136,8 @@ struct config_t
135136
bool rotate90;
136137
bool screensaverEnabled;
137138
uint16_t screensaverTimeout;
139+
char mdnsname[24];
140+
bool skipPlaylistUpDown;
138141
};
139142

140143
#if IR_PIN!=255
@@ -260,6 +263,13 @@ class Config {
260263
if(commit)
261264
EEPROM.commit();
262265
}
266+
uint32_t getChipId(){
267+
uint32_t chipId = 0;
268+
for(int i=0; i<17; i=i+8) {
269+
chipId |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
270+
}
271+
return chipId;
272+
}
263273
private:
264274
template <class T> int eepromWrite(int ee, const T& value);
265275
template <class T> int eepromRead(int ee, T& value);

yoRadio/src/core/controls.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ void encodersLoop(yoEncoder *enc, bool first){
180180
controlsEvent(encoderDelta > 0, encoderDelta);
181181
}else{
182182
if (encBtnState == HIGH && display.mode() == PLAYER) {
183+
if(config.store.skipPlaylistUpDown){
184+
if(encoderDelta > 0) player.next(); else player.prev();
185+
return;
186+
}
183187
display.putRequest(NEWMODE, STATIONS);
184188
while(display.mode() != STATIONS) {delay(10);}
185189
}
@@ -521,7 +525,15 @@ void onBtnClick(int id) {
521525
}
522526
} else {
523527
if (display.mode() == PLAYER) {
524-
display.putRequest(NEWMODE, STATIONS);
528+
if(config.store.skipPlaylistUpDown){
529+
if (id == EVT_BTNUP) {
530+
player.prev();
531+
} else {
532+
player.next();
533+
}
534+
}else{
535+
display.putRequest(NEWMODE, STATIONS);
536+
}
525537
}
526538
if (display.mode() == STATIONS) {
527539
controlsEvent(id == EVT_BTNDOWN);

yoRadio/src/core/netserver.cpp

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "mqtt.h"
1111
#include "controls.h"
1212
#include <Update.h>
13+
#include <ESPmDNS.h>
1314
#ifdef USE_SD
1415
#include "sdmanager.h"
1516
#endif
@@ -97,6 +98,8 @@ bool NetServer::begin(bool quiet) {
9798
DefaultHeaders::Instance().addHeader(F("Access-Control-Allow-Headers"), F("content-type"));
9899
#endif
99100
webserver.begin();
101+
if(strlen(config.store.mdnsname)>0)
102+
MDNS.begin(config.store.mdnsname);
100103
websocket.onEvent(onWsEvent);
101104
webserver.addHandler(&websocket);
102105

@@ -287,12 +290,13 @@ void NetServer::processQueue(){
287290
return;
288291
break;
289292
}
290-
case GETSYSTEM: sprintf (wsbuf, "{\"sst\":%d,\"aif\":%d,\"vu\":%d,\"softr\":%d,\"vut\":%d}",
293+
case GETSYSTEM: sprintf (wsbuf, "{\"sst\":%d,\"aif\":%d,\"vu\":%d,\"softr\":%d,\"vut\":%d,\"mdns\":\"%s\"}",
291294
config.store.smartstart != 2,
292295
config.store.audioinfo,
293296
config.store.vumeter,
294297
config.store.softapdelay,
295-
config.vuThreshold);
298+
config.vuThreshold,
299+
config.store.mdnsname);
296300
break;
297301
case GETSCREEN: sprintf (wsbuf, "{\"flip\":%d,\"inv\":%d,\"nump\":%d,\"tsf\":%d,\"tsd\":%d,\"dspon\":%d,\"br\":%d,\"con\":%d,\"scre\":%d,\"scrt\":%d}",
298302
config.store.flipscreen,
@@ -318,10 +322,11 @@ void NetServer::processQueue(){
318322
config.store.weatherlon,
319323
config.store.weatherkey);
320324
break;
321-
case GETCONTROLS: sprintf (wsbuf, "{\"vols\":%d,\"enca\":%d,\"irtl\":%d}",
325+
case GETCONTROLS: sprintf (wsbuf, "{\"vols\":%d,\"enca\":%d,\"irtl\":%d,\"skipup\":%d}",
322326
config.store.volsteps,
323327
config.store.encacc,
324-
config.store.irtlp);
328+
config.store.irtlp,
329+
config.store.skipPlaylistUpDown);
325330
break;
326331
case DSPON: sprintf (wsbuf, "{\"dspontrue\":%d}", 1); break;
327332
case STATION: requestOnChange(STATIONNAME, clientId); requestOnChange(ITEM, clientId); break;
@@ -429,6 +434,21 @@ void NetServer::onWsMessage(void *arg, uint8_t *data, size_t len, uint8_t client
429434
config.saveValue(&config.store.softapdelay, valb);
430435
return;
431436
}
437+
if (strcmp(cmd, "mdnsname") == 0) {
438+
config.saveValue(config.store.mdnsname, val, MDNS_LENGTH);
439+
return;
440+
}
441+
if (strcmp(cmd, "rebootmdns") == 0) {
442+
char buf[MDNS_LENGTH*2];
443+
if(strlen(config.store.mdnsname)>0)
444+
snprintf(buf, MDNS_LENGTH*2, "{\"redirect\": \"http://%s.local\"}", config.store.mdnsname);
445+
else
446+
snprintf(buf, MDNS_LENGTH*2, "{\"redirect\": \"http://%s/\"}", WiFi.localIP().toString().c_str());
447+
websocket.text(clientId, buf);
448+
delay(500);
449+
ESP.restart();
450+
return;
451+
}
432452
if (strcmp(cmd, "invertdisplay") == 0) {
433453
bool valb = static_cast<bool>(atoi(val));
434454
config.saveValue(&config.store.invertdisplay, valb);
@@ -540,6 +560,11 @@ void NetServer::onWsMessage(void *arg, uint8_t *data, size_t len, uint8_t client
540560
setIRTolerance(valb);
541561
return;
542562
}
563+
if (strcmp(cmd, "oneclickswitching") == 0) {
564+
bool valb = static_cast<bool>(atoi(val));
565+
config.saveValue(&config.store.skipPlaylistUpDown, valb);
566+
return;
567+
}
543568
if (strcmp(cmd, "showweather") == 0) {
544569
bool valb = static_cast<bool>(atoi(val));
545570
config.saveValue(&config.store.showweather, valb);
@@ -568,7 +593,9 @@ void NetServer::onWsMessage(void *arg, uint8_t *data, size_t len, uint8_t client
568593
config.saveValue(&config.store.smartstart, (uint8_t)2, false);
569594
config.saveValue(&config.store.audioinfo, false, false);
570595
config.saveValue(&config.store.vumeter, false, false);
571-
config.saveValue(&config.store.softapdelay, (uint8_t)0);
596+
config.saveValue(&config.store.softapdelay, (uint8_t)0, false);
597+
snprintf(config.store.mdnsname, MDNS_LENGTH, "yoradio-%x", config.getChipId());
598+
config.saveValue(config.store.mdnsname, config.store.mdnsname, MDNS_LENGTH, true, true);
572599
display.putRequest(NEWMODE, CLEAR); display.putRequest(NEWMODE, PLAYER);
573600
requestOnChange(GETSYSTEM, clientId);
574601
return;
@@ -584,13 +611,15 @@ void NetServer::onWsMessage(void *arg, uint8_t *data, size_t len, uint8_t client
584611
config.saveValue(&config.store.contrast, (uint8_t)55, false);
585612
display.setContrast();
586613
config.saveValue(&config.store.numplaylist, false);
614+
config.saveValue(&config.store.screensaverEnabled, false);
615+
config.saveValue(&config.store.screensaverTimeout, (uint16_t)20);
587616
display.putRequest(NEWMODE, CLEAR); display.putRequest(NEWMODE, PLAYER);
588617
requestOnChange(GETSCREEN, clientId);
589618
return;
590619
}
591620
if (strcmp(val, "timezone") == 0) {
592-
config.store.tzHour = 3;
593-
config.store.tzMin = 0;
621+
config.saveValue(&config.store.tzHour, (int8_t)3, false);
622+
config.saveValue(&config.store.tzMin, (int8_t)0, false);
594623
config.saveValue(config.store.sntp1, "pool.ntp.org", 35, false);
595624
config.saveValue(config.store.sntp2, "0.ru.pool.ntp.org", 35);
596625
configTime(config.store.tzHour * 3600 + config.store.tzMin * 60, config.getTimezoneOffset(), config.store.sntp1, config.store.sntp2);
@@ -599,7 +628,7 @@ void NetServer::onWsMessage(void *arg, uint8_t *data, size_t len, uint8_t client
599628
return;
600629
}
601630
if (strcmp(val, "weather") == 0) {
602-
config.store.showweather = 0;
631+
config.saveValue(&config.store.showweather, false, false);
603632
config.saveValue(config.store.weatherlat, "55.7512", 10, false);
604633
config.saveValue(config.store.weatherlon, "37.6184", 10, false);
605634
config.saveValue(config.store.weatherkey, "", WEATHERKEY_LENGTH);
@@ -609,9 +638,11 @@ void NetServer::onWsMessage(void *arg, uint8_t *data, size_t len, uint8_t client
609638
return;
610639
}
611640
if (strcmp(val, "controls") == 0) {
612-
config.store.volsteps = 1;
613-
config.store.fliptouch = false;
614-
config.store.dbgtouch = false;
641+
config.saveValue(&config.store.volsteps, (uint8_t)1, false);
642+
config.saveValue(&config.store.fliptouch, false, false);
643+
config.saveValue(&config.store.dbgtouch, false, false);
644+
config.saveValue(&config.store.skipPlaylistUpDown, false);
645+
615646
setEncAcceleration(200);
616647
setIRTolerance(40);
617648
requestOnChange(GETCONTROLS, clientId);

yoRadio/src/core/network.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ bool MyNetwork::wifiBegin(bool silent){
119119
uint8_t startedls = ls;
120120
uint8_t errcnt = 0;
121121
WiFi.mode(WIFI_STA);
122+
/*
123+
char buf[MDNS_LENGTH];
124+
WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);
125+
if(strlen(config.store.mdnsname)>0){
126+
WiFi.setHostname(config.store.mdnsname);
127+
}else{
128+
snprintf(buf, MDNS_LENGTH, "yoradio-%x", config.getChipId());
129+
WiFi.setHostname(buf);
130+
}
131+
*/
122132
while (true) {
123133
if(!silent){
124134
Serial.printf("##[BOOT]#\tAttempt to connect to %s\n", config.ssids[ls].ssid);

yoRadio/src/core/options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef options_h
22
#define options_h
33

4-
#define YOVERSION "0.9.399"
4+
#define YOVERSION "0.9.412"
55

66
/*******************************************************
77
DO NOT EDIT THIS FILE.

0 commit comments

Comments
 (0)