Skip to content

Commit 001fcb4

Browse files
committed
v0.9.350
1 parent fd6c1ea commit 001fcb4

26 files changed

+679
-110
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,28 @@ download _http://\<yoradioip\>/data/playlist.csv_ and _http://\<yoradioip\>/data
225225

226226
---
227227
## Plugins
228-
There is no documentation yet, you will have to deal with the examples, which is in directory [examples/plugins/](https://github.com/e2002/yoradio/tree/main/examples/plugins).\
228+
The `Plugin` class serves as a base class for creating plugins that hook into various system events.
229+
To use it, inherit from `Plugin` and override the necessary virtual methods.
230+
Place your new class in the `src/plugins/<MyPlugin>` directory
231+
More details can be found in the comments within the `yoRadio/src/pluginsManager/pluginsManager.h` file and at [here](https://github.com/e2002/yoradio/blob/main/yoRadio/src/pluginsManager/README.md).
232+
Additional examples are provided in the `examples/plugins` folder.
229233
Work is in progress...
230234

231235
---
232236
## Version history
237+
#### v0.9.350
238+
- **Added parameters for configuring `LED_BUILTIN` on ESP32S3 modules:**
239+
- `USE_BUILTIN_LED`: Determines whether to use the built-in `LED_BUILTIN` (default is `true`).
240+
- `LED_BUILTIN_S3`: Specifies a custom pin for the built-in `LED_BUILTIN`. Used in combination with `USE_BUILTIN_LED = false` (default is `255`).
241+
242+
**Note:** For ESP32S3 boards, no changes are required by default; the onboard LED will work as expected.
243+
These settings were added to allow disabling the built-in LED or reassigning it to a custom pin.
244+
245+
- **New class for plugin management**, enabling multiple plugins to be assigned to each function.
246+
More details can be found in the comments within the `yoRadio/src/pluginsManager/pluginsManager.h` file and at [here](https://github.com/e2002/yoradio/blob/main/yoRadio/src/pluginsManager/README.md).
247+
Additional examples are provided in the `examples/plugins` folder.
248+
**Backward compatibility:** The old method of adding plugins will remain functional for some time in future versions but will eventually be deprecated and removed.
249+
233250
#### v0.9.342b
234251
- fixed compilation error for OLED displays
235252

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* Example of display backlight control depending on playback.
3+
* To connect the plugin, copy its folder to the src/plugins directory.
4+
*/
5+
#include "backlightcontrols.h"
6+
#include <Arduino.h>
7+
#include <Ticker.h>
8+
#include "../../core/options.h"
9+
10+
Ticker backlightTicker;
11+
backlightControls blc;
12+
13+
const uint8_t backlightPin = 13;
14+
const uint8_t backlightInitValue = HIGH;
15+
const uint16_t turnBlOffInterval = 120; /* 2 min */
16+
17+
void backlightOff(){
18+
backlightTicker.detach();
19+
digitalWrite(backlightPin, !backlightInitValue);
20+
}
21+
22+
backlightControls::backlightControls() {
23+
registerPlugin();
24+
log_i("Plugin is registered");
25+
}
26+
27+
void backlightControls::on_setup(){
28+
log_i("%s called", __func__ );
29+
pinMode(backlightPin, OUTPUT);
30+
digitalWrite(backlightPin, backlightInitValue);
31+
backlightTicker.attach(turnBlOffInterval, backlightOff);
32+
}
33+
34+
void backlightControls::on_track_change(){
35+
log_i("%s called", __func__ );
36+
digitalWrite(backlightPin, backlightInitValue);
37+
backlightTicker.detach();
38+
backlightTicker.attach(turnBlOffInterval, backlightOff);
39+
}
40+
41+
void backlightControls::on_stop_play(){
42+
log_i("%s called", __func__ );
43+
digitalWrite(backlightPin, backlightInitValue);
44+
backlightTicker.detach();
45+
backlightTicker.attach(turnBlOffInterval, backlightOff);
46+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* Example of display backlight control depending on playback.
3+
* To connect the plugin, copy its folder to the src/plugins directory.
4+
*/
5+
#ifndef BACKLIGHTCONTROLS_H
6+
#define BACKLIGHTCONTROLS_H
7+
8+
#include "../../pluginsManager/pluginsManager.h"
9+
10+
class backlightControls : public Plugin {
11+
public:
12+
backlightControls();
13+
/**
14+
* See src/pluginsManager/pluginsManager.h for available events
15+
*/
16+
void on_setup();
17+
void on_track_change();
18+
void on_stop_play();
19+
};
20+
21+
22+
#endif // BACKLIGHTCONTROLS_H
23+

examples/plugins/backlightcontrols.ino

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/*
2+
*******************************************************************************************
3+
* Attention!
4+
* This method of connecting plugins no longer works and is left here for history.
5+
*******************************************************************************************
6+
7+
*/
18
/**************************************************************
29
310
Example of display backlight control depending on playback.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/**
2+
* Example of esp32 deep sleep when playback is stopped.
3+
* To connect the plugin, copy its folder to the src/plugins directory.
4+
*/
5+
6+
#include "deepsleep.h"
7+
#include <Arduino.h>
8+
#include <Ticker.h>
9+
#include "../../core/options.h"
10+
#include "../../core/display.h"
11+
12+
#define SLEEP_DELAY 60 /* 1 min deep sleep delay */
13+
#define WAKEUP_PIN ENC_BTNB /* wakeup pin (one of: BTN_XXXX, ENC_BTNB, ENC2_BTNB) */
14+
/* must be one of: 0,2,4,12,13,14,15,25,26,27,32,33,34,35,36,39 */
15+
#define WAKEUP_LEVEL LOW /* wakeup level (usually LOW) */
16+
17+
Ticker deepSleepTicker;
18+
deepSleep dsleep;
19+
20+
deepSleep::deepSleep() {
21+
registerPlugin();
22+
log_i("Plugin is registered");
23+
}
24+
25+
void goToSleep(){
26+
if(BRIGHTNESS_PIN!=255) analogWrite(BRIGHTNESS_PIN, 0); /* BRIGHTNESS_PIN added in v0.7.330 */
27+
if(display.deepsleep()) { /* if deep sleep is possible */
28+
esp_deep_sleep_start(); /* go to sleep */
29+
}else{ /* else */
30+
deepSleepTicker.detach(); /* detach the timer */
31+
}
32+
}
33+
34+
void deepSleep::on_setup(){ /* occurs during loading */
35+
log_i("%s called", __func__ );
36+
if(WAKEUP_PIN!=255){
37+
esp_sleep_enable_ext0_wakeup((gpio_num_t)WAKEUP_PIN, WAKEUP_LEVEL); /* enable wakeup pin */
38+
deepSleepTicker.attach(SLEEP_DELAY, goToSleep); /* attach to delay */
39+
}
40+
}
41+
42+
void deepSleep::on_start_play(){ /* occurs during player is start playing */
43+
log_i("%s called", __func__ );
44+
if(WAKEUP_PIN!=255){
45+
deepSleepTicker.detach(); /* detach the timer */
46+
}
47+
}
48+
49+
void deepSleep::on_stop_play(){ /* occurs during player is stop playing */
50+
log_i("%s called", __func__ );
51+
if(WAKEUP_PIN!=255){
52+
deepSleepTicker.attach(SLEEP_DELAY, goToSleep); /* attach to delay */
53+
}
54+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* Example of esp32 deep sleep when playback is stopped.
3+
* To connect the plugin, copy its folder to the src/plugins directory.
4+
*/
5+
#ifndef DEEPSLEEP_H
6+
#define DEEPSLEEP_H
7+
8+
#include "../../pluginsManager/pluginsManager.h"
9+
10+
class deepSleep : public Plugin {
11+
public:
12+
deepSleep();
13+
/**
14+
* See src/pluginsManager/pluginsManager.h for available events
15+
*/
16+
void on_setup();
17+
void on_start_play();
18+
void on_stop_play();
19+
};
20+
21+
22+
#endif // DEEPSLEEP_H
23+

examples/plugins/deepsleep.ino

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/*
2+
*******************************************************************************************
3+
* Attention!
4+
* This method of connecting plugins no longer works and is left here for history.
5+
*******************************************************************************************
6+
7+
*/
18
/******************************************************************************************************************
29
310
Example of esp32 deep sleep when playback is stopped.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* Example of a plugin.
3+
* To connect the plugin, copy its folder to the src/plugins directory.
4+
*/
5+
6+
#include "helloworld.h"
7+
#include "../../core/options.h"
8+
9+
helloWorld hellow;
10+
11+
helloWorld::helloWorld() {
12+
registerPlugin();
13+
log_i("Plugin is registered");
14+
}
15+
16+
void helloWorld::on_setup(){
17+
log_i("%s called", __func__ );
18+
}
19+
20+
void helloWorld::on_end_setup(){
21+
log_i("%s called", __func__ );
22+
}
23+
24+
void helloWorld::on_connect(){
25+
log_i("%s called", __func__ );
26+
}
27+
28+
void helloWorld::on_start_play(){
29+
log_i("%s called", __func__ );
30+
}
31+
32+
void helloWorld::on_stop_play(){
33+
log_i("%s called", __func__ );
34+
}
35+
36+
void helloWorld::on_track_change(){
37+
log_i("%s called", __func__ );
38+
}
39+
40+
void helloWorld::on_station_change(){
41+
log_i("%s called", __func__ );
42+
}
43+
44+
void helloWorld::on_display_queue(requestParams_t &request, bool& result){
45+
result = true;
46+
log_i("%s called, type=%d, payload=%d ", __func__ , request.type, request.payload);
47+
}
48+
49+
void helloWorld::on_display_player(){
50+
log_i("%s called", __func__ );
51+
}
52+
53+
void helloWorld::on_ticker(){
54+
log_i("%s called", __func__ );
55+
}
56+
57+
void helloWorld::on_btn_click(controlEvt_e &btnid){
58+
log_i("%s called, btnid=%d", __func__ , btnid);
59+
}
60+
61+
62+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Example of a plugin.
3+
* To connect the plugin, copy its folder to the src/plugins directory.
4+
*/
5+
#ifndef HELLOWORLD_H
6+
#define HELLOWORLD_H
7+
8+
#include "../../pluginsManager/pluginsManager.h"
9+
10+
class helloWorld : public Plugin {
11+
public:
12+
helloWorld();
13+
/**
14+
* See src/pluginsManager/pluginsManager.h for available events
15+
*/
16+
void on_setup();
17+
void on_end_setup();
18+
void on_connect();
19+
void on_start_play();
20+
void on_stop_play();
21+
void on_track_change();
22+
void on_station_change();
23+
void on_display_queue(requestParams_t &request, bool& result);
24+
void on_display_player();
25+
void on_ticker();
26+
void on_btn_click(controlEvt_e &btnid);
27+
};
28+
29+
30+
#endif // HELLOWORLD_H
31+

yoRadio/src/AsyncWebServer/AsyncWebSocket.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -833,11 +833,7 @@ void AsyncWebSocketClient::binary(AsyncWebSocketMessageBuffer * buffer)
833833

834834
IPAddress AsyncWebSocketClient::remoteIP() {
835835
if(!_client) {
836-
#if ESP_IDF_VERSION_MAJOR < 5
837-
return IPAddress(0U);
838-
#else
839-
return IPAddress(0ul);
840-
#endif
836+
return IPAddress((uint32_t)0);
841837
}
842838
return _client->remoteIP();
843839
}

0 commit comments

Comments
 (0)