sd_snuffle
This commit is contained in:
Binary file not shown.
@@ -25,8 +25,9 @@ void Config::init() {
|
||||
if (store.config_set != 4262) setDefaults();
|
||||
backupLastStation = store.lastStation;
|
||||
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)) {
|
||||
return;
|
||||
@@ -159,7 +160,7 @@ void Config::setDefaults() {
|
||||
strlcpy(store.weatherkey,"", 64);
|
||||
store.volsteps = 1;
|
||||
store.encacc = 200;
|
||||
store.play_mode = 0;
|
||||
store.play_mode = 0b100;
|
||||
store.irtlp = 35;
|
||||
store.btnpullup = true;
|
||||
store.btnlongpress = 200;
|
||||
@@ -191,12 +192,20 @@ uint16_t Config::getTimezoneOffset() {
|
||||
|
||||
void Config::save() {
|
||||
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_WEB) backupLastStation = store.lastStation;
|
||||
bitWrite(store.play_mode, 2, sdSnuffle);
|
||||
eepromWrite(EEPROM_START, store);
|
||||
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
|
||||
void Config::saveIR(){
|
||||
eepromWrite(EEPROM_START_IR, ircodes);
|
||||
|
||||
@@ -154,6 +154,7 @@ class Config {
|
||||
uint16_t sleepfor;
|
||||
uint32_t sdResumePos;
|
||||
uint16_t backupLastStation;
|
||||
bool sdSnuffle;
|
||||
public:
|
||||
Config() {};
|
||||
void save();
|
||||
@@ -191,6 +192,7 @@ class Config {
|
||||
void sleepForAfter(uint16_t sleepfor, uint16_t sleepafter=0);
|
||||
void bootInfo();
|
||||
void doSleepW();
|
||||
void setSnuffle(bool sn);
|
||||
private:
|
||||
template <class T> int eepromWrite(int ee, const 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) {
|
||||
int8_t valb = atoi(val);
|
||||
player.setBalance(valb);
|
||||
@@ -587,7 +592,7 @@ void NetServer::requestOnChange(requestType_e request, uint8_t clientId) {
|
||||
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 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;
|
||||
@@ -602,6 +607,7 @@ void NetServer::requestOnChange(requestType_e request, uint8_t clientId) {
|
||||
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 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 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;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "ESPAsyncWebServer.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 };
|
||||
|
||||
class NetServer {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef options_h
|
||||
#define options_h
|
||||
|
||||
#define YOVERSION "0.8.841"
|
||||
#define YOVERSION "0.8.855"
|
||||
|
||||
/*******************************************************
|
||||
DO NOT EDIT THIS FILE.
|
||||
|
||||
@@ -165,7 +165,7 @@ void Player::play(uint16_t stationId, uint32_t filePos) {
|
||||
}
|
||||
|
||||
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--;
|
||||
}
|
||||
request.station = config.store.lastStation;
|
||||
@@ -173,7 +173,7 @@ void Player::prev() {
|
||||
}
|
||||
|
||||
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++;
|
||||
}else{
|
||||
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
|
||||
config.sdResumePos = 0;
|
||||
if(config.sdSnuffle){
|
||||
player.play(random(1, config.store.countStation));
|
||||
}else{
|
||||
player.next();
|
||||
}
|
||||
}
|
||||
void audio_progress(uint32_t startpos, uint32_t endpos){
|
||||
player.sd_min = startpos;
|
||||
|
||||
Reference in New Issue
Block a user