Skip to content

Commit 40f194a

Browse files
committed
v0.6.110
1 parent 864d8f9 commit 40f194a

40 files changed

+523
-360
lines changed

Images.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,6 @@
4141
\
4242
![ёRadio](images/img19.jpg)\
4343
\
44-
![ёRadio](images/img20.jpg)
44+
![ёRadio](images/img20.jpg)\
45+
\
46+
![ёRadio](images/img21.jpg)

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,14 @@ Work is in progress...
280280

281281
---
282282
## Version history
283+
#### v0.6.110
284+
- the logic of division by cores has been changed
285+
- fixed choppy playback (again)
286+
- improvements in the stability of the web interface
287+
- increased smoothness of the encoder
288+
- bug fixes
289+
- bug fixes
290+
283291
#### v0.6.012
284292
- fixed choppy playback
285293

exsamples/displayhandlers.ino

Lines changed: 61 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
/**************************************************************
2-
*
3-
* An example of displaying user information on the display.
4-
* This file must be in the root directory of the sketch.
5-
*
2+
3+
An example of displaying user information on the display.
4+
This file must be in the root directory of the sketch.
5+
66
**************************************************************/
77

88
#if DSP_MODEL==DSP_ST7735
9+
// 3600s = 60 minutes to not flooding
10+
#define WEATHER_REQUEST_INTERVAL 3600 // 60min
911

1012
#include <JSON_Decoder.h> // https://github.com/Bodmer/OpenWeather
1113
#include <OpenWeather.h> // https://github.com/Bodmer/JSON_Decoder
14+
#include <Ticker.h>
1215

1316
String api_key = "********************************"; // openweathermap.org API key
1417

@@ -19,59 +22,90 @@ String units = "metric";
1922
String language = "ru";
2023

2124
OW_Weather ow;
25+
Ticker ticker;
2226

2327
/***********************************************
24-
* scrolled line
28+
scrolled line
2529
***********************************************/
2630
Scroll hello;
2731

32+
char weather[140] = { 0 };
33+
bool weatherRequest = false;
34+
TaskHandle_t weatherUpdateTaskHandle;
35+
36+
void getWeather( void * pvParameters ) {
37+
OW_current *current = new OW_current;
38+
OW_hourly *hourly = new OW_hourly;
39+
OW_daily *daily = new OW_daily;
40+
delay(5000);
41+
ow.getForecast(current, hourly, daily, api_key, latitude, longitude, units, language);
42+
sprintf(weather, "TEMP: %.1f C * PRESS: %d HG * HUM: %d%%", current->temp, (int)(current->pressure / 1.333), current->humidity);
43+
weatherRequest = true;
44+
vTaskDelete( NULL );
45+
}
46+
47+
void updateWeather() {
48+
xTaskCreatePinnedToCore(
49+
getWeather, /* Task function. */
50+
"getWeather1", /* name of task. */
51+
8192, /* Stack size of task */
52+
NULL, /* parameter of the task */
53+
0, /* priority of the task */
54+
&weatherUpdateTaskHandle, /* Task handle to keep track of created task */
55+
0); /* pin task to core CORE_FOR_LOOP_CONTROLS */
56+
}
2857

