This commit is contained in:
e2002
2023-02-24 17:15:17 +03:00
parent 6bef9ca9d7
commit a43d639467
12 changed files with 56 additions and 48 deletions

24
examples/mqttoptions.h Normal file
View File

@@ -0,0 +1,24 @@
#define MQTT_HOST "192.168.3.100"
#define MQTT_PORT 1883
#define MQTT_USER ""
#define MQTT_PASS ""
#define MQTT_ROOT_TOPIC "yoradio/100/"
/*
Topics:
MQTT_ROOT_TOPIC/command // Commands
MQTT_ROOT_TOPIC/status // Player status
MQTT_ROOT_TOPIC/playlist // Playlist URL
MQTT_ROOT_TOPIC/volume // Current volume
Commands:
prev // prev station
next // next station
toggle // start/stop playing
stop // stop playing
start, play // start playing
boot, reboot // reboot
vol x // set volume
play x // play station x
*/

164
examples/myoptions.h Normal file
View File

@@ -0,0 +1,164 @@
#ifndef myoptions_h
#define myoptions_h
/*******************************************************
Copy this file in the project root directory (next to the yoRadio.ino file)
Uncomment the lines you need, to override the default value and set the values according to the connected equipment.
The connection tables are located here https://github.com/e2002/yoradio#connection-tables
********************************************************/
//#define LED_BUILTIN 255 /* Onboard LED Pin (turn OFF by default) */
//#define LED_INVERT false /* Invert Onboard LED? */
#define L10N_LANGUAGE EN /* Language (EN, RU). More info in yoRadio/locale/displayL10n_(en|ru).h */
/* DSP_MODEL. See description/available values in https://github.com/e2002/yoradio/wiki/Available-display-models */
/* This option is required. Use DSP_DUMMY if no display is connected */
#define DSP_MODEL DSP_DUMMY
/*
* !!! Important !!!
* if you use colored TFT displays with the esp32 wroom, due to lack of memory, you must modify the file Arduino/libraries/AsyncTCP/src/AsyncTCP.cpp
* replace the line 221
* xTaskCreateUniversal(_async_service_task, "async_tcp", 8192 * 2, NULL, 3, &_async_service_task_handle, CONFIG_ASYNC_TCP_RUNNING_CORE);
* with
* xTaskCreateUniversal(_async_service_task, "async_tcp", 8192 / 2, NULL, 3, &_async_service_task_handle, CONFIG_ASYNC_TCP_RUNNING_CORE);
*/
/******************************************/
/* VSPI PINS. SCL(SCK, CLK) must be connected to pin 18
SDA(MOSI, DIN, SDI) must be connected to pin 23 */
//#define TFT_CS 5 /* SPI CS pin */
//#define TFT_RST 15 /* SPI RST pin. set to -1 and connect to Esp EN pin */
//#define TFT_DC 4 /* SPI DC/RS pin */
/* HSPI PINS. SCL(SCK, CLK) must be connected to pin 14
SDA(MOSI, DIN, SDI) must be connected to pin 13 */
//#define DSP_HSPI false /* Use HSPI for display */
/******************************************/
/* NEXTION */
//#define NEXTION_RX 255 /* Nextion RX pin */
//#define NEXTION_TX 255 /* Nextion TX pin */
/* I2C PINS */
//#define I2C_SDA 21 /* I2C SDA pin. It is best to connect to pin 21. */
//#define I2C_SCL 22 /* I2C SCL pin. It is best to connect to pin 22. */
//#define I2C_RST -1 /* I2C RST pin. Set to -1 if not used */
/* I2S DAC */
//#define I2S_DOUT 27 /* DIN connection. Should be set to 255 if the board is not used */
//#define I2S_BCLK 26 /* BCLK Bit clock */
//#define I2S_LRC 25 /* WSEL Left Right Clock */
/******************************************/
/* VS1053 VSPI PINS. VS1053 SCK must be connected to pin 18
VS1053 MISO must be connected to pin 19
VS1053 MOSI must be connected to pin 23 */
//#define VS1053_CS 255 /* XCS pin. Should be set to 255 if the board is not used */
//#define VS1053_DCS 25 /* XDCS pin. */
//#define VS1053_DREQ 26 /* DREQ pin. */
//#define VS1053_RST -1 /* XRESET pin. Set to -1 if connected to Esp EN pin */
/* VS1053 HSPI PINS. VS1053 SCK must be connected to pin 14
VS1053 MISO must be connected to pin 12
VS1053 MOSI must be connected to pin 13 */
//#define VS_HSPI false /* Use HSPI for VS */
/******************************************/
/* ENCODER */
//#define ENC_BTNL 255 /* Left rotation */
//#define ENC_BTNB 255 /* Encoder button */
//#define ENC_BTNR 255 /* Right rotation */
//#define ENC_INTERNALPULLUP true /* Enable the weak pull up resistors */
//#define ENC_HALFQUARD true /* Experiment with it */
/******************************************/
/* SDCARD */
/* MISO is the same as D0, MOSI is the same as D1 */
/* SD VSPI PINS. SD SCK must be connected to pin 18
SD MISO must be connected to pin 19
SD MOSI must be connected to pin 23 */
//#define SDC_CS 255 /* SDCARD CS pin */
/* ENCODER2 */
//#define ENC2_BTNL 255 /* Left rotation */
//#define ENC2_BTNB 255 /* Encoder button */
//#define ENC2_BTNR 255 /* Right rotation */
//#define ENC2_INTERNALPULLUP true /* Enable the weak pull up resistors */
//#define ENC2_HALFQUARD false /* (true, false, 255) Experiment with it */
/******************************************/
/* BUTTONS */
//#define BTN_LEFT 255 /* VolDown, Prev */
//#define BTN_CENTER 255 /* Play, Stop, Show playlist */
//#define BTN_RIGHT 255 /* VolUp, Next */
//#define BTN_UP 255 /* Prev, Move Up */
//#define BTN_DOWN 255 /* Next, Move Down */
//#define BTN_INTERNALPULLUP true /* Enable the weak pull up resistors */
//#define BTN_LONGPRESS_LOOP_DELAY 200 /* Delay between calling DuringLongPress event */
//#define BTN_CLICK_TICKS 300 /* Event Timing https://github.com/mathertel/OneButton#event-timing */
//#define BTN_PRESS_TICKS 500 /* Event Timing https://github.com/mathertel/OneButton#event-timing */
//#define BTN_MODE 255 /* MODE switcher */
/******************************************/
/* LCD DISPLAY 1602 */
//#define LCD_RS 255 /* RS Pin */
//#define LCD_E 255 /* E Pin */
//#define LCD_D4 255 /* D4 Pin */
//#define LCD_D5 255 /* D5 Pin */
//#define LCD_D6 255 /* D6 Pin */
//#define LCD_D7 255 /* D7 Pin */
/******************************************/
/* TOUCHSCREEN */
//#define TS_MODEL TS_MODEL_UNDEFINED /* See description/available values in yoRadio/src/core/options.h */
/* Resistive SPI touch screen */
/* TS VSPI PINS. CLK must be connected to pin 18
DIN must be connected to pin 23
DO must be connected to pin 19
IRQ - not connected */
//#define TS_CS 255 /* Touch screen CS pin */
/* TS HSPI PINS. CLK must be connected to pin 14
DIN must be connected to pin 13
DO must be connected to pin 12
IRQ - not connected */
//#define TS_HSPI false /* Use HSPI for Touch screen */
/* Capacitive I2C touch screen */
//#define TS_SDA 33
//#define TS_SCL 32
//#define TS_INT 21
//#define TS_RST 25
/******************************************/
/* Other settings. */
//#define DTYPE INITR_BLACKTAB /* ST7735 display submodel */
/* Could be one of: */
/* INITR_BLACKTAB 1.8' https://aliexpress.com/item/1005002822797745.html */
/* (See this note If INITR_BLACKTAB have a noisy line on one side of the screen https://github.com/e2002/yoradio#note-if-initr_blacktab-dsp-have-a-noisy-line-on-one-side-of-the-screen-then-in-adafruit_st7735cpp ) */
/* INITR_144GREENTAB // 1.44' https://aliexpress.com/item/1005002822797745.html */
/* INITR_MINI160x80 // 0.96' 160x80 ST7735S https://???? */
/* INITR_GREENTAB */
/* INITR_REDTAB */
//#define MUTE_PIN 255 /* MUTE Pin */
//#define MUTE_VAL HIGH /* Write this to MUTE_PIN when player is stopped */
//#define BRIGHTNESS_PIN 255 /* Pin for adjusting the brightness of the display (output 0 - 3v3) */
//#define PLAYER_FORCE_MONO false /* mono option on boot - false stereo, true mono */
//#define I2S_INTERNAL false /* If true - use esp32 internal DAC */
//#define ROTATE_90 false /* Optional 90 degree rotation for square displays */
//#define WAKE_PIN 255 /* Wake Pin (for manual wakeup from sleep mode. can match with 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) */
/* For sample #define ENC_BTNB 36 - next line - #define WAKE_PIN ENC_BTNB */
//#define LIGHT_SENSOR 255 /* Light sensor */
//#define AUTOBACKLIGHT(x) *function* /* Autobacklight function. See options.h for example */
//#define DSP_INVERT_TITLE true /* Invert title colors for OLED displays ? */
/******************************************/
/* IR control */
//#define IR_PIN 255
//#define IR_TIMEOUT 80 /* see kTimeout description in IRremoteESP8266 example https://github.com/crankyoldgit/IRremoteESP8266/blob/master/examples/IRrecvDumpV2/IRrecvDumpV2.ino */
/******************************************/
#endif

53
examples/mytheme.h Normal file
View File

@@ -0,0 +1,53 @@
#ifndef _my_theme_h
#define _my_theme_h
/*
Theming of color displays
DSP_ST7735, DSP_ST7789, DSP_ILI9341, DSP_GC9106, DSP_ILI9225, DSP_ST7789_240
***********************************************************************
* !!! This file must be in the root directory of the sketch !!! *
***********************************************************************
Uncomment (remove double slash //) from desired line to apply color
*/
#define ENABLE_THEME
#ifdef ENABLE_THEME
/*----------------------------------------------------------------------------------------------------------------*/
/* | COLORS | values (0-255) | */
/* | color name | R G B | */
/*----------------------------------------------------------------------------------------------------------------*/
//#define COLOR_BACKGROUND 255, 255, 0 /* background */
//#define COLOR_STATION_NAME 0, 0, 0 /* station name */
//#define COLOR_STATION_BG 91, 118, 255 /* station name background */
//#define COLOR_STATION_FILL 91, 118, 255 /* station name fill background */
//#define COLOR_SNG_TITLE_1 255, 0, 0 /* first title */
//#define COLOR_SNG_TITLE_2 0, 0, 0 /* second title */
//#define COLOR_WEATHER 255, 0, 216 /* weather string */
//#define COLOR_VU_MAX 152, 138, 138 /* max of VU meter */
//#define COLOR_VU_MIN 250, 130, 130 /* min of VU meter */
//#define COLOR_CLOCK 60, 224, 33 /* clock color */
//#define COLOR_SECONDS 0, 255, 255 /* seconds color (DSP_ST7789, DSP_ILI9341, DSP_ILI9225) */
//#define COLOR_DAY_OF_W 255, 0, 0 /* day of week color (DSP_ST7789, DSP_ILI9341, DSP_ILI9225) */
//#define COLOR_DATE 0, 0, 255 /* date color (DSP_ST7789, DSP_ILI9341, DSP_ILI9225) */
//#define COLOR_HEAP 255, 168, 162 /* heap string */
//#define COLOR_BUFFER 157, 171, 251 /* buffer line */
//#define COLOR_IP 41, 189, 207 /* ip address */
//#define COLOR_VOLUME_VALUE 165, 162, 132 /* volume string (DSP_ST7789, DSP_ILI9341, DSP_ILI9225) */
//#define COLOR_RSSI 255, 148, 156 /* rssi */
//#define COLOR_VOLBAR_OUT 198, 93, 0 /* volume bar outline */
//#define COLOR_VOLBAR_IN 189, 189, 189 /* volume bar fill */
//#define COLOR_DIGITS 100, 100, 255 /* volume / station number */
//#define COLOR_DIVIDER 0, 255, 0 /* divider color (DSP_ST7789, DSP_ILI9341, DSP_ILI9225) */
//#define COLOR_BITRATE 231, 211, 90 /* bitrate */
//#define COLOR_PL_CURRENT 0, 0, 0 /* playlist current item */
//#define COLOR_PL_CURRENT_BG 91, 118, 255 /* playlist current item background */
//#define COLOR_PL_CURRENT_FILL 91, 118, 255 /* playlist current item fill background */
//#define COLOR_PLAYLIST_0 255, 0, 0 /* playlist string 0 */
//#define COLOR_PLAYLIST_1 0, 255, 0 /* playlist string 1 */
//#define COLOR_PLAYLIST_2 255, 0, 255 /* playlist string 2 */
//#define COLOR_PLAYLIST_3 0, 0, 255 /* playlist string 3 */
//#define COLOR_PLAYLIST_4 0, 255, 255 /* playlist string 4 */
#endif /* #ifdef ENABLE_THEME */
#endif /* #define _my_theme_h */

View File

@@ -0,0 +1,36 @@
/**************************************************************
Example of display backlight control depending on playback.
This file must be in the root directory of the sketch.
**************************************************************/
#include <Ticker.h>
const uint8_t backlightPin = 13;
const uint8_t backlightInitValue = HIGH;
const uint16_t turnBlOffInterval = 120; /* 2 min */
Ticker backlightTicker;
void backlightOff(){
backlightTicker.detach();
digitalWrite(backlightPin, !backlightInitValue);
}
void yoradio_on_setup() {
pinMode(backlightPin, OUTPUT);
digitalWrite(backlightPin, backlightInitValue);
backlightTicker.attach(turnBlOffInterval, backlightOff);
}
void player_on_track_change(){
digitalWrite(backlightPin, backlightInitValue);
backlightTicker.detach();
backlightTicker.attach(turnBlOffInterval, backlightOff);
}
void player_on_stop_play(){
digitalWrite(backlightPin, backlightInitValue);
backlightTicker.detach();
backlightTicker.attach(turnBlOffInterval, backlightOff);
}

View File

@@ -0,0 +1,36 @@
/******************************************************************************************************************
Example of esp32 deep sleep when playback is stopped.
This file must be in the root directory of the sketch.
*******************************************************************************************************************/
#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) */
#if WAKEUP_PIN!=255
Ticker deepSleepTicker;
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 yoradio_on_setup(){ /* occurs during loading */
esp_sleep_enable_ext0_wakeup((gpio_num_t)WAKEUP_PIN, WAKEUP_LEVEL); /* enable wakeup pin */
deepSleepTicker.attach(SLEEP_DELAY, goToSleep); /* attach to delay */
}
void player_on_start_play(){ /* occurs during player is start playing */
deepSleepTicker.detach(); /* detach the timer */
}
void player_on_stop_play(){ /* occurs during player is stop playing */
deepSleepTicker.attach(SLEEP_DELAY, goToSleep); /* attach to delay */
}
#endif /* #if WAKEUP_PIN!=255 */