Skip to content

Commit 287bc69

Browse files
committed
v0.4.210
1 parent e20bcd9 commit 287bc69

File tree

13 files changed

+163
-61
lines changed

13 files changed

+163
-61
lines changed

README.md

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ Three tact buttons or Encoder or all together
4242
| RSTL | 15* | TFT_RST |
4343
| DCL | 4* | TFT_DC |
4444

45+
| NOKIA5110 | ESP-32 | options.h |
46+
| ------ | ------ | ------ |
47+
| RST | 15* | TFT_RST |
48+
| CE | 5* | TFT_CS |
49+
| DC | 4* | TFT_DC |
50+
| DIN | 23 | - |
51+
| CLK | 18 | - |
52+
| VCC | +3v3 | - |
53+
| GND | GND | - |
54+
4555
| I2C Display | ESP-32 | options.h |
4656
| ------ | ------ | ------ |
4757
| GND | GND | - |
@@ -76,7 +86,7 @@ Adafruit_GFX, Adafruit_ST7735\*, Adafruit_SSD1306\*, Adafruit_PCD8544\*, (\* dep
7686
## Hardware setup
7787
Hardware is connected in the **[options.h](yoRadio/options.h)** file. \
7888
_so that the settings are not overwritten when updating git, you need to put the file **myoptions.h** ([exsample](exsamples/myoptions.h)) in the root of the project and make settings in it_
79-
````
89+
````c++
8090
/* DISPLAY MODEL
8191
* 0 - DUMMY
8292
* 1 - ST7735
@@ -86,16 +96,16 @@ _so that the settings are not overwritten when updating git, you need to put the
8696
#define DSP_MODEL 1
8797
````
8898
The ST7735 display model is configured in the file [src/displays/displayST7735.cpp](yoRadio/src/displays/displayST7735.cpp)
89-
````
99+
````c++
90100
#define DTYPE INITR_BLACKTAB // 1.8' https://aliexpress.ru/item/1005002822797745.html
91101
//#define DTYPE INITR_144GREENTAB // 1.44' https://aliexpress.ru/item/1005002822797745.html
92102
````
93103
Rotation of the ST7735 display is configured in the file [src/displays/displayST7735.h](yoRadio/src/displays/displayST7735.h)
94-
````
104+
````c++
95105
#define TFT_ROTATE 3 // 180 degress
96106
````
97107
If there is a noisy line on one side of the screen, then in Adafruit_ST7735.cpp:
98-
````
108+
````c++
99109
// Black tab, change MADCTL color filter
100110
if ((options == INITR_BLACKTAB) || (options == INITR_MINI160x80)) {
101111
uint8_t data = 0xC0;
@@ -107,42 +117,50 @@ If there is a noisy line on one side of the screen, then in Adafruit_ST7735.cpp:
107117

108118
---
109119
## Quick start
110-
1. In ArduinoIDE - upload sketch data (Tools→ESP32 Sketch Data Upload)
111-
2. Upload the sketch to the board ([example of the board connection](images/board.jpg))
120+
1. In ArduinoIDE - upload sketch data via Tools→ESP32 Sketch Data Upload ([it's here](images/board2.jpg))
121+
2. Upload the sketch to the board ([example of the board settings](images/board.jpg))
112122
3. Connect to yoRadioAP acces point with password 12345987, go to http://192.168.4.1/ configure and wifi connections. \
113123
_\*this step can be skipped if you add WiFiSSID WiFiPassword pairs to the [yoRadio/data/data/wifi.csv](yoRadio/data/data/wifi.csv) file (tab-separated values, one line per access point) before uploading the sketch data in step 1_
114-
4. After successful connection go to http://\<ipaddress\>/ , add stations to playlist (or import WebStations.txt from KaRadio)
124+
4. After successful connection go to http://\<yoipaddress\>/ , add stations to playlist (or import WebStations.txt from KaRadio)
115125
5. Well done!
116126

117-
**localization:**
127+
**Localization:**
118128
Если Adafruit_GFX ещё не русифицирована, русифицировать её, заменив файл Arduino/libraries/Adafruit_GFX_Library/glcdfont.c файлом [yoRadio/fonts/glcdfont.c](yoRadio/fonts/glcdfont.c)
119129

120130
---
121131
## More features
122132
- Сan add up to 65535 stations to a playlist. Supports and imports [KaRadio](https://github.com/karawin/Ka-Radio32) playlists (WebStations.txt)
123133
- Telnet with KaRadio format output \
124134
**Commands**: \
125-
cli.prev (or simply prev) - previous station \
126-
cli.next, next - next station \
127-
cli.toggle, toggle - start/stop \
128-
cli.stop, stop - stop \
129-
cli.start, start, cli.play, play - start playing \
130-
cli.play("x"), play(x), play x - play station x \
131-
cli.vol, vol - the current value of volume (0-254) \
132-
cli.vol("x"), vol(x), vol x - set volume (0-254) \
133-
cli.audioinfo, audioinfo - the current value of debug (0-1) \
134-
cli.audioinfo("x"), audioinfo(x), audioinfo x - debug on/off (0-1) \
135-
cli.smartstart, smartstart - the current value of smart start \
136-
cli.smartstart("x"), smartstart(x), smartstart x - smart start: 2-off, 0-1 - start playing on boot, if the radio was playing before the reboot \
137-
cli.list, list - get playlist \
138-
cli.info, info - get current state \
139-
sys.boot, boot, reboot - reboot \
140-
sys.date - date/time
135+
**cli.prev** (_or simply_ **prev**) - previous station \
136+
**cli.next** _or_ **next** - next station \
137+
**cli.toggle** _or_ **toggle** - start/stop \
138+
**cli.stop** _or_ **stop** - stop \
139+
**cli.start** _or_ **start** _or_ **cli.play** _or_ **play** - start playing \
140+
**cli.play("x")** _or_ **play(x)** _or_ **play x** - play station x \
141+
**cli.vol** _or_ **vol** - display the current value of volume (0-254) \
142+
**cli.vol("x")** _or_ **vol(x)** _or_ **vol x** - set volume (0-254) \
143+
**cli.audioinfo** _or_ **audioinfo** - display the current value of debug (0-1) \
144+
**cli.audioinfo("x")** _or_ **audioinfo(x)** _or_ **audioinfo x** - debug on/off (0-1) \
145+
**cli.smartstart** _or_ **smartstart** - display the current value of smart start \
146+
**cli.smartstart("x")** _or_ **smartstart(x)** _or_ **smartstart x** - smart start: 2-off, 0-1 - start playing on boot, if the radio was playing before the reboot \
147+
**cli.list** _or_ **list** - display playlist \
148+
**cli.info** _or_ **info** - display current state \
149+
**sys.boot** _or_ **boot** _or_ **reboot** - reboot \
150+
**sys.date** - sync date/time and display it \
151+
**sys.tzo** _or_ **tzo** - display the timezone offset \
152+
**sys.tzo("h:m")** _or_ **tzo(h:m)** _or_ **tzo h:m** - set timezone offset \
153+
**sys.tzo("h")** _or_ **tzo(h)** _or_ **tzo h** - set timezone offset in hours only
141154

142155
---
143156
## Version history
157+
#### v0.4.210
158+
- added timezone config by telnet
159+
- fix telnet output
160+
- some separation apples and oranges
161+
144162
#### v0.4.199
145-
- excluded required installation of all libraries for displays.
163+
- excluded required installation of all libraries for displays
146164

147165
#### v0.4.197
148166
- added support for Nokia 5110 SPI displays

images/board.jpg

39.1 KB
Loading

images/board2.jpg

102 KB
Loading

yoRadio/audiohandlers.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void audio_showstreamtitle(const char *info) {
3333
telnet.info();
3434
player.requesToStart = false;
3535
} else {
36-
telnet.printf("##CLI.META#: %s\n", info);
36+
telnet.printf("##CLI.META#: %s\n> ", info);
3737
}
3838
}
3939
}

yoRadio/config.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ Config config;
66

77
void Config::init() {
88
eepromRead(EEPROM_START, store);
9+
if (store.tz_set!=57){ // update to v0.4.200
10+
store.tz_set = 57;
11+
store.tzHour = 3;
12+
store.tzMin = 0;
13+
store.timezoneOffset = 0;
14+
}
915
if (store.config_set != 4256) setDefaults();
1016
//if (!SPIFFS.begin(false, "/spiffs", 30)) {
1117
if (!SPIFFS.begin(false)) {
@@ -54,6 +60,25 @@ void Config::setDefaults() {
5460
store.lastSSID = 0;
5561
store.audioinfo = false;
5662
store.smartstart = 2;
63+
store.tz_set = 57;
64+
store.tzHour = 3;
65+
store.tzMin = 0;
66+
store.timezoneOffset = 0;
67+
}
68+
69+
void Config::setTimezone(int8_t tzh, int8_t tzm) {
70+
store.tzHour=tzh;
71+
store.tzMin=tzm;
72+
save();
73+
}
74+
75+
void Config::setTimezoneOffset(uint16_t tzo) {
76+
store.timezoneOffset=tzo;
77+
save();
78+
}
79+
80+
uint16_t Config::getTimezoneOffset() {
81+
return 0; // TODO
5782
}
5883

5984
void Config::save() {

yoRadio/config.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ struct config_t
2323
byte lastSSID;
2424
bool audioinfo;
2525
byte smartstart;
26+
byte tz_set; // must be 57
27+
int8_t tzHour;
28+
int8_t tzMin;
29+
uint16_t timezoneOffset;
2630
};
2731

2832
struct station_t
@@ -67,6 +71,9 @@ class Config {
6771
void initPlaylist();
6872
void indexPlaylist();
6973
void fillPlMenu(char plmenu[][40], int from, byte count);
74+
void setTimezone(int8_t tzh, int8_t tzm);
75+
void setTimezoneOffset(uint16_t tzo);
76+
uint16_t getTimezoneOffset();
7077
private:
7178
template <class T> int eepromWrite(int ee, const T& value);
7279
template <class T> int eepromRead(int ee, T& value);

yoRadio/display.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
#include "options.h"
2+
13
#include "WiFi.h"
24
#include "time.h"
35
#include "display.h"
46

57
#include "player.h"
68
#include "netserver.h"
7-
#include "options.h"
89
#include "network.h"
910

1011
#if DSP_MODEL==0
@@ -85,7 +86,7 @@ void Scroll::clearscrolls() {
8586
void Scroll::loop() {
8687
if (checkdelay(x == TFT_FRAMEWDT ? delayStartScroll : SCROLLTIME, scrolldelay)) {
8788
scroll();
88-
ticks();
89+
sticks();
8990
}
9091
yield();
9192
}
@@ -103,7 +104,7 @@ void Scroll::drawFrame() {
103104
dsp.drawScrollFrame(texttop, textheight, bg);
104105
}
105106

106-
void Scroll::ticks() {
107+
void Scroll::sticks() {
107108
if (!doscroll || locked) return;
108109
setTextParams();
109110
dsp.set_Cursor(x, texttop);
@@ -170,7 +171,6 @@ void Display::start() {
170171
station();
171172
rssi();
172173
time();
173-
configTime(TIMEZONE, OFFSET, "pool.ntp.org", "ru.pool.ntp.org");
174174
timer.attach_ms(1000, ticks);
175175
// Экстреминатус секвестирован
176176
}
@@ -213,14 +213,8 @@ void Display::swichMode(displayMode_e newmode) {
213213

214214
void Display::drawPlayer() {
215215
if (clockRequest) {
216-
if (syncTicks % 21600 == 0) { //6hours
217-
configTime(TIMEZONE, OFFSET, "pool.ntp.org", "ru.pool.ntp.org");
218-
yield();
219-
syncTicks = 0;
220-
}
221-
getLocalTime(&timeinfo);
216+
getLocalTime(&network.timeinfo);
222217
time();
223-
syncTicks++;
224218
clockRequest = false;
225219
}
226220
meta.loop();
@@ -322,9 +316,9 @@ void Display::time() {
322316
if (!dt) {
323317
heap();
324318
rssi();
325-
strftime(timeStringBuff, sizeof(timeStringBuff), "%H:%M", &timeinfo);
319+
strftime(timeStringBuff, sizeof(timeStringBuff), "%H:%M", &network.timeinfo);
326320
} else {
327-
strftime(timeStringBuff, sizeof(timeStringBuff), "%H %M", &timeinfo);
321+
strftime(timeStringBuff, sizeof(timeStringBuff), "%H %M", &network.timeinfo);
328322
}
329323
dsp.printClock(timeStringBuff);
330324
dt = !dt;

yoRadio/display.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
enum displayMode_e { PLAYER, VOL, STATIONS };
99

10-
#define TIMEZONE 10800 // 3600*3=10800 (UTC+3)
11-
#define OFFSET 0 // Daylight Offset (sec.)
12-
1310
class Scroll {
1411
public:
1512
Scroll() { };
@@ -33,16 +30,14 @@ class Scroll {
3330
void getbounds(uint16_t &tWidth, uint16_t &tHeight, uint16_t &sWidth);
3431
boolean checkdelay(int m, unsigned long &tstamp);
3532
void scroll();
36-
void ticks();
33+
void sticks();
3734
void clear();
3835
void setTextParams();
3936
void drawFrame();
4037
};
4138

4239
class Display {
4340
public:
44-
struct tm timeinfo;
45-
uint16_t syncTicks;
4641
bool clockRequest;
4742
uint16_t screenwidth, screenheight;
4843
displayMode_e mode;

yoRadio/network.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@
22
#include "WiFi.h"
33
#include "display.h"
44
#include "options.h"
5+
#include "config.h"
6+
#include "telnet.h"
57

68
Network network;
79

10+
void syncTime() {
11+
network.requestTimeSync(true);
12+
}
13+
814
void Network::begin() {
915
config.initNetwork();
1016
if (config.ssidsCount == 0) {
@@ -35,7 +41,7 @@ void Network::begin() {
3541
break;
3642
}
3743
}
38-
if(WiFi.status() != WL_CONNECTED && ls==startedls){
44+
if (WiFi.status() != WL_CONNECTED && ls == startedls) {
3945
raiseSoftAP();
4046
return;
4147
}
@@ -46,6 +52,22 @@ void Network::begin() {
4652
}
4753
digitalWrite(LED_BUILTIN, LOW);
4854
status = CONNECTED;
55+
requestTimeSync();
56+
ntimer.attach_ms(TSYNC_DELAY, syncTime);
57+
}
58+
59+
void Network::requestTimeSync(bool withTelnetOutput) {
60+
configTime(config.store.tzHour * 3600 + config.store.tzMin * 60, config.getTimezoneOffset(), "pool.ntp.org", "ru.pool.ntp.org");
61+
if (withTelnetOutput) {
62+
getLocalTime(&timeinfo);
63+
char timeStringBuff[50];
64+
strftime(timeStringBuff, sizeof(timeStringBuff), "%Y-%m-%dT%H:%M:%S", &timeinfo);
65+
if (config.store.tzHour < 0) {
66+
telnet.printf(0, "##SYS.DATE#: %s%03d:%02d\n> ", timeStringBuff, config.store.tzHour, config.store.tzMin);
67+
} else {
68+
telnet.printf(0, "##SYS.DATE#: %s+%02d:%02d\n> ", timeStringBuff, config.store.tzHour, config.store.tzMin);
69+
}
70+
}
4971
}
5072

5173
void Network::raiseSoftAP() {

yoRadio/network.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
#ifndef network_h
22
#define network_h
3+
#include <Ticker.h>
4+
#include "time.h"
35

46
#define apSsid "yoRadioAP"
57
#define apPassword "12345987"
8+
#define TSYNC_DELAY 10800000 // 1000*60*60*3 = 3 hours
69

710
enum n_Status_e { CONNECTED, SOFT_AP, FAILED };
811

912
class Network {
1013
public:
1114
n_Status_e status;
15+
struct tm timeinfo;
1216
public:
1317
Network() {};
1418
void begin();
19+
void requestTimeSync(bool withTelnetOutput=false);
1520
private:
21+
Ticker ntimer;
1622
void raiseSoftAP();
1723
};
1824

0 commit comments

Comments
 (0)