v0.9.350
This commit is contained in:
46
examples/plugins/backlightControls/backlightcontrols.cpp
Normal file
46
examples/plugins/backlightControls/backlightcontrols.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Example of display backlight control depending on playback.
|
||||
* To connect the plugin, copy its folder to the src/plugins directory.
|
||||
*/
|
||||
#include "backlightcontrols.h"
|
||||
#include <Arduino.h>
|
||||
#include <Ticker.h>
|
||||
#include "../../core/options.h"
|
||||
|
||||
Ticker backlightTicker;
|
||||
backlightControls blc;
|
||||
|
||||
const uint8_t backlightPin = 13;
|
||||
const uint8_t backlightInitValue = HIGH;
|
||||
const uint16_t turnBlOffInterval = 120; /* 2 min */
|
||||
|
||||
void backlightOff(){
|
||||
backlightTicker.detach();
|
||||
digitalWrite(backlightPin, !backlightInitValue);
|
||||
}
|
||||
|
||||
backlightControls::backlightControls() {
|
||||
registerPlugin();
|
||||
log_i("Plugin is registered");
|
||||
}
|
||||
|
||||
void backlightControls::on_setup(){
|
||||
log_i("%s called", __func__ );
|
||||
pinMode(backlightPin, OUTPUT);
|
||||
digitalWrite(backlightPin, backlightInitValue);
|
||||
backlightTicker.attach(turnBlOffInterval, backlightOff);
|
||||
}
|
||||
|
||||
void backlightControls::on_track_change(){
|
||||
log_i("%s called", __func__ );
|
||||
digitalWrite(backlightPin, backlightInitValue);
|
||||
backlightTicker.detach();
|
||||
backlightTicker.attach(turnBlOffInterval, backlightOff);
|
||||
}
|
||||
|
||||
void backlightControls::on_stop_play(){
|
||||
log_i("%s called", __func__ );
|
||||
digitalWrite(backlightPin, backlightInitValue);
|
||||
backlightTicker.detach();
|
||||
backlightTicker.attach(turnBlOffInterval, backlightOff);
|
||||
}
|
||||
23
examples/plugins/backlightControls/backlightcontrols.h
Normal file
23
examples/plugins/backlightControls/backlightcontrols.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Example of display backlight control depending on playback.
|
||||
* To connect the plugin, copy its folder to the src/plugins directory.
|
||||
*/
|
||||
#ifndef BACKLIGHTCONTROLS_H
|
||||
#define BACKLIGHTCONTROLS_H
|
||||
|
||||
#include "../../pluginsManager/pluginsManager.h"
|
||||
|
||||
class backlightControls : public Plugin {
|
||||
public:
|
||||
backlightControls();
|
||||
/**
|
||||
* See src/pluginsManager/pluginsManager.h for available events
|
||||
*/
|
||||
void on_setup();
|
||||
void on_track_change();
|
||||
void on_stop_play();
|
||||
};
|
||||
|
||||
|
||||
#endif // BACKLIGHTCONTROLS_H
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
*******************************************************************************************
|
||||
* Attention!
|
||||
* This method of connecting plugins no longer works and is left here for history.
|
||||
*******************************************************************************************
|
||||
|
||||
*/
|
||||
/**************************************************************
|
||||
|
||||
Example of display backlight control depending on playback.
|
||||
|
||||
54
examples/plugins/deepSleep/deepsleep.cpp
Normal file
54
examples/plugins/deepSleep/deepsleep.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* Example of esp32 deep sleep when playback is stopped.
|
||||
* To connect the plugin, copy its folder to the src/plugins directory.
|
||||
*/
|
||||
|
||||
#include "deepsleep.h"
|
||||
#include <Arduino.h>
|
||||
#include <Ticker.h>
|
||||
#include "../../core/options.h"
|
||||
#include "../../core/display.h"
|
||||
|
||||
#define SLEEP_DELAY 60 /* 1 min deep sleep delay */
|
||||
#define WAKEUP_PIN ENC_BTNB /* wakeup pin (one of: BTN_XXXX, ENC_BTNB, ENC2_BTNB) */
|
||||
/* must be one of: 0,2,4,12,13,14,15,25,26,27,32,33,34,35,36,39 */
|
||||
#define WAKEUP_LEVEL LOW /* wakeup level (usually LOW) */
|
||||
|
||||
Ticker deepSleepTicker;
|
||||
deepSleep dsleep;
|
||||
|
||||
deepSleep::deepSleep() {
|
||||
registerPlugin();
|
||||
log_i("Plugin is registered");
|
||||
}
|
||||
|
||||
void goToSleep(){
|
||||
if(BRIGHTNESS_PIN!=255) analogWrite(BRIGHTNESS_PIN, 0); /* BRIGHTNESS_PIN added in v0.7.330 */
|
||||
if(display.deepsleep()) { /* if deep sleep is possible */
|
||||
esp_deep_sleep_start(); /* go to sleep */
|
||||
}else{ /* else */
|
||||
deepSleepTicker.detach(); /* detach the timer */
|
||||
}
|
||||
}
|
||||
|
||||
void deepSleep::on_setup(){ /* occurs during loading */
|
||||
log_i("%s called", __func__ );
|
||||
if(WAKEUP_PIN!=255){
|
||||
esp_sleep_enable_ext0_wakeup((gpio_num_t)WAKEUP_PIN, WAKEUP_LEVEL); /* enable wakeup pin */
|
||||
deepSleepTicker.attach(SLEEP_DELAY, goToSleep); /* attach to delay */
|
||||
}
|
||||
}
|
||||
|
||||
void deepSleep::on_start_play(){ /* occurs during player is start playing */
|
||||
log_i("%s called", __func__ );
|
||||
if(WAKEUP_PIN!=255){
|
||||
deepSleepTicker.detach(); /* detach the timer */
|
||||
}
|
||||
}
|
||||
|
||||
void deepSleep::on_stop_play(){ /* occurs during player is stop playing */
|
||||
log_i("%s called", __func__ );
|
||||
if(WAKEUP_PIN!=255){
|
||||
deepSleepTicker.attach(SLEEP_DELAY, goToSleep); /* attach to delay */
|
||||
}
|
||||
}
|
||||
23
examples/plugins/deepSleep/deepsleep.h
Normal file
23
examples/plugins/deepSleep/deepsleep.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* Example of esp32 deep sleep when playback is stopped.
|
||||
* To connect the plugin, copy its folder to the src/plugins directory.
|
||||
*/
|
||||
#ifndef DEEPSLEEP_H
|
||||
#define DEEPSLEEP_H
|
||||
|
||||
#include "../../pluginsManager/pluginsManager.h"
|
||||
|
||||
class deepSleep : public Plugin {
|
||||
public:
|
||||
deepSleep();
|
||||
/**
|
||||
* See src/pluginsManager/pluginsManager.h for available events
|
||||
*/
|
||||
void on_setup();
|
||||
void on_start_play();
|
||||
void on_stop_play();
|
||||
};
|
||||
|
||||
|
||||
#endif // DEEPSLEEP_H
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
*******************************************************************************************
|
||||
* Attention!
|
||||
* This method of connecting plugins no longer works and is left here for history.
|
||||
*******************************************************************************************
|
||||
|
||||
*/
|
||||
/******************************************************************************************************************
|
||||
|
||||
Example of esp32 deep sleep when playback is stopped.
|
||||
|
||||
62
examples/plugins/helloWorld/helloworld.cpp
Normal file
62
examples/plugins/helloWorld/helloworld.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* Example of a plugin.
|
||||
* To connect the plugin, copy its folder to the src/plugins directory.
|
||||
*/
|
||||
|
||||
#include "helloworld.h"
|
||||
#include "../../core/options.h"
|
||||
|
||||
helloWorld hellow;
|
||||
|
||||
helloWorld::helloWorld() {
|
||||
registerPlugin();
|
||||
log_i("Plugin is registered");
|
||||
}
|
||||
|
||||
void helloWorld::on_setup(){
|
||||
log_i("%s called", __func__ );
|
||||
}
|
||||
|
||||
void helloWorld::on_end_setup(){
|
||||
log_i("%s called", __func__ );
|
||||
}
|
||||
|
||||
void helloWorld::on_connect(){
|
||||
log_i("%s called", __func__ );
|
||||
}
|
||||
|
||||
void helloWorld::on_start_play(){
|
||||
log_i("%s called", __func__ );
|
||||
}
|
||||
|
||||
void helloWorld::on_stop_play(){
|
||||
log_i("%s called", __func__ );
|
||||
}
|
||||
|
||||
void helloWorld::on_track_change(){
|
||||
log_i("%s called", __func__ );
|
||||
}
|
||||
|
||||
void helloWorld::on_station_change(){
|
||||
log_i("%s called", __func__ );
|
||||
}
|
||||
|
||||
void helloWorld::on_display_queue(requestParams_t &request, bool& result){
|
||||
result = true;
|
||||
log_i("%s called, type=%d, payload=%d ", __func__ , request.type, request.payload);
|
||||
}
|
||||
|
||||
void helloWorld::on_display_player(){
|
||||
log_i("%s called", __func__ );
|
||||
}
|
||||
|
||||
void helloWorld::on_ticker(){
|
||||
log_i("%s called", __func__ );
|
||||
}
|
||||
|
||||
void helloWorld::on_btn_click(controlEvt_e &btnid){
|
||||
log_i("%s called, btnid=%d", __func__ , btnid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
31
examples/plugins/helloWorld/helloworld.h
Normal file
31
examples/plugins/helloWorld/helloworld.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* Example of a plugin.
|
||||
* To connect the plugin, copy its folder to the src/plugins directory.
|
||||
*/
|
||||
#ifndef HELLOWORLD_H
|
||||
#define HELLOWORLD_H
|
||||
|
||||
#include "../../pluginsManager/pluginsManager.h"
|
||||
|
||||
class helloWorld : public Plugin {
|
||||
public:
|
||||
helloWorld();
|
||||
/**
|
||||
* See src/pluginsManager/pluginsManager.h for available events
|
||||
*/
|
||||
void on_setup();
|
||||
void on_end_setup();
|
||||
void on_connect();
|
||||
void on_start_play();
|
||||
void on_stop_play();
|
||||
void on_track_change();
|
||||
void on_station_change();
|
||||
void on_display_queue(requestParams_t &request, bool& result);
|
||||
void on_display_player();
|
||||
void on_ticker();
|
||||
void on_btn_click(controlEvt_e &btnid);
|
||||
};
|
||||
|
||||
|
||||
#endif // HELLOWORLD_H
|
||||
|
||||
Reference in New Issue
Block a user