sd_snuffle
This commit is contained in:
Binary file not shown.
@@ -25,8 +25,9 @@ void Config::init() {
|
|||||||
if (store.config_set != 4262) setDefaults();
|
if (store.config_set != 4262) setDefaults();
|
||||||
backupLastStation = store.lastStation;
|
backupLastStation = store.lastStation;
|
||||||
Serial.print("Config::init, backupLastStation=\t"); Serial.println(backupLastStation);
|
Serial.print("Config::init, backupLastStation=\t"); Serial.println(backupLastStation);
|
||||||
if(store.play_mode==80) store.play_mode=PM_WEB;
|
if(store.play_mode==80) store.play_mode=0b100;
|
||||||
|
sdSnuffle = bitRead(store.play_mode, 2);
|
||||||
|
store.play_mode = store.play_mode & 0b11;
|
||||||
//if (!SPIFFS.begin(false, "/spiffs", 30)) {
|
//if (!SPIFFS.begin(false, "/spiffs", 30)) {
|
||||||
if (!SPIFFS.begin(false)) {
|
if (!SPIFFS.begin(false)) {
|
||||||
return;
|
return;
|
||||||
@@ -159,7 +160,7 @@ void Config::setDefaults() {
|
|||||||
strlcpy(store.weatherkey,"", 64);
|
strlcpy(store.weatherkey,"", 64);
|
||||||
store.volsteps = 1;
|
store.volsteps = 1;
|
||||||
store.encacc = 200;
|
store.encacc = 200;
|
||||||
store.play_mode = 0;
|
store.play_mode = 0b100;
|
||||||
store.irtlp = 35;
|
store.irtlp = 35;
|
||||||
store.btnpullup = true;
|
store.btnpullup = true;
|
||||||
store.btnlongpress = 200;
|
store.btnlongpress = 200;
|
||||||
@@ -191,12 +192,20 @@ uint16_t Config::getTimezoneOffset() {
|
|||||||
|
|
||||||
void Config::save() {
|
void Config::save() {
|
||||||
uint16_t ls = store.lastStation;
|
uint16_t ls = store.lastStation;
|
||||||
|
uint8_t pm = store.play_mode;
|
||||||
if(store.play_mode==PM_SDCARD) store.lastStation = backupLastStation;
|
if(store.play_mode==PM_SDCARD) store.lastStation = backupLastStation;
|
||||||
if(store.play_mode==PM_WEB) backupLastStation = store.lastStation;
|
if(store.play_mode==PM_WEB) backupLastStation = store.lastStation;
|
||||||
|
bitWrite(store.play_mode, 2, sdSnuffle);
|
||||||
eepromWrite(EEPROM_START, store);
|
eepromWrite(EEPROM_START, store);
|
||||||
store.lastStation = ls;
|
store.lastStation = ls;
|
||||||
|
store.play_mode = pm;
|
||||||
|
}
|
||||||
|
void Config::setSnuffle(bool sn){
|
||||||
|
sdSnuffle=sn;
|
||||||
|
save();
|
||||||
|
if(sdSnuffle) player.next();
|
||||||
|
//player blah blah blah
|
||||||
}
|
}
|
||||||
|
|
||||||
#if IR_PIN!=255
|
#if IR_PIN!=255
|
||||||
void Config::saveIR(){
|
void Config::saveIR(){
|
||||||
eepromWrite(EEPROM_START_IR, ircodes);
|
eepromWrite(EEPROM_START_IR, ircodes);
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ class Config {
|
|||||||
uint16_t sleepfor;
|
uint16_t sleepfor;
|
||||||
uint32_t sdResumePos;
|
uint32_t sdResumePos;
|
||||||
uint16_t backupLastStation;
|
uint16_t backupLastStation;
|
||||||
|
bool sdSnuffle;
|
||||||
public:
|
public:
|
||||||
Config() {};
|
Config() {};
|
||||||
void save();
|
void save();
|
||||||
@@ -191,6 +192,7 @@ class Config {
|
|||||||
void sleepForAfter(uint16_t sleepfor, uint16_t sleepafter=0);
|
void sleepForAfter(uint16_t sleepfor, uint16_t sleepafter=0);
|
||||||
void bootInfo();
|
void bootInfo();
|
||||||
void doSleepW();
|
void doSleepW();
|
||||||
|
void setSnuffle(bool sn);
|
||||||
private:
|
private:
|
||||||
template <class T> int eepromWrite(int ee, const T& value);
|
template <class T> int eepromWrite(int ee, const T& value);
|
||||||
template <class T> int eepromRead(int ee, T& value);
|
template <class T> int eepromRead(int ee, T& value);
|
||||||
|
|||||||
@@ -423,6 +423,11 @@ void NetServer::onWsMessage(void *arg, uint8_t *data, size_t len, uint8_t client
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (strcmp(cmd, "snuffle") == 0) {
|
||||||
|
Serial.printf("snuffle=%s\t********************\n", val);
|
||||||
|
config.setSnuffle(strcmp(val, "true") == 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (strcmp(cmd, "balance") == 0) {
|
if (strcmp(cmd, "balance") == 0) {
|
||||||
int8_t valb = atoi(val);
|
int8_t valb = atoi(val);
|
||||||
player.setBalance(valb);
|
player.setBalance(valb);
|
||||||
@@ -587,7 +592,7 @@ void NetServer::requestOnChange(requestType_e request, uint8_t clientId) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GETMODE: sprintf (wsbuf, "{\"pmode\":\"%s\"}", network.status == CONNECTED ? "player" : "ap"); break;
|
case GETMODE: sprintf (wsbuf, "{\"pmode\":\"%s\"}", network.status == CONNECTED ? "player" : "ap"); break;
|
||||||
case GETINDEX: requestOnChange(STATION, clientId); requestOnChange(TITLE, clientId); requestOnChange(VOLUME, clientId); requestOnChange(EQUALIZER, clientId); requestOnChange(BALANCE, clientId); requestOnChange(BITRATE, clientId); requestOnChange(MODE, clientId); if (config.store.play_mode==PM_SDCARD) { requestOnChange(SDPOS, clientId); requestOnChange(SDLEN, clientId); } return; break;
|
case GETINDEX: requestOnChange(STATION, clientId); requestOnChange(TITLE, clientId); requestOnChange(VOLUME, clientId); requestOnChange(EQUALIZER, clientId); requestOnChange(BALANCE, clientId); requestOnChange(BITRATE, clientId); requestOnChange(MODE, clientId); if (config.store.play_mode==PM_SDCARD) { requestOnChange(SDPOS, clientId); requestOnChange(SDLEN, clientId); requestOnChange(SDSNUFFLE, clientId); } return; break;
|
||||||
case GETSYSTEM: sprintf (wsbuf, "{\"sst\":%d,\"aif\":%d,\"vu\":%d,\"softr\":%d}", config.store.smartstart != 2, config.store.audioinfo, config.store.vumeter, config.store.softapdelay); break;
|
case GETSYSTEM: sprintf (wsbuf, "{\"sst\":%d,\"aif\":%d,\"vu\":%d,\"softr\":%d}", config.store.smartstart != 2, config.store.audioinfo, config.store.vumeter, config.store.softapdelay); break;
|
||||||
case GETSCREEN: sprintf (wsbuf, "{\"flip\":%d,\"inv\":%d,\"nump\":%d,\"tsf\":%d,\"tsd\":%d,\"dspon\":%d,\"br\":%d,\"con\":%d}", config.store.flipscreen, config.store.invertdisplay, config.store.numplaylist, config.store.fliptouch, config.store.dbgtouch, config.store.dspon, config.store.brightness, config.store.contrast); break;
|
case GETSCREEN: sprintf (wsbuf, "{\"flip\":%d,\"inv\":%d,\"nump\":%d,\"tsf\":%d,\"tsd\":%d,\"dspon\":%d,\"br\":%d,\"con\":%d}", config.store.flipscreen, config.store.invertdisplay, config.store.numplaylist, config.store.fliptouch, config.store.dbgtouch, config.store.dspon, config.store.brightness, config.store.contrast); break;
|
||||||
case GETTIMEZONE: sprintf (wsbuf, "{\"tzh\":%d,\"tzm\":%d,\"sntp1\":\"%s\",\"sntp2\":\"%s\"}", config.store.tzHour, config.store.tzMin, config.store.sntp1, config.store.sntp2); break;
|
case GETTIMEZONE: sprintf (wsbuf, "{\"tzh\":%d,\"tzm\":%d,\"sntp1\":\"%s\",\"sntp2\":\"%s\"}", config.store.tzHour, config.store.tzMin, config.store.sntp1, config.store.sntp2); break;
|
||||||
@@ -602,11 +607,12 @@ void NetServer::requestOnChange(requestType_e request, uint8_t clientId) {
|
|||||||
case NRSSI: sprintf (wsbuf, "{\"rssi\": %d}", rssi); rssi = 255; break;
|
case NRSSI: sprintf (wsbuf, "{\"rssi\": %d}", rssi); rssi = 255; break;
|
||||||
case SDPOS: sprintf (wsbuf, "{\"sdpos\": %d,\"sdend\": %d,\"sdtpos\": %d,\"sdtend\": %d}", player.getFilePos(), player.getFileSize(), player.getAudioCurrentTime(), player.getAudioFileDuration()); break;
|
case SDPOS: sprintf (wsbuf, "{\"sdpos\": %d,\"sdend\": %d,\"sdtpos\": %d,\"sdtend\": %d}", player.getFilePos(), player.getFileSize(), player.getAudioCurrentTime(), player.getAudioFileDuration()); break;
|
||||||
case SDLEN: sprintf (wsbuf, "{\"sdmin\": %d,\"sdmax\": %d}", player.sd_min, player.sd_max); break;
|
case SDLEN: sprintf (wsbuf, "{\"sdmin\": %d,\"sdmax\": %d}", player.sd_min, player.sd_max); break;
|
||||||
|
case SDSNUFFLE: sprintf (wsbuf, "{\"snuffle\": %d}", config.sdSnuffle); break;
|
||||||
case BITRATE: sprintf (wsbuf, "{\"bitrate\": %d}", config.station.bitrate); break;
|
case BITRATE: sprintf (wsbuf, "{\"bitrate\": %d}", config.station.bitrate); break;
|
||||||
case MODE: sprintf (wsbuf, "{\"mode\": \"%s\"}", player.mode == PLAYING ? "playing" : "stopped"); break;
|
case MODE: sprintf (wsbuf, "{\"mode\": \"%s\"}", player.mode == PLAYING ? "playing" : "stopped"); break;
|
||||||
case EQUALIZER: sprintf (wsbuf, "{\"bass\": %d, \"middle\": %d, \"trebble\": %d}", config.store.bass, config.store.middle, config.store.trebble); break;
|
case EQUALIZER: sprintf (wsbuf, "{\"bass\": %d, \"middle\": %d, \"trebble\": %d}", config.store.bass, config.store.middle, config.store.trebble); break;
|
||||||
case BALANCE: sprintf (wsbuf, "{\"balance\": %d}", config.store.balance); break;
|
case BALANCE: sprintf (wsbuf, "{\"balance\": %d}", config.store.balance); break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
if (strlen(wsbuf) > 0) {
|
if (strlen(wsbuf) > 0) {
|
||||||
if (clientId == 0) { websocket.textAll(wsbuf); }else{ websocket.text(clientId, wsbuf); }
|
if (clientId == 0) { websocket.textAll(wsbuf); }else{ websocket.text(clientId, wsbuf); }
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include "ESPAsyncWebServer.h"
|
#include "ESPAsyncWebServer.h"
|
||||||
#include "AsyncUDP.h"
|
#include "AsyncUDP.h"
|
||||||
|
|
||||||
enum requestType_e : uint8_t { PLAYLIST=1, STATION=2, STATIONNAME=3, ITEM=4, TITLE=5, VOLUME=6, NRSSI=7, BITRATE=8, MODE=9, EQUALIZER=10, BALANCE=11, PLAYLISTSAVED=12, GETMODE=13, GETINDEX=14, GETACTIVE=15, GETSYSTEM=16, GETSCREEN=17, GETTIMEZONE=18, GETWEATHER=19, GETCONTROLS=20, DSPON=21, SDPOS=22, SDLEN=23 };
|
enum requestType_e : uint8_t { PLAYLIST=1, STATION=2, STATIONNAME=3, ITEM=4, TITLE=5, VOLUME=6, NRSSI=7, BITRATE=8, MODE=9, EQUALIZER=10, BALANCE=11, PLAYLISTSAVED=12, GETMODE=13, GETINDEX=14, GETACTIVE=15, GETSYSTEM=16, GETSCREEN=17, GETTIMEZONE=18, GETWEATHER=19, GETCONTROLS=20, DSPON=21, SDPOS=22, SDLEN=23, SDSNUFFLE=24 };
|
||||||
enum import_e : uint8_t { IMDONE=0, IMPL=1, IMWIFI=2 };
|
enum import_e : uint8_t { IMDONE=0, IMPL=1, IMWIFI=2 };
|
||||||
|
|
||||||
class NetServer {
|
class NetServer {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef options_h
|
#ifndef options_h
|
||||||
#define options_h
|
#define options_h
|
||||||
|
|
||||||
#define YOVERSION "0.8.841"
|
#define YOVERSION "0.8.855"
|
||||||
|
|
||||||
/*******************************************************
|
/*******************************************************
|
||||||
DO NOT EDIT THIS FILE.
|
DO NOT EDIT THIS FILE.
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ void Player::play(uint16_t stationId, uint32_t filePos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Player::prev() {
|
void Player::prev() {
|
||||||
if(config.store.play_mode==PM_WEB){
|
if(config.store.play_mode==PM_WEB || !config.sdSnuffle){
|
||||||
if (config.store.lastStation == 1) config.store.lastStation = config.store.countStation; else config.store.lastStation--;
|
if (config.store.lastStation == 1) config.store.lastStation = config.store.countStation; else config.store.lastStation--;
|
||||||
}
|
}
|
||||||
request.station = config.store.lastStation;
|
request.station = config.store.lastStation;
|
||||||
@@ -173,7 +173,7 @@ void Player::prev() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Player::next() {
|
void Player::next() {
|
||||||
if(config.store.play_mode==PM_WEB){
|
if(config.store.play_mode==PM_WEB || !config.sdSnuffle){
|
||||||
if (config.store.lastStation == config.store.countStation) config.store.lastStation = 1; else config.store.lastStation++;
|
if (config.store.lastStation == config.store.countStation) config.store.lastStation = 1; else config.store.lastStation++;
|
||||||
}else{
|
}else{
|
||||||
config.store.lastStation = random(1, config.store.countStation);
|
config.store.lastStation = random(1, config.store.countStation);
|
||||||
|
|||||||
@@ -200,7 +200,11 @@ void audio_id3data(const char *info){ //id3 metadata
|
|||||||
}
|
}
|
||||||
void audio_eof_mp3(const char *info){ //end of file
|
void audio_eof_mp3(const char *info){ //end of file
|
||||||
config.sdResumePos = 0;
|
config.sdResumePos = 0;
|
||||||
player.play(random(1, config.store.countStation));
|
if(config.sdSnuffle){
|
||||||
|
player.play(random(1, config.store.countStation));
|
||||||
|
}else{
|
||||||
|
player.next();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void audio_progress(uint32_t startpos, uint32_t endpos){
|
void audio_progress(uint32_t startpos, uint32_t endpos){
|
||||||
player.sd_min = startpos;
|
player.sd_min = startpos;
|
||||||
|
|||||||
Reference in New Issue
Block a user