Skip to content

Commit 60601da

Browse files
committed
v0.9.300
1 parent e823f97 commit 60601da

File tree

14 files changed

+191
-84
lines changed

14 files changed

+191
-84
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,9 @@ Work is in progress...
229229

230230
---
231231
## Version history
232+
#### v0.9.300
233+
- added the ability to play SDCARD without an Internet connection. More in [Wiki](https://github.com/e2002/yoradio/wiki/A-little-about-SD-CARD-and-RTC)
234+
232235
#### v0.9.280
233236
- fixed an issue where it was impossible to reconnect when the WiFi connection was lost
234237

yoRadio/src/core/config.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//#include <SPIFFS.h>
44
#include "display.h"
55
#include "player.h"
6+
#include "network.h"
67
#include "netserver.h"
78
#include "spidog.h"
89

@@ -149,6 +150,13 @@ void Config::_mountSD(){
149150
}
150151

151152
void Config::changeMode(int newmode){
153+
if(SDC_CS==255) return;
154+
if(network.status==SOFT_AP || display.mode()==LOST){
155+
store.play_mode=PM_SDCARD;
156+
save();
157+
delay(50);
158+
ESP.restart();
159+
}
152160
if(!SDinit) {
153161
_mountSD();
154162
if(!SDinit){
@@ -174,7 +182,8 @@ void Config::changeMode(int newmode){
174182
delay(10);
175183
delay(50);
176184
}
177-
if(getMode()==PM_WEB) player.setResumeFilePos(0);
185+
//if(getMode()==PM_WEB) player.setResumeFilePos(0);
186+
if((getMode()==PM_WEB && network.status==SDREADY)) ESP.restart();
178187
initPlaylistMode();
179188
if (store.smartstart == 1) player.sendCommand({PR_PLAY, store.lastStation});
180189
//else

yoRadio/src/core/controls.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "config.h"
55
#include "player.h"
66
#include "display.h"
7+
#include "network.h"
78
#include "netserver.h"
89

910
long encOldPosition = 0;
@@ -67,14 +68,14 @@ decode_results irResults;
6768
#if ENC_BTNL!=255
6869
void IRAM_ATTR readEncoderISR()
6970
{
70-
if(display.mode()==LOST || display.mode()==UPDATING) return;
71+
if((SDC_CS==255 && display.mode()==LOST) || display.mode()==UPDATING) return;
7172
encoder.readEncoder_ISR();
7273
}
7374
#endif
7475
#if ENC2_BTNL!=255
7576
void IRAM_ATTR readEncoder2ISR()
7677
{
77-
if(display.mode()==LOST || display.mode()==UPDATING) return;
78+
if((SDC_CS==255 && display.mode()==LOST) || display.mode()==UPDATING) return;
7879
encoder2.readEncoder_ISR();
7980
}
8081
#endif
@@ -129,8 +130,9 @@ void initControls() {
129130
}
130131

131132
void loopControls() {
132-
if(display.mode()==LOST || display.mode()==UPDATING || display.mode()==SDCHANGE) return;
133-
if (ctrls_on_loop) ctrls_on_loop();
133+
if(display.mode()==UPDATING || display.mode()==SDCHANGE) return;
134+
if(SDC_CS==255 && display.mode()==LOST) return;
135+
if(ctrls_on_loop) ctrls_on_loop();
134136
#if ENC_BTNL!=255
135137
encoder1Loop();
136138
#endif
@@ -152,11 +154,13 @@ void loopControls() {
152154
irLoop();
153155
#endif
154156
#if (TS_MODEL!=TS_MODEL_UNDEFINED) && (DSP_MODEL!=DSP_DUMMY)
155-
touchscreen.loop();
157+
if (network.status == CONNECTED || network.status==SDREADY) touchscreen.loop();
156158
#endif
157159
}
158160
#if ENC_BTNL!=255 || ENC2_BTNL!=255
159161
void encodersLoop(yoEncoder *enc, bool first){
162+
if (network.status != CONNECTED && network.status!=SDREADY) return;
163+
if(display.mode()==LOST) return;
160164
int8_t encoderDelta = enc->encoderChanged();
161165
if (encoderDelta!=0)
162166
{
@@ -246,6 +250,8 @@ void irLoop() {
246250
for(int target=0; target<17; target++){
247251
for(int j=0; j<3; j++){
248252
if(config.ircodes.irVals[target][j]==irResults.value){
253+
if (network.status != CONNECTED && network.status!=SDREADY && target!=IR_AST) return;
254+
if(target!=IR_AST && display.mode()==LOST) return;
249255
switch (target){
250256
case IR_PLAY: {
251257
irBlink();
@@ -402,6 +408,7 @@ boolean checklpdelay(int m, unsigned long &tstamp) {
402408
}
403409

404410
void onBtnDuringLongPress(int id) {
411+
if (network.status != CONNECTED && network.status!=SDREADY) return;
405412
if (checklpdelay(BTN_LONGPRESS_LOOP_DELAY, lpdelay)) {
406413
switch ((controlEvt_e)id) {
407414
case EVT_BTNLEFT: {
@@ -457,6 +464,8 @@ void controlsEvent(bool toRight, int8_t volDelta) {
457464
}
458465

459466
void onBtnClick(int id) {
467+
bool passBnCenter = (controlEvt_e)id==EVT_BTNCENTER || (controlEvt_e)id==EVT_ENCBTNB || (controlEvt_e)id==EVT_ENC2BTNB;
468+
if (network.status != CONNECTED && network.status!=SDREADY && (controlEvt_e)id!=EVT_BTNMODE && !passBnCenter) return;
460469
switch ((controlEvt_e)id) {
461470
case EVT_BTNLEFT: {
462471
controlsEvent(false);
@@ -479,6 +488,11 @@ void onBtnClick(int id) {
479488
#endif
480489
player.sendCommand({PR_PLAY, display.currentPlItem});
481490
}
491+
if(network.status==SOFT_AP || display.mode()==LOST){
492+
#ifdef USE_SD
493+
config.changeMode();
494+
#endif
495+
}
482496
break;
483497
}
484498
case EVT_BTNRIGHT: {
@@ -517,6 +531,7 @@ void onBtnDoubleClick(int id) {
517531
switch ((controlEvt_e)id) {
518532
case EVT_BTNLEFT: {
519533
if (display.mode() != PLAYER) return;
534+
if (network.status != CONNECTED && network.status!=SDREADY) return;
520535
player.prev();
521536
break;
522537
}
@@ -529,6 +544,7 @@ void onBtnDoubleClick(int id) {
529544
}
530545
case EVT_BTNRIGHT: {
531546
if (display.mode() != PLAYER) return;
547+
if (network.status != CONNECTED && network.status!=SDREADY) return;
532548
player.next();
533549
break;
534550
}

yoRadio/src/core/display.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ void Display::_start() {
209209
#ifdef USE_NEXTION
210210
nextion.wake();
211211
#endif
212-
if (network.status != CONNECTED) {
212+
if (network.status != CONNECTED && network.status != SDREADY) {
213213
_apScreen();
214214
#ifdef USE_NEXTION
215215
nextion.apScreen();
@@ -262,7 +262,7 @@ void Display::_swichMode(displayMode_e newmode) {
262262
//nextion.swichMode(newmode);
263263
nextion.putRequest({NEWMODE, newmode});
264264
#endif
265-
if (newmode == _mode || network.status != CONNECTED) return;
265+
if (newmode == _mode || (network.status != CONNECTED && network.status != SDREADY)) return;
266266
_mode = newmode;
267267
dsp.setScrollId(NULL);
268268
if (newmode == PLAYER) {
@@ -436,6 +436,12 @@ void Display::loop() {
436436
case PSTART: _layoutChange(true); break;
437437
case PSTOP: _layoutChange(false); break;
438438
case DSP_START: _start(); break;
439+
case NEWIP: {
440+
#ifndef HIDE_IP
441+
if(_volip) _volip->setText(WiFi.localIP().toString().c_str(), iptxtFmt);
442+
#endif
443+
break;
444+
}
439445
default: break;
440446
}
441447
}

yoRadio/src/core/display.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ enum displayMode_e { PLAYER, VOL, STATIONS, NUMBERS, LOST, UPDATING, INFO, SETTI
1212
enum pages_e : uint8_t { PG_PLAYER=0, PG_DIALOG=1, PG_PLAYLIST=2 };
1313
//enum dialogType_e : uint8_t { DG_NONE=0, DG_VOLUME=1, DG_LOST=2, DG_UPDATING=3, DG_NEXTION=4 };
1414

15-
enum displayRequestType_e { BOOTSTRING, NEWMODE, CLOCK, NEWTITLE, NEWSTATION, NEXTSTATION, DRAWPLAYLIST, DRAWVOL, DBITRATE, AUDIOINFO, SHOWVUMETER, DSPRSSI, SHOWWEATHER, NEWWEATHER, PSTOP, PSTART, DSP_START, WAITFORSD, SDFILEINDEX };
15+
enum displayRequestType_e { BOOTSTRING, NEWMODE, CLOCK, NEWTITLE, NEWSTATION, NEXTSTATION, DRAWPLAYLIST, DRAWVOL, DBITRATE, AUDIOINFO, SHOWVUMETER, DSPRSSI, SHOWWEATHER, NEWWEATHER, PSTOP, PSTART, DSP_START, WAITFORSD, SDFILEINDEX, NEWIP };
1616
struct requestParams_t
1717
{
1818
displayRequestType_e type;

yoRadio/src/core/netserver.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ char* updateError() {
5959
return ret;
6060
}
6161

62-
bool NetServer::begin() {
63-
Serial.print("##[BOOT]#\tnetserver.begin\t");
62+
bool NetServer::begin(bool quiet) {
63+
if(network.status==SDREADY) return true;
64+
if(!quiet) Serial.print("##[BOOT]#\tnetserver.begin\t");
6465
importRequest = IMDONE;
6566
irRecordEnable = false;
6667
nsQueue = xQueueCreate( 20, sizeof( nsRequestParams_t ) );
@@ -112,7 +113,7 @@ bool NetServer::begin() {
112113
packet.println(WiFi.localIP());
113114
});
114115
}
115-
Serial.println("done");
116+
if(!quiet) Serial.println("done");
116117
return true;
117118
}
118119

@@ -313,6 +314,7 @@ void NetServer::processQueue(){
313314
}
314315

315316
void NetServer::loop() {
317+
if(network.status==SDREADY) return;
316318
if (shouldReboot) {
317319
Serial.println("Rebooting...");
318320
delay(100);

yoRadio/src/core/netserver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class NetServer {
5555
char chunkedPathBuffer[40];
5656
public:
5757
NetServer() {};
58-
bool begin();
58+
bool begin(bool quiet=false);
5959
void loop();
6060
void requestOnChange(requestType_e request, uint8_t clientId);
6161
void setRSSI(int val) { rssi = val; };

0 commit comments

Comments
 (0)