2958
/***********************************************
30-
* Occurs when the display is initialized
59+
Occurs when the network is connected
3160
***********************************************/
32-
void dsp_on_init(){
33-
hello.init(" * ", 1, TFT_LINEHGHT*4+6, 2000, ORANGE, TFT_BG);
61+
void network_on_connect() {
62+
ticker.attach(WEATHER_REQUEST_INTERVAL, updateWeather);
63+
updateWeather();
3464
}
3565

3666
/*********************************************************************************************
37-
* The display has initialized, the network is connected, the player is ready to play.
38-
* DspCore class documentation is missing :^( See the source in src/displays
67+
The display has initialized, the network is connected, the player is ready to play.
68+
DspCore class documentation is missing :^( See the source in src/displays
3969
*********************************************************************************************/
40-
void dsp_on_start(DspCore *dsp){
41-
OW_current *current = new OW_current;
42-
OW_hourly *hourly = new OW_hourly;
43-
OW_daily *daily = new OW_daily;
44-
char weather[140] = { 0 };
45-
ow.getForecast(current, hourly, daily, api_key, latitude, longitude, units, language);
70+
void dsp_on_start(DspCore *dsp) {
4671

47-
sprintf(weather, "temp: %.1f * pressure: %d * humidity: %d", current->temp, (int)(current->pressure/1.333), current->humidity);
72+
}
4873

49-
hello.setText(dsp->utf8Rus(weather, true));
74+
/***********************************************
75+
Occurs when the display is initialized
76+
***********************************************/
77+
void dsp_on_init() {
78+
hello.init(5, " * ", 1, TFT_LINEHGHT*4+6, 0, ORANGE, TFT_BG);
79+
Serial.println(TFT_LINEHGHT*4+6);
5080
}
5181

5282
/************************
53-
* The loop cycle
83+
The loop cycle
5484
************************/
55-
void dsp_on_loop(){
56-
if(display.mode==PLAYER) hello.loop();
85+
void dsp_on_loop() {
86+
if (weatherRequest) {
87+
weatherRequest = false;
88+
hello.setText(weather);
89+
}
90+
if (display.mode == PLAYER) hello.loop();
5791
}
5892

5993
/***********************************************
60-
* Occurs when the display changes mode
94+
Occurs when the display changes mode
6195
***********************************************/
62-
void dsp_on_newmode(displayMode_e newmode){
96+
void dsp_on_newmode(displayMode_e newmode) {
6397
if (newmode == PLAYER) {
6498
hello.reset();
65-
}else{
99+
} else {
66100
hello.lock();
67101
}
68102
}
69103

70104
/************************
71-
* Before print the clock
105+
Before print the clock
72106
************************/
73-
bool dsp_before_clock(DspCore *dsp, bool dots){
74-
if(display.mode==PLAYER){
107+
bool dsp_before_clock(DspCore *dsp, bool dots) {
108+
if (display.mode == PLAYER) {
75109
dsp->setFont();
76110
dsp->setTextSize(1);
77111
display.centerText(dsp->utf8Rus("Hello from plugin!", true), display.screenheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT * 2 - 2, PINK, TFT_BG);

exsamples/myoptions.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ Uncomment the lines you need, to override the default value and set the values a
99
The connection tables are located here https://github.com/e2002/yoradio#connection-tables
1010
1111
********************************************************/
12-
/* CORE_FOR_LOOP_CONTROLS. See description/available values in the options.h file */
13-
/* This setting was added to eliminate audio jerking when adjusting the volume/playlist. The default value is 2 */
14-
#define CORE_FOR_LOOP_CONTROLS 2
15-
/******************************************/
1612

1713
/* DSP_MODEL. See description/available values in the options.h file */
1814
/* This option is required. Use DSP_DUMMY if no display is connected */

images/img21.jpg

278 KB
Loading

yoRadio/config.cpp

Lines changed: 69 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
#include <EEPROM.h>
33
#include <SPIFFS.h>
44
#include "display.h"
5+
#include "player.h"
56
Config config;
67

78
void Config::init() {
9+
EEPROM.begin(EEPROM_SIZE);
810
eepromRead(EEPROM_START, store);
9-
if (store.tz_set!=57){ // update to v0.4.200
11+
if (store.tz_set != 57) { // update to v0.4.200
1012
store.tz_set = 57;
1113
store.tzHour = 3;
1214
store.tzMin = 0;
@@ -29,22 +31,17 @@ void Config::init() {
2931
template <class T> int Config::eepromWrite(int ee, const T& value) {
3032
const byte* p = (const byte*)(const void*)&value;
3133
int i;
32-
EEPROM.begin(EEPROM_SIZE);
3334
for (i = 0; i < sizeof(value); i++)
3435
EEPROM.write(ee++, *p++);
3536
EEPROM.commit();
36-
delay(20);
37-
EEPROM.end();
3837
return i;
3938
}
4039

4140
template <class T> int Config::eepromRead(int ee, T& value) {
4241
byte* p = (byte*)(void*)&value;
43-
int i;
44-
EEPROM.begin(EEPROM_SIZE);
42+
int i;;
4543
for (i = 0; i < sizeof(value); i++)
4644
*p++ = EEPROM.read(ee++);
47-
EEPROM.end();
4845
return i;
4946
}
5047

@@ -67,13 +64,13 @@ void Config::setDefaults() {
6764
}
6865

6966
void Config::setTimezone(int8_t tzh, int8_t tzm) {
70-
store.tzHour=tzh;
71-
store.tzMin=tzm;
67+
store.tzHour = tzh;
68+
store.tzMin = tzm;
7269
save();
7370
}
7471

7572
void Config::setTimezoneOffset(uint16_t tzo) {
76-
store.timezoneOffset=tzo;
73+
store.timezoneOffset = tzo;
7774
save();
7875
}
7976

@@ -87,7 +84,11 @@ void Config::save() {
8784

8885
byte Config::setVolume(byte val, bool dosave) {
8986
store.volume = val;
90-
if (dosave) save();
87+
if (dosave) {
88+
//save();
89+
EEPROM.write(EEPROM_START + sizeof(store.config_set), store.volume);
90+
EEPROM.commit();
91+
}
9192
return store.volume;
9293
}
9394

@@ -128,17 +129,17 @@ byte Config::setLastSSID(byte val) {
128129
return store.lastSSID;
129130
}
130131

131-
void Config::setTitle(const char* title){
132+
void Config::setTitle(const char* title) {
132133
memset(config.station.title, 0, BUFLEN);
133134
strlcpy(config.station.title, title, BUFLEN);
134-
display.refreshTitle = true;
135+
display.title();
135136
}
136137

137-
void Config::setStation(const char* station){
138+
void Config::setStation(const char* station) {
138139
memset(config.station.name, 0, BUFLEN);
139140
strlcpy(config.station.name, station, BUFLEN);
140141
}
141-
142+
142143
void Config::indexPlaylist() {
143144
File playlist = SPIFFS.open(PLAYLIST_PATH, "r");
144145
if (!playlist) {
@@ -244,16 +245,16 @@ bool Config::parseCSV(const char* line, char* name, char* url, int &ovol) {
244245
char *tmpe;
245246
const char* cursor = line;
246247
char buf[5];
247-
tmpe=strstr(cursor, "\t");
248-
if(tmpe==NULL) return false;
249-
strlcpy(name, cursor, tmpe-cursor+1);
250-
if(strlen(name)==0) return false;
251-
cursor=tmpe+1;
252-
tmpe=strstr(cursor, "\t");
253-
if(tmpe==NULL) return false;
254-
strlcpy(url, cursor, tmpe-cursor+1);
255-
if(strlen(url)==0) return false;
256-
cursor=tmpe+1;
248+
tmpe = strstr(cursor, "\t");
249+
if (tmpe == NULL) return false;
250+
strlcpy(name, cursor, tmpe - cursor + 1);
251+
if (strlen(name) == 0) return false;
252+
cursor = tmpe + 1;
253+
tmpe = strstr(cursor, "\t");
254+
if (tmpe == NULL) return false;
255+
strlcpy(url, cursor, tmpe - cursor + 1);
256+
if (strlen(url) == 0) return false;
257+
cursor = tmpe + 1;
257258
if (strlen(cursor) == 0) return false;
258259
strlcpy(buf, cursor, 4);
259260
ovol = atoi(buf);
@@ -264,68 +265,68 @@ bool Config::parseJSON(const char* line, char* name, char* url, int &ovol) {
264265
char* tmps, *tmpe;
265266
const char* cursor = line;
266267
char port[8], host[254], file[254];
267-
tmps=strstr(cursor, "\":\"");
268-
if(tmps==NULL) return false;
269-
tmpe=strstr(tmps, "\",\"");
270-
if(tmpe==NULL) return false;
271-
strlcpy(name, tmps+3, tmpe-tmps-3+1);
272-
if(strlen(name)==0) return false;
273-
cursor=tmpe+3;
274-
tmps=strstr(cursor, "\":\"");
275-
if(tmps==NULL) return false;
276-
tmpe=strstr(tmps, "\",\"");
277-
if(tmpe==NULL) return false;
278-
strlcpy(host, tmps+3, tmpe-tmps-3+1);
279-
if(strlen(host)==0) return false;
280-
if(strstr(host,"http://")==NULL && strstr(host,"https://")==NULL) {
268+
tmps = strstr(cursor, "\":\"");
269+
if (tmps == NULL) return false;
270+
tmpe = strstr(tmps, "\",\"");
271+
if (tmpe == NULL) return false;
272+
strlcpy(name, tmps + 3, tmpe - tmps - 3 + 1);
273+
if (strlen(name) == 0) return false;
274+
cursor = tmpe + 3;
275+
tmps = strstr(cursor, "\":\"");
276+
if (tmps == NULL) return false;
277+
tmpe = strstr(tmps, "\",\"");
278+
if (tmpe == NULL) return false;
279+
strlcpy(host, tmps + 3, tmpe - tmps - 3 + 1);
280+
if (strlen(host) == 0) return false;
281+
if (strstr(host, "http://") == NULL && strstr(host, "https://") == NULL) {
281282
sprintf(file, "http://%s", host);
282-
strlcpy(host, file, strlen(file)+1);
283+
strlcpy(host, file, strlen(file) + 1);
283284
}
284-
cursor=tmpe+3;
285-
tmps=strstr(cursor, "\":\"");
286-
if(tmps==NULL) return false;
287-
tmpe=strstr(tmps, "\",\"");
288-
if(tmpe==NULL) return false;
289-
strlcpy(file, tmps+3, tmpe-tmps-3+1);
290-
cursor=tmpe+3;
291-
tmps=strstr(cursor, "\":\"");
292-
if(tmps==NULL) return false;
293-
tmpe=strstr(tmps, "\",\"");
294-
if(tmpe==NULL) return false;
295-
strlcpy(port, tmps+3, tmpe-tmps-3+1);
285+
cursor = tmpe + 3;
286+
tmps = strstr(cursor, "\":\"");
287+
if (tmps == NULL) return false;
288+
tmpe = strstr(tmps, "\",\"");
289+
if (tmpe == NULL) return false;
290+
strlcpy(file, tmps + 3, tmpe - tmps - 3 + 1);
291+
cursor = tmpe + 3;
292+
tmps = strstr(cursor, "\":\"");
293+
if (tmps == NULL) return false;
294+
tmpe = strstr(tmps, "\",\"");
295+
if (tmpe == NULL) return false;
296+
strlcpy(port, tmps + 3, tmpe - tmps - 3 + 1);
296297
int p = atoi(port);
297-
if(p>0){
298+
if (p > 0) {
298299
sprintf(url, "%s:%d%s", host, p, file);
299-
}else{
300+
} else {
300301
sprintf(url, "%s%s", host, file);
301302
}
302-
cursor=tmpe+3;
303-
tmps=strstr(cursor, "\":\"");
304-
if(tmps==NULL) return false;
305-
tmpe=strstr(tmps, "\"}");
306-
if(tmpe==NULL) return false;
307-
strlcpy(port, tmps+3, tmpe-tmps-3+1);
303+
cursor = tmpe + 3;
304+
tmps = strstr(cursor, "\":\"");
305+
if (tmps == NULL) return false;
306+
tmpe = strstr(tmps, "\"}");
307+
if (tmpe == NULL) return false;
308+
strlcpy(port, tmps + 3, tmpe - tmps - 3 + 1);
308309
ovol = atoi(port);
309310
return true;
310311
}
311312

312313
bool Config::parseWsCommand(const char* line, char* cmd, char* val, byte cSize) {
313314
char *tmpe;
314-
tmpe=strstr(line, "=");
315-
if(tmpe==NULL) return false;
315+
tmpe = strstr(line, "=");
316+
if (tmpe == NULL) return false;
316317
memset(cmd, 0, cSize);
317-
strlcpy(cmd, line, tmpe-line+1);
318-
if (strlen(tmpe+1) == 0) return false;
318+
strlcpy(cmd, line, tmpe - line + 1);
319+
if (strlen(tmpe + 1) == 0) return false;
319320
memset(val, 0, cSize);
320-
strlcpy(val, tmpe+1, tmpe+1-line+1);
321+
strlcpy(val, tmpe + 1, tmpe + 1 - line + 1);
321322
return true;
322323
}
323324

324325
bool Config::parseSsid(const char* line, char* ssid, char* pass) {
325326
char *tmpe;
326-
tmpe=strstr(line, "\t");
327-
if(tmpe==NULL) return false;
328-
uint16_t pos= tmpe-line;
327+
tmpe = strstr(line, "\t");
328+
if (tmpe == NULL) return false;
329+
uint16_t pos = tmpe - line;
329330
if (pos > 19 || strlen(line) > 61) return false;
330331
memset(ssid, 0, 20);
331332
strlcpy(ssid, line, pos + 1);

0 commit comments

Comments
 (0)