This commit is contained in:
e2002
2022-04-18 12:55:32 +03:00
parent 22fe7a36b1
commit 1895043ba4
9 changed files with 38 additions and 22 deletions

View File

@@ -533,27 +533,10 @@ void Display::ip() {
dsp.ip(WiFi.localIP().toString().c_str());
}
void Display::checkConnection() {
if (WiFi.status() != WL_CONNECTED) {
bool playing = player.mode == PLAYING;
swichMode(LOST);
if (playing) player.mode = STOPPED;
WiFi.disconnect();
ip();
WiFi.reconnect();
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
swichMode(PLAYER);
if (playing) player.play(config.store.lastStation);
}
}
void Display::time(bool redraw) {
if (dsp_before_clock) if (!dsp_before_clock(&dsp, dt)) return;
char timeStringBuff[20] = { 0 };
if (!dt) {
checkConnection();
heap();
rssi();
}

View File

@@ -129,7 +129,6 @@ class Display {
void apScreen();
void drawPlayer();
void drawVolume();
void checkConnection();
void swichMode(displayMode_e newmode);
void drawPlaylist();
void volume();

View File

@@ -1,7 +1,7 @@
#ifndef options_h
#define options_h
#define VERSION "0.6.210"
#define VERSION "0.6.220"
/*******************************************************
DO NOT EDIT THIS FILE.
@@ -203,7 +203,9 @@ The connection tables are located here https://github.com/e2002/yoradio#connecti
#ifndef MUTE_VAL
#define MUTE_VAL HIGH // Write this to MUTE_PIN when player is stopped
#endif
#ifndef PLAYER_FORCE_MONO
#define PLAYER_FORCE_MONO false // mono option - false stereo, true mono
#endif
/*
*** ST7735 display submodel ***
INITR_BLACKTAB // 1.8' https://aliexpress.ru/item/1005002822797745.html

View File

@@ -272,6 +272,7 @@ public:
void setBalance(int8_t bal = 0);
void setTone(int8_t gainLowPass, int8_t gainBandPass, int8_t gainHighPass);
void setDefaults();
void forceMono(bool m) {} // TODO
// implement several function with respect to the index of string
bool startsWith (const char* base, const char* str) { return (strstr(base, str) - base) == 0;}
bool endsWith (const char* base, const char* str) {

View File

@@ -14,8 +14,8 @@
#if !defined(SCROLLDELTA) || !defined(SCROLLTIME)
//#define SCROLLDELTA 8
//#define SCROLLTIME 332
#define SCROLLDELTA 5
#define SCROLLTIME 200
#define SCROLLDELTA 4
#define SCROLLTIME 250
#endif
#define META_SIZE 1

View File

@@ -14,6 +14,9 @@
#include "controls.h"
#include "mqtt.h"
unsigned long checkMillis = 0;
unsigned long checkInterval = 3000;
void setup() {
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT);
@@ -28,6 +31,9 @@ void setup() {
}
netserver.begin();
telnet.begin();
#if PLAYER_FORCE_MONO
player.forceMono(true);
#endif
player.setVol(config.store.volume, true);
initControls();
display.start();
@@ -44,7 +50,26 @@ void loop() {
telnet.loop();
player.loop();
loopControls();
checkConnection();
}
// display.loop();
netserver.loop();
}
void checkConnection(){
if ((WiFi.status() != WL_CONNECTED) && (millis() - checkMillis >=checkInterval)) {
bool playing = player.isRunning();
if (playing) player.mode = STOPPED;
display.putRequest({NEWMODE, LOST});
Serial.println("Lost connection, reconnecting...");
while(true){
if (WiFi.status() == WL_CONNECTED) break;
WiFi.disconnect();
WiFi.reconnect();
delay(3000);
}
display.putRequest({NEWMODE, PLAYER});
if (playing) player.request.station = config.store.lastStation;
checkMillis = millis();
}
}