This commit is contained in:
e2002
2022-08-22 11:50:48 +03:00
parent 8fa32f1587
commit 223bae1923
39 changed files with 644 additions and 380 deletions

View File

@@ -317,6 +317,17 @@ Work is in progress...
--- ---
## Version history ## 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 #### v0.7.355
- updating libraries ESP32-audioI2S and ESP32-vs1053_ext to the latest version - updating libraries ESP32-audioI2S and ESP32-vs1053_ext to the latest version
- optimization of the web interface during playback - optimization of the web interface during playback

47
exsamples/mytheme.h Normal file
View File

@@ -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 */

View File

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

View File

@@ -157,11 +157,11 @@ void dsp_on_start(DspCore *dsp) {
***********************************************/ ***********************************************/
void dsp_on_init() { void dsp_on_init() {
if (DSP_MODEL == DSP_ST7735 || (DSP_MODEL == DSP_SSD1327)) { 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){ }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 { } 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);
} }
} }
@@ -194,7 +194,7 @@ bool dsp_before_clock(DspCore *dsp, bool dots) {
if (display.mode == PLAYER) { if (display.mode == PLAYER) {
dsp->setFont(); dsp->setFont();
dsp->setTextSize(1); 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 return true; // false, if you need to disable the drawing of the clock
} }

View File

@@ -16,7 +16,7 @@ bool dsp_before_rssi(DspCore *dsp){
sprintf(buf, "RSSI:000dBm"); sprintf(buf, "RSSI:000dBm");
dsp->setTextSize(1); dsp->setTextSize(1);
dsp->getTextBounds(buf, 0, 0, &x1, &y1, &w, &h); 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); sprintf(buf, "%dkBits", config.station.bitrate);
dsp->getTextBounds(buf, 0, 0, &x1, &y1, &w, &h); dsp->getTextBounds(buf, 0, 0, &x1, &y1, &w, &h);
if(cnt<2){ if(cnt<2){
@@ -25,7 +25,7 @@ bool dsp_before_rssi(DspCore *dsp){
} }
cnt++; cnt++;
if(cnt>3) cnt=0; 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->setCursor(dsp->width() - w - TFT_FRAMEWDT, vTop);
dsp->print(buf); /* print bitrate */ dsp->print(buf); /* print bitrate */
return false; /* disable to print RSSI */ return false; /* disable to print RSSI */

View File

@@ -28,6 +28,7 @@ void Config::init() {
if (!SPIFFS.begin(false)) { if (!SPIFFS.begin(false)) {
return; return;
} }
loadTheme();
ssidsCount = 0; ssidsCount = 0;
initPlaylist(); initPlaylist();
if (store.lastStation == 0 && store.countStation > 0) { if (store.lastStation == 0 && store.countStation > 0) {
@@ -48,6 +49,39 @@ void Config::init() {
#endif #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) { template <class T> int Config::eepromWrite(int ee, const T& value) {
const byte* p = (const byte*)(const void*)&value; const byte* p = (const byte*)(const void*)&value;
int i; int i;
@@ -435,7 +469,28 @@ bool Config::initNetwork() {
void Config::setBrightness(bool dosave){ void Config::setBrightness(bool dosave){
#if BRIGHTNESS_PIN!=255 #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(); if(dosave) save();
#endif #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
}
}

View File

@@ -15,6 +15,29 @@
void DBGVB(const char *format, ...); 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 struct config_t
{ {
unsigned int config_set; //must be 4262 unsigned int config_set; //must be 4262
@@ -92,6 +115,7 @@ class Config {
public: public:
config_t store; config_t store;
station_t station; station_t station;
theme_t theme;
#if IR_PIN!=255 #if IR_PIN!=255
int irindex; int irindex;
uint8_t irchck; uint8_t irchck;
@@ -106,6 +130,7 @@ class Config {
void saveIR(); void saveIR();
#endif #endif
void init(); void init();
void loadTheme();
byte setVolume(byte val); byte setVolume(byte val);
void saveVolume(); void saveVolume();
void setTone(int8_t bass, int8_t middle, int8_t trebble); void setTone(int8_t bass, int8_t middle, int8_t trebble);
@@ -130,11 +155,12 @@ class Config {
void setTimezoneOffset(uint16_t tzo); void setTimezoneOffset(uint16_t tzo);
uint16_t getTimezoneOffset(); uint16_t getTimezoneOffset();
void setBrightness(bool dosave=false); void setBrightness(bool dosave=false);
void setDspOn(bool dspon);
private: private:
template <class T> int eepromWrite(int ee, const T& value); template <class T> int eepromWrite(int ee, const T& value);
template <class T> int eepromRead(int ee, T& value); template <class T> int eepromRead(int ee, T& value);
void setDefaults(); void setDefaults();
uint16_t color565(uint8_t r, uint8_t g, uint8_t b);
}; };
extern Config config; extern Config config;

Binary file not shown.

View File

@@ -42,14 +42,14 @@
<div class="button apply" data-name="fwupdate" id="fwupdate">Firmware update</div> <div class="button apply" data-name="fwupdate" id="fwupdate">Firmware update</div>
</div> </div>
</section><a name="screen"></a> </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="title"><span>screen</span></div><div class="reset" data-name="screen"></div>
<div class="flex-row"> <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="flipscreen">Flip screen</div>
<div class="checkbox off nous group group_tft hidden" id="invertdisplay">Invert 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>
<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 class="checkbox off nous" id="numplaylist">numbered playlist</div>
</div> </div>
<div class="flex-row group group_brightness hidden"> <div class="flex-row group group_brightness hidden">

View File

@@ -237,22 +237,22 @@ void Display::init() {
#endif #endif
dsp.initD(screenwidth, screenheight); dsp.initD(screenwidth, screenheight);
dsp.drawLogo(); dsp.drawLogo();
meta.init(1, " * ", META_SIZE, TFT_FRAMEWDT, STARTTIME, TFT_LOGO, TFT_BG); meta.init(1, " * ", META_SIZE, TFT_FRAMEWDT, STARTTIME, config.theme.meta, config.theme.background);
title1.init(2, " * ", TITLE_SIZE1, TITLE_TOP1, STARTTIME, TITLE_FG1, TFT_BG); title1.init(2, " * ", TITLE_SIZE1, TITLE_TOP1, STARTTIME, config.theme.title1, config.theme.background);
title2.init(3, " * ", TITLE_SIZE2, TITLE_TOP2, STARTTIME, TITLE_FG2, TFT_BG); title2.init(3, " * ", TITLE_SIZE2, TITLE_TOP2, STARTTIME, config.theme.title2, config.theme.background);
int yStart = (screenheight / 2 - PLMITEMHEIGHT / 2) + 3; int yStart = (screenheight / 2 - PLMITEMHEIGHT / 2) + 3;
#ifdef PL_TOP #ifdef PL_TOP
yStart = PL_TOP; yStart = PL_TOP;
#endif #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(); plCurrent.lock();
#if WEATHER_READY==1 #if WEATHER_READY==1
if (DSP_MODEL == DSP_ST7735 || (DSP_MODEL == DSP_SSD1327)) { 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){ }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 { } 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 #endif
if (dsp_on_init) dsp_on_init(); if (dsp_on_init) dsp_on_init();
@@ -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) { void Display::bootString(const char* text, byte y) {
dsp.set_TextSize(1); 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); dsp.loop(true);
#ifdef USE_NEXTION #ifdef USE_NEXTION
if(y==2) nextion.bootString(text); if(y==2) nextion.bootString(text);
@@ -673,6 +673,22 @@ void Display::setContrast(){
dsp.setContrast(config.store.contrast); dsp.setContrast(config.store.contrast);
} }
#endif // DSP_MODEL==DSP_NOKIA5110 #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 #endif // !DUMMYDISPLAY

View File

@@ -44,6 +44,9 @@
#ifndef DSP_FLIPPED #ifndef DSP_FLIPPED
#define DSP_FLIPPED 1 #define DSP_FLIPPED 1
#endif #endif
#ifndef DSP_OLED
#define DSP_OLED false
#endif
#ifndef WEATHER_READY #ifndef WEATHER_READY
#define WEATHER_READY 0 #define WEATHER_READY 0
#else #else
@@ -127,6 +130,8 @@ class Display {
void invert(); void invert();
static void updateWeather(); static void updateWeather();
void showWeather(); void showWeather();
bool deepsleep();
void wakeup();
#if DSP_MODEL==DSP_NOKIA5110 #if DSP_MODEL==DSP_NOKIA5110
void setContrast(); void setContrast();
#else #else
@@ -148,6 +153,8 @@ class Display {
void setContrast(){}; void setContrast(){};
static void updateWeather(){}; static void updateWeather(){};
void showWeather(){}; void showWeather(){};
bool deepsleep(){return true;};
void wakeup(){};
#endif #endif
#ifndef DUMMYDISPLAY #ifndef DUMMYDISPLAY
private: private:

View File

@@ -1,9 +1,10 @@
#ifndef display_vu_h #ifndef display_vu_h
#define display_vu_h #define display_vu_h
#include "player.h" #include "player.h"
#include "network.h"
#ifdef VU_PARAMS2 #ifdef VU_PARAMS3
enum : uint16_t VU_PARAMS2; enum : uint16_t VU_PARAMS3;
#else #else
/* /*
* vu left - left position * vu left - left position
@@ -22,26 +23,26 @@ enum : uint16_t VU_PARAMS2;
/**********************************************************************************************************************************************************************************/ /**********************************************************************************************************************************************************************************/
#if DSP_MODEL==DSP_ST7735 && DTYPE==INITR_BLACKTAB /* ST7735 160x128 */ #if DSP_MODEL==DSP_ST7735 && DTYPE==INITR_BLACKTAB /* ST7735 160x128 */
enum : uint16_t { VU_X = 4, VU_Y = 50, VU_BW = 10, VU_BH = 44, VU_BS = 2, VU_NB = 8, VU_FS = 2, VU_HOR = 0, VU_COLOR_MAX = TFT_LOGO, VU_COLOR_MIN = GRAY }; enum : uint16_t { VU_X = 4, VU_Y = 50, VU_BW = 10, VU_BH = 44, VU_BS = 2, VU_NB = 8, VU_FS = 3, VU_HOR = 0 };
#elif DSP_MODEL==DSP_ST7735 && DTYPE==INITR_144GREENTAB /* ST7735 128x128 */ #elif DSP_MODEL==DSP_ST7735 && DTYPE==INITR_144GREENTAB /* ST7735 128x128 */
enum : uint16_t { VU_X = 4, VU_Y = 97, VU_BW = 60, VU_BH = 8, VU_BS = 0, VU_NB = 10, VU_FS = 2, VU_HOR = 1, VU_COLOR_MAX = TFT_LOGO, VU_COLOR_MIN = DARK_GRAY }; enum : uint16_t { VU_X = 4, VU_Y = 97, VU_BW = 60, VU_BH = 8, VU_BS = 0, VU_NB = 10, VU_FS = 3, VU_HOR = 1 };
#define GREENTAB128 #define GREENTAB128
#elif DSP_MODEL==DSP_ILI9341 /* ILI9341 320x240 */ #elif DSP_MODEL==DSP_ILI9341 /* ILI9341 320x240 */
enum : uint16_t { VU_X = 4, VU_Y = 116, VU_BW = 24, VU_BH = 80, VU_BS = 4, VU_NB = 8, VU_FS = 5, VU_HOR = 0, VU_COLOR_MAX = TFT_LOGO, VU_COLOR_MIN = GRAY }; enum : uint16_t { VU_X = 4, VU_Y = 116, VU_BW = 24, VU_BH = 80, VU_BS = 4, VU_NB = 8, VU_FS = 5, VU_HOR = 0 };
#elif DSP_MODEL==DSP_ST7789 /* ST7789 320x240 */ #elif DSP_MODEL==DSP_ST7789 /* ST7789 320x240 */
enum : uint16_t { VU_X = 4, VU_Y = 116, VU_BW = 24, VU_BH = 80, VU_BS = 4, VU_NB = 8, VU_FS = 5, VU_HOR = 0, VU_COLOR_MAX = TFT_LOGO, VU_COLOR_MIN = GRAY }; enum : uint16_t { VU_X = 4, VU_Y = 116, VU_BW = 24, VU_BH = 80, VU_BS = 4, VU_NB = 8, VU_FS = 5, VU_HOR = 0 };
#elif DSP_MODEL==DSP_ST7789_240 /* ST7789 240x240 */ #elif DSP_MODEL==DSP_ST7789_240 /* ST7789 240x240 */
enum : uint16_t { VU_X = 4, VU_Y = 90, VU_BW = 120, VU_BH = 20, VU_BS = 0, VU_NB = 12, VU_FS = 3, VU_HOR = 1, VU_COLOR_MAX = TFT_LOGO, VU_COLOR_MIN = GRAY }; enum : uint16_t { VU_X = 4, VU_Y = 90, VU_BW = 120, VU_BH = 20, VU_BS = 0, VU_NB = 12, VU_FS = 3, VU_HOR = 1 };
#elif DSP_MODEL==DSP_ILI9225 /* ILI9225 220x176 */ #elif DSP_MODEL==DSP_ILI9225 /* ILI9225 220x176 */
enum : uint16_t { VU_X = 4, VU_Y = 80, VU_BW = 13, VU_BH = 56, VU_BS = 2, VU_NB = 8, VU_FS = 4, VU_HOR = 0, VU_COLOR_MAX = TFT_LOGO, VU_COLOR_MIN = GRAY }; enum : uint16_t { VU_X = 4, VU_Y = 80, VU_BW = 13, VU_BH = 56, VU_BS = 2, VU_NB = 8, VU_FS = 4, VU_HOR = 0 };
#elif (DSP_MODEL==DSP_ST7735 && DTYPE==INITR_MINI160x80) || (DSP_MODEL==DSP_GC9106) /* ST7735 160x80, GC9106 160x80 */ #elif (DSP_MODEL==DSP_ST7735 && DTYPE==INITR_MINI160x80) || (DSP_MODEL==DSP_GC9106) /* ST7735 160x80, GC9106 160x80 */
enum : uint16_t { VU_X = 1, VU_Y = 30, VU_BW = 12, VU_BH = 36, VU_BS = 4, VU_NB = 8, VU_FS = 2, VU_HOR = 0, VU_COLOR_MAX = TFT_LOGO, VU_COLOR_MIN = GRAY }; enum : uint16_t { VU_X = 1, VU_Y = 30, VU_BW = 12, VU_BH = 36, VU_BS = 4, VU_NB = 8, VU_FS = 3, VU_HOR = 0 };
#endif #endif
#endif //VU_PARAMS #endif //VU_PARAMS
@@ -52,7 +53,7 @@ void drawVU(DspCore *dsp);
GFXcanvas16 gfxc(VU_BW*2+VU_BS,VU_BH); GFXcanvas16 gfxc(VU_BW*2+VU_BS,VU_BH);
void drawVU(DspCore *dsp){ void drawVU(DspCore *dsp){
if(!config.store.vumeter) return; if(!config.store.vumeter || network.status!=CONNECTED) return;
if(display.mode!=PLAYER && display.mode!=VOL) return; if(display.mode!=PLAYER && display.mode!=VOL) return;
#ifdef GREENTAB128 #ifdef GREENTAB128
if(display.mode==VOL) return; if(display.mode==VOL) return;
@@ -75,21 +76,22 @@ void drawVU(DspCore *dsp){
if(measL>dimension) measL=dimension; if(measL>dimension) measL=dimension;
if(measR>dimension) measR=dimension; if(measR>dimension) measR=dimension;
uint8_t h=(dimension/VU_NB)-2; uint8_t h=(dimension/VU_NB)-2;
gfxc.fillRect(0,0,VU_BW*2+VU_BS,VU_BH, config.theme.background);
for(int i=0; i<dimension; i++){ for(int i=0; i<dimension; i++){
if(i%(dimension/VU_NB)==0){ if(i%(dimension/VU_NB)==0){
if(VU_HOR){ if(VU_HOR){
#ifndef BOOMBOX_STYLE #ifndef BOOMBOX_STYLE
bandColor = (i>VU_BW-(VU_BW/VU_NB)*4)?VU_COLOR_MAX:VU_COLOR_MIN; bandColor = (i>VU_BW-(VU_BW/VU_NB)*4)?config.theme.vumax:config.theme.vumin;
gfxc.fillRect(i, 0, h, VU_BH, bandColor); gfxc.fillRect(i, 0, h, VU_BH, bandColor);
gfxc.fillRect(i+VU_BW+VU_BS, 0, h, VU_BH, bandColor); gfxc.fillRect(i+VU_BW+VU_BS, 0, h, VU_BH, bandColor);
#else #else
bandColor = (i>(VU_BW/VU_NB))?VU_COLOR_MIN:VU_COLOR_MAX; bandColor = (i>(VU_BW/VU_NB))?VU_COLOR_MIN:config.theme.vumax;
gfxc.fillRect(i, 0, h, VU_BH, bandColor); gfxc.fillRect(i, 0, h, VU_BH, bandColor);
bandColor = (i>VU_BW-(VU_BW/VU_NB)*3)?VU_COLOR_MAX:VU_COLOR_MIN; bandColor = (i>VU_BW-(VU_BW/VU_NB)*3)?config.theme.vumax:config.theme.vumin;
gfxc.fillRect(i+VU_BW+VU_BS, 0, h, VU_BH, bandColor); gfxc.fillRect(i+VU_BW+VU_BS, 0, h, VU_BH, bandColor);
#endif #endif
}else{ }else{
bandColor = (i<(VU_BH/VU_NB)*3)?VU_COLOR_MAX:VU_COLOR_MIN; bandColor = (i<(VU_BH/VU_NB)*3)?config.theme.vumax:config.theme.vumin;
gfxc.fillRect(0, i, VU_BW, h, bandColor); gfxc.fillRect(0, i, VU_BW, h, bandColor);
gfxc.fillRect(VU_BW+VU_BS, i, VU_BW, h, bandColor); gfxc.fillRect(VU_BW+VU_BS, i, VU_BW, h, bandColor);
} }
@@ -97,17 +99,17 @@ void drawVU(DspCore *dsp){
} }
if(VU_HOR){ if(VU_HOR){
#ifndef BOOMBOX_STYLE #ifndef BOOMBOX_STYLE
gfxc.fillRect(VU_BW-measL, 0, measL, VU_BW, TFT_BG); gfxc.fillRect(VU_BW-measL, 0, measL, VU_BW, config.theme.background);
gfxc.fillRect(VU_BW*2+VU_BS-measR, 0, measR, VU_BW, TFT_BG); gfxc.fillRect(VU_BW*2+VU_BS-measR, 0, measR, VU_BW, config.theme.background);
dsp->drawRGBBitmap(VU_X, (display.mode==VOL && DSP_MODEL==DSP_ST7789_240)?VU_Y-40:VU_Y, gfxc.getBuffer(), VU_BW*2+VU_BS, VU_BH); dsp->drawRGBBitmap(VU_X, (display.mode==VOL && DSP_MODEL==DSP_ST7789_240)?VU_Y-40:VU_Y, gfxc.getBuffer(), VU_BW*2+VU_BS, VU_BH);
#else #else
gfxc.fillRect(0, 0, VU_BW-(VU_BW-measL), VU_BW, TFT_BG); gfxc.fillRect(0, 0, VU_BW-(VU_BW-measL), VU_BW, config.theme.background);
gfxc.fillRect(VU_BW*2+VU_BS-measR, 0, measR, VU_BW, TFT_BG); gfxc.fillRect(VU_BW*2+VU_BS-measR, 0, measR, VU_BW, config.theme.background);
dsp->drawRGBBitmap(VU_X, (display.mode==VOL && DSP_MODEL==DSP_ST7789_240)?VU_Y-40:VU_Y, gfxc.getBuffer(), VU_BW*2+VU_BS, VU_BH); dsp->drawRGBBitmap(VU_X, (display.mode==VOL && DSP_MODEL==DSP_ST7789_240)?VU_Y-40:VU_Y, gfxc.getBuffer(), VU_BW*2+VU_BS, VU_BH);
#endif #endif
}else{ }else{
gfxc.fillRect(0, 0, VU_BW, measL, TFT_BG); gfxc.fillRect(0, 0, VU_BW, measL, config.theme.background);
gfxc.fillRect(VU_BW+VU_BS, 0, VU_BW, measR, TFT_BG); gfxc.fillRect(VU_BW+VU_BS, 0, VU_BW, measR, config.theme.background);
dsp->drawRGBBitmap(VU_X, VU_Y, gfxc.getBuffer(), VU_BW*2+VU_BS, VU_BH); dsp->drawRGBBitmap(VU_X, VU_Y, gfxc.getBuffer(), VU_BW*2+VU_BS, VU_BH);
} }
} }

View File

@@ -362,6 +362,7 @@ void NetServer::onWsMessage(void *arg, uint8_t *data, size_t len, uint8_t client
} }
if (strcmp(cmd, "brightness") == 0) { if (strcmp(cmd, "brightness") == 0) {
byte valb=atoi(val); byte valb=atoi(val);
if(!config.store.dspon) requestOnChange(DSPON, 0);
config.store.brightness=valb; config.store.brightness=valb;
//display.setContrast(); //display.setContrast();
config.setBrightness(true); config.setBrightness(true);
@@ -369,8 +370,9 @@ void NetServer::onWsMessage(void *arg, uint8_t *data, size_t len, uint8_t client
} }
if (strcmp(cmd, "screenon") == 0) { if (strcmp(cmd, "screenon") == 0) {
byte valb=atoi(val); byte valb=atoi(val);
config.store.dspon=valb==1; //config.store.dspon=valb==1;
config.setBrightness(true); //config.setBrightness(true);
config.setDspOn(valb==1);
return; return;
} }
if (strcmp(cmd, "contrast") == 0) { if (strcmp(cmd, "contrast") == 0) {
@@ -732,6 +734,9 @@ void NetServer::requestOnChange(requestType_e request, uint8_t clientId) {
if (WEATHER_READY==0 || dbgact){ if (WEATHER_READY==0 || dbgact){
act+="\"group_weather\","; act+="\"group_weather\",";
} }
#endif
#if defined(LCD_I2C) || DSP_OLED
act+="\"group_oled\",";
#endif #endif
if(VU_READY==1 || dbgact){ if(VU_READY==1 || dbgact){
act+="\"group_vu\","; act+="\"group_vu\",";
@@ -803,6 +808,10 @@ void NetServer::requestOnChange(requestType_e request, uint8_t clientId) {
sprintf (buf, "{\"vols\":%d,\"enca\":%d,\"irtl\":%d}", config.store.volsteps, config.store.encacc, config.store.irtlp); sprintf (buf, "{\"vols\":%d,\"enca\":%d,\"irtl\":%d}", config.store.volsteps, config.store.encacc, config.store.irtlp);
break; break;
} }
case DSPON: {
sprintf (buf, "{\"dspontrue\":%d}", 1);
break;
}
case STATION: { case STATION: {
sprintf (buf, "{\"nameset\": \"%s\"}", config.station.name); sprintf (buf, "{\"nameset\": \"%s\"}", config.station.name);
requestOnChange(ITEM, clientId); requestOnChange(ITEM, clientId);

View File

@@ -5,7 +5,7 @@
#include "ESPAsyncWebServer.h" #include "ESPAsyncWebServer.h"
#include "AsyncUDP.h" #include "AsyncUDP.h"
enum requestType_e : uint8_t { PLAYLIST=1, STATION=2, ITEM=3, TITLE=4, VOLUME=5, NRSSI=6, BITRATE=7, MODE=8, EQUALIZER=9, BALANCE=10, PLAYLISTSAVED=11, GETMODE=12, GETINDEX=13, GETACTIVE=14, GETSYSTEM=15, GETSCREEN=16, GETTIMEZONE=17, GETWEATHER=18, GETCONTROLS=19 }; enum requestType_e : uint8_t { PLAYLIST=1, STATION=2, ITEM=3, TITLE=4, VOLUME=5, NRSSI=6, BITRATE=7, MODE=8, EQUALIZER=9, BALANCE=10, PLAYLISTSAVED=11, GETMODE=12, GETINDEX=13, GETACTIVE=14, GETSYSTEM=15, GETSCREEN=16, GETTIMEZONE=17, GETWEATHER=18, GETCONTROLS=19, DSPON=20 };
enum htmlPath_e : uint8_t { PINDEX=1, PSETTINGS=2, PUPDATE=3, PIR=4, PPLAYLIST=5, PSSIDS=6 }; enum htmlPath_e : uint8_t { PINDEX=1, PSETTINGS=2, PUPDATE=3, PIR=4, PPLAYLIST=5, PSSIDS=6 };
class NetServer { class NetServer {

View File

@@ -1,7 +1,7 @@
#ifndef options_h #ifndef options_h
#define options_h #define options_h
#define VERSION "0.7.355" #define VERSION "0.7.402"
/******************************************************* /*******************************************************
DO NOT EDIT THIS FILE. DO NOT EDIT THIS FILE.
@@ -12,7 +12,9 @@ STORE YOUR SETTINGS IN THE *** myoptions.h *** FILE.
#if __has_include("myoptions.h") #if __has_include("myoptions.h")
#include "myoptions.h" /* <- write your variable values here */ #include "myoptions.h" /* <- write your variable values here */
#endif #endif
#if __has_include("mytheme.h")
#include "mytheme.h" /* <- Theme file */
#endif
/******************************************************* /*******************************************************
The connection tables are located here https://github.com/e2002/yoradio#connection-tables The connection tables are located here https://github.com/e2002/yoradio#connection-tables
@@ -28,7 +30,7 @@ The connection tables are located here https://github.com/e2002/yoradio#connecti
#define DSP_1602I2C 6 // https://aliexpress.com/item/32305776560.html #define DSP_1602I2C 6 // https://aliexpress.com/item/32305776560.html
#define DSP_SSD1306x32 7 // https://aliexpress.com/item/32798439084.html #define DSP_SSD1306x32 7 // https://aliexpress.com/item/32798439084.html
#define DSP_SSD1327 8 // https://aliexpress.com/item/1005001414175498.html #define DSP_SSD1327 8 // https://aliexpress.com/item/1005001414175498.html
#define DSP_ILI9341 9 // use it with the [#define TFT_INVERT false] option https://aliexpress.com/item/33048191074.html #define DSP_ILI9341 9 // https://aliexpress.com/item/33048191074.html
#define DSP_SSD1305 10 // SSD1305 and SSD1309 128x64 SPI https://aliexpress.com/item/32950307344.html #define DSP_SSD1305 10 // SSD1305 and SSD1309 128x64 SPI https://aliexpress.com/item/32950307344.html
#define DSP_SH1107 11 // https://aliexpress.com/item/4000551696674.html #define DSP_SH1107 11 // https://aliexpress.com/item/4000551696674.html
#define DSP_1602 12 // https://aliexpress.com/item/32685016568.html #define DSP_1602 12 // https://aliexpress.com/item/32685016568.html
@@ -233,4 +235,83 @@ INITR_REDTAB
#define IR_TIMEOUT 80 // kTimeout, see IRremoteESP8266 documentation #define IR_TIMEOUT 80 // kTimeout, see IRremoteESP8266 documentation
#endif #endif
/* THEMES */
/* color name R G B */
#ifndef COLOR_BACKGROUND
#define COLOR_BACKGROUND 0, 0, 0
#endif
#ifndef COLOR_STATION_NAME
#define COLOR_STATION_NAME 231, 211, 90
#endif
#ifndef COLOR_SNG_TITLE_1
#define COLOR_SNG_TITLE_1 255, 255, 255
#endif
#ifndef COLOR_SNG_TITLE_2
#define COLOR_SNG_TITLE_2 165, 162, 132
#endif
#ifndef COLOR_WEATHER
#define COLOR_WEATHER 255, 150, 0
#endif
#ifndef COLOR_VU_MAX
#define COLOR_VU_MAX 231, 211, 90
#endif
#ifndef COLOR_VU_MIN
#define COLOR_VU_MIN 123, 125, 123
#endif
#ifndef COLOR_CLOCK
#define COLOR_CLOCK 231, 211, 90
#endif
#ifndef COLOR_SECONDS
#define COLOR_SECONDS 231, 211, 90
#endif
#ifndef COLOR_DAY_OF_W
#define COLOR_DAY_OF_W 255, 255, 255
#endif
#ifndef COLOR_DATE
#define COLOR_DATE 255, 255, 255
#endif
#ifndef COLOR_HEAP
#define COLOR_HEAP 41, 40, 41
#endif
#ifndef COLOR_BUFFER
#define COLOR_BUFFER 165, 162, 132
#endif
#ifndef COLOR_IP
#define COLOR_IP 165, 162, 132
#endif
#ifndef COLOR_VOLUME_VALUE
#define COLOR_VOLUME_VALUE 165, 162, 132
#endif
#ifndef COLOR_RSSI
#define COLOR_RSSI 165, 162, 132
#endif
#ifndef COLOR_VOLBAR_OUT
#define COLOR_VOLBAR_OUT 231, 211, 90
#endif
#ifndef COLOR_VOLBAR_IN
#define COLOR_VOLBAR_IN 231, 211, 90
#endif
#ifndef COLOR_DIGITS
#define COLOR_DIGITS 255, 255, 255
#endif
#ifndef COLOR_DIVIDER
#define COLOR_DIVIDER 165, 162, 132
#endif
#ifndef COLOR_PLAYLIST_0
#define COLOR_PLAYLIST_0 115, 115, 115
#endif
#ifndef COLOR_PLAYLIST_1
#define COLOR_PLAYLIST_1 89, 89, 89
#endif
#ifndef COLOR_PLAYLIST_2
#define COLOR_PLAYLIST_2 56, 56, 56
#endif
#ifndef COLOR_PLAYLIST_3
#define COLOR_PLAYLIST_3 35, 35, 35
#endif
#ifndef COLOR_PLAYLIST_4
#define COLOR_PLAYLIST_4 25, 25, 25
#endif
#endif #endif

View File

@@ -536,10 +536,10 @@ void TFT_22_ILI9225::_resetWindow() {
} }
void TFT_22_ILI9225::clear() { void TFT_22_ILI9225::clear(uint16_t withColor) {
uint8_t old = _orientation; uint8_t old = _orientation;
setOrientation(0); setOrientation(0);
fillRectangle(0, 0, _maxX - 1, _maxY - 1, COLOR_BLACK); fillRectangle(0, 0, _maxX - 1, _maxY - 1, withColor);
setOrientation(old); setOrientation(old);
delay(10); delay(10);
} }

View File

@@ -182,7 +182,7 @@ class TFT_22_ILI9225 {
#endif #endif
/// Clear the screen /// Clear the screen
void clear(void); void clear(uint16_t withColor = COLOR_BLACK);
/// Invert screen /// Invert screen
/// @param flag true to invert, false for normal screen /// @param flag true to invert, false for normal screen

View File

@@ -97,14 +97,14 @@ char* DspCore::utf8Rus(const char* str, bool uppercase) {
void DspCore::apScreen() { void DspCore::apScreen() {
setTextSize(1); setTextSize(1);
setTextColor(TFT_FG, TFT_BG); setTextColor(config.theme.title1, config.theme.background);
setCursor(TFT_FRAMEWDT, TFT_FRAMEWDT + 2 * TFT_LINEHGHT); setCursor(TFT_FRAMEWDT, TFT_FRAMEWDT + 2 * TFT_LINEHGHT);
print("AP NAME: "); print("AP NAME: ");
print(apSsid); print(apSsid);
setCursor(TFT_FRAMEWDT, TFT_FRAMEWDT + 3 * TFT_LINEHGHT); setCursor(TFT_FRAMEWDT, TFT_FRAMEWDT + 3 * TFT_LINEHGHT);
print("PASSWORD: "); print("PASSWORD: ");
print(apPassword); print(apPassword);
setTextColor(SILVER, TFT_BG); setTextColor(config.theme.title2, config.theme.background);
setCursor(TFT_FRAMEWDT, 107); setCursor(TFT_FRAMEWDT, 107);
print("SETTINGS PAGE ON: "); print("SETTINGS PAGE ON: ");
setCursor(TFT_FRAMEWDT, 117); setCursor(TFT_FRAMEWDT, 117);
@@ -117,7 +117,7 @@ void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
begin(DEF_SPI_FREQ); begin(DEF_SPI_FREQ);
cp437(true); cp437(true);
invert(); invert();
fillScreen(TFT_BG); // fillScreen(TFT_BG);
flip(); flip();
setTextWrap(false); setTextWrap(false);
screenwidth = width(); screenwidth = width();
@@ -128,14 +128,10 @@ void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
} }
void DspCore::drawLogo() { void DspCore::drawLogo() {
fillScreen(0x0000);
drawRGBBitmap((swidth - 62) / 2, 5, bootlogo40, 62, 40); drawRGBBitmap((swidth - 62) / 2, 5, bootlogo40, 62, 40);
} }
// http://greekgeeks.net/#maker-tools_convertColor
#define CLR_ITEM1 0x52AA
#define CLR_ITEM2 0x39C7
#define CLR_ITEM3 0x18E3
void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) { void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
for (byte i = 0; i < PLMITEMS; i++) { for (byte i = 0; i < PLMITEMS; i++) {
plMenu[i][0] = '\0'; plMenu[i][0] = '\0';
@@ -145,21 +141,21 @@ void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
int yStart = (sheight / 2 - PLMITEMHEIGHT / 2) - PLMITEMHEIGHT * (PLMITEMS - 1) / 2 + 3; int yStart = (sheight / 2 - PLMITEMHEIGHT / 2) - PLMITEMHEIGHT * (PLMITEMS - 1) / 2 + 3;
//fillRect(0, (sheight / 2 - PLMITEMHEIGHT / 2) - 1, swidth, PLMITEMHEIGHT + 2, TFT_LOGO); //fillRect(0, (sheight / 2 - PLMITEMHEIGHT / 2) - 1, swidth, PLMITEMHEIGHT + 2, TFT_LOGO);
for (byte i = 0; i < PLMITEMS; i++) { for (byte i = 0; i < PLMITEMS; i++) {
if (abs(i - 3) == 3) setTextColor(CLR_ITEM3, TFT_BG); if (abs(i - 3) == 3) setTextColor(config.theme.playlist[2], config.theme.background);
if (abs(i - 3) == 2) setTextColor(CLR_ITEM2, TFT_BG); if (abs(i - 3) == 2) setTextColor(config.theme.playlist[1], config.theme.background);
if (abs(i - 3) == 1) setTextColor(CLR_ITEM1, TFT_BG); if (abs(i - 3) == 1) setTextColor(config.theme.playlist[0], config.theme.background);
if (i == 3) { if (i == 3) {
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1); strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
} else { } else {
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT); setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
fillRect(0, yStart + i * PLMITEMHEIGHT - 1, swidth, PLMITEMHEIGHT - 4, TFT_BG); fillRect(0, yStart + i * PLMITEMHEIGHT - 1, swidth, PLMITEMHEIGHT - 4, config.theme.background);
print(utf8Rus(plMenu[i], true)); print(utf8Rus(plMenu[i], true));
} }
} }
} }
void DspCore::clearDsp() { void DspCore::clearDsp() {
fillScreen(TFT_BG); fillScreen(config.theme.background);
} }
void DspCore::drawScrollFrame(uint16_t texttop, uint16_t textheight, uint16_t bg) { void DspCore::drawScrollFrame(uint16_t texttop, uint16_t textheight, uint16_t bg) {
@@ -239,7 +235,7 @@ void DspCore::printClock(struct tm timeinfo, bool dots, bool redraw){
if(strstr(oldTimeBuf, timeBuf)==NULL || redraw){ if(strstr(oldTimeBuf, timeBuf)==NULL || redraw){
getTextBounds(oldTimeBuf, 0, 0, &x, &y, &wot, &hot); getTextBounds(oldTimeBuf, 0, 0, &x, &y, &wot, &hot);
setCursor((swidth - wot) / 2 - 4 + clockdelta, clockY+28+6); setCursor((swidth - wot) / 2 - 4 + clockdelta, clockY+28+6);
setTextColor(TFT_BG); setTextColor(config.theme.background);
print(oldTimeBuf); print(oldTimeBuf);
dot = (swidth - wot) / 2 - 4 + clockdelta; dot = (swidth - wot) / 2 - 4 + clockdelta;
/* dots */ /* dots */
@@ -253,7 +249,7 @@ void DspCore::printClock(struct tm timeinfo, bool dots, bool redraw){
strlcpy(oldTimeBuf, timeBuf, 20); strlcpy(oldTimeBuf, timeBuf, 20);
setTextSize(1); setTextSize(1);
getTextBounds(timeBuf, 0, 0, &x, &y, &ncwidth, &ncheight); getTextBounds(timeBuf, 0, 0, &x, &y, &ncwidth, &ncheight);
setTextColor(TFT_LOGO); setTextColor(config.theme.clock);
setCursor((swidth - ncwidth) / 2 - 4 + clockdelta, clockY+28+6); setCursor((swidth - ncwidth) / 2 - 4 + clockdelta, clockY+28+6);
dot = (swidth - ncwidth) / 2 - 4 + clockdelta; dot = (swidth - ncwidth) / 2 - 4 + clockdelta;
setTextSize(1); setTextSize(1);
@@ -265,7 +261,7 @@ void DspCore::printClock(struct tm timeinfo, bool dots, bool redraw){
/* dots */ /* dots */
} }
setCursor(dot, clockY+28+6); setCursor(dot, clockY+28+6);
setTextColor(dots?TFT_BG:TFT_LOGO); setTextColor(dots?config.theme.background:config.theme.clock);
print(":"); print(":");
setFont(); setFont();
yield(); yield();
@@ -277,18 +273,18 @@ void DspCore::drawVolumeBar(bool withNumber) {
int16_t vTop = sheight - TFT_FRAMEWDT - 2; int16_t vTop = sheight - TFT_FRAMEWDT - 2;
int16_t vWidth = swidth - TFT_FRAMEWDT * 2; int16_t vWidth = swidth - TFT_FRAMEWDT * 2;
uint8_t ww = map(config.store.volume, 0, 254, 0, vWidth); uint8_t ww = map(config.store.volume, 0, 254, 0, vWidth);
fillRect(TFT_FRAMEWDT, vTop, vWidth, 2, TFT_BG); fillRect(TFT_FRAMEWDT, vTop, vWidth, 2, config.theme.background);
fillRect(TFT_FRAMEWDT, vTop, ww, 2, TFT_LOGO); fillRect(TFT_FRAMEWDT, vTop, ww, 2, config.theme.volbarout);
if (withNumber) { if (withNumber) {
setTextSize(1); setTextSize(1);
setTextColor(TFT_FG); setTextColor(config.theme.digit);
setFont(&DS_DIGI28pt7b); setFont(&DS_DIGI28pt7b);
char volstr[4]; char volstr[4];
uint16_t wv, hv; uint16_t wv, hv;
int16_t x1, y1; int16_t x1, y1;
sprintf(volstr, "%d", config.store.volume); sprintf(volstr, "%d", config.store.volume);
getTextBounds(volstr, 0, 0, &x1, &y1, &wv, &hv); getTextBounds(volstr, 0, 0, &x1, &y1, &wv, &hv);
fillRect(TFT_FRAMEWDT, VTOP, swidth - TFT_FRAMEWDT / 2, hv + 3, TFT_BG); fillRect(TFT_FRAMEWDT, VTOP, swidth - TFT_FRAMEWDT / 2, hv + 3, config.theme.background);
setCursor((swidth - wv) / 2, VTOP + hv); setCursor((swidth - wv) / 2, VTOP + hv);
print(volstr); print(volstr);
setFont(); setFont();
@@ -297,14 +293,14 @@ void DspCore::drawVolumeBar(bool withNumber) {
void DspCore::drawNextStationNum(uint16_t num) { void DspCore::drawNextStationNum(uint16_t num) {
setTextSize(1); setTextSize(1);
setTextColor(TFT_FG); setTextColor(config.theme.digit);
setFont(&DS_DIGI28pt7b); setFont(&DS_DIGI28pt7b);
char numstr[7]; char numstr[7];
uint16_t wv, hv; uint16_t wv, hv;
int16_t x1, y1; int16_t x1, y1;
sprintf(numstr, "%d", num); sprintf(numstr, "%d", num);
getTextBounds(numstr, 0, 0, &x1, &y1, &wv, &hv); getTextBounds(numstr, 0, 0, &x1, &y1, &wv, &hv);
fillRect(TFT_FRAMEWDT, VTOP, swidth - TFT_FRAMEWDT / 2, hv + 3, TFT_BG); fillRect(TFT_FRAMEWDT, VTOP, swidth - TFT_FRAMEWDT / 2, hv + 3, config.theme.background);
setCursor((swidth - wv) / 2, VTOP + hv); setCursor((swidth - wv) / 2, VTOP + hv);
print(numstr); print(numstr);
setFont(); setFont();
@@ -312,19 +308,19 @@ void DspCore::drawNextStationNum(uint16_t num) {
void DspCore::frameTitle(const char* str) { void DspCore::frameTitle(const char* str) {
setTextSize(2); setTextSize(2);
centerText(str, TFT_FRAMEWDT, TFT_LOGO, TFT_BG); centerText(str, TFT_FRAMEWDT, config.theme.meta, config.theme.background);
} }
void DspCore::rssi(const char* str) { void DspCore::rssi(const char* str) {
int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT - 2; int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT - 2;
setTextSize(1); setTextSize(1);
rightText(str, vTop, SILVER, TFT_BG); rightText(str, vTop, config.theme.rssi, config.theme.background);
} }
void DspCore::ip(const char* str) { void DspCore::ip(const char* str) {
int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT - 2; int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT - 2;
setTextSize(1); setTextSize(1);
setTextColor(SILVER, TFT_BG); setTextColor(config.theme.ip, config.theme.background);
setCursor(4, vTop); setCursor(4, vTop);
print(str); print(str);
} }
@@ -385,4 +381,8 @@ void DspCore::flip(){
void DspCore::invert(){ void DspCore::invert(){
invertDisplay(config.store.invertdisplay); invertDisplay(config.store.invertdisplay);
} }
void DspCore::sleep(void) { sendCommand(GC9106_SLPIN); delay(150); sendCommand(GC9106_DISPOFF); delay(150); }
void DspCore::wake(void) { sendCommand(GC9106_DISPON); delay(150); sendCommand(GC9106_SLPOUT); delay(150); }
#endif #endif

View File

@@ -8,6 +8,7 @@
#include "fonts/DS_DIGI28pt7b.h" #include "fonts/DS_DIGI28pt7b.h"
#define VU_READY 1 #define VU_READY 1
#define DSP_CAN_SLEEP true
#define TFT_LINEHGHT 10 #define TFT_LINEHGHT 10
#define TFT_FRAMEWDT 0 #define TFT_FRAMEWDT 0
@@ -62,6 +63,8 @@ class DspCore: public Adafruit_GC9106Ex {
virtual void endWrite(void); virtual void endWrite(void);
void flip(); void flip();
void invert(); void invert();
void sleep();
void wake();
/*virtual void sendCommand(uint8_t commandByte, uint8_t *dataBytes, /*virtual void sendCommand(uint8_t commandByte, uint8_t *dataBytes,
uint8_t numDataBytes); uint8_t numDataBytes);
virtual void sendCommand(uint8_t commandByte, const uint8_t *dataBytes = NULL, virtual void sendCommand(uint8_t commandByte, const uint8_t *dataBytes = NULL,
@@ -83,7 +86,7 @@ extern DspCore dsp;
/* /*
* TFT COLORS * TFT COLORS
*/ */
#define BLACK 0x0000 /*#define BLACK 0x0000
#define BLUE 0x001F #define BLUE 0x001F
#define RED 0xF800 #define RED 0xF800
#define GREEN 0x07E0 #define GREEN 0x07E0
@@ -110,6 +113,6 @@ extern DspCore dsp;
#define TFT_BG BLACK #define TFT_BG BLACK
#define TFT_FG WHITE #define TFT_FG WHITE
#define TFT_LOGO 0xE68B // 224, 209, 92 #define TFT_LOGO 0xE68B // 224, 209, 92*/
#endif #endif

View File

@@ -96,15 +96,17 @@ char* DspCore::utf8Rus(const char* str, bool uppercase) {
} }
void DspCore::apScreen() { void DspCore::apScreen() {
started = true;
clearDsp();
setTextSize(TITLE_SIZE1); setTextSize(TITLE_SIZE1);
setTextColor(TFT_FG, TFT_BG); setTextColor(config.theme.title1, config.theme.background);
setCursor(TFT_FRAMEWDT, TITLE_TOP1); setCursor(TFT_FRAMEWDT, TITLE_TOP1);
print("AP NAME: "); print("AP NAME: ");
print(apSsid); print(apSsid);
setCursor(TFT_FRAMEWDT, TITLE_TOP2); setCursor(TFT_FRAMEWDT, TITLE_TOP2);
print("PASSWORD: "); print("PASSWORD: ");
print(apPassword); print(apPassword);
setTextColor(SILVER, TFT_BG); setTextColor(config.theme.title2, config.theme.background);
setCursor(TFT_FRAMEWDT, sheight-TFT_FRAMEWDT-TFT_LINEHGHT*4); setCursor(TFT_FRAMEWDT, sheight-TFT_FRAMEWDT-TFT_LINEHGHT*4);
print("SETTINGS PAGE ON: "); print("SETTINGS PAGE ON: ");
setCursor(TFT_FRAMEWDT, sheight-TFT_FRAMEWDT-TFT_LINEHGHT*2); setCursor(TFT_FRAMEWDT, sheight-TFT_FRAMEWDT-TFT_LINEHGHT*2);
@@ -112,7 +114,7 @@ void DspCore::apScreen() {
print(WiFi.softAPIP().toString().c_str()); print(WiFi.softAPIP().toString().c_str());
print("/"); print("/");
TAKE_MUTEX(); TAKE_MUTEX();
drawLine(TFT_FRAMEWDT, TITLE_TOP1-8, swidth-TFT_FRAMEWDT*2, TITLE_TOP1-8, SILVER); drawLine(TFT_FRAMEWDT, TITLE_TOP1-8, swidth-TFT_FRAMEWDT*2, TITLE_TOP1-8, config.theme.div);
GIVE_MUTEX(); GIVE_MUTEX();
} }
@@ -189,10 +191,10 @@ void DspCore::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) { void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
//hspi.begin(); //hspi.begin();
started = false;
begin(); begin();
invert(); invert();
setBackgroundColor(TFT_BG); // clear(0x0000);
clear();
flip(); flip();
setTextSize(1); setTextSize(1);
screenwidth = maxX(); screenwidth = maxX();
@@ -202,11 +204,11 @@ void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
} }
void DspCore::drawLogo() { void DspCore::drawLogo() {
// setBackgroundColor(0x0000);
drawBitmap((swidth - 99) / 2, (sheight-64)/2 - TFT_LINEHGHT*2, bootlogo2, 99, 64); drawBitmap((swidth - 99) / 2, (sheight-64)/2 - TFT_LINEHGHT*2, bootlogo2, 99, 64);
// setBackgroundColor(config.theme.background);
} }
// http://greekgeeks.net/#maker-tools_convertColor
uint16_t iclrs[] = { 0x738E /*707070*/, 0x52AA /*575757*/, 0x39C7, 0x18E3 };
void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) { void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
for (byte i = 0; i < PLMITEMS; i++) { for (byte i = 0; i < PLMITEMS; i++) {
plMenu[i][0] = '\0'; plMenu[i][0] = '\0';
@@ -214,22 +216,24 @@ void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
config.fillPlMenu(plMenu, currentItem - 4, PLMITEMS); config.fillPlMenu(plMenu, currentItem - 4, PLMITEMS);
setTextSize(2); setTextSize(2);
int yStart = (sheight / 2 - PLMITEMHEIGHT / 2) - PLMITEMHEIGHT * (PLMITEMS - 1) / 2 + 3; int yStart = (sheight / 2 - PLMITEMHEIGHT / 2) - PLMITEMHEIGHT * (PLMITEMS - 1) / 2 + 3;
fillRect(0, (sheight / 2 - PLMITEMHEIGHT / 2) - 1, swidth, PLMITEMHEIGHT, TFT_LOGO); fillRect(0, (sheight / 2 - PLMITEMHEIGHT / 2) - 1, swidth, PLMITEMHEIGHT, config.theme.meta);
for (byte i = 0; i < PLMITEMS; i++) { for (byte i = 0; i < PLMITEMS; i++) {
if (i == 4) { if (i == 4) {
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1); strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
} else { } else {
setTextColor(iclrs[abs(i - 4)-1], TFT_BG); setTextColor(config.theme.playlist[abs(i - 4)-1], config.theme.background);
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT); setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
fillRect(0, yStart + i * PLMITEMHEIGHT-1, swidth, PLMITEMHEIGHT-7, TFT_BG); fillRect(0, yStart + i * PLMITEMHEIGHT-1, swidth, PLMITEMHEIGHT-7, config.theme.background);
print(utf8Rus(plMenu[i], true)); print(utf8Rus(plMenu[i], true));
} }
} }
} }
void DspCore::clearDsp() { void DspCore::clearDsp() {
//fillScreen(TFT_BG); //fillRect(0, 0, swidth, sheight, config.theme.background);
clear(); TAKE_MUTEX();
clear(started?config.theme.background:0x0000);
GIVE_MUTEX();
} }
void DspCore::drawScrollFrame(uint16_t texttop, uint16_t textheight, uint16_t bg) { void DspCore::drawScrollFrame(uint16_t texttop, uint16_t textheight, uint16_t bg) {
@@ -260,7 +264,7 @@ void DspCore::centerText(const char* text, uint16_t y, uint16_t fg, uint16_t bg)
if(y==90) y=(sheight-64)/2 + 64 + TFT_LINEHGHT; if(y==90) y=(sheight-64)/2 + 64 + TFT_LINEHGHT;
if(y==110) y=(sheight-64)/2 + 64 + TFT_LINEHGHT*3; if(y==110) y=(sheight-64)/2 + 64 + TFT_LINEHGHT*3;
getTextBounds(txt, 0, 0, &x1, &y1, &w, &h); getTextBounds(txt, 0, 0, &x1, &y1, &w, &h);
setTextColor(fg); setTextColor(fg, bg);
setCursor((swidth - w) / 2, y); setCursor((swidth - w) / 2, y);
fillRect((swidth-w)/2-5, y, w+10, h, bg); fillRect((swidth-w)/2-5, y, w+10, h, bg);
print(txt); print(txt);
@@ -279,18 +283,18 @@ void DspCore::displayHeapForDebug() {
int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT * 2 - 2; int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT * 2 - 2;
char buf[50]; char buf[50];
setTextSize(1); setTextSize(1);
setTextColor(DARK_GRAY, TFT_BG); setTextColor(config.theme.heap, config.theme.background);
setCursor(TFT_FRAMEWDT, vTop); setCursor(TFT_FRAMEWDT, vTop);
fillRect(TFT_FRAMEWDT, vTop, swidth - TFT_FRAMEWDT / 2, 7, TFT_BG); fillRect(TFT_FRAMEWDT, vTop, swidth - TFT_FRAMEWDT / 2, 7, config.theme.background);
sprintf(buf, "%d / %d", ESP.getFreeHeap(), ESP.getMaxAllocHeap()); sprintf(buf, "%d / %d", ESP.getFreeHeap(), ESP.getMaxAllocHeap());
print(buf); print(buf);
// audio buffer; // audio buffer;
fillRect(0, sheight - 2, swidth, 2, TFT_BG); fillRect(0, sheight - 2, swidth, 2, config.theme.background);
int astored = player.inBufferFilled(); int astored = player.inBufferFilled();
int afree = player.inBufferFree(); int afree = player.inBufferFree();
int aprcnt = 100 * astored / (astored + afree); int aprcnt = 100 * astored / (astored + afree);
byte sbw = map(aprcnt, 0, 100 , 0, swidth); uint16_t sbw = map(aprcnt, 0, 100 , 0, swidth);
fillRect(0, sheight - 2, sbw, 2, SILVER); fillRect(0, sheight - 2, sbw, 2, config.theme.buffer);
} }
void DspCore::printClock(const char* timestr) { void DspCore::printClock(const char* timestr) {
@@ -316,34 +320,34 @@ void DspCore::printClock(struct tm timeinfo, bool dots, bool redraw){
clwidth = wot+clsp+34; clwidth = wot+clsp+34;
clleft=swidth-TFT_FRAMEWDT-clwidth; clleft=swidth-TFT_FRAMEWDT-clwidth;
setCursor(clleft, cltop); setCursor(clleft, cltop);
setTextColor(TFT_BG); setTextColor(config.theme.background, config.theme.background);
print(oldTimeBuf); print(oldTimeBuf);
strlcpy(oldTimeBuf, timeBuf, 20); strlcpy(oldTimeBuf, timeBuf, 20);
getTextBounds(timeBuf, 0, 0, &x1, &y1, &wot, &hot); getTextBounds(timeBuf, 0, 0, &x1, &y1, &wot, &hot);
clwidth = wot+clsp+34; clwidth = wot+clsp+34;
clleft=swidth-TFT_FRAMEWDT-clwidth; clleft=swidth-TFT_FRAMEWDT-clwidth;
setTextColor(TFT_LOGO, TFT_BG); setTextColor(config.theme.clock, config.theme.background);
setCursor(clleft, cltop); setCursor(clleft, cltop);
print(timeBuf); print(timeBuf);
gFont=false; gFont=false;
setTextSize(2); setTextSize(2);
setTextColor(TFT_FG, TFT_BG); setTextColor(config.theme.dow, config.theme.background);
setCursor(clleft+wot+clsp, cltop-hot+22); setCursor(clleft+wot+clsp, cltop-hot+22);
print(utf8Rus(dow[timeinfo.tm_wday], false)); print(utf8Rus(dow[timeinfo.tm_wday], false));
TAKE_MUTEX(); TAKE_MUTEX();
drawLine(clleft+wot+clsp/2, cltop-34, clleft+wot+clsp/2, cltop+1, SILVER); //vert drawLine(clleft+wot+clsp/2, cltop-34, clleft+wot+clsp/2, cltop+1, config.theme.div); //vert
drawLine(clleft+wot+clsp/2, cltop-hot+20, clleft+wot+clsp/2+35, cltop-hot+20, SILVER); //hor drawLine(clleft+wot+clsp/2, cltop-hot+20, clleft+wot+clsp/2+35, cltop-hot+20, config.theme.div); //hor
drawLine(TFT_FRAMEWDT, TITLE_TOP1-8, swidth-TFT_FRAMEWDT*2, TITLE_TOP1-8, SILVER); drawLine(TFT_FRAMEWDT, TITLE_TOP1-8, swidth-TFT_FRAMEWDT*2, TITLE_TOP1-8, config.theme.div);
GIVE_MUTEX(); GIVE_MUTEX();
sprintf(timeBuf, "%2d %s %d", timeinfo.tm_mday,mnths[timeinfo.tm_mon], timeinfo.tm_year+1900); sprintf(timeBuf, "%2d %s %d", timeinfo.tm_mday,mnths[timeinfo.tm_mon], timeinfo.tm_year+1900);
uint16_t wdate, hdate; uint16_t wdate, hdate;
getTextBounds(timeBuf, 0, 0, &x1, &y1, &wdate, &hdate); getTextBounds(timeBuf, 0, 0, &x1, &y1, &wdate, &hdate);
fillRect(swidth - wdate - TFT_FRAMEWDT-20, cltop+10, wdate+20, hdate, TFT_BG); fillRect(swidth - wdate - TFT_FRAMEWDT-20, cltop+10, wdate+20, hdate, config.theme.background);
setTextSize(1); setTextSize(1);
rightText(utf8Rus(timeBuf,true), cltop+10, TFT_FG, TFT_BG, false, 12); rightText(utf8Rus(timeBuf,true), cltop+10, config.theme.date, config.theme.background, false, 12);
} }
setTextSize(2); setTextSize(2);
setTextColor(TFT_LOGO, TFT_BG); setTextColor(config.theme.seconds, config.theme.background);
setCursor(clleft+wot+clsp, cltop-hot+1); setCursor(clleft+wot+clsp, cltop-hot+1);
sprintf(timeBuf, "%02d", timeinfo.tm_sec); sprintf(timeBuf, "%02d", timeinfo.tm_sec);
print(timeBuf); print(timeBuf);
@@ -355,12 +359,13 @@ void DspCore::drawVolumeBar(bool withNumber) {
int16_t vWidth = swidth - TFT_FRAMEWDT *2; int16_t vWidth = swidth - TFT_FRAMEWDT *2;
(void)volTop; (void)volTop;
uint16_t ww = map(config.store.volume, 0, 254, 0, vWidth - 2); uint16_t ww = map(config.store.volume, 0, 254, 0, vWidth - 2);
fillRect(TFT_FRAMEWDT, vTop - 2, vWidth, 6, TFT_BG); fillRect(TFT_FRAMEWDT, vTop - 2, vWidth, 6, config.theme.background);
drawRectangle(TFT_FRAMEWDT, vTop - 2, TFT_FRAMEWDT+vWidth, 6+vTop - 2, TFT_LOGO); fillRect(TFT_FRAMEWDT + 1, vTop - 1, ww, 5, config.theme.volbarin);
fillRect(TFT_FRAMEWDT + 1, vTop - 1, ww, 5, TFT_LOGO); drawRectangle(TFT_FRAMEWDT, vTop - 2, TFT_FRAMEWDT+vWidth, 6+vTop - 2, config.theme.volbarout);
if (withNumber) { if (withNumber) {
setTextSize(1); setTextSize(1);
setTextColor(TFT_FG); setTextColor(config.theme.digit, config.theme.background);
setFont(&DS_DIGI28pt7b); setFont(&DS_DIGI28pt7b);
char volstr[4]; char volstr[4];
uint16_t wv, hv; uint16_t wv, hv;
@@ -373,9 +378,9 @@ void DspCore::drawVolumeBar(bool withNumber) {
print(volstr);*/ print(volstr);*/
sprintf(volstr, "%d", oldVolume); sprintf(volstr, "%d", oldVolume);
getTextBounds(volstr, 0, 0, &x1, &y1, &wv, &hv); getTextBounds(volstr, 0, 0, &x1, &y1, &wv, &hv);
fillRect((swidth - wv) / 2 - 12, (sheight-hv)/2, wv+24, hv, TFT_BG); fillRect((swidth - wv) / 2 - 12, (sheight-hv)/2, wv+24, hv, config.theme.background);
setTextColor(TFT_FG); setTextColor(config.theme.vol, config.theme.background);
sprintf(volstr, "%d", config.store.volume); sprintf(volstr, "%d", config.store.volume);
getTextBounds(volstr, 0, 0, &x1, &y1, &wv, &hv); getTextBounds(volstr, 0, 0, &x1, &y1, &wv, &hv);
setCursor((swidth - wv) / 2, (sheight-hv)/2 + hv); setCursor((swidth - wv) / 2, (sheight-hv)/2 + hv);
@@ -386,23 +391,23 @@ void DspCore::drawVolumeBar(bool withNumber) {
void DspCore::drawNextStationNum(uint16_t num) { void DspCore::drawNextStationNum(uint16_t num) {
setTextSize(1); setTextSize(1);
setTextColor(TFT_FG); setTextColor(config.theme.digit, config.theme.background);
setFont(&DS_DIGI28pt7b); setFont(&DS_DIGI28pt7b);
char numstr[7]; char numstr[7];
uint16_t wv, hv; uint16_t wv, hv;
int16_t x1, y1; int16_t x1, y1;
sprintf(numstr, "%d", num); sprintf(numstr, "%d", num);
getTextBounds(numstr, 0, 0, &x1, &y1, &wv, &hv); getTextBounds(numstr, 0, 0, &x1, &y1, &wv, &hv);
fillRect(TFT_FRAMEWDT, (sheight-hv)/2, swidth - TFT_FRAMEWDT / 2, hv + 3, TFT_BG); fillRect(TFT_FRAMEWDT, (sheight-hv)/2, swidth - TFT_FRAMEWDT / 2, hv + 3, config.theme.background);
setCursor((swidth - wv) / 2, (sheight-hv)/2 + hv); setCursor((swidth - wv) / 2, (sheight-hv)/2 + hv);
print(numstr); print(numstr);
} }
void DspCore::frameTitle(const char* str) { void DspCore::frameTitle(const char* str) {
setTextSize(META_SIZE); setTextSize(META_SIZE);
centerText(str, TFT_FRAMEWDT, TFT_LOGO, TFT_BG); centerText(str, TFT_FRAMEWDT, config.theme.meta, config.theme.background);
TAKE_MUTEX(); TAKE_MUTEX();
drawLine(TFT_FRAMEWDT, TITLE_TOP1-8, swidth-TFT_FRAMEWDT*2, TITLE_TOP1-8, SILVER); drawLine(TFT_FRAMEWDT, TITLE_TOP1-8, swidth-TFT_FRAMEWDT*2, TITLE_TOP1-8, config.theme.div);
GIVE_MUTEX(); GIVE_MUTEX();
} }
@@ -411,15 +416,19 @@ void DspCore::rssi(const char* str) {
char buf[20]; char buf[20];
sprintf(buf, "RSSI:%s", str); sprintf(buf, "RSSI:%s", str);
setTextSize(1); setTextSize(1);
rightText(buf, vTop, SILVER, TFT_BG); rightText(buf, vTop, config.theme.rssi, config.theme.background);
} }
void DspCore::ip(const char* str) { void DspCore::ip(const char* str) {
if(!started){
started = true;
clear(config.theme.background);
}
int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT - 2; int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT - 2;
char buf[30]; char buf[30];
sprintf(buf, "IP: %s", str); sprintf(buf, "IP: %s", str);
setTextSize(1); setTextSize(1);
setTextColor(SILVER, TFT_BG); setTextColor(config.theme.ip, config.theme.background);
setCursor(TFT_FRAMEWDT, vTop); setCursor(TFT_FRAMEWDT, vTop);
print(buf); print(buf);
} }
@@ -455,4 +464,8 @@ void DspCore::flip(){
void DspCore::invert(){ void DspCore::invert(){
invertDisplay(config.store.invertdisplay); invertDisplay(config.store.invertdisplay);
} }
void DspCore::sleep(void) { setDisplay(false); }
void DspCore::wake(void) { setDisplay(true); }
#endif #endif

View File

@@ -7,6 +7,7 @@
#define VU_READY 1 #define VU_READY 1
#define WEATHER_READY 1 #define WEATHER_READY 1
#define DSP_CAN_SLEEP true
#define TFT_LINEHGHT 10 #define TFT_LINEHGHT 10
#define TFT_FRAMEWDT 4 #define TFT_FRAMEWDT 4
@@ -32,7 +33,6 @@
#ifndef TITLE_TOP2 #ifndef TITLE_TOP2
#define TITLE_TOP2 TFT_FRAMEWDT + (META_SIZE+2) * TFT_LINEHGHT #define TITLE_TOP2 TFT_FRAMEWDT + (META_SIZE+2) * TFT_LINEHGHT
#endif #endif
#define TITLE_FG2 SILVER
class DspCore: public TFT_22_ILI9225 { class DspCore: public TFT_22_ILI9225 {
public: public:
@@ -66,7 +66,7 @@ class DspCore: public TFT_22_ILI9225 {
void setFont(uint8_t* font, bool monoSp=false ); void setFont(uint8_t* font, bool monoSp=false );
void setFont(const GFXfont *f = NULL); void setFont(const GFXfont *f = NULL);
void setTextSize(uint8_t s); void setTextSize(uint8_t s);
void setTextColor(uint16_t fg, uint16_t bg=0x0000); void setTextColor(uint16_t fg, uint16_t bg);
void setCursor(int16_t x, int16_t y); void setCursor(int16_t x, int16_t y);
uint16_t print(const char* s); uint16_t print(const char* s);
void getTextBounds(const char *string, int16_t x, int16_t y, int16_t *x1, void getTextBounds(const char *string, int16_t x, int16_t y, int16_t *x1,
@@ -78,11 +78,13 @@ class DspCore: public TFT_22_ILI9225 {
void drawRGBBitmap(int16_t x, int16_t y, const uint16_t *bitmap, int16_t w, int16_t h); void drawRGBBitmap(int16_t x, int16_t y, const uint16_t *bitmap, int16_t w, int16_t h);
void flip(); void flip();
void invert(); void invert();
void sleep();
void wake();
private: private:
uint16_t swidth, sheight; uint16_t swidth, sheight;
uint16_t bgcolor, fgcolor; uint16_t bgcolor, fgcolor;
int16_t cursorx, cursory; int16_t cursorx, cursory;
bool gFont; bool gFont, started;
char oldTimeBuf[20]; char oldTimeBuf[20];
uint8_t oldVolume; uint8_t oldVolume;
uint16_t wot, hot; uint16_t wot, hot;
@@ -91,36 +93,4 @@ class DspCore: public TFT_22_ILI9225 {
extern DspCore dsp; extern DspCore dsp;
/*
* TFT COLORS
*/
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define GRAY 0x7BEF
#define DARK_GRAY 0x2945
#define LIGHT_GRAY 0xC618
#define LIME 0x87E0
#define AQUA 0x5D1C
#define CYAN 0x07FF
#define DARK_CYAN 0x03EF
#define ORANGE 0xFCA0
#define PINK 0xF97F
#define BROWN 0x8200
#define VIOLET 0x9199
#define SILVER 0xA510
#define GOLD 0xA508
#define NAVY 0x000F
#define MAROON 0x7800
#define PURPLE 0x780F
#define OLIVE 0x7BE0
#define TFT_BG BLACK
#define TFT_FG WHITE
#define TFT_LOGO 0xE68B // 224, 209, 92
#endif #endif

View File

@@ -94,28 +94,28 @@ char* DspCore::utf8Rus(const char* str, bool uppercase) {
void DspCore::apScreen() { void DspCore::apScreen() {
setTextSize(TITLE_SIZE1); setTextSize(TITLE_SIZE1);
setTextColor(TFT_FG, TFT_BG); setTextColor(config.theme.title1, config.theme.background);
setCursor(TFT_FRAMEWDT, TITLE_TOP1); setCursor(TFT_FRAMEWDT, TITLE_TOP1);
print("AP NAME: "); print("AP NAME: ");
print(apSsid); print(apSsid);
setCursor(TFT_FRAMEWDT, TITLE_TOP2); setCursor(TFT_FRAMEWDT, TITLE_TOP2);
print("PASSWORD: "); print("PASSWORD: ");
print(apPassword); print(apPassword);
setTextColor(SILVER, TFT_BG); setTextColor(config.theme.title2, config.theme.background);
setCursor(TFT_FRAMEWDT, sheight-TFT_FRAMEWDT-TFT_LINEHGHT*4); setCursor(TFT_FRAMEWDT, sheight-TFT_FRAMEWDT-TFT_LINEHGHT*4);
print("SETTINGS PAGE ON: "); print("SETTINGS PAGE ON: ");
setCursor(TFT_FRAMEWDT, sheight-TFT_FRAMEWDT-TFT_LINEHGHT*2); setCursor(TFT_FRAMEWDT, sheight-TFT_FRAMEWDT-TFT_LINEHGHT*2);
print("http://"); print("http://");
print(WiFi.softAPIP().toString().c_str()); print(WiFi.softAPIP().toString().c_str());
print("/"); print("/");
drawFastHLine(TFT_FRAMEWDT, TITLE_TOP1-8, swidth-TFT_FRAMEWDT*2, SILVER); drawFastHLine(TFT_FRAMEWDT, TITLE_TOP1-8, swidth-TFT_FRAMEWDT*2, config.theme.div);
} }
void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) { void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
begin(); /* SPI_DEFAULT_FREQ 40000000 */ begin(); /* SPI_DEFAULT_FREQ 40000000 */
invert(); invert();
cp437(true); cp437(true);
fillScreen(TFT_BG); // fillScreen(config.theme.background);
flip(); flip();
setTextWrap(false); setTextWrap(false);
setTextSize(1); setTextSize(1);
@@ -126,33 +126,32 @@ void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
} }
void DspCore::drawLogo() { void DspCore::drawLogo() {
fillScreen(0x0000);
drawRGBBitmap((swidth - 99) / 2, (sheight-64)/2 - TFT_LINEHGHT*2, bootlogo2, 99, 64); drawRGBBitmap((swidth - 99) / 2, (sheight-64)/2 - TFT_LINEHGHT*2, bootlogo2, 99, 64);
} }
// http://greekgeeks.net/#maker-tools_convertColor
uint16_t iclrs[] = { 0x738E /*707070*/, 0x52AA /*575757*/, 0x39C7, 0x18E3 };
void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) { void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
for (byte i = 0; i < PLMITEMS; i++) { for (byte i = 0; i < PLMITEMS; i++) {
plMenu[i][0] = '\0'; plMenu[i][0] = '\0';
} }
config.fillPlMenu(plMenu, currentItem - 4, PLMITEMS); config.fillPlMenu(plMenu, currentItem - 5, PLMITEMS);
setTextSize(2); setTextSize(2);
int yStart = (sheight / 2 - PLMITEMHEIGHT / 2) - PLMITEMHEIGHT * (PLMITEMS - 1) / 2 + 3; int yStart = (sheight / 2 - PLMITEMHEIGHT / 2) - PLMITEMHEIGHT * (PLMITEMS - 1) / 2 + 3;
fillRect(0, (sheight / 2 - PLMITEMHEIGHT / 2) - 1, swidth, PLMITEMHEIGHT + 2, TFT_LOGO); fillRect(0, (sheight / 2 - PLMITEMHEIGHT / 2) - 1, swidth, PLMITEMHEIGHT + 2, config.theme.meta);
for (byte i = 0; i < PLMITEMS; i++) { for (byte i = 0; i < PLMITEMS; i++) {
if (i == 4) { if (i == 5) {
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1); strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
} else { } else {
setTextColor(iclrs[abs(i - 4)-1], TFT_BG); setTextColor(config.theme.playlist[abs(i - 5)-1], config.theme.background);
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT); setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
fillRect(0, yStart + i * PLMITEMHEIGHT-1, swidth, PLMITEMHEIGHT-4, TFT_BG); fillRect(0, yStart + i * PLMITEMHEIGHT-1, swidth, PLMITEMHEIGHT-4, config.theme.background);
print(utf8Rus(plMenu[i], true)); print(utf8Rus(plMenu[i], true));
} }
} }
} }
void DspCore::clearDsp() { void DspCore::clearDsp() {
fillScreen(TFT_BG); fillScreen(config.theme.background);
} }
void DspCore::drawScrollFrame(uint16_t texttop, uint16_t textheight, uint16_t bg) { void DspCore::drawScrollFrame(uint16_t texttop, uint16_t textheight, uint16_t bg) {
@@ -202,19 +201,19 @@ void DspCore::rightText(const char* text, uint16_t y, uint16_t fg, uint16_t bg,
void DspCore::displayHeapForDebug() { void DspCore::displayHeapForDebug() {
int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT * 2 - 2; int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT * 2 - 2;
setTextSize(1); setTextSize(1);
setTextColor(DARK_GRAY, TFT_BG); setTextColor(config.theme.heap, config.theme.background);
setCursor(TFT_FRAMEWDT, vTop); setCursor(TFT_FRAMEWDT, vTop);
fillRect(TFT_FRAMEWDT, vTop, swidth - TFT_FRAMEWDT / 2, 7, TFT_BG); fillRect(TFT_FRAMEWDT, vTop, swidth - TFT_FRAMEWDT / 2, 7, config.theme.background);
print(ESP.getFreeHeap()); print(ESP.getFreeHeap());
print(" / "); print(" / ");
print(ESP.getMaxAllocHeap()); print(ESP.getMaxAllocHeap());
// audio buffer; // audio buffer;
fillRect(0, sheight - 2, swidth, 2, TFT_BG); fillRect(0, sheight - 2, swidth, 2, config.theme.background);
int astored = player.inBufferFilled(); int astored = player.inBufferFilled();
int afree = player.inBufferFree(); int afree = player.inBufferFree();
int aprcnt = 100 * astored / (astored + afree); int aprcnt = 100 * astored / (astored + afree);
byte sbw = map(aprcnt, 0, 100 , 0, swidth); uint16_t sbw = map(aprcnt, 0, 100 , 0, swidth);
fillRect(0, sheight - 2, sbw, 2, SILVER); fillRect(0, sheight - 2, sbw, 2, config.theme.buffer);
} }
void DspCore::printClock(const char* timestr) { void DspCore::printClock(const char* timestr) {
@@ -239,21 +238,21 @@ void DspCore::printClock(struct tm timeinfo, bool dots, bool redraw){
} }
clwidth = wot+clsp+(swidth>240?46:34); clwidth = wot+clsp+(swidth>240?46:34);
clleft=swidth-TFT_FRAMEWDT-clwidth; clleft=swidth-TFT_FRAMEWDT-clwidth;
//fillRect(swidth-TFT_FRAMEWDT-clwidth, cltop-hot, clwidth, hot+3, TFT_BG); //fillRect(swidth-TFT_FRAMEWDT-clwidth, cltop-hot, clwidth, hot+3, config.theme.background);
setCursor(clleft, cltop); setCursor(clleft, cltop);
setTextColor(TFT_BG); setTextColor(config.theme.background);
print(oldTimeBuf); print(oldTimeBuf);
strlcpy(oldTimeBuf, timeBuf, 20); strlcpy(oldTimeBuf, timeBuf, 20);
getTextBounds(timeBuf, 0, 0, &x1, &y1, &wot, &hot); getTextBounds(timeBuf, 0, 0, &x1, &y1, &wot, &hot);
clwidth = wot+clsp+(swidth>240?46:34); clwidth = wot+clsp+(swidth>240?46:34);
clleft=swidth-TFT_FRAMEWDT-clwidth; clleft=swidth-TFT_FRAMEWDT-clwidth;
setTextColor(TFT_LOGO, TFT_BG); setTextColor(config.theme.clock, config.theme.background);
setCursor(clleft, cltop); setCursor(clleft, cltop);
print(timeBuf); print(timeBuf);
setFont(); setFont();
setTextSize(3); setTextSize(3);
setTextColor(TFT_FG, TFT_BG); setTextColor(config.theme.dow, config.theme.background);
setCursor(clleft+wot+clsp, cltop-hot+32); setCursor(clleft+wot+clsp, cltop-hot+32);
print(utf8Rus(dow[timeinfo.tm_wday], false)); print(utf8Rus(dow[timeinfo.tm_wday], false));
@@ -261,15 +260,15 @@ void DspCore::printClock(struct tm timeinfo, bool dots, bool redraw){
setTextSize(1); setTextSize(1);
uint16_t wdate, hdate; uint16_t wdate, hdate;
getTextBounds(timeBuf, 0, 0, &x1, &y1, &wdate, &hdate); getTextBounds(timeBuf, 0, 0, &x1, &y1, &wdate, &hdate);
fillRect(swidth - wdate - TFT_FRAMEWDT-20, cltop+10, wdate+20, hdate, TFT_BG); fillRect(swidth - wdate - TFT_FRAMEWDT-20, cltop+10, wdate+20, hdate, config.theme.background);
rightText(utf8Rus(timeBuf,true), cltop+10, TFT_FG, TFT_BG, false, swidth>240?12:0); rightText(utf8Rus(timeBuf,true), cltop+10, config.theme.date, config.theme.background, false, swidth>240?12:0);
drawFastVLine(clleft+wot+clsp/2+3, cltop-hot, hot+3, SILVER); drawFastVLine(clleft+wot+clsp/2+3, cltop-hot, hot+3, config.theme.div);
drawFastHLine(clleft+wot+clsp/2+3, cltop-hot+29, 42, SILVER); drawFastHLine(clleft+wot+clsp/2+3, cltop-hot+29, 42, config.theme.div);
drawFastHLine(TFT_FRAMEWDT, TITLE_TOP1-8, swidth-TFT_FRAMEWDT*2, SILVER); drawFastHLine(TFT_FRAMEWDT, TITLE_TOP1-8, swidth-TFT_FRAMEWDT*2, config.theme.div);
} }
setTextSize(3); setTextSize(3);
setTextColor(TFT_LOGO, TFT_BG); setTextColor(config.theme.seconds, config.theme.background);
setCursor(clleft+wot+clsp, cltop-hot+1); setCursor(clleft+wot+clsp, cltop-hot+1);
sprintf(timeBuf, "%02d", timeinfo.tm_sec); sprintf(timeBuf, "%02d", timeinfo.tm_sec);
print(timeBuf); print(timeBuf);
@@ -280,36 +279,36 @@ void DspCore::drawVolumeBar(bool withNumber) {
int16_t volTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT - 2; int16_t volTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT - 2;
int16_t vWidth = swidth - TFT_FRAMEWDT *2; int16_t vWidth = swidth - TFT_FRAMEWDT *2;
uint16_t ww = map(config.store.volume, 0, 254, 0, vWidth - 2); uint16_t ww = map(config.store.volume, 0, 254, 0, vWidth - 2);
fillRect(TFT_FRAMEWDT, vTop - 2, vWidth, 6, TFT_BG); fillRect(TFT_FRAMEWDT, vTop - 2, vWidth, 6, config.theme.background);
drawRect(TFT_FRAMEWDT, vTop - 2, vWidth, 6, TFT_LOGO); fillRect(TFT_FRAMEWDT + 1, vTop - 1, ww, 5, config.theme.volbarin);
fillRect(TFT_FRAMEWDT + 1, vTop - 1, ww, 5, TFT_LOGO); drawRect(TFT_FRAMEWDT, vTop - 2, vWidth, 6, config.theme.volbarout);
if(swidth>240){ if(swidth>240){
char buf[20]; char buf[20];
sprintf(buf, "VOL %d", config.store.volume); sprintf(buf, "VOL %d", config.store.volume);
setTextSize(1); setTextSize(1);
centerText(buf, volTop, SILVER, TFT_BG); centerText(buf, volTop, config.theme.vol, config.theme.background);
} }
if (withNumber) { if (withNumber) {
setTextSize(1); setTextSize(1);
setTextColor(TFT_FG); setTextColor(config.theme.digit);
setFont(&DS_DIGI42pt7b); setFont(&DS_DIGI42pt7b);
char volstr[4]; char volstr[4];
uint16_t wv, hv; uint16_t wv, hv;
int16_t x1, y1; int16_t x1, y1;
/*setTextColor(TFT_BG); /*setTextColor(config.theme.background);
sprintf(volstr, "%d", oldVolume); sprintf(volstr, "%d", oldVolume);
getTextBounds(volstr, 0, 0, &x1, &y1, &wv, &hv); getTextBounds(volstr, 0, 0, &x1, &y1, &wv, &hv);
setCursor((swidth - wv) / 2, (sheight-hv)/2 + hv); setCursor((swidth - wv) / 2, (sheight-hv)/2 + hv);
print(volstr);*/ print(volstr);*/
sprintf(volstr, "%d", oldVolume); sprintf(volstr, "%d", oldVolume);
getTextBounds(volstr, 0, 0, &x1, &y1, &wv, &hv); getTextBounds(volstr, 0, 0, &x1, &y1, &wv, &hv);
fillRect((swidth - wv) / 2 - 12, (sheight-hv)/2, wv+24, hv+4, TFT_BG); fillRect((swidth - wv) / 2 - 12, (sheight-hv)/2, wv+24, hv+4, config.theme.background);
setTextColor(TFT_FG); setTextColor(config.theme.vol);
sprintf(volstr, "%d", config.store.volume); sprintf(volstr, "%d", config.store.volume);
getTextBounds(volstr, 0, 0, &x1, &y1, &wv, &hv); getTextBounds(volstr, 0, 0, &x1, &y1, &wv, &hv);
//fillRect(TFT_FRAMEWDT, (sheight-hv)/2, swidth - TFT_FRAMEWDT / 2, hv + 3, TFT_BG); //fillRect(TFT_FRAMEWDT, (sheight-hv)/2, swidth - TFT_FRAMEWDT / 2, hv + 3, config.theme.background);
setCursor((swidth - wv) / 2, (sheight-hv)/2 + hv); setCursor((swidth - wv) / 2, (sheight-hv)/2 + hv);
print(volstr); print(volstr);
oldVolume=config.store.volume; oldVolume=config.store.volume;
@@ -319,14 +318,14 @@ void DspCore::drawVolumeBar(bool withNumber) {
void DspCore::drawNextStationNum(uint16_t num) { void DspCore::drawNextStationNum(uint16_t num) {
setTextSize(1); setTextSize(1);
setTextColor(TFT_FG); setTextColor(config.theme.digit);
setFont(&DS_DIGI42pt7b); setFont(&DS_DIGI42pt7b);
char numstr[7]; char numstr[7];
uint16_t wv, hv; uint16_t wv, hv;
int16_t x1, y1; int16_t x1, y1;
sprintf(numstr, "%d", num); sprintf(numstr, "%d", num);
getTextBounds(numstr, 0, 0, &x1, &y1, &wv, &hv); getTextBounds(numstr, 0, 0, &x1, &y1, &wv, &hv);
fillRect(TFT_FRAMEWDT, (sheight-hv)/2, swidth - TFT_FRAMEWDT / 2, hv + 3, TFT_BG); fillRect(TFT_FRAMEWDT, (sheight-hv)/2, swidth - TFT_FRAMEWDT / 2, hv + 3, config.theme.background);
setCursor((swidth - wv) / 2, (sheight-hv)/2 + hv); setCursor((swidth - wv) / 2, (sheight-hv)/2 + hv);
print(numstr); print(numstr);
setFont(); setFont();
@@ -334,8 +333,8 @@ void DspCore::drawNextStationNum(uint16_t num) {
void DspCore::frameTitle(const char* str) { void DspCore::frameTitle(const char* str) {
setTextSize(META_SIZE); setTextSize(META_SIZE);
centerText(str, TFT_FRAMEWDT, TFT_LOGO, TFT_BG); centerText(str, TFT_FRAMEWDT, config.theme.meta, config.theme.background);
drawFastHLine(TFT_FRAMEWDT, TITLE_TOP1-8, swidth-TFT_FRAMEWDT*2, SILVER); drawFastHLine(TFT_FRAMEWDT, TITLE_TOP1-8, swidth-TFT_FRAMEWDT*2, config.theme.div);
} }
void DspCore::rssi(const char* str) { void DspCore::rssi(const char* str) {
@@ -343,7 +342,7 @@ void DspCore::rssi(const char* str) {
char buf[20]; char buf[20];
sprintf(buf, "RSSI:%s", str); sprintf(buf, "RSSI:%s", str);
setTextSize(1); setTextSize(1);
rightText(buf, vTop, SILVER, TFT_BG); rightText(buf, vTop, config.theme.rssi, config.theme.background);
} }
void DspCore::ip(const char* str) { void DspCore::ip(const char* str) {
@@ -351,7 +350,7 @@ void DspCore::ip(const char* str) {
char buf[30]; char buf[30];
sprintf(buf, "IP: %s", str); sprintf(buf, "IP: %s", str);
setTextSize(1); setTextSize(1);
setTextColor(SILVER, TFT_BG); setTextColor(config.theme.ip, config.theme.background);
setCursor(TFT_FRAMEWDT, vTop); setCursor(TFT_FRAMEWDT, vTop);
print(buf); print(buf);
} }
@@ -392,4 +391,8 @@ void DspCore::flip(){
void DspCore::invert(){ void DspCore::invert(){
invertDisplay(config.store.invertdisplay); invertDisplay(config.store.invertdisplay);
} }
void DspCore::sleep(void) { sendCommand(ILI9341_SLPIN); delay(150); sendCommand(ILI9341_DISPOFF); delay(150);}
void DspCore::wake(void) { sendCommand(ILI9341_DISPON); delay(150); sendCommand(ILI9341_SLPOUT); delay(150);}
#endif #endif

View File

@@ -9,6 +9,7 @@
#define VU_READY 1 #define VU_READY 1
#define WEATHER_READY 1 #define WEATHER_READY 1
#define DSP_CAN_SLEEP true
#define TFT_LINEHGHT 10 #define TFT_LINEHGHT 10
#define TFT_FRAMEWDT 8 #define TFT_FRAMEWDT 8
@@ -21,14 +22,13 @@
#define SCROLLTIME 30 #define SCROLLTIME 30
#endif #endif
#define PLMITEMS 9 #define PLMITEMS 11
#define PLMITEMLENGHT 40 #define PLMITEMLENGHT 40
#define PLMITEMHEIGHT 22 #define PLMITEMHEIGHT 22
#define TFT_FULLTIME 1 #define TFT_FULLTIME 1
#define TITLE_TOP1 TFT_FRAMEWDT + META_SIZE * TFT_LINEHGHT + 8 #define TITLE_TOP1 TFT_FRAMEWDT + META_SIZE * TFT_LINEHGHT + 8
#define TITLE_TOP2 TFT_FRAMEWDT + (META_SIZE+2) * TFT_LINEHGHT + 8 #define TITLE_TOP2 TFT_FRAMEWDT + (META_SIZE+2) * TFT_LINEHGHT + 8
#define TITLE_FG2 SILVER
class DspCore: public Adafruit_ILI9341 { class DspCore: public Adafruit_ILI9341 {
public: public:
@@ -63,6 +63,8 @@ class DspCore: public Adafruit_ILI9341 {
virtual void endWrite(void); virtual void endWrite(void);
void flip(); void flip();
void invert(); void invert();
void sleep();
void wake();
private: private:
uint16_t swidth, sheight; uint16_t swidth, sheight;
char oldTimeBuf[20]; char oldTimeBuf[20];
@@ -73,36 +75,4 @@ class DspCore: public Adafruit_ILI9341 {
extern DspCore dsp; extern DspCore dsp;
/*
* TFT COLORS
*/
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define GRAY 0x7BEF
#define DARK_GRAY 0x2945
#define LIGHT_GRAY 0xC618
#define LIME 0x87E0
#define AQUA 0x5D1C
#define CYAN 0x07FF
#define DARK_CYAN 0x03EF
#define ORANGE 0xFCA0
#define PINK 0xF97F
#define BROWN 0x8200
#define VIOLET 0x9199
#define SILVER 0xA510
#define GOLD 0xA508
#define NAVY 0x000F
#define MAROON 0x7800
#define PURPLE 0x780F
#define OLIVE 0x7BE0
#define TFT_BG BLACK
#define TFT_FG WHITE
#define TFT_LOGO 0xE68B // 224, 209, 92
#endif #endif

View File

@@ -11,7 +11,11 @@
#define SCREEN_ADDRESS 0x27 ///< See datasheet for Address or scan it https://create.arduino.cc/projecthub/abdularbi17/how-to-scan-i2c-address-in-arduino-eaadda #define SCREEN_ADDRESS 0x27 ///< See datasheet for Address or scan it https://create.arduino.cc/projecthub/abdularbi17/how-to-scan-i2c-address-in-arduino-eaadda
#endif #endif
#ifdef LCD_2004
const byte controlspaces[] = { CLOCK_SPACE, 0, 0, VOL_SPACE };
#else
const byte controlspaces[] = { CLOCK_SPACE, VOL_SPACE }; const byte controlspaces[] = { CLOCK_SPACE, VOL_SPACE };
#endif
DspCore::DspCore(): DSP_INIT {} DspCore::DspCore(): DSP_INIT {}
@@ -219,6 +223,19 @@ boolean DspCore::checkdelay(int m, unsigned long & tstamp) {
} }
} }
void DspCore::sleep(void) {
noDisplay();
#ifdef LCD_I2C
noBacklight();
#endif
}
void DspCore::wake(void) {
display();
#ifdef LCD_I2C
backlight();
#endif
}
char* DspCore::utf8Rus(const char* str, bool uppercase) { char* DspCore::utf8Rus(const char* str, bool uppercase) {
int index = 0; int index = 0;
static char strn[BUFLEN]; static char strn[BUFLEN];

View File

@@ -29,7 +29,7 @@
#define TFT_LINEHGHT 1 #define TFT_LINEHGHT 1
#define TFT_FRAMEWDT 0 #define TFT_FRAMEWDT 0
#define DSP_CAN_SLEEP true
#define PLMITEMLENGHT 40 #define PLMITEMLENGHT 40
#define PLMITEMHEIGHT 9 #define PLMITEMHEIGHT 9
@@ -93,6 +93,8 @@ class DspCore: public LiquidCrystal {
void loop(bool force=false); void loop(bool force=false);
void flip(){}; void flip(){};
void invert(){}; void invert(){};
void sleep();
void wake();
private: private:
uint16_t swidth, sheight, xOffset, yOffset; uint16_t swidth, sheight, xOffset, yOffset;
int16_t nextX; int16_t nextX;

View File

@@ -134,6 +134,13 @@ void DspCore::data(uint8_t c) {
void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) { void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
begin(); begin();
setReinitInterval(255);
config.theme.background = TFT_BG;
config.theme.meta = TFT_FG;
config.theme.title1 = TFT_FG;
config.theme.title2 = TFT_FG;
config.theme.rssi = TFT_FG;
for(byte i=0;i<5;i++) config.theme.playlist[i] = TFT_FG;
setContrast(config.store.contrast); setContrast(config.store.contrast);
cp437(true); cp437(true);
invert(); invert();
@@ -344,4 +351,8 @@ void DspCore::flip(){
void DspCore::invert(){ void DspCore::invert(){
invertDisplay(config.store.invertdisplay); invertDisplay(config.store.invertdisplay);
} }
void DspCore::sleep(void) { command( PCD8544_FUNCTIONSET | PCD8544_POWERDOWN); }
void DspCore::wake(void) { initDisplay(); }
#endif #endif

View File

@@ -11,6 +11,9 @@
#define TFT_LINEHGHT 8 #define TFT_LINEHGHT 8
#define TFT_FRAMEWDT 0 #define TFT_FRAMEWDT 0
#define DSP_CAN_SLEEP true
#define DSP_OLED true
#if !defined(SCROLLDELTA) || !defined(SCROLLTIME) #if !defined(SCROLLDELTA) || !defined(SCROLLTIME)
//#define SCROLLDELTA 8 //#define SCROLLDELTA 8
//#define SCROLLTIME 332 //#define SCROLLTIME 332
@@ -60,6 +63,8 @@ class DspCore: public Adafruit_PCD8544 {
virtual void data(uint8_t c); virtual void data(uint8_t c);
void flip(); void flip();
void invert(); void invert();
void sleep();
void wake();
private: private:
uint16_t swidth, sheight; uint16_t swidth, sheight;
unsigned long loopdelay; unsigned long loopdelay;

View File

@@ -140,6 +140,12 @@ void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
Serial.println(F("SH110X allocation failed")); Serial.println(F("SH110X allocation failed"));
for (;;); // Don't proceed, loop forever for (;;); // Don't proceed, loop forever
} }
config.theme.background = TFT_BG;
config.theme.meta = TFT_FG;
config.theme.title1 = TFT_FG;
config.theme.title2 = TFT_FG;
config.theme.rssi = TFT_FG;
for(byte i=0;i<5;i++) config.theme.playlist[i] = TFT_FG;
cp437(true); cp437(true);
fillScreen(TFT_BG); fillScreen(TFT_BG);
flip(); flip();
@@ -356,4 +362,8 @@ void DspCore::flip(){
void DspCore::invert(){ void DspCore::invert(){
invertDisplay(config.store.invertdisplay); invertDisplay(config.store.invertdisplay);
} }
void DspCore::sleep(void) { oled_command(SH110X_DISPLAYOFF); }
void DspCore::wake(void) { oled_command(SH110X_DISPLAYON); }
#endif #endif

View File

@@ -7,6 +7,8 @@
#define TFT_LINEHGHT 8 #define TFT_LINEHGHT 8
#define TFT_FRAMEWDT 0 #define TFT_FRAMEWDT 0
#define DSP_CAN_SLEEP true
#define DSP_OLED true
#define PLMITEMS 7 #define PLMITEMS 7
#define PLMITEMLENGHT 40 #define PLMITEMLENGHT 40
@@ -59,6 +61,8 @@ class DspCore: public Adafruit_SH1107 {
void loop(bool force=false); void loop(bool force=false);
void flip(); void flip();
void invert(); void invert();
void sleep();
void wake();
private: private:
uint16_t swidth, sheight; uint16_t swidth, sheight;
unsigned long loopdelay; unsigned long loopdelay;

View File

@@ -142,6 +142,12 @@ void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
Serial.println(F("SSD1305 allocation failed")); Serial.println(F("SSD1305 allocation failed"));
for (;;); // Don't proceed, loop forever for (;;); // Don't proceed, loop forever
} }
config.theme.background = TFT_BG;
config.theme.meta = TFT_FG;
config.theme.title1 = TFT_FG;
config.theme.title2 = TFT_FG;
config.theme.rssi = TFT_FG;
for(byte i=0;i<5;i++) config.theme.playlist[i] = TFT_FG;
cp437(true); cp437(true);
fillScreen(TFT_BG); fillScreen(TFT_BG);
flip(); flip();

View File

@@ -6,6 +6,8 @@
#include <Adafruit_SSD1305.h> #include <Adafruit_SSD1305.h>
#define WEATHER_READY 0 #define WEATHER_READY 0
#define DSP_CAN_SLEEP true
#define DSP_OLED true
#define TFT_LINEHGHT 8 #define TFT_LINEHGHT 8
#define TFT_FRAMEWDT 0 #define TFT_FRAMEWDT 0

View File

@@ -139,6 +139,13 @@ void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
Serial.println(F("SSD1306 allocation failed")); Serial.println(F("SSD1306 allocation failed"));
for (;;); // Don't proceed, loop forever for (;;); // Don't proceed, loop forever
} }
maxcontrast = DSP_MODEL==DSP_SSD1306?0xCF:0x8F;
config.theme.background = TFT_BG;
config.theme.meta = TFT_FG;
config.theme.title1 = TFT_FG;
config.theme.title2 = TFT_FG;
config.theme.rssi = TFT_FG;
for(byte i=0;i<5;i++) config.theme.playlist[i] = TFT_FG;
cp437(true); cp437(true);
fillScreen(TFT_BG); fillScreen(TFT_BG);
flip(); flip();
@@ -360,4 +367,8 @@ void DspCore::flip(){
void DspCore::invert(){ void DspCore::invert(){
invertDisplay(config.store.invertdisplay); invertDisplay(config.store.invertdisplay);
} }
void DspCore::sleep(void) { ssd1306_command(SSD1306_DISPLAYOFF); }
void DspCore::wake(void) { ssd1306_command(SSD1306_DISPLAYON); }
#endif #endif

View File

@@ -8,6 +8,8 @@
#define TFT_LINEHGHT 8 #define TFT_LINEHGHT 8
#define TFT_FRAMEWDT 0 #define TFT_FRAMEWDT 0
#define PLMITEMLENGHT 40 #define PLMITEMLENGHT 40
#define DSP_CAN_SLEEP true
#define DSP_OLED true
#if !defined(SCROLLDELTA) || !defined(SCROLLTIME) #if !defined(SCROLLDELTA) || !defined(SCROLLTIME)
#define SCROLLDELTA 2 #define SCROLLDELTA 2
@@ -73,9 +75,12 @@ class DspCore: public Adafruit_SSD1306 {
void loop(bool force=false); void loop(bool force=false);
void flip(); void flip();
void invert(); void invert();
void sleep();
void wake();
private: private:
uint16_t swidth, sheight; uint16_t swidth, sheight;
unsigned long loopdelay; unsigned long loopdelay;
uint8_t maxcontrast;
char insideClc[10]; char insideClc[10];
boolean checkdelay(int m, unsigned long &tstamp); boolean checkdelay(int m, unsigned long &tstamp);
}; };

View File

@@ -114,13 +114,28 @@ void DspCore::apScreen() {
print(WiFi.softAPIP().toString().c_str()); print(WiFi.softAPIP().toString().c_str());
print("/"); print("/");
} }
#define CLR_ITEM1 0xA
#define CLR_ITEM2 0x8
#define CLR_ITEM3 0x5
void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) { void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
tw.begin(I2C_SDA, I2C_SCL); tw.begin(I2C_SDA, I2C_SCL);
if (!begin(SCREEN_ADDRESS)) { if (!begin(SCREEN_ADDRESS)) {
Serial.println(F("SSD1327 allocation failed")); Serial.println(F("SSD1327 allocation failed"));
for (;;); for (;;);
} }
config.theme.background = TFT_BG;
config.theme.meta = TFT_FG;
config.theme.title1 = TFT_FG;
config.theme.title2 = SILVER;
config.theme.rssi = TFT_FG;
config.theme.weather = ORANGE;
config.theme.heap = SILVER;
config.theme.ip = SILVER;
config.theme.playlist[0] = CLR_ITEM1;
config.theme.playlist[1] = CLR_ITEM2;
config.theme.playlist[2] = CLR_ITEM3;
config.theme.playlist[3] = CLR_ITEM3;
config.theme.playlist[4] = CLR_ITEM3;
cp437(true); cp437(true);
fillScreen(TFT_BG); fillScreen(TFT_BG);
flip(); flip();
@@ -137,9 +152,6 @@ void DspCore::drawLogo() {
drawGrayscaleBitmap((swidth - 99) / 2, 18, bootlogobw, 99, 64); drawGrayscaleBitmap((swidth - 99) / 2, 18, bootlogobw, 99, 64);
} }
#define CLR_ITEM1 0xA
#define CLR_ITEM2 0x8
#define CLR_ITEM3 0x5
void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) { void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
for (byte i = 0; i < PLMITEMS; i++) { for (byte i = 0; i < PLMITEMS; i++) {
plMenu[i][0] = '\0'; plMenu[i][0] = '\0';
@@ -413,4 +425,8 @@ void DspCore::flip(){
void DspCore::invert(){ void DspCore::invert(){
invertDisplay(config.store.invertdisplay); invertDisplay(config.store.invertdisplay);
} }
void DspCore::sleep(void) { oled_command(SSD1327_DISPLAYOFF); }
void DspCore::wake(void) { oled_command(SSD1327_DISPLAYON); }
#endif #endif

View File

@@ -7,6 +7,7 @@
#include "fonts/DS_DIGI28pt7b.h" #include "fonts/DS_DIGI28pt7b.h"
#define WEATHER_READY 1 #define WEATHER_READY 1
#define DSP_CAN_SLEEP true
#define TFT_LINEHGHT 10 #define TFT_LINEHGHT 10
#define TFT_FRAMEWDT 4 #define TFT_FRAMEWDT 4
@@ -57,6 +58,8 @@ class DspCore: public Adafruit_SSD1327 {
void loop(bool force=false); void loop(bool force=false);
void flip(); void flip();
void invert(); void invert();
void sleep();
void wake();
private: private:
uint16_t swidth, sheight; uint16_t swidth, sheight;
int16_t x, y; int16_t x, y;

View File

@@ -107,14 +107,14 @@ char* DspCore::utf8Rus(const char* str, bool uppercase) {
void DspCore::apScreen() { void DspCore::apScreen() {
setTextSize(1); setTextSize(1);
setTextColor(TFT_FG, TFT_BG); setTextColor(config.theme.title1, config.theme.background);
setCursor(TFT_FRAMEWDT, TFT_FRAMEWDT + 2 * TFT_LINEHGHT); setCursor(TFT_FRAMEWDT, TFT_FRAMEWDT + 2 * TFT_LINEHGHT);
print("AP NAME: "); print("AP NAME: ");
print(apSsid); print(apSsid);
setCursor(TFT_FRAMEWDT, TFT_FRAMEWDT + 3 * TFT_LINEHGHT); setCursor(TFT_FRAMEWDT, TFT_FRAMEWDT + 3 * TFT_LINEHGHT);
print("PASSWORD: "); print("PASSWORD: ");
print(apPassword); print(apPassword);
setTextColor(SILVER, TFT_BG); setTextColor(config.theme.title2, config.theme.background);
setCursor(TFT_FRAMEWDT, 107); setCursor(TFT_FRAMEWDT, 107);
print("SETTINGS PAGE ON: "); print("SETTINGS PAGE ON: ");
setCursor(TFT_FRAMEWDT, 117); setCursor(TFT_FRAMEWDT, 117);
@@ -128,7 +128,7 @@ void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
if(DEF_SPI_FREQ > 0) setSPISpeed(DEF_SPI_FREQ); if(DEF_SPI_FREQ > 0) setSPISpeed(DEF_SPI_FREQ);
cp437(true); cp437(true);
invert(); invert();
fillScreen(TFT_BG); // fillScreen(0x0000);
flip(); flip();
setTextWrap(false); setTextWrap(false);
screenwidth = width(); screenwidth = width();
@@ -139,6 +139,7 @@ void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
} }
void DspCore::drawLogo() { void DspCore::drawLogo() {
fillScreen(0x0000);
#ifdef DSP_MINI #ifdef DSP_MINI
drawRGBBitmap((swidth - 62) / 2, 5, bootlogo40, 62, 40); drawRGBBitmap((swidth - 62) / 2, 5, bootlogo40, 62, 40);
#else #else
@@ -146,11 +147,6 @@ void DspCore::drawLogo() {
#endif #endif
} }
// http://greekgeeks.net/#maker-tools_convertColor
#define CLR_ITEM1 0x52AA
#define CLR_ITEM2 0x39C7
#define CLR_ITEM3 0x18E3
void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) { void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
for (byte i = 0; i < PLMITEMS; i++) { for (byte i = 0; i < PLMITEMS; i++) {
plMenu[i][0] = '\0'; plMenu[i][0] = '\0';
@@ -160,21 +156,21 @@ void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
int yStart = (sheight / 2 - PLMITEMHEIGHT / 2) - PLMITEMHEIGHT * (PLMITEMS - 1) / 2 + 3; int yStart = (sheight / 2 - PLMITEMHEIGHT / 2) - PLMITEMHEIGHT * (PLMITEMS - 1) / 2 + 3;
//fillRect(0, (sheight / 2 - PLMITEMHEIGHT / 2) - 1, swidth, PLMITEMHEIGHT + 2, TFT_LOGO); //fillRect(0, (sheight / 2 - PLMITEMHEIGHT / 2) - 1, swidth, PLMITEMHEIGHT + 2, TFT_LOGO);
for (byte i = 0; i < PLMITEMS; i++) { for (byte i = 0; i < PLMITEMS; i++) {
if (abs(i - 3) == 3) setTextColor(CLR_ITEM3, TFT_BG); if (abs(i - 3) == 3) setTextColor(config.theme.playlist[2], config.theme.background);
if (abs(i - 3) == 2) setTextColor(CLR_ITEM2, TFT_BG); if (abs(i - 3) == 2) setTextColor(config.theme.playlist[1], config.theme.background);
if (abs(i - 3) == 1) setTextColor(CLR_ITEM1, TFT_BG); if (abs(i - 3) == 1) setTextColor(config.theme.playlist[0], config.theme.background);
if (i == 3) { if (i == 3) {
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1); strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
} else { } else {
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT); setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
fillRect(0, yStart + i * PLMITEMHEIGHT - 1, swidth, PLMITEMHEIGHT - 4, TFT_BG); fillRect(0, yStart + i * PLMITEMHEIGHT - 1, swidth, PLMITEMHEIGHT - 4, config.theme.background);
print(utf8Rus(plMenu[i], true)); print(utf8Rus(plMenu[i], true));
} }
} }
} }
void DspCore::clearDsp() { void DspCore::clearDsp() {
fillScreen(TFT_BG); fillScreen(config.theme.background);
} }
void DspCore::drawScrollFrame(uint16_t texttop, uint16_t textheight, uint16_t bg) { void DspCore::drawScrollFrame(uint16_t texttop, uint16_t textheight, uint16_t bg) {
@@ -222,19 +218,19 @@ void DspCore::displayHeapForDebug() {
#ifndef DSP_MINI #ifndef DSP_MINI
int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT * 2 - 2; int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT * 2 - 2;
setTextSize(1); setTextSize(1);
setTextColor(DARK_GRAY, TFT_BG); setTextColor(config.theme.heap, config.theme.background);
setCursor(TFT_FRAMEWDT, vTop); setCursor(TFT_FRAMEWDT, vTop);
fillRect(TFT_FRAMEWDT, vTop, swidth - TFT_FRAMEWDT / 2, 7, TFT_BG); fillRect(TFT_FRAMEWDT, vTop, swidth - TFT_FRAMEWDT / 2, 7, config.theme.background);
print(ESP.getFreeHeap()); print(ESP.getFreeHeap());
print(" / "); print(" / ");
print(ESP.getMaxAllocHeap()); print(ESP.getMaxAllocHeap());
// audio buffer; // audio buffer;
fillRect(0, sheight - 2, swidth, 2, TFT_BG); fillRect(0, sheight - 2, swidth, 2, config.theme.background);
int astored = player.inBufferFilled(); int astored = player.inBufferFilled();
int afree = player.inBufferFree(); int afree = player.inBufferFree();
int aprcnt = 100 * astored / (astored + afree); int aprcnt = 100 * astored / (astored + afree);
byte sbw = map(aprcnt, 0, 100 , 0, swidth); byte sbw = map(aprcnt, 0, 100 , 0, swidth);
fillRect(0, sheight - 2, sbw, 2, SILVER); fillRect(0, sheight - 2, sbw, 2, config.theme.title2);
#endif #endif
} }
@@ -271,7 +267,7 @@ void DspCore::printClock(struct tm timeinfo, bool dots, bool redraw){
if(strstr(oldTimeBuf, timeBuf)==NULL || redraw){ if(strstr(oldTimeBuf, timeBuf)==NULL || redraw){
getTextBounds(oldTimeBuf, 0, 0, &x, &y, &wot, &hot); getTextBounds(oldTimeBuf, 0, 0, &x, &y, &wot, &hot);
setCursor((swidth - wot) / 2 - 4 + clockdelta, clockY+28+6); setCursor((swidth - wot) / 2 - 4 + clockdelta, clockY+28+6);
setTextColor(TFT_BG); setTextColor(config.theme.background);
print(oldTimeBuf); print(oldTimeBuf);
dot = (swidth - wot) / 2 - 4 + clockdelta; dot = (swidth - wot) / 2 - 4 + clockdelta;
/* dots */ /* dots */
@@ -285,7 +281,7 @@ void DspCore::printClock(struct tm timeinfo, bool dots, bool redraw){
strlcpy(oldTimeBuf, timeBuf, 20); strlcpy(oldTimeBuf, timeBuf, 20);
setTextSize(1); setTextSize(1);
getTextBounds(timeBuf, 0, 0, &x, &y, &ncwidth, &ncheight); getTextBounds(timeBuf, 0, 0, &x, &y, &ncwidth, &ncheight);
setTextColor(TFT_LOGO); setTextColor(config.theme.clock);
setCursor((swidth - ncwidth) / 2 - 4 + clockdelta, clockY+28+6); setCursor((swidth - ncwidth) / 2 - 4 + clockdelta, clockY+28+6);
dot = (swidth - ncwidth) / 2 - 4 + clockdelta; dot = (swidth - ncwidth) / 2 - 4 + clockdelta;
setTextSize(1); setTextSize(1);
@@ -297,7 +293,7 @@ void DspCore::printClock(struct tm timeinfo, bool dots, bool redraw){
/* dots */ /* dots */
} }
setCursor(dot, clockY+28+6); setCursor(dot, clockY+28+6);
setTextColor(dots?TFT_BG:TFT_LOGO); setTextColor(dots?config.theme.background:config.theme.clock);
print(":"); print(":");
setFont(); setFont();
yield(); yield();
@@ -312,26 +308,26 @@ void DspCore::drawVolumeBar(bool withNumber) {
int16_t vTop = sheight - TFT_FRAMEWDT - 2; int16_t vTop = sheight - TFT_FRAMEWDT - 2;
int16_t vWidth = swidth - TFT_FRAMEWDT * 2; int16_t vWidth = swidth - TFT_FRAMEWDT * 2;
uint8_t ww = map(config.store.volume, 0, 254, 0, vWidth); uint8_t ww = map(config.store.volume, 0, 254, 0, vWidth);
fillRect(TFT_FRAMEWDT, vTop, vWidth, 2, TFT_BG); fillRect(TFT_FRAMEWDT, vTop, vWidth, 2, config.theme.background);
fillRect(TFT_FRAMEWDT, vTop, ww, 2, TFT_LOGO); fillRect(TFT_FRAMEWDT, vTop, ww, 2, config.theme.volbarin);
#else #else
int16_t vTop = sheight - TFT_FRAMEWDT - 6; int16_t vTop = sheight - TFT_FRAMEWDT - 6;
int16_t vWidth = swidth - TFT_FRAMEWDT * 2; int16_t vWidth = swidth - TFT_FRAMEWDT * 2;
uint8_t ww = map(config.store.volume, 0, 254, 0, vWidth - 2); uint8_t ww = map(config.store.volume, 0, 254, 0, vWidth - 2);
fillRect(TFT_FRAMEWDT, vTop - 2, vWidth, 6, TFT_BG); fillRect(TFT_FRAMEWDT, vTop - 2 + 3, vWidth, 5, config.theme.background);
drawRect(TFT_FRAMEWDT, vTop - 2, vWidth, 6, TFT_LOGO); fillRect(TFT_FRAMEWDT + 1, vTop - 1 + 3, ww, 3, config.theme.volbarin);
fillRect(TFT_FRAMEWDT + 1, vTop - 1, ww, 5, TFT_LOGO); drawRect(TFT_FRAMEWDT, vTop - 2 + 3, vWidth, 5, config.theme.volbarout);
#endif #endif
if (withNumber) { if (withNumber) {
setTextSize(1); setTextSize(1);
setTextColor(TFT_FG); setTextColor(config.theme.digit);
setFont(&DS_DIGI28pt7b); setFont(&DS_DIGI28pt7b);
char volstr[4]; char volstr[4];
uint16_t wv, hv; uint16_t wv, hv;
int16_t x1, y1; int16_t x1, y1;
sprintf(volstr, "%d", config.store.volume); sprintf(volstr, "%d", config.store.volume);
getTextBounds(volstr, 0, 0, &x1, &y1, &wv, &hv); getTextBounds(volstr, 0, 0, &x1, &y1, &wv, &hv);
fillRect(TFT_FRAMEWDT, VTOP, swidth - TFT_FRAMEWDT / 2, hv + 3, TFT_BG); fillRect(TFT_FRAMEWDT, VTOP, swidth - TFT_FRAMEWDT / 2, hv + 3, config.theme.background);
setCursor((swidth - wv) / 2, VTOP + hv); setCursor((swidth - wv) / 2, VTOP + hv);
print(volstr); print(volstr);
setFont(); setFont();
@@ -340,14 +336,14 @@ void DspCore::drawVolumeBar(bool withNumber) {
void DspCore::drawNextStationNum(uint16_t num) { void DspCore::drawNextStationNum(uint16_t num) {
setTextSize(1); setTextSize(1);
setTextColor(TFT_FG); setTextColor(config.theme.digit);
setFont(&DS_DIGI28pt7b); setFont(&DS_DIGI28pt7b);
char numstr[7]; char numstr[7];
uint16_t wv, hv; uint16_t wv, hv;
int16_t x1, y1; int16_t x1, y1;
sprintf(numstr, "%d", num); sprintf(numstr, "%d", num);
getTextBounds(numstr, 0, 0, &x1, &y1, &wv, &hv); getTextBounds(numstr, 0, 0, &x1, &y1, &wv, &hv);
fillRect(TFT_FRAMEWDT, VTOP, swidth - TFT_FRAMEWDT / 2, hv + 3, TFT_BG); fillRect(TFT_FRAMEWDT, VTOP, swidth - TFT_FRAMEWDT / 2, hv + 3, config.theme.background);
setCursor((swidth - wv) / 2, VTOP + hv); setCursor((swidth - wv) / 2, VTOP + hv);
print(numstr); print(numstr);
setFont(); setFont();
@@ -355,19 +351,19 @@ void DspCore::drawNextStationNum(uint16_t num) {
void DspCore::frameTitle(const char* str) { void DspCore::frameTitle(const char* str) {
setTextSize(2); setTextSize(2);
centerText(str, TFT_FRAMEWDT, TFT_LOGO, TFT_BG); centerText(str, TFT_FRAMEWDT, config.theme.meta, config.theme.background);
} }
void DspCore::rssi(const char* str) { void DspCore::rssi(const char* str) {
int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT - 2; int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT - 2;
setTextSize(1); setTextSize(1);
rightText(str, vTop, SILVER, TFT_BG); rightText(str, vTop, config.theme.rssi, config.theme.background);
} }
void DspCore::ip(const char* str) { void DspCore::ip(const char* str) {
int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT - 2; int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT - 2;
setTextSize(1); setTextSize(1);
setTextColor(SILVER, TFT_BG); setTextColor(config.theme.ip, config.theme.background);
setCursor(4, vTop); setCursor(4, vTop);
print(str); print(str);
} }
@@ -401,6 +397,7 @@ void DspCore::printText(const char* txt) {
void DspCore::loop(bool force) { void DspCore::loop(bool force) {
} }
void DspCore::flip(){ void DspCore::flip(){
if(ROTATE_90){ if(ROTATE_90){
setRotation(config.store.flipscreen?2:0); setRotation(config.store.flipscreen?2:0);
@@ -412,4 +409,12 @@ void DspCore::flip(){
void DspCore::invert(){ void DspCore::invert(){
invertDisplay((DTYPE==INITR_MINI160x80)?!config.store.invertdisplay:config.store.invertdisplay); invertDisplay((DTYPE==INITR_MINI160x80)?!config.store.invertdisplay:config.store.invertdisplay);
} }
void DspCore::sleep(void) {
enableSleep(true); delay(150); enableDisplay(false); delay(150);
}
void DspCore::wake(void) {
enableDisplay(true); delay(150); enableSleep(false); delay(150);
}
#endif #endif

View File

@@ -8,6 +8,7 @@
#define VU_READY 1 #define VU_READY 1
#define WEATHER_READY 1 #define WEATHER_READY 1
#define DSP_CAN_SLEEP true
#define TFT_LINEHGHT 10 #define TFT_LINEHGHT 10
#if DTYPE==INITR_MINI160x80 #if DTYPE==INITR_MINI160x80
@@ -25,7 +26,6 @@
#define PLMITEMHEIGHT 21 #define PLMITEMHEIGHT 21
#endif #endif
#define TITLE_TOP2 TFT_FRAMEWDT + 3 * TFT_LINEHGHT #define TITLE_TOP2 TFT_FRAMEWDT + 3 * TFT_LINEHGHT
#define TITLE_FG2 SILVER
#if !defined(SCROLLDELTA) || !defined(SCROLLTIME) #if !defined(SCROLLDELTA) || !defined(SCROLLTIME)
#define SCROLLDELTA 2 #define SCROLLDELTA 2
@@ -74,6 +74,8 @@ class DspCore: public Adafruit_ST7735 {
virtual void endWrite(void); virtual void endWrite(void);
void flip(); void flip();
void invert(); void invert();
void sleep();
void wake();
private: private:
uint16_t swidth, sheight; uint16_t swidth, sheight;
char oldTimeBuf[20]; char oldTimeBuf[20];
@@ -86,36 +88,4 @@ class DspCore: public Adafruit_ST7735 {
extern DspCore dsp; extern DspCore dsp;
/*
* TFT COLORS
*/
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define GRAY 0x7BEF
#define DARK_GRAY 0x2945
#define LIGHT_GRAY 0xC618
#define LIME 0x87E0
#define AQUA 0x5D1C
#define CYAN 0x07FF
#define DARK_CYAN 0x03EF
#define ORANGE 0xFCA0
#define PINK 0xF97F
#define BROWN 0x8200
#define VIOLET 0x9199
#define SILVER 0xA510
#define GOLD 0xA508
#define NAVY 0x000F
#define MAROON 0x7800
#define PURPLE 0x780F
#define OLIVE 0x7BE0
#define TFT_BG BLACK
#define TFT_FG WHITE
#define TFT_LOGO 0xE68B // 224, 209, 92
#endif #endif

View File

@@ -97,21 +97,21 @@ char* DspCore::utf8Rus(const char* str, bool uppercase) {
void DspCore::apScreen() { void DspCore::apScreen() {
setTextSize(TITLE_SIZE1); setTextSize(TITLE_SIZE1);
setTextColor(TFT_FG, TFT_BG); setTextColor(config.theme.title1, config.theme.background);
setCursor(TFT_FRAMEWDT, TITLE_TOP1); setCursor(TFT_FRAMEWDT, TITLE_TOP1);
print("AP NAME: "); print("AP NAME: ");
print(apSsid); print(apSsid);
setCursor(TFT_FRAMEWDT, TITLE_TOP2); setCursor(TFT_FRAMEWDT, TITLE_TOP2);
print("PASSWORD: "); print("PASSWORD: ");
print(apPassword); print(apPassword);
setTextColor(SILVER, TFT_BG); setTextColor(config.theme.title2, config.theme.background);
setCursor(TFT_FRAMEWDT, sheight-TFT_FRAMEWDT-TFT_LINEHGHT*4); setCursor(TFT_FRAMEWDT, sheight-TFT_FRAMEWDT-TFT_LINEHGHT*4);
print("SETTINGS PAGE ON: "); print("SETTINGS PAGE ON: ");
setCursor(TFT_FRAMEWDT, sheight-TFT_FRAMEWDT-TFT_LINEHGHT*2); setCursor(TFT_FRAMEWDT, sheight-TFT_FRAMEWDT-TFT_LINEHGHT*2);
print("http://"); print("http://");
print(WiFi.softAPIP().toString().c_str()); print(WiFi.softAPIP().toString().c_str());
print("/"); print("/");
drawFastHLine(TFT_FRAMEWDT, TITLE_TOP1-8, swidth-TFT_FRAMEWDT*2, SILVER); drawFastHLine(TFT_FRAMEWDT, TITLE_TOP1-8, swidth-TFT_FRAMEWDT*2, config.theme.div);
} }
void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) { void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
@@ -119,7 +119,7 @@ void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
if(DEF_SPI_FREQ > 0) setSPISpeed(DEF_SPI_FREQ); if(DEF_SPI_FREQ > 0) setSPISpeed(DEF_SPI_FREQ);
invert(); invert();
cp437(true); cp437(true);
fillScreen(TFT_BG); // fillScreen(0x0000);
flip(); flip();
setTextWrap(false); setTextWrap(false);
setTextSize(1); setTextSize(1);
@@ -130,34 +130,33 @@ void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
} }
void DspCore::drawLogo() { void DspCore::drawLogo() {
fillScreen(0x0000);
drawRGBBitmap((swidth - 99) / 2, (sheight-64)/2 - TFT_LINEHGHT*2, bootlogo2, 99, 64); drawRGBBitmap((swidth - 99) / 2, (sheight-64)/2 - TFT_LINEHGHT*2, bootlogo2, 99, 64);
} }
// http://greekgeeks.net/#maker-tools_convertColor
uint16_t iclrs[] = { 0x738E /*707070*/, 0x52AA /*575757*/, 0x39C7, 0x18E3 };
void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) { void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
for (byte i = 0; i < PLMITEMS; i++) { for (byte i = 0; i < PLMITEMS; i++) {
plMenu[i][0] = '\0'; plMenu[i][0] = '\0';
} }
config.fillPlMenu(plMenu, currentItem - 4, PLMITEMS); config.fillPlMenu(plMenu, currentItem - 5, PLMITEMS);
setTextSize(2); setTextSize(2);
int yStart = (sheight / 2 - PLMITEMHEIGHT / 2) - PLMITEMHEIGHT * (PLMITEMS - 1) / 2 + 3; int yStart = (sheight / 2 - PLMITEMHEIGHT / 2) - PLMITEMHEIGHT * (PLMITEMS - 1) / 2 + 3;
for (byte i = 0; i < PLMITEMS; i++) { for (byte i = 0; i < PLMITEMS; i++) {
if (i == 4) { if (i == 5) {
//fillRect(0, (sheight / 2 - PLMITEMHEIGHT / 2) - 1, swidth, PLMITEMHEIGHT + 2, TFT_LOGO); //fillRect(0, (sheight / 2 - PLMITEMHEIGHT / 2) - 1, swidth, PLMITEMHEIGHT + 2, TFT_LOGO);
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1); strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
} else { } else {
setTextColor(iclrs[abs(i - 4)-1], TFT_BG); setTextColor(config.theme.playlist[abs(i - 5)-1], config.theme.background);
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT); setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
fillRect(0, yStart + i * PLMITEMHEIGHT - 1, swidth, PLMITEMHEIGHT - 2, TFT_BG); fillRect(0, yStart + i * PLMITEMHEIGHT - 1, swidth, PLMITEMHEIGHT - 2, config.theme.background);
print(utf8Rus(plMenu[i], true)); print(utf8Rus(plMenu[i], true));
} }
} }
} }
void DspCore::clearDsp() { void DspCore::clearDsp() {
fillScreen(TFT_BG); fillScreen(config.theme.background);
} }
void DspCore::drawScrollFrame(uint16_t texttop, uint16_t textheight, uint16_t bg) { void DspCore::drawScrollFrame(uint16_t texttop, uint16_t textheight, uint16_t bg) {
@@ -210,19 +209,19 @@ void DspCore::rightText(const char* text, uint16_t y, uint16_t fg, uint16_t bg,
void DspCore::displayHeapForDebug() { void DspCore::displayHeapForDebug() {
int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT * 2 - 2; int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT * 2 - 2;
setTextSize(1); setTextSize(1);
setTextColor(DARK_GRAY, TFT_BG); setTextColor(config.theme.heap, config.theme.background);
setCursor(TFT_FRAMEWDT, vTop); setCursor(TFT_FRAMEWDT, vTop);
fillRect(TFT_FRAMEWDT, vTop, swidth - TFT_FRAMEWDT / 2, 7, TFT_BG); fillRect(TFT_FRAMEWDT, vTop, swidth - TFT_FRAMEWDT / 2, 7, config.theme.background);
print(ESP.getFreeHeap()); print(ESP.getFreeHeap());
print(" / "); print(" / ");
print(ESP.getMaxAllocHeap()); print(ESP.getMaxAllocHeap());
// audio buffer; // audio buffer;
fillRect(0, sheight - 2, swidth, 2, TFT_BG); fillRect(0, sheight - 2, swidth, 2, config.theme.background);
int astored = player.inBufferFilled(); int astored = player.inBufferFilled();
int afree = player.inBufferFree(); int afree = player.inBufferFree();
int aprcnt = 100 * astored / (astored + afree); int aprcnt = 100 * astored / (astored + afree);
byte sbw = map(aprcnt, 0, 100 , 0, swidth); uint16_t sbw = map(aprcnt, 0, 100 , 0, swidth);
fillRect(0, sheight - 2, sbw, 2, SILVER); fillRect(0, sheight - 2, sbw, 2, config.theme.buffer);
yield(); yield();
} }
@@ -247,20 +246,20 @@ void DspCore::printClock(struct tm timeinfo, bool dots, bool redraw){
cltop=sheight-(TFT_FRAMEWDT * 2 + TFT_LINEHGHT + 38) - hot; cltop=sheight-(TFT_FRAMEWDT * 2 + TFT_LINEHGHT + 38) - hot;
} }
clwidth = wot+clsp+(swidth>240?46:34); clwidth = wot+clsp+(swidth>240?46:34);
fillRect(swidth-TFT_FRAMEWDT-clwidth, cltop-hot, clwidth, hot+3, TFT_BG); fillRect(swidth-TFT_FRAMEWDT-clwidth, cltop-hot, clwidth, hot+3, config.theme.background);
strlcpy(oldTimeBuf, timeBuf, 20); strlcpy(oldTimeBuf, timeBuf, 20);
setTextSize(1); setTextSize(1);
getTextBounds(timeBuf, 0, 0, &x1, &y1, &wot, &hot); getTextBounds(timeBuf, 0, 0, &x1, &y1, &wot, &hot);
clwidth = wot+clsp+(swidth>240?46:34); clwidth = wot+clsp+(swidth>240?46:34);
clleft=swidth-TFT_FRAMEWDT-clwidth; clleft=swidth-TFT_FRAMEWDT-clwidth;
setTextColor(TFT_LOGO, TFT_BG); setTextColor(config.theme.clock, config.theme.background);
setCursor(clleft, cltop); setCursor(clleft, cltop);
setTextSize(1); setTextSize(1);
print(timeBuf); print(timeBuf);
setFont(); setFont();
setTextSize(3); setTextSize(3);
setTextColor(TFT_FG, TFT_BG); setTextColor(config.theme.dow, config.theme.background);
setCursor(clleft+wot+clsp, cltop-hot+32); setCursor(clleft+wot+clsp, cltop-hot+32);
print(utf8Rus(dow[timeinfo.tm_wday], false)); print(utf8Rus(dow[timeinfo.tm_wday], false));
@@ -268,15 +267,15 @@ void DspCore::printClock(struct tm timeinfo, bool dots, bool redraw){
setTextSize(1); setTextSize(1);
uint16_t wdate, hdate; uint16_t wdate, hdate;
getTextBounds(timeBuf, 0, 0, &x1, &y1, &wdate, &hdate); getTextBounds(timeBuf, 0, 0, &x1, &y1, &wdate, &hdate);
fillRect(swidth - wdate - TFT_FRAMEWDT-20, cltop+10, wdate+20, hdate, TFT_BG); fillRect(swidth - wdate - TFT_FRAMEWDT-20, cltop+10, wdate+20, hdate, config.theme.background);
rightText(utf8Rus(timeBuf,true), cltop+10, TFT_FG, TFT_BG, false, swidth>240?12:0); rightText(utf8Rus(timeBuf,true), cltop+10, config.theme.date, config.theme.background, false, swidth>240?12:0);
drawFastVLine(clleft+wot+clsp/2+3, cltop-hot, hot+3, SILVER); drawFastVLine(clleft+wot+clsp/2+3, cltop-hot, hot+3, config.theme.div);
drawFastHLine(clleft+wot+clsp/2+3, cltop-hot+29, 42, SILVER); drawFastHLine(clleft+wot+clsp/2+3, cltop-hot+29, 42, config.theme.div);
drawFastHLine(TFT_FRAMEWDT, TITLE_TOP1-8, swidth-TFT_FRAMEWDT*2, SILVER); drawFastHLine(TFT_FRAMEWDT, TITLE_TOP1-8, swidth-TFT_FRAMEWDT*2, config.theme.div);
} }
setTextSize(3); setTextSize(3);
setTextColor(TFT_LOGO, TFT_BG); setTextColor(config.theme.seconds, config.theme.background);
setCursor(clleft+wot+clsp, cltop-hot+1); setCursor(clleft+wot+clsp, cltop-hot+1);
sprintf(timeBuf, "%02d", timeinfo.tm_sec); sprintf(timeBuf, "%02d", timeinfo.tm_sec);
print(timeBuf); print(timeBuf);
@@ -288,25 +287,25 @@ void DspCore::drawVolumeBar(bool withNumber) {
int16_t volTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT - 2; int16_t volTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT - 2;
int16_t vWidth = swidth - TFT_FRAMEWDT *2; int16_t vWidth = swidth - TFT_FRAMEWDT *2;
uint16_t ww = map(config.store.volume, 0, 254, 0, vWidth - 2); uint16_t ww = map(config.store.volume, 0, 254, 0, vWidth - 2);
fillRect(TFT_FRAMEWDT, vTop - 2, vWidth, 6, TFT_BG); fillRect(TFT_FRAMEWDT, vTop - 2, vWidth, 6, config.theme.background);
drawRect(TFT_FRAMEWDT, vTop - 2, vWidth, 6, TFT_LOGO); fillRect(TFT_FRAMEWDT + 1, vTop - 1, ww, 5, config.theme.volbarin);
fillRect(TFT_FRAMEWDT + 1, vTop - 1, ww, 5, TFT_LOGO); drawRect(TFT_FRAMEWDT, vTop - 2, vWidth, 6, config.theme.volbarout);
if(swidth>240){ if(swidth>240){
char buf[20]; char buf[20];
sprintf(buf, "VOL %d", config.store.volume); sprintf(buf, "VOL %d", config.store.volume);
setTextSize(1); setTextSize(1);
centerText(buf, volTop, SILVER, TFT_BG); centerText(buf, volTop, config.theme.vol, config.theme.background);
} }
if (withNumber) { if (withNumber) {
setTextSize(1); setTextSize(1);
setTextColor(TFT_FG); setTextColor(config.theme.digit);
setFont(&DS_DIGI42pt7b); setFont(&DS_DIGI42pt7b);
char volstr[4]; char volstr[4];
uint16_t wv, hv; uint16_t wv, hv;
int16_t x1, y1; int16_t x1, y1;
sprintf(volstr, "%d", config.store.volume); sprintf(volstr, "%d", config.store.volume);
getTextBounds(volstr, 0, 0, &x1, &y1, &wv, &hv); getTextBounds(volstr, 0, 0, &x1, &y1, &wv, &hv);
fillRect(TFT_FRAMEWDT, (sheight-hv)/2, swidth - TFT_FRAMEWDT / 2, hv + 3, TFT_BG); fillRect(TFT_FRAMEWDT, (sheight-hv)/2, swidth - TFT_FRAMEWDT / 2, hv + 3, config.theme.background);
setCursor((swidth - wv) / 2, (sheight-hv)/2 + hv); setCursor((swidth - wv) / 2, (sheight-hv)/2 + hv);
print(volstr); print(volstr);
setFont(); setFont();
@@ -316,14 +315,14 @@ void DspCore::drawVolumeBar(bool withNumber) {
void DspCore::drawNextStationNum(uint16_t num) { void DspCore::drawNextStationNum(uint16_t num) {
setTextSize(1); setTextSize(1);
setTextColor(TFT_FG); setTextColor(config.theme.digit);
setFont(&DS_DIGI42pt7b); setFont(&DS_DIGI42pt7b);
char numstr[7]; char numstr[7];
uint16_t wv, hv; uint16_t wv, hv;
int16_t x1, y1; int16_t x1, y1;
sprintf(numstr, "%d", num); sprintf(numstr, "%d", num);
getTextBounds(numstr, 0, 0, &x1, &y1, &wv, &hv); getTextBounds(numstr, 0, 0, &x1, &y1, &wv, &hv);
fillRect(TFT_FRAMEWDT, (sheight-hv)/2, swidth - TFT_FRAMEWDT / 2, hv + 3, TFT_BG); fillRect(TFT_FRAMEWDT, (sheight-hv)/2, swidth - TFT_FRAMEWDT / 2, hv + 3, config.theme.background);
setCursor((swidth - wv) / 2, (sheight-hv)/2 + hv); setCursor((swidth - wv) / 2, (sheight-hv)/2 + hv);
print(numstr); print(numstr);
setFont(); setFont();
@@ -331,8 +330,8 @@ void DspCore::drawNextStationNum(uint16_t num) {
void DspCore::frameTitle(const char* str) { void DspCore::frameTitle(const char* str) {
setTextSize(META_SIZE); setTextSize(META_SIZE);
centerText(str, TFT_FRAMEWDT, TFT_LOGO, TFT_BG); centerText(str, TFT_FRAMEWDT, config.theme.meta, config.theme.background);
drawFastHLine(TFT_FRAMEWDT, TITLE_TOP1-8, swidth-TFT_FRAMEWDT*2, SILVER); drawFastHLine(TFT_FRAMEWDT, TITLE_TOP1-8, swidth-TFT_FRAMEWDT*2, config.theme.div);
} }
void DspCore::rssi(const char* str) { void DspCore::rssi(const char* str) {
@@ -340,7 +339,7 @@ void DspCore::rssi(const char* str) {
char buf[20]; char buf[20];
sprintf(buf, "RSSI:%s", str); sprintf(buf, "RSSI:%s", str);
setTextSize(1); setTextSize(1);
rightText(buf, vTop, SILVER, TFT_BG); rightText(buf, vTop, config.theme.rssi, config.theme.background);
} }
void DspCore::ip(const char* str) { void DspCore::ip(const char* str) {
@@ -348,7 +347,7 @@ void DspCore::ip(const char* str) {
char buf[30]; char buf[30];
sprintf(buf, "IP: %s", str); sprintf(buf, "IP: %s", str);
setTextSize(1); setTextSize(1);
setTextColor(SILVER, TFT_BG); setTextColor(config.theme.ip, config.theme.background);
setCursor(TFT_FRAMEWDT, vTop); setCursor(TFT_FRAMEWDT, vTop);
print(buf); print(buf);
} }
@@ -398,4 +397,12 @@ void DspCore::flip(){
void DspCore::invert(){ void DspCore::invert(){
invertDisplay(config.store.invertdisplay); invertDisplay(config.store.invertdisplay);
} }
void DspCore::sleep(void) {
enableSleep(true); delay(150); enableDisplay(false); delay(150);
}
void DspCore::wake(void) {
enableDisplay(true); delay(150); enableSleep(false); delay(150);
}
#endif #endif

View File

@@ -9,6 +9,7 @@
#define VU_READY 1 #define VU_READY 1
#define WEATHER_READY 1 #define WEATHER_READY 1
#define DSP_CAN_SLEEP true
#define TFT_LINEHGHT 10 #define TFT_LINEHGHT 10
#define TFT_FRAMEWDT 8 #define TFT_FRAMEWDT 8
@@ -21,14 +22,13 @@
#define SCROLLTIME 30 #define SCROLLTIME 30
#endif #endif
#define PLMITEMS 9 #define PLMITEMS 11
#define PLMITEMLENGHT 40 #define PLMITEMLENGHT 40
#define PLMITEMHEIGHT 22 #define PLMITEMHEIGHT 22
#define TFT_FULLTIME 1 #define TFT_FULLTIME 1
#define TITLE_TOP1 TFT_FRAMEWDT + META_SIZE * TFT_LINEHGHT + 8 #define TITLE_TOP1 TFT_FRAMEWDT + META_SIZE * TFT_LINEHGHT + 8
#define TITLE_TOP2 TFT_FRAMEWDT + (META_SIZE+2) * TFT_LINEHGHT + 8 #define TITLE_TOP2 TFT_FRAMEWDT + (META_SIZE+2) * TFT_LINEHGHT + 8
#define TITLE_FG2 SILVER
class DspCore: public Adafruit_ST7789 { class DspCore: public Adafruit_ST7789 {
public: public:
@@ -63,6 +63,8 @@ class DspCore: public Adafruit_ST7789 {
virtual void endWrite(void); virtual void endWrite(void);
void flip(); void flip();
void invert(); void invert();
void sleep();
void wake();
private: private:
uint16_t swidth, sheight; uint16_t swidth, sheight;
char oldTimeBuf[20]; char oldTimeBuf[20];
@@ -72,36 +74,4 @@ class DspCore: public Adafruit_ST7789 {
extern DspCore dsp; extern DspCore dsp;
/*
* TFT COLORS
*/
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
#define GRAY 0x7BEF
#define DARK_GRAY 0x2945
#define LIGHT_GRAY 0xC618
#define LIME 0x87E0
#define AQUA 0x5D1C
#define CYAN 0x07FF
#define DARK_CYAN 0x03EF
#define ORANGE 0xFCA0
#define PINK 0xF97F
#define BROWN 0x8200
#define VIOLET 0x9199
#define SILVER 0xA510
#define GOLD 0xA508
#define NAVY 0x000F
#define MAROON 0x7800
#define PURPLE 0x780F
#define OLIVE 0x7BE0
#define TFT_BG BLACK
#define TFT_FG WHITE
#define TFT_LOGO 0xE68B // 224, 209, 92
#endif #endif