mirror of https://github.com/e2002/yoradio.git
sd_i2s+sd_vs_v6
This commit is contained in:
parent
2a2bbf2c16
commit
345510a58b
Binary file not shown.
|
|
@ -544,8 +544,10 @@ bool NetServer::importPlaylist() {
|
||||||
#else
|
#else
|
||||||
#define SHOW_WEATHER false
|
#define SHOW_WEATHER false
|
||||||
#endif
|
#endif
|
||||||
|
char wsbuf[BUFLEN * 2];
|
||||||
void NetServer::requestOnChange(requestType_e request, uint8_t clientId) {
|
void NetServer::requestOnChange(requestType_e request, uint8_t clientId) {
|
||||||
char buf[BUFLEN * 2] = { 0 };
|
//char buf[BUFLEN * 2] = { 0 };
|
||||||
|
memset(wsbuf, 0, BUFLEN * 2);
|
||||||
switch (request) {
|
switch (request) {
|
||||||
case PLAYLIST: getPlaylist(clientId); break;
|
case PLAYLIST: getPlaylist(clientId); break;
|
||||||
case PLAYLISTSAVED: config.indexPlaylist(); config.initPlaylist(); getPlaylist(clientId); break;
|
case PLAYLISTSAVED: config.indexPlaylist(); config.initPlaylist(); getPlaylist(clientId); break;
|
||||||
|
|
@ -577,30 +579,31 @@ void NetServer::requestOnChange(requestType_e request, uint8_t clientId) {
|
||||||
if (IR_PIN != 255 || dbgact) act += F("\"group_ir\",");
|
if (IR_PIN != 255 || dbgact) act += F("\"group_ir\",");
|
||||||
}
|
}
|
||||||
act = act.substring(0, act.length() - 1);
|
act = act.substring(0, act.length() - 1);
|
||||||
sprintf (buf, "{\"act\":[%s]}", act.c_str());
|
sprintf (wsbuf, "{\"act\":[%s]}", act.c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GETMODE: sprintf (buf, "{\"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); 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); return; break;
|
||||||
case GETSYSTEM: sprintf (buf, "{\"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 (buf, "{\"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 (buf, "{\"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;
|
||||||
case GETWEATHER: sprintf (buf, "{\"wen\":%d,\"wlat\":\"%s\",\"wlon\":\"%s\",\"wkey\":\"%s\"}", config.store.showweather, config.store.weatherlat, config.store.weatherlon, config.store.weatherkey); break;
|
case GETWEATHER: sprintf (wsbuf, "{\"wen\":%d,\"wlat\":\"%s\",\"wlon\":\"%s\",\"wkey\":\"%s\"}", config.store.showweather, config.store.weatherlat, config.store.weatherlon, config.store.weatherkey); break;
|
||||||
case GETCONTROLS: sprintf (buf, "{\"vols\":%d,\"enca\":%d,\"irtl\":%d}", config.store.volsteps, config.store.encacc, config.store.irtlp); break;
|
case GETCONTROLS: sprintf (wsbuf, "{\"vols\":%d,\"enca\":%d,\"irtl\":%d}", config.store.volsteps, config.store.encacc, config.store.irtlp); break;
|
||||||
case DSPON: sprintf (buf, "{\"dspontrue\":%d}", 1); break;
|
case DSPON: sprintf (wsbuf, "{\"dspontrue\":%d}", 1); break;
|
||||||
case STATION: sprintf (buf, "{\"nameset\": \"%s\"}", config.station.name); requestOnChange(ITEM, clientId); break;
|
case STATION: requestOnChange(STATIONNAME, clientId); requestOnChange(ITEM, clientId); break;
|
||||||
case ITEM: sprintf (buf, "{\"current\": %d}", config.store.lastStation); break;
|
case STATIONNAME: sprintf (wsbuf, "{\"nameset\": \"%s\"}", config.station.name); break;
|
||||||
case TITLE: sprintf (buf, "{\"meta\": \"%s\"}", config.station.title); if (player.requestToStart) { telnet.info(); player.requestToStart = false; } else { telnet.printf("##CLI.META#: %s\n> ", config.station.title); } break;
|
case ITEM: sprintf (wsbuf, "{\"current\": %d}", config.store.lastStation); break;
|
||||||
case VOLUME: sprintf (buf, "{\"vol\": %d}", config.store.volume); break;
|
case TITLE: sprintf (wsbuf, "{\"meta\": \"%s\"}", config.station.title); if (player.requestToStart) { telnet.info(); player.requestToStart = false; } else { telnet.printf("##CLI.META#: %s\n> ", config.station.title); } break;
|
||||||
case NRSSI: sprintf (buf, "{\"rssi\": %d}", rssi); rssi = 255; break;
|
case VOLUME: sprintf (wsbuf, "{\"vol\": %d}", config.store.volume); break;
|
||||||
case SDPOS: if(player.getFilePos()>295903) sprintf (buf, "{\"sdpos\": %d,\"sdend\": %d,\"sdtpos\": %d,\"sdtend\": %d}", player.getFilePos(), player.getFileSize(), player.getAudioCurrentTime(), player.getAudioFileDuration()); break;
|
case NRSSI: sprintf (wsbuf, "{\"rssi\": %d}", rssi); rssi = 255; break;
|
||||||
case BITRATE: sprintf (buf, "{\"bitrate\": %d}", config.station.bitrate); break;
|
case SDPOS: sprintf (wsbuf, "{\"sdpos\": %d,\"sdend\": %d,\"sdtpos\": %d,\"sdtend\": %d}", player.getFilePos(), player.getFileSize(), player.getAudioCurrentTime(), player.getAudioFileDuration()); break;
|
||||||
case MODE: sprintf (buf, "{\"mode\": \"%s\"}", player.mode == PLAYING ? "playing" : "stopped"); break;
|
case BITRATE: sprintf (wsbuf, "{\"bitrate\": %d}", config.station.bitrate); break;
|
||||||
case EQUALIZER: sprintf (buf, "{\"bass\": %d, \"middle\": %d, \"trebble\": %d}", config.store.bass, config.store.middle, config.store.trebble); break;
|
case MODE: sprintf (wsbuf, "{\"mode\": \"%s\"}", player.mode == PLAYING ? "playing" : "stopped"); break;
|
||||||
case BALANCE: sprintf (buf, "{\"balance\": %d}", config.store.balance); 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;
|
||||||
}
|
}
|
||||||
if (strlen(buf) > 0) {
|
if (strlen(wsbuf) > 0) {
|
||||||
if (clientId == 0) { websocket.textAll(buf); }else{ websocket.text(clientId, buf); }
|
if (clientId == 0) { websocket.textAll(wsbuf); }else{ websocket.text(clientId, wsbuf); }
|
||||||
#ifdef MQTT_HOST
|
#ifdef MQTT_HOST
|
||||||
if (clientId == 0 && (request == STATION || request == ITEM || request == TITLE || request == MODE)) mqttPublishStatus();
|
if (clientId == 0 && (request == STATION || request == ITEM || request == TITLE || request == MODE)) mqttPublishStatus();
|
||||||
if (clientId == 0 && request == VOLUME) mqttPublishVolume();
|
if (clientId == 0 && request == VOLUME) mqttPublishVolume();
|
||||||
|
|
|
||||||
|
|
@ -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, ITEM=3, TITLE=4, VOLUME=5, NRSSI=6, BITRATE=7, MODE=8, EQUALIZER=9, BALANCE=10, PLAYLISTSAVED=11, GETMODE=12, GETINDEX=13, GETACTIVE=14, GETSYSTEM=15, GETSCREEN=16, GETTIMEZONE=17, GETWEATHER=18, GETCONTROLS=19, DSPON=20, SDPOS=21 };
|
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 };
|
||||||
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 {
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,18 @@ void Player::stop(const char *nttl){
|
||||||
if (player_on_stop_play) player_on_stop_play();
|
if (player_on_stop_play) player_on_stop_play();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::initHeaders(const char *file) {
|
||||||
|
if(strlen(file)==0) return;
|
||||||
|
connecttoFS(SD,file);
|
||||||
|
for(int c=0;c<20;c++) player.loopreader();
|
||||||
|
//netserver.requestOnChange(SDPOS, 0);
|
||||||
|
setDefaults();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Player::loopreader() {
|
||||||
|
Audio::loop();
|
||||||
|
}
|
||||||
|
|
||||||
void Player::loop() {
|
void Player::loop() {
|
||||||
if (mode == PLAYING) {
|
if (mode == PLAYING) {
|
||||||
xSemaphoreTake(playmutex, portMAX_DELAY);
|
xSemaphoreTake(playmutex, portMAX_DELAY);
|
||||||
|
|
|
||||||
|
|
@ -26,10 +26,13 @@ class Player: public Audio {
|
||||||
bool requestToStart;
|
bool requestToStart;
|
||||||
void zeroRequest();
|
void zeroRequest();
|
||||||
SemaphoreHandle_t playmutex=NULL;
|
SemaphoreHandle_t playmutex=NULL;
|
||||||
|
bool lockOutput = true;
|
||||||
public:
|
public:
|
||||||
Player();
|
Player();
|
||||||
void init();
|
void init();
|
||||||
void loop();
|
void loop();
|
||||||
|
void initHeaders(const char *file);
|
||||||
|
void loopreader();
|
||||||
void play(uint16_t stationId, uint32_t filePos=0);
|
void play(uint16_t stationId, uint32_t filePos=0);
|
||||||
void stop(const char *nttl = NULL);
|
void stop(const char *nttl = NULL);
|
||||||
void prev();
|
void prev();
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,8 @@ void setup() {
|
||||||
#ifdef MQTT_HOST
|
#ifdef MQTT_HOST
|
||||||
mqttInit();
|
mqttInit();
|
||||||
#endif
|
#endif
|
||||||
|
if (config.store.play_mode==PM_SDCARD) player.initHeaders(config.station.url);
|
||||||
|
player.lockOutput=false;
|
||||||
if (config.store.smartstart == 1) player.play(config.store.lastStation);
|
if (config.store.smartstart == 1) player.play(config.store.lastStation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,6 +98,7 @@ void checkConnection(){
|
||||||
//=============================================//
|
//=============================================//
|
||||||
|
|
||||||
void audio_info(const char *info) {
|
void audio_info(const char *info) {
|
||||||
|
if(player.lockOutput) return;
|
||||||
if(config.store.audioinfo) telnet.printf("##AUDIO.INFO#: %s\n", info);
|
if(config.store.audioinfo) telnet.printf("##AUDIO.INFO#: %s\n", info);
|
||||||
#ifdef USE_NEXTION
|
#ifdef USE_NEXTION
|
||||||
nextion.audioinfo(info);
|
nextion.audioinfo(info);
|
||||||
|
|
@ -167,6 +170,7 @@ void audio_id3artist(const char *info){
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio_id3album(const char *info){
|
void audio_id3album(const char *info){
|
||||||
|
if(player.lockOutput) return;
|
||||||
if(printable(info)){
|
if(printable(info)){
|
||||||
if(strlen(config.station.title)==0){
|
if(strlen(config.station.title)==0){
|
||||||
config.setTitle(info);
|
config.setTitle(info);
|
||||||
|
|
@ -191,6 +195,7 @@ void audio_beginSDread(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void audio_id3data(const char *info){ //id3 metadata
|
void audio_id3data(const char *info){ //id3 metadata
|
||||||
|
if(player.lockOutput) return;
|
||||||
telnet.printf("##AUDIO.ID3#: %s\n", info);
|
telnet.printf("##AUDIO.ID3#: %s\n", info);
|
||||||
}
|
}
|
||||||
void audio_eof_mp3(const char *info){ //end of file
|
void audio_eof_mp3(const char *info){ //end of file
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue