This commit is contained in:
e2002
2024-12-17 15:31:43 +03:00
parent 3f5ed098de
commit 9ad82acc80
9 changed files with 77 additions and 13 deletions

View File

@@ -59,7 +59,6 @@ void Config::init() {
if (store.config_set != 4262) {
setDefaults();
eepromWrite(EEPROM_START, store);
}
if(store.version>CONFIG_VERSION) store.version=1;
while(store.version!=CONFIG_VERSION) _setupVersion();
@@ -285,7 +284,6 @@ template <class T> int Config::eepromRead(int ee, T& value) {
void Config::reset(){
setDefaults();
eepromWrite(EEPROM_START, store);
delay(500);
ESP.restart();
}
@@ -341,6 +339,7 @@ void Config::setDefaults() {
store.forcemono = false;
store.i2sinternal = false;
store.rotate90 = false;
eepromWrite(EEPROM_START, store);
}
void Config::setTimezone(int8_t tzh, int8_t tzm) {

View File

@@ -250,7 +250,8 @@ class Config {
if (strcmp(field, value) == 0 && !force) return;
strlcpy(field, value, N);
size_t address = getAddr(field);
for (size_t i = 0; i <= strlen(field); i++) EEPROM.write(address + i, field[i]);
size_t fieldlen = strlen(field);
for (size_t i = 0; i <=fieldlen ; i++) EEPROM.write(address + i, field[i]);
if(commit)
EEPROM.commit();
}

View File

@@ -840,6 +840,18 @@ void handleHTTPArgs(AsyncWebServerRequest * request) {
if (request->hasArg("next")) { player.next(); commandFound=true; }
if (request->hasArg("volm")) { player.stepVol(false); commandFound=true; }
if (request->hasArg("volp")) { player.stepVol(true); commandFound=true; }
#ifdef USE_SD
if (request->hasArg("mode")) {
AsyncWebParameter* p = request->getParam("mode");
int mm = atoi(p->value().c_str());
if(mm>2) mm=0;
if(mm==2)
config.changeMode();
else
config.changeMode(mm);
commandFound=true;
}
#endif
if (request->hasArg("reset")) { request->redirect("/"); request->send(200); config.reset(); return; }
if (request->hasArg("trebble") && request->hasArg("middle") && request->hasArg("bass")) {
AsyncWebParameter* pt = request->getParam("trebble", request->method() == HTTP_POST);

View File

@@ -50,9 +50,11 @@ void ticks() {
}
}
#if RTCSUPPORTED
rtc.getTime(&network.timeinfo);
mktime(&network.timeinfo);
display.putRequest(CLOCK);
if(config.isRTCFound()){
rtc.getTime(&network.timeinfo);
mktime(&network.timeinfo);
display.putRequest(CLOCK);
}
#else
if(network.timeinfo.tm_year>100 || network.status == SDREADY) {
network.timeinfo.tm_sec++;
@@ -185,9 +187,11 @@ void MyNetwork::begin() {
if(REAL_LEDBUILTIN!=255) digitalWrite(REAL_LEDBUILTIN, LOW);
#if RTCSUPPORTED
rtc.getTime(&network.timeinfo);
mktime(&network.timeinfo);
display.putRequest(CLOCK);
if(config.isRTCFound()){
rtc.getTime(&network.timeinfo);
mktime(&network.timeinfo);
display.putRequest(CLOCK);
}
#endif
ctimer.attach(1, ticks);
if (network_on_connect) network_on_connect();

View File

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

View File

@@ -296,6 +296,17 @@ void Telnet::on_input(const char* str, uint8_t clientId) {
player.sendCommand({PR_PLAY, (uint16_t)sb});
return;
}
#ifdef USE_SD
int mm;
if (sscanf(str, "mode %d", &mm) == 1 ) {
if (mm > 2) mm = 0;
if(mm==2)
config.changeMode();
else
config.changeMode(mm);
return;
}
#endif
if (strcmp(str, "sys.tzo") == 0 || strcmp(str, "tzo") == 0) {
printf(clientId, "##SYS.TZO#: %d:%d\n> ", config.store.tzHour, config.store.tzMin);
return;