This commit is contained in:
e2002
2024-12-27 17:53:19 +03:00
parent 8a3fc15f60
commit c2c1908f96
9 changed files with 107 additions and 17 deletions

Binary file not shown.

View File

@@ -37,7 +37,14 @@
<span class="inputinfo" id="slsoftapinfo">0</span>
<input type="range" id="slsoftap" class="slider" data-slaveid="slsoftapinfo" name="softap" min="0" max="20" value="0">
</div>
</div>
</div>
<div class="flex-row" id="mdnsnamerow">
<div class="inputwrap">
<span class="inputtitle">mDNS name</span>
<input type="text" id="mdnsname" class="textinput inputchange" name="mdnsname" value="" maxlength="24" />
</div>
<div class="button apply hlbutton" data-name="rebootmdns" style=" margin-top: 24px; height: 37px;">save</div>
</div>
<div class="row-title"><span>update</span></div>
<div class="flex-row last">
<div class="button apply" data-name="fwupdate" id="fwupdate">Firmware</div>
@@ -70,7 +77,10 @@
</div>
<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="checkbox off nous" id="screensaverenabled">screensaver enabled</div>
<div class="inputwrap">
<span class="inputtitle">screensaver enabled</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" />
@@ -97,6 +107,12 @@
<input type="range" id="slencacceleration" class="slider" data-slaveid="slencaccelerationinfo" name="encacceleration" min="0" max="700" value="200">
</div>
</div>
<div class="flex-row">
<div class="inputwrap">
<span class="inputtitle">one-click station switching</span>
<div class="checkbox off nous" id="oneclickswitching"></div>
</div>
</div>
<div class="flex-row group group_ir hidden">
<div class="inputwrap">
<span class="inputtitle">IR tolerance [<a href="https://crankyoldgit.github.io/IRremoteESP8266/doxygen/html/" target="_blank">docs</a>]</span>

View File

@@ -92,6 +92,10 @@ void Config::_setupVersion(){
saveValue(&store.screensaverTimeout, (uint16_t)20);
break;
case 2:
char buf[MDNS_LENGTH];
snprintf(buf, MDNS_LENGTH, "yoradio-%x", getChipId());
saveValue(store.mdnsname, buf, MDNS_LENGTH);
saveValue(&store.skipPlaylistUpDown, false);
break;
default:
break;
@@ -347,6 +351,8 @@ void Config::setDefaults() {
store.rotate90 = false;
store.screensaverEnabled = false;
store.screensaverTimeout = 20;
snprintf(store.mdnsname, MDNS_LENGTH, "yoradio-%x", getChipId());
store.skipPlaylistUpDown = false;
eepromWrite(EEPROM_START, store);
}
@@ -626,7 +632,7 @@ bool Config::parseWsCommand(const char* line, char* cmd, char* val, uint8_t cSiz
if (tmpe == NULL) return false;
memset(cmd, 0, cSize);
strlcpy(cmd, line, tmpe - line + 1);
if (strlen(tmpe + 1) == 0) return false;
//if (strlen(tmpe + 1) == 0) return false;
memset(val, 0, cSize);
strlcpy(val, tmpe + 1, strlen(line) - strlen(cmd) + 1);
return true;

View File

@@ -39,13 +39,14 @@
#define MAX_PLAY_MODE 1
#define WEATHERKEY_LENGTH 58
#define MDNS_LENGTH 24
#if SDC_CS!=255
#define USE_SD
#endif
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0)
#define ESP_ARDUINO_3 1
#endif
#define CONFIG_VERSION 2
#define CONFIG_VERSION 3
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 };
@@ -135,6 +136,8 @@ struct config_t
bool rotate90;
bool screensaverEnabled;
uint16_t screensaverTimeout;
char mdnsname[24];
bool skipPlaylistUpDown;
};
#if IR_PIN!=255
@@ -260,6 +263,13 @@ class Config {
if(commit)
EEPROM.commit();
}
uint32_t getChipId(){
uint32_t chipId = 0;
for(int i=0; i<17; i=i+8) {
chipId |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
}
return chipId;
}
private:
template <class T> int eepromWrite(int ee, const T& value);
template <class T> int eepromRead(int ee, T& value);

View File

@@ -180,6 +180,10 @@ void encodersLoop(yoEncoder *enc, bool first){
controlsEvent(encoderDelta > 0, encoderDelta);
}else{
if (encBtnState == HIGH && display.mode() == PLAYER) {
if(config.store.skipPlaylistUpDown){
if(encoderDelta > 0) player.next(); else player.prev();
return;
}
display.putRequest(NEWMODE, STATIONS);
while(display.mode() != STATIONS) {delay(10);}
}
@@ -521,7 +525,15 @@ void onBtnClick(int id) {
}
} else {
if (display.mode() == PLAYER) {
display.putRequest(NEWMODE, STATIONS);
if(config.store.skipPlaylistUpDown){
if (id == EVT_BTNUP) {
player.prev();
} else {
player.next();
}
}else{
display.putRequest(NEWMODE, STATIONS);
}
}
if (display.mode() == STATIONS) {
controlsEvent(id == EVT_BTNDOWN);

View File

@@ -10,6 +10,7 @@
#include "mqtt.h"
#include "controls.h"
#include <Update.h>
#include <ESPmDNS.h>
#ifdef USE_SD
#include "sdmanager.h"
#endif
@@ -97,6 +98,8 @@ bool NetServer::begin(bool quiet) {
DefaultHeaders::Instance().addHeader(F("Access-Control-Allow-Headers"), F("content-type"));
#endif
webserver.begin();
if(strlen(config.store.mdnsname)>0)
MDNS.begin(config.store.mdnsname);
websocket.onEvent(onWsEvent);
webserver.addHandler(&websocket);
@@ -287,12 +290,13 @@ void NetServer::processQueue(){
return;
break;
}
case GETSYSTEM: sprintf (wsbuf, "{\"sst\":%d,\"aif\":%d,\"vu\":%d,\"softr\":%d,\"vut\":%d}",
case GETSYSTEM: sprintf (wsbuf, "{\"sst\":%d,\"aif\":%d,\"vu\":%d,\"softr\":%d,\"vut\":%d,\"mdns\":\"%s\"}",
config.store.smartstart != 2,
config.store.audioinfo,
config.store.vumeter,
config.store.softapdelay,
config.vuThreshold);
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}",
config.store.flipscreen,
@@ -318,10 +322,11 @@ void NetServer::processQueue(){
config.store.weatherlon,
config.store.weatherkey);
break;
case GETCONTROLS: sprintf (wsbuf, "{\"vols\":%d,\"enca\":%d,\"irtl\":%d}",
case GETCONTROLS: sprintf (wsbuf, "{\"vols\":%d,\"enca\":%d,\"irtl\":%d,\"skipup\":%d}",
config.store.volsteps,
config.store.encacc,
config.store.irtlp);
config.store.irtlp,
config.store.skipPlaylistUpDown);
break;
case DSPON: sprintf (wsbuf, "{\"dspontrue\":%d}", 1); break;
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
config.saveValue(&config.store.softapdelay, valb);
return;
}
if (strcmp(cmd, "mdnsname") == 0) {
config.saveValue(config.store.mdnsname, val, MDNS_LENGTH);
return;
}
if (strcmp(cmd, "rebootmdns") == 0) {
char buf[MDNS_LENGTH*2];
if(strlen(config.store.mdnsname)>0)
snprintf(buf, MDNS_LENGTH*2, "{\"redirect\": \"http://%s.local\"}", config.store.mdnsname);
else
snprintf(buf, MDNS_LENGTH*2, "{\"redirect\": \"http://%s/\"}", WiFi.localIP().toString().c_str());
websocket.text(clientId, buf);
delay(500);
ESP.restart();
return;
}
if (strcmp(cmd, "invertdisplay") == 0) {
bool valb = static_cast<bool>(atoi(val));
config.saveValue(&config.store.invertdisplay, valb);
@@ -540,6 +560,11 @@ void NetServer::onWsMessage(void *arg, uint8_t *data, size_t len, uint8_t client
setIRTolerance(valb);
return;
}
if (strcmp(cmd, "oneclickswitching") == 0) {
bool valb = static_cast<bool>(atoi(val));
config.saveValue(&config.store.skipPlaylistUpDown, valb);
return;
}
if (strcmp(cmd, "showweather") == 0) {
bool valb = static_cast<bool>(atoi(val));
config.saveValue(&config.store.showweather, valb);
@@ -568,7 +593,9 @@ void NetServer::onWsMessage(void *arg, uint8_t *data, size_t len, uint8_t client
config.saveValue(&config.store.smartstart, (uint8_t)2, false);
config.saveValue(&config.store.audioinfo, false, false);
config.saveValue(&config.store.vumeter, false, false);
config.saveValue(&config.store.softapdelay, (uint8_t)0);
config.saveValue(&config.store.softapdelay, (uint8_t)0, false);
snprintf(config.store.mdnsname, MDNS_LENGTH, "yoradio-%x", config.getChipId());
config.saveValue(config.store.mdnsname, config.store.mdnsname, MDNS_LENGTH, true, true);
display.putRequest(NEWMODE, CLEAR); display.putRequest(NEWMODE, PLAYER);
requestOnChange(GETSYSTEM, clientId);
return;
@@ -584,13 +611,15 @@ void NetServer::onWsMessage(void *arg, uint8_t *data, size_t len, uint8_t client
config.saveValue(&config.store.contrast, (uint8_t)55, false);
display.setContrast();
config.saveValue(&config.store.numplaylist, false);
config.saveValue(&config.store.screensaverEnabled, false);
config.saveValue(&config.store.screensaverTimeout, (uint16_t)20);
display.putRequest(NEWMODE, CLEAR); display.putRequest(NEWMODE, PLAYER);
requestOnChange(GETSCREEN, clientId);
return;
}
if (strcmp(val, "timezone") == 0) {
config.store.tzHour = 3;
config.store.tzMin = 0;
config.saveValue(&config.store.tzHour, (int8_t)3, false);
config.saveValue(&config.store.tzMin, (int8_t)0, false);
config.saveValue(config.store.sntp1, "pool.ntp.org", 35, false);
config.saveValue(config.store.sntp2, "0.ru.pool.ntp.org", 35);
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
return;
}
if (strcmp(val, "weather") == 0) {
config.store.showweather = 0;
config.saveValue(&config.store.showweather, false, false);
config.saveValue(config.store.weatherlat, "55.7512", 10, false);
config.saveValue(config.store.weatherlon, "37.6184", 10, false);
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
return;
}
if (strcmp(val, "controls") == 0) {
config.store.volsteps = 1;
config.store.fliptouch = false;
config.store.dbgtouch = false;
config.saveValue(&config.store.volsteps, (uint8_t)1, false);
config.saveValue(&config.store.fliptouch, false, false);
config.saveValue(&config.store.dbgtouch, false, false);
config.saveValue(&config.store.skipPlaylistUpDown, false);
setEncAcceleration(200);
setIRTolerance(40);
requestOnChange(GETCONTROLS, clientId);

View File

@@ -119,6 +119,16 @@ bool MyNetwork::wifiBegin(bool silent){
uint8_t startedls = ls;
uint8_t errcnt = 0;
WiFi.mode(WIFI_STA);
/*
char buf[MDNS_LENGTH];
WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);
if(strlen(config.store.mdnsname)>0){
WiFi.setHostname(config.store.mdnsname);
}else{
snprintf(buf, MDNS_LENGTH, "yoradio-%x", config.getChipId());
WiFi.setHostname(buf);
}
*/
while (true) {
if(!silent){
Serial.printf("##[BOOT]#\tAttempt to connect to %s\n", config.ssids[ls].ssid);

View File

@@ -1,7 +1,7 @@
#ifndef options_h
#define options_h
#define YOVERSION "0.9.399"
#define YOVERSION "0.9.412"
/*******************************************************
DO NOT EDIT THIS FILE.