Skip to content

Commit

Permalink
v0.7.402
Browse files Browse the repository at this point in the history
  • Loading branch information
e2002 committed Aug 22, 2022
1 parent 8fa32f1 commit 223bae1
Show file tree
Hide file tree
Showing 39 changed files with 644 additions and 380 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,17 @@ Work is in progress...

---
## Version history
#### v0.7.402
**!!! a [full update](#update-over-web-interface) with Sketch data upload is required. After updating please press CTRL+F5 in browser !!!** \
**Please backup playlist.csv and wifi.csv before updating.**
- added the ability to themize color displays. Details in [exsamples/mytheme.h](exsamples/mytheme.h)
- in this connection, examples of plugins displayhandlers.ino and rssibitrate.ino have been updated
- parameter VU_PARAMS2 is deprecated. New parameter - VU_PARAMS3. Details in [yoRadio/display_vu.h](yoRadio/display_vu.h)
- added deepsleep capability for LCD_I2C and OLED displays
- in this connection, a full update with Sketch data upload is required
- in this connection, example of plugi deepsleep.ino (exsamples/plugins/deepsleep.ino) have been updated
- some bug fixes

#### v0.7.355
- updating libraries ESP32-audioI2S and ESP32-vs1053_ext to the latest version
- optimization of the web interface during playback
Expand Down
47 changes: 47 additions & 0 deletions exsamples/mytheme.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#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 91, 118, 255 /* station name */
//#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_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 */
35 changes: 21 additions & 14 deletions exsamples/plugins/deepsleep.ino
Original file line number Diff line number Diff line change
@@ -1,29 +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
#define WAKEUP_PIN_1 GPIO_NUM_12
#define WAKEUP_LEVEL LOW
*******************************************************************************************************************/
#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 */
esp_deep_sleep_start();
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(){
esp_sleep_enable_ext0_wakeup(WAKEUP_PIN_1, WAKEUP_LEVEL);
deepSleepTicker.attach(SLEEP_DELAY, goToSleep);
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(){
deepSleepTicker.detach();
void player_on_start_play(){ /* occurs during player is start playing */
deepSleepTicker.detach(); /* detach the timer */
}

void player_on_stop_play(){
deepSleepTicker.attach(SLEEP_DELAY, goToSleep);
void player_on_stop_play(){ /* occurs during player is stop playing */
deepSleepTicker.attach(SLEEP_DELAY, goToSleep); /* attach to delay */
}
#endif /* #if WAKEUP_PIN!=255 */
8 changes: 4 additions & 4 deletions exsamples/plugins/displayhandlers.ino
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ void dsp_on_start(DspCore *dsp) {
***********************************************/
void dsp_on_init() {
if (DSP_MODEL == DSP_ST7735 || (DSP_MODEL == DSP_SSD1327)) {
hello.init(5, " * ", 1, TFT_LINEHGHT * 4 + 6, 0, ORANGE, TFT_BG);
hello.init(5, " * ", 1, TFT_LINEHGHT * 4 + 6, 0, config.theme.weather, config.theme.background);
}else if(DSP_MODEL == DSP_ILI9225){
hello.init(5, " * ", 1, TFT_LINEHGHT * 6 + 5, 0, ORANGE, TFT_BG);
hello.init(5, " * ", 1, TFT_LINEHGHT * 6 + 5, 0, config.theme.weather, config.theme.background);
} else {
hello.init(5, " * ", 2, TFT_LINEHGHT * 9 + 5, 0, ORANGE, TFT_BG);
hello.init(5, " * ", 2, TFT_LINEHGHT * 9 + 5, 0, config.theme.weather, config.theme.background);
}
}

Expand Down Expand Up @@ -194,7 +194,7 @@ bool dsp_before_clock(DspCore *dsp, bool dots) {
if (display.mode == PLAYER) {
dsp->setFont();
dsp->setTextSize(1);
display.centerText(dsp->utf8Rus("Hello from plugin!", true), display.screenheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT * 2 - 2, PINK, TFT_BG);
display.centerText(dsp->utf8Rus("Hello from plugin!", true), display.screenheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT * 2 - 2, 0xF97F, config.theme.background);
}
return true; // false, if you need to disable the drawing of the clock
}
Expand Down
4 changes: 2 additions & 2 deletions exsamples/plugins/rssibitrate.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bool dsp_before_rssi(DspCore *dsp){
sprintf(buf, "RSSI:000dBm");
dsp->setTextSize(1);
dsp->getTextBounds(buf, 0, 0, &x1, &y1, &w, &h);
dsp->fillRect(dsp->width() - w - TFT_FRAMEWDT /* left */, vTop /* top */, w /* width */, TFT_LINEHGHT-2 /* height */, TFT_BG /* background color */);
dsp->fillRect(dsp->width() - w - TFT_FRAMEWDT /* left */, vTop /* top */, w /* width */, TFT_LINEHGHT-2 /* height */, config.theme.background /* background color */);
sprintf(buf, "%dkBits", config.station.bitrate);
dsp->getTextBounds(buf, 0, 0, &x1, &y1, &w, &h);
if(cnt<2){
Expand All @@ -25,7 +25,7 @@ bool dsp_before_rssi(DspCore *dsp){
}
cnt++;
if(cnt>3) cnt=0;
dsp->setTextColor(SILVER,TFT_BG);
dsp->setTextColor(config.theme.rssi,config.theme.background);
dsp->setCursor(dsp->width() - w - TFT_FRAMEWDT, vTop);
dsp->print(buf); /* print bitrate */
return false; /* disable to print RSSI */
Expand Down
57 changes: 56 additions & 1 deletion yoRadio/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ void Config::init() {
if (!SPIFFS.begin(false)) {
return;
}
loadTheme();
ssidsCount = 0;
initPlaylist();
if (store.lastStation == 0 && store.countStation > 0) {
Expand All @@ -48,6 +49,39 @@ void Config::init() {
#endif
}

uint16_t Config::color565(uint8_t r, uint8_t g, uint8_t b)
{
return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);
}

void Config::loadTheme(){
theme.background = color565(COLOR_BACKGROUND);
theme.meta = color565(COLOR_STATION_NAME);
theme.title1 = color565(COLOR_SNG_TITLE_1);
theme.title2 = color565(COLOR_SNG_TITLE_2);
theme.digit = color565(COLOR_DIGITS);
theme.div = color565(COLOR_DIVIDER);
theme.weather = color565(COLOR_WEATHER);
theme.vumax = color565(COLOR_VU_MAX);
theme.vumin = color565(COLOR_VU_MIN);
theme.clock = color565(COLOR_CLOCK);
theme.seconds = color565(COLOR_SECONDS);
theme.dow = color565(COLOR_DAY_OF_W);
theme.date = color565(COLOR_DATE);
theme.heap = color565(COLOR_HEAP);
theme.buffer = color565(COLOR_BUFFER);
theme.ip = color565(COLOR_IP);
theme.vol = color565(COLOR_VOLUME_VALUE);
theme.rssi = color565(COLOR_RSSI);
theme.volbarout = color565(COLOR_VOLBAR_OUT);
theme.volbarin = color565(COLOR_VOLBAR_IN);
theme.playlist[0] = color565(COLOR_PLAYLIST_0);
theme.playlist[1] = color565(COLOR_PLAYLIST_1);
theme.playlist[2] = color565(COLOR_PLAYLIST_2);
theme.playlist[3] = color565(COLOR_PLAYLIST_3);
theme.playlist[4] = color565(COLOR_PLAYLIST_4);
}

template <class T> int Config::eepromWrite(int ee, const T& value) {
const byte* p = (const byte*)(const void*)&value;
int i;
Expand Down Expand Up @@ -435,7 +469,28 @@ bool Config::initNetwork() {

void Config::setBrightness(bool dosave){
#if BRIGHTNESS_PIN!=255
analogWrite(BRIGHTNESS_PIN, config.store.dspon?map(store.brightness, 0, 100, 0, 255):0);
if(!store.dspon && dosave) {
display.wakeup();
}
//analogWrite(BRIGHTNESS_PIN, config.store.dspon?map(store.brightness, 0, 100, 0, 255):0);
analogWrite(BRIGHTNESS_PIN, map(store.brightness, 0, 100, 0, 255));
if(!store.dspon) store.dspon = true;
if(dosave) save();
#endif
}

void Config::setDspOn(bool dspon){
store.dspon = dspon;
save();
if(!dspon){
#if BRIGHTNESS_PIN!=255
analogWrite(BRIGHTNESS_PIN, 0);
#endif
display.deepsleep();
}else{
display.wakeup();
#if BRIGHTNESS_PIN!=255
analogWrite(BRIGHTNESS_PIN, map(store.brightness, 0, 100, 0, 255));
#endif
}
}
28 changes: 27 additions & 1 deletion yoRadio/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,29 @@

void DBGVB(const char *format, ...);

struct theme_t {
uint16_t background;
uint16_t meta;
uint16_t title1;
uint16_t title2;
uint16_t digit;
uint16_t div;
uint16_t weather;
uint16_t vumax;
uint16_t vumin;
uint16_t clock;
uint16_t seconds;
uint16_t dow;
uint16_t date;
uint16_t heap;
uint16_t buffer;
uint16_t ip;
uint16_t vol;
uint16_t rssi;
uint16_t volbarout;
uint16_t volbarin;
uint16_t playlist[5];
};
struct config_t
{
unsigned int config_set; //must be 4262
Expand Down Expand Up @@ -92,6 +115,7 @@ class Config {
public:
config_t store;
station_t station;
theme_t theme;
#if IR_PIN!=255
int irindex;
uint8_t irchck;
Expand All @@ -106,6 +130,7 @@ class Config {
void saveIR();
#endif
void init();
void loadTheme();
byte setVolume(byte val);
void saveVolume();
void setTone(int8_t bass, int8_t middle, int8_t trebble);
Expand All @@ -130,11 +155,12 @@ class Config {
void setTimezoneOffset(uint16_t tzo);
uint16_t getTimezoneOffset();
void setBrightness(bool dosave=false);

void setDspOn(bool dspon);
private:
template <class T> int eepromWrite(int ee, const T& value);
template <class T> int eepromRead(int ee, T& value);
void setDefaults();
uint16_t color565(uint8_t r, uint8_t g, uint8_t b);
};

extern Config config;
Expand Down
Binary file modified yoRadio/data/www/script.js.gz
Binary file not shown.
6 changes: 3 additions & 3 deletions yoRadio/data/www/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ <h2 class="pagetitle">SёTTINGS</h2>
<div class="button apply" data-name="fwupdate" id="fwupdate">Firmware update</div>
</div>
</section><a name="screen"></a>
<section class="group group_display group_nextion hidden" id="group_display">
<section class="group group_display group_oled group_nextion hidden" id="group_display">
<div class="title"><span>screen</span></div><div class="reset" data-name="screen"></div>
<div class="flex-row">
<div class="checkbox off nous group group_tft hidden" id="flipscreen">Flip screen</div>
<div class="checkbox off nous group group_tft hidden" id="invertdisplay">Invert screen</div>
<div class="checkbox on nous group group_brightness hidden" id="screenon">Turn on</div>
<div class="checkbox on nous group group_brightness group_oled hidden" id="screenon">Turn on</div>
</div>
<div class="flex-row group group_tft group_nextion hidden">
<div class="flex-row group group_tft group_oled group_nextion hidden">
<div class="checkbox off nous" id="numplaylist">numbered playlist</div>
</div>
<div class="flex-row group group_brightness hidden">
Expand Down
32 changes: 24 additions & 8 deletions yoRadio/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,22 +237,22 @@ void Display::init() {
#endif
dsp.initD(screenwidth, screenheight);
dsp.drawLogo();
meta.init(1, " * ", META_SIZE, TFT_FRAMEWDT, STARTTIME, TFT_LOGO, TFT_BG);
title1.init(2, " * ", TITLE_SIZE1, TITLE_TOP1, STARTTIME, TITLE_FG1, TFT_BG);
title2.init(3, " * ", TITLE_SIZE2, TITLE_TOP2, STARTTIME, TITLE_FG2, TFT_BG);
meta.init(1, " * ", META_SIZE, TFT_FRAMEWDT, STARTTIME, config.theme.meta, config.theme.background);
title1.init(2, " * ", TITLE_SIZE1, TITLE_TOP1, STARTTIME, config.theme.title1, config.theme.background);
title2.init(3, " * ", TITLE_SIZE2, TITLE_TOP2, STARTTIME, config.theme.title2, config.theme.background);
int yStart = (screenheight / 2 - PLMITEMHEIGHT / 2) + 3;
#ifdef PL_TOP
yStart = PL_TOP;
#endif
plCurrent.init(4, " * ", PLCURRENT_SIZE, yStart, STARTTIME_PL, TFT_BG, TFT_LOGO);
plCurrent.init(4, " * ", PLCURRENT_SIZE, yStart, STARTTIME_PL, config.theme.background, config.theme.meta);
plCurrent.lock();
#if WEATHER_READY==1
if (DSP_MODEL == DSP_ST7735 || (DSP_MODEL == DSP_SSD1327)) {
weatherScroll.init(5, " * ", 1, TFT_LINEHGHT * 4 + 6, 0, ORANGE, TFT_BG);
weatherScroll.init(5, " * ", 1, TFT_LINEHGHT * 4 + 6, 0, config.theme.weather, config.theme.background);
}else if(DSP_MODEL == DSP_ILI9225){
weatherScroll.init(5, " * ", 1, TFT_LINEHGHT * 6 + 5, 0, ORANGE, TFT_BG);
weatherScroll.init(5, " * ", 1, TFT_LINEHGHT * 6 + 5, 0, config.theme.weather, config.theme.background);
} else {
weatherScroll.init(5, " * ", 2, TFT_LINEHGHT * 9 + 5, 0, ORANGE, TFT_BG);
weatherScroll.init(5, " * ", 2, TFT_LINEHGHT * 9 + 5, 0, config.theme.weather, config.theme.background);
}
#endif
if (dsp_on_init) dsp_on_init();
Expand Down Expand Up @@ -536,7 +536,7 @@ void Display::centerText(const char* text, byte y, uint16_t fg, uint16_t bg) {

void Display::bootString(const char* text, byte y) {
dsp.set_TextSize(1);
dsp.centerText(text, y == 1 ? BOOTSTR_TOP1 : BOOTSTR_TOP2, TFT_LOGO, TFT_BG);
dsp.centerText(text, y == 1 ? BOOTSTR_TOP1 : BOOTSTR_TOP2, DSP_OLED?1:0xE68B, 0x0000);
dsp.loop(true);
#ifdef USE_NEXTION
if(y==2) nextion.bootString(text);
Expand Down Expand Up @@ -673,6 +673,22 @@ void Display::setContrast(){
dsp.setContrast(config.store.contrast);
}
#endif // DSP_MODEL==DSP_NOKIA5110

bool Display::deepsleep(){
//#ifdef DSP_CAN_SLEEP
#if defined(LCD_I2C) || DSP_OLED || BRIGHTNESS_PIN!=255
dsp.sleep();
return true;
#endif
return false;
}

void Display::wakeup(){
//#ifdef DSP_CAN_SLEEP
#if defined(LCD_I2C) || DSP_OLED || BRIGHTNESS_PIN!=255
dsp.wake();
#endif
}
/******************************************************************************************************************/
#endif // !DUMMYDISPLAY

Expand Down
Loading

0 comments on commit 223bae1

Please sign in to comment.