sd_i2s+sd_vs_v1

This commit is contained in:
e2002
2022-12-15 17:49:44 +03:00
parent b75b9c6d11
commit 495d4375da
16 changed files with 191 additions and 67 deletions

View File

@@ -9,7 +9,7 @@ Config config;
#if DSP_HSPI || TS_HSPI || VS_HSPI
SPIClass SPI2(HSPI);
#endif
SPIClass SDSPI(VSPI);
//SPIClass SDSPI(VSPI);
void u8fix(char *src){
char last = src[strlen(src)-1];
@@ -32,10 +32,11 @@ void Config::init() {
loadTheme();
ssidsCount = 0;
if(SDC_CS!=255 && store.play_mode==PM_WEB){
pinMode(SDC_CS, OUTPUT); digitalWrite(SDC_CS, HIGH);
SDSPI.begin(SDC_SPI);
SDSPI.setFrequency(1000000);
if(SDC_CS!=255 && store.play_mode==PM_SDCARD){
//pinMode(SDC_CS, OUTPUT); digitalWrite(SDC_CS, HIGH);
//SDSPI.begin(SDC_SPI);
//SDSPI.setFrequency(1000000);
//SDSPI.setFrequency(100000);
if(!SD.begin(SDC_CS)){
store.play_mode=PM_WEB;
Serial.println("##[ERROR]#\tCard Mount Failed");
@@ -49,6 +50,7 @@ void Config::init() {
store.lastStation = 1;
save();
}
loadStation(store.lastStation);
#if IR_PIN!=255
eepromRead(EEPROM_START_IR, ircodes);
@@ -297,11 +299,11 @@ bool endsWith (const char* base, const char* str) {
void Config::listSD(File &plSDfile, File &plSDindex, const char * dirname, uint8_t levels){
File root = SD.open(dirname);
if(!root){
Serial.println("Failed to open directory");
Serial.println("##[ERROR]#\tFailed to open directory");
return;
}
if(!root.isDirectory()){
Serial.println("Not a directory");
Serial.println("##[ERROR]#\tNot a directory");
return;
}
@@ -315,12 +317,10 @@ void Config::listSD(File &plSDfile, File &plSDindex, const char * dirname, uint8
listSD(plSDfile, plSDindex, file.path(), levels -1);
}
} else {
if(endsWith(file.name(), ".mp3") || endsWith(file.name(), ".m4a") || endsWith(file.name(), ".aac") || endsWith(file.name(), ".wav") || endsWith(file.name(), ".flac")){
if(endsWith(strlwr((char*)file.name()), ".mp3") || endsWith(file.name(), ".m4a") || endsWith(file.name(), ".aac") || endsWith(file.name(), ".wav") || endsWith(file.name(), ".flac")){
pos = plSDfile.position();
plSDfile.print(file.name()); plSDfile.print("\t"); plSDfile.print(file.path()); plSDfile.print("\t"); plSDfile.println(0);
plSDindex.write((byte *) &pos, 4);
Serial.print(" plSDfile.position:\t");
Serial.println(pos);
}
}
file = root.openNextFile();
@@ -342,8 +342,9 @@ void Config::initSDPlaylist() {
store.countStation = 0;
indexSDPlaylist();
if (SPIFFS.exists(INDEX_SD_PATH)) {
File index = SD.open(INDEX_SD_PATH, "r");
File index = SPIFFS.open(INDEX_SD_PATH, "r");
store.countStation = index.size() / 4;
store.lastStation = random(1, store.countStation);
index.close();
save();
}
@@ -362,9 +363,9 @@ void Config::loadStation(uint16_t ls) {
if (ls > store.countStation) {
ls = 1;
}
File playlist = SPIFFS.open(PLAYLIST_PATH, "r");
File playlist = SPIFFS.open(REAL_PLAYL, "r");
File index = SPIFFS.open(INDEX_PATH, "r");
File index = SPIFFS.open(REAL_INDEX, "r");
index.seek((ls - 1) * 4, SeekSet);
uint32_t pos;
@@ -378,7 +379,7 @@ void Config::loadStation(uint16_t ls) {
strncpy(station.name, sName, BUFLEN);
strncpy(station.url, sUrl, BUFLEN);
station.ovol = sOvol;
setLastStation(ls);
if(store.play_mode==PM_WEB) setLastStation(ls);
}
playlist.close();
}
@@ -392,8 +393,8 @@ void Config::fillPlMenu(char plmenu[][40], int from, byte count, bool removeNum)
if (store.countStation == 0) {
return;
}
File playlist = SPIFFS.open(PLAYLIST_PATH, "r");
File index = SPIFFS.open(INDEX_PATH, "r");
File playlist = SPIFFS.open(REAL_PLAYL, "r");
File index = SPIFFS.open(REAL_INDEX, "r");
while (true) {
if (ls < 1) {
ls++;

View File

@@ -4,7 +4,7 @@
#include <Ticker.h>
#include <SPI.h>
#include <SPIFFS.h>
#include <SD.h>
#include "SD.h"
#include "options.h"
#define EEPROM_SIZE 768
@@ -29,6 +29,8 @@
#endif
#define BOOTLOG( ... ) { char buf[120]; sprintf( buf, __VA_ARGS__ ) ; Serial.print("##[BOOT]#\t"); Serial.println(buf); }
#define EVERY_MS(x) static uint32_t tmr; bool flag = millis() - tmr >= (x); if (flag) tmr += (x); if (flag)
#define REAL_PLAYL store.play_mode==PM_WEB?PLAYLIST_PATH:PLAYLIST_SD_PATH
#define REAL_INDEX store.play_mode==PM_WEB?INDEX_PATH:INDEX_SD_PATH
#define MAX_PLAY_MODE 1

View File

@@ -363,8 +363,8 @@ void onBtnLongPressStart(int id) {
break;
}
case EVT_BTNMODE: {
//onBtnClick(EVT_BTNMODE);
config.doSleepW();
//config.doSleepW();
display.putRequest(NEWMODE, SLEEPING);
break;
}
default: break;
@@ -380,6 +380,10 @@ void onBtnLongPressStop(int id) {
lpId = -1;
break;
}
case EVT_BTNMODE: {
config.doSleepW();
break;
}
default:
break;
}
@@ -498,9 +502,9 @@ void onBtnClick(int id) {
config.store.play_mode++;
if(config.store.play_mode > MAX_PLAY_MODE){
config.store.play_mode=0;
config.save();
ESP.restart();
}
config.save();
ESP.restart();
break;
}
default: break;

View File

@@ -262,6 +262,7 @@ void Display::_swichMode(displayMode_e newmode) {
}
if (newmode == LOST) _showDialog(const_DlgLost);
if (newmode == UPDATING) _showDialog(const_DlgUpdate);
if (newmode == SLEEPING) _showDialog("SLEEPING");
if (newmode == INFO || newmode == SETTINGS || newmode == TIMEZONE || newmode == WIFI) _showDialog(const_DlgNextion);
if (newmode == NUMBERS) _showDialog("");
if (newmode == STATIONS) {
@@ -443,8 +444,12 @@ void Display::_title() {
/*#ifdef USE_NEXTION
nextion.newTitle(config.station.title);
#endif*/
if (player_on_track_change) player_on_track_change();
}else{
_title1.setText("");
if(_title2) _title2->setText("");
}
if (player_on_track_change) player_on_track_change();
}
void Display::_time(bool redraw) {

View File

@@ -8,7 +8,7 @@
#include "../displays/dspcore.h"
enum displayMode_e { PLAYER, VOL, STATIONS, NUMBERS, LOST, UPDATING, INFO, SETTINGS, TIMEZONE, WIFI, CLEAR };
enum displayMode_e { PLAYER, VOL, STATIONS, NUMBERS, LOST, UPDATING, INFO, SETTINGS, TIMEZONE, WIFI, CLEAR, SLEEPING };
enum pages_e : uint8_t { PG_PLAYER=0, PG_DIALOG=1, PG_PLAYLIST=2 };
//enum dialogType_e : uint8_t { DG_NONE=0, DG_VOLUME=1, DG_LOST=2, DG_UPDATING=3, DG_NEXTION=4 };

View File

@@ -636,7 +636,11 @@ void handleHTTPArgs(AsyncWebServerRequest * request) {
#ifdef MQTT_HOST
if (strcmp(request->url().c_str(), PLAYLIST_PATH) == 0) while (mqttplaylistblock) vTaskDelay(5);
#endif
netserver.chunkedHtmlPage("application/octet-stream", request, request->url().c_str());
if(strcmp(request->url().c_str(), PLAYLIST_PATH) == 0 && config.store.play_mode==PM_SDCARD){
netserver.chunkedHtmlPage("application/octet-stream", request, PLAYLIST_SD_PATH);
}else{
netserver.chunkedHtmlPage("application/octet-stream", request, request->url().c_str());
}
return;
}
if (strcmp(request->url().c_str(), "/") == 0 && request->params() == 0) {

View File

@@ -76,6 +76,7 @@ void Network::begin() {
errcnt = 0;
ls++;
if (ls > config.ssidsCount - 1) ls = 0;
Serial.println();
break;
}
}

View File

@@ -1,7 +1,7 @@
#ifndef options_h
#define options_h
#define YOVERSION "0.9.000"
#define YOVERSION "0.8.800"
/*******************************************************
DO NOT EDIT THIS FILE.
@@ -58,7 +58,7 @@ The connection tables are located here https://github.com/e2002/yoradio#connecti
/* TFT DISPLAY */
#ifndef TFT_CS
#define TFT_CS 5
#define TFT_CS 255
#endif
#ifndef TFT_RST
#define TFT_RST 15 // Or set to -1 and connect to Esp EN pin

View File

@@ -128,7 +128,7 @@ void Player::play(uint16_t stationId) {
display.putRequest(PSTOP);
setDefaults();
setOutputPins(false);
config.setTitle(const_PlConnect);
config.setTitle(config.store.play_mode==PM_WEB?const_PlConnect:"");
config.station.bitrate=0;
netserver.requestOnChange(TITLE, 0);
config.loadStation(stationId);
@@ -136,8 +136,10 @@ void Player::play(uint16_t stationId) {
display.putRequest(NEWSTATION);
netserver.requestOnChange(STATION, 0);
telnet.printf("##CLI.NAMESET#: %d %s\n", config.store.lastStation, config.station.name);
if (connecttohost(config.station.url)) {
if (config.store.play_mode==PM_WEB?connecttohost(config.station.url):connecttoFS(SD,config.station.url)) {
mode = PLAYING;
config.setTitle("");
netserver.requestOnChange(TITLE, 0);
config.setSmartStart(1);
netserver.requestOnChange(MODE, 0);
setOutputPins(true);
@@ -150,13 +152,19 @@ void Player::play(uint16_t stationId) {
}
void Player::prev() {
if (config.store.lastStation == 1) config.store.lastStation = config.store.countStation; else config.store.lastStation--;
if(config.store.play_mode==PM_WEB){
if (config.store.lastStation == 1) config.store.lastStation = config.store.countStation; else config.store.lastStation--;
}
request.station = config.store.lastStation;
request.doSave = true;
}
void Player::next() {
if (config.store.lastStation == config.store.countStation) config.store.lastStation = 1; else config.store.lastStation++;
if(config.store.play_mode==PM_WEB){
if (config.store.lastStation == config.store.countStation) config.store.lastStation = 1; else config.store.lastStation++;
}else{
config.store.lastStation = random(1, config.store.countStation);
}
request.station = config.store.lastStation;
request.doSave = true;
}