pl_text_size_017

This commit is contained in:
e2002
2023-03-08 19:26:25 +03:00
parent a50dd1a353
commit ebd6acd3fe
22 changed files with 203 additions and 170 deletions

View File

@@ -335,7 +335,7 @@ void ILI9486_SPI::init(void)
_writeCommand(0x36); _writeCommand(0x36);
_writeData(0x48); // MX, BGR == rotation 0 _writeData(0x48); // MX, BGR == rotation 0
// PGAMCTRL(Positive Gamma Control) // PGAMCTRL(Positive Gamma Control)
#if DSP_MODEL==DSP_ILI9486 #if DSP_MODEL==DSP_ILI9486 && false
_writeCommand(0xE0); _writeCommand(0xE0);
_writeData(0x0F); _writeData(0x0F);
_writeData(0x1F); _writeData(0x1F);

View File

@@ -437,7 +437,7 @@ char * Config::stationByNum(uint16_t num){
return _stationBuf; return _stationBuf;
} }
uint8_t Config::fillPlMenu(int from, uint8_t count) { uint8_t Config::fillPlMenu(int from, uint8_t count, bool fromNextion) {
int ls = from; int ls = from;
uint8_t c = 0; uint8_t c = 0;
bool finded = false; bool finded = false;
@@ -449,7 +449,10 @@ uint8_t Config::fillPlMenu(int from, uint8_t count) {
while (true) { while (true) {
if (ls < 1) { if (ls < 1) {
ls++; ls++;
display.printPLitem(c, ""); if(!fromNextion) display.printPLitem(c, "");
#ifdef USE_NEXTION
if(fromNextion) nextion.printPLitem(c, "");
#endif
c++; c++;
continue; continue;
} }
@@ -465,7 +468,10 @@ uint8_t Config::fillPlMenu(int from, uint8_t count) {
String stationName = playlist.readStringUntil('\n'); String stationName = playlist.readStringUntil('\n');
stationName = stationName.substring(0, stationName.indexOf('\t')); stationName = stationName.substring(0, stationName.indexOf('\t'));
if(config.store.numplaylist) stationName = String(from+c)+" "+stationName; if(config.store.numplaylist) stationName = String(from+c)+" "+stationName;
display.printPLitem(c, stationName.c_str()); if(!fromNextion) display.printPLitem(c, stationName.c_str());
#ifdef USE_NEXTION
if(fromNextion) nextion.printPLitem(c, stationName.c_str());
#endif
c++; c++;
if (c >= count) break; if (c >= count) break;
} }

View File

@@ -186,7 +186,7 @@ class Config {
void setSmartStart(byte ss); void setSmartStart(byte ss);
void initPlaylist(); void initPlaylist();
void indexPlaylist(); void indexPlaylist();
uint8_t fillPlMenu(int from, uint8_t count); uint8_t fillPlMenu(int from, uint8_t count, bool fromNextion=false);
char * stationByNum(uint16_t num); char * stationByNum(uint16_t num);
void setTimezone(int8_t tzh, int8_t tzm); void setTimezone(int8_t tzh, int8_t tzm);
void setTimezoneOffset(uint16_t tzo); void setTimezoneOffset(uint16_t tzo);

View File

@@ -211,7 +211,7 @@ void Display::_start() {
return; return;
} }
#ifdef USE_NEXTION #ifdef USE_NEXTION
nextion.putcmd("page player"); //nextion.putcmd("page player");
nextion.start(); nextion.start();
#endif #endif
_buildPager(); _buildPager();
@@ -539,6 +539,7 @@ void Display::init(){
} }
void Display::_start(){ void Display::_start(){
#ifdef USE_NEXTION #ifdef USE_NEXTION
//nextion.putcmd("page player");
nextion.start(); nextion.start();
#endif #endif
} }

View File

@@ -1,7 +1,7 @@
#ifndef options_h #ifndef options_h
#define options_h #define options_h
#define YOVERSION "0.9.012" #define YOVERSION "0.9.017"
/******************************************************* /*******************************************************
DO NOT EDIT THIS FILE. DO NOT EDIT THIS FILE.

View File

@@ -11,9 +11,6 @@
#define DSP_WIDTH 160 #define DSP_WIDTH 160
#define TFT_FRAMEWDT 1 #define TFT_FRAMEWDT 1
#define MAX_WIDTH DSP_WIDTH-TFT_FRAMEWDT*2 #define MAX_WIDTH DSP_WIDTH-TFT_FRAMEWDT*2
#define PLMITEMS 7
#define PLMITEMLENGHT 40
#define PLMITEMHEIGHT 19
#define HIDE_IP #define HIDE_IP
#define HIDE_TITLE2 #define HIDE_TITLE2
@@ -25,10 +22,10 @@
const ScrollConfig metaConf PROGMEM = {{ TFT_FRAMEWDT, TFT_FRAMEWDT, 2, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 4, 30 }; const ScrollConfig metaConf PROGMEM = {{ TFT_FRAMEWDT, TFT_FRAMEWDT, 2, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 4, 30 };
const ScrollConfig title1Conf PROGMEM = {{ TFT_FRAMEWDT, 19, 1, WA_LEFT }, 140, true, MAX_WIDTH-6*3-4, 5000, 3, 30 }; const ScrollConfig title1Conf PROGMEM = {{ TFT_FRAMEWDT, 19, 1, WA_LEFT }, 140, true, MAX_WIDTH-6*3-4, 5000, 3, 30 };
//const ScrollConfig title2Conf PROGMEM = {{ TFT_FRAMEWDT, 36, 1, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 2, 30 }; //const ScrollConfig title2Conf PROGMEM = {{ TFT_FRAMEWDT, 36, 1, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 2, 30 };
const ScrollConfig playlistConf PROGMEM = {{ TFT_FRAMEWDT, 33, 2, WA_LEFT }, 140, true, MAX_WIDTH, 0, 3, 30 }; const ScrollConfig playlistConf PROGMEM = {{ TFT_FRAMEWDT, 33, 1, WA_LEFT }, 140, true, MAX_WIDTH, 0, 3, 30 };
const ScrollConfig apTitleConf PROGMEM = {{ TFT_FRAMEWDT, TFT_FRAMEWDT, 2, WA_CENTER }, 140, false, MAX_WIDTH, 0, 3, 30 }; const ScrollConfig apTitleConf PROGMEM = {{ TFT_FRAMEWDT, TFT_FRAMEWDT, 2, WA_CENTER }, 140, false, MAX_WIDTH, 0, 3, 30 };
const ScrollConfig apSettConf PROGMEM = {{ TFT_FRAMEWDT, 80-TFT_FRAMEWDT-8, 1, WA_LEFT }, 140, false, MAX_WIDTH, 0, 3, 30 }; const ScrollConfig apSettConf PROGMEM = {{ TFT_FRAMEWDT, 80-TFT_FRAMEWDT-8, 1, WA_LEFT }, 140, false, MAX_WIDTH, 0, 3, 30 };
const ScrollConfig weatherConf PROGMEM = {{ TFT_FRAMEWDT, 80-13, 1, WA_LEFT }, 140, true, MAX_WIDTH-6*3-4, 0, 3, 30 }; // ПОГОДА!! const ScrollConfig weatherConf PROGMEM = {{ TFT_FRAMEWDT, 80-13, 1, WA_LEFT }, 140, true, MAX_WIDTH-6*3, 0, 3, 30 }; // ПОГОДА!!
/* BACKGROUNGC9106DS */ /* {{ left, top, fontsize, align }, width, height, outlined } */ /* BACKGROUNGC9106DS */ /* {{ left, top, fontsize, align }, width, height, outlined } */
const FillConfig metaBGConf PROGMEM = {{ 0, 0, 0, WA_LEFT }, DSP_WIDTH, 16, false }; const FillConfig metaBGConf PROGMEM = {{ 0, 0, 0, WA_LEFT }, DSP_WIDTH, 16, false };
@@ -66,7 +63,7 @@ const char bitrateFmt[] PROGMEM = "%d";
/* MOVES */ /* { left, top, width } */ /* MOVES */ /* { left, top, width } */
const MoveConfig clockMove PROGMEM = { 14, 29+34, 0}; const MoveConfig clockMove PROGMEM = { 14, 29+34, 0};
const MoveConfig weatherMove PROGMEM = { TFT_FRAMEWDT, 80-13, MAX_WIDTH-6*3-4-30 }; const MoveConfig weatherMove PROGMEM = { TFT_FRAMEWDT, 80-13, MAX_WIDTH-6*3-30 };
const MoveConfig weatherMoveVU PROGMEM = { 30, 80-13, MAX_WIDTH-6*3-4-30 }; const MoveConfig weatherMoveVU PROGMEM = { 30, 80-13, MAX_WIDTH-6*3-30 };
#endif #endif

View File

@@ -11,10 +11,7 @@
#define DSP_WIDTH 240 #define DSP_WIDTH 240
#define TFT_FRAMEWDT 8 #define TFT_FRAMEWDT 8
#define MAX_WIDTH DSP_WIDTH-TFT_FRAMEWDT*2 #define MAX_WIDTH DSP_WIDTH-TFT_FRAMEWDT*2
#define PLMITEMS 11 #define RSSI_DIGIT true
#define PLMITEMLENGHT 40
#define PLMITEMHEIGHT 22
#define bootLogoTop 68 #define bootLogoTop 68
#define HIDE_TITLE2 #define HIDE_TITLE2
#define BOOMBOX_STYLE #define BOOMBOX_STYLE

View File

@@ -12,9 +12,6 @@
#define DSP_HEIGHT 320 #define DSP_HEIGHT 320
#define TFT_FRAMEWDT 10 #define TFT_FRAMEWDT 10
#define MAX_WIDTH DSP_WIDTH-TFT_FRAMEWDT*2 #define MAX_WIDTH DSP_WIDTH-TFT_FRAMEWDT*2
#define PLMITEMS 11
#define PLMITEMLENGHT 40
#define PLMITEMHEIGHT 32
#define bootLogoTop 110 #define bootLogoTop 110

View File

@@ -11,9 +11,6 @@
#define DSP_WIDTH 128 #define DSP_WIDTH 128
#define TFT_FRAMEWDT 1 #define TFT_FRAMEWDT 1
#define MAX_WIDTH DSP_WIDTH-TFT_FRAMEWDT*2 #define MAX_WIDTH DSP_WIDTH-TFT_FRAMEWDT*2
#define PLMITEMS 7
#define PLMITEMLENGHT 40
#define PLMITEMHEIGHT 10
#define HIDE_HEAPBAR #define HIDE_HEAPBAR
#define HIDE_VOL #define HIDE_VOL

View File

@@ -11,9 +11,6 @@
#define DSP_WIDTH 128 #define DSP_WIDTH 128
#define TFT_FRAMEWDT 1 #define TFT_FRAMEWDT 1
#define MAX_WIDTH DSP_WIDTH-TFT_FRAMEWDT*2 #define MAX_WIDTH DSP_WIDTH-TFT_FRAMEWDT*2
#define PLMITEMS 7
#define PLMITEMLENGHT 40
#define PLMITEMHEIGHT 10
#define HIDE_HEAPBAR #define HIDE_HEAPBAR
#define HIDE_VOL #define HIDE_VOL

View File

@@ -11,9 +11,6 @@
#define DSP_WIDTH 128 #define DSP_WIDTH 128
#define TFT_FRAMEWDT 4 #define TFT_FRAMEWDT 4
#define MAX_WIDTH DSP_WIDTH-TFT_FRAMEWDT*2 #define MAX_WIDTH DSP_WIDTH-TFT_FRAMEWDT*2
#define PLMITEMS 7
#define PLMITEMLENGHT 40
#define PLMITEMHEIGHT 21
#define HIDE_HEAPBAR #define HIDE_HEAPBAR
#define HIDE_VU #define HIDE_VU
@@ -24,7 +21,7 @@
const ScrollConfig metaConf PROGMEM = {{ TFT_FRAMEWDT, TFT_FRAMEWDT, 2, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 4, 30 }; const ScrollConfig metaConf PROGMEM = {{ TFT_FRAMEWDT, TFT_FRAMEWDT, 2, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 4, 30 };
const ScrollConfig title1Conf PROGMEM = {{ TFT_FRAMEWDT, 26, 1, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 2, 30 }; const ScrollConfig title1Conf PROGMEM = {{ TFT_FRAMEWDT, 26, 1, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 2, 30 };
const ScrollConfig title2Conf PROGMEM = {{ TFT_FRAMEWDT, 36, 1, WA_LEFT }, 140, true, MAX_WIDTH-6*3-4, 5000, 2, 30 }; const ScrollConfig title2Conf PROGMEM = {{ TFT_FRAMEWDT, 36, 1, WA_LEFT }, 140, true, MAX_WIDTH-6*3-4, 5000, 2, 30 };
const ScrollConfig playlistConf PROGMEM = {{ TFT_FRAMEWDT, 56, 2, WA_LEFT }, 140, true, MAX_WIDTH, 1000, 4, 30 }; const ScrollConfig playlistConf PROGMEM = {{ TFT_FRAMEWDT, 56, 1, WA_LEFT }, 140, true, MAX_WIDTH, 1000, 4, 30 };
const ScrollConfig apTitleConf PROGMEM = {{ TFT_FRAMEWDT, TFT_FRAMEWDT, 2, WA_CENTER }, 140, false, MAX_WIDTH, 0, 4, 30 }; const ScrollConfig apTitleConf PROGMEM = {{ TFT_FRAMEWDT, TFT_FRAMEWDT, 2, WA_CENTER }, 140, false, MAX_WIDTH, 0, 4, 30 };
const ScrollConfig apSettConf PROGMEM = {{ TFT_FRAMEWDT, 128-TFT_FRAMEWDT-8, 1, WA_LEFT }, 140, false, MAX_WIDTH, 0, 2, 30 }; const ScrollConfig apSettConf PROGMEM = {{ TFT_FRAMEWDT, 128-TFT_FRAMEWDT-8, 1, WA_LEFT }, 140, false, MAX_WIDTH, 0, 2, 30 };
const ScrollConfig weatherConf PROGMEM = {{ TFT_FRAMEWDT, 42, 1, WA_LEFT }, 140, true, MAX_WIDTH, 0, 3, 30 }; const ScrollConfig weatherConf PROGMEM = {{ TFT_FRAMEWDT, 42, 1, WA_LEFT }, 140, true, MAX_WIDTH, 0, 3, 30 };

View File

@@ -25,7 +25,7 @@ const ScrollConfig title1Conf PROGMEM = {{ TFT_FRAMEWDT, 19, 1, WA_LEFT }, 1
const ScrollConfig playlistConf PROGMEM = {{ TFT_FRAMEWDT, 33, 1, WA_LEFT }, 140, true, MAX_WIDTH, 0, 3, 30 }; const ScrollConfig playlistConf PROGMEM = {{ TFT_FRAMEWDT, 33, 1, WA_LEFT }, 140, true, MAX_WIDTH, 0, 3, 30 };
const ScrollConfig apTitleConf PROGMEM = {{ TFT_FRAMEWDT, TFT_FRAMEWDT, 2, WA_CENTER }, 140, false, MAX_WIDTH, 0, 3, 30 }; const ScrollConfig apTitleConf PROGMEM = {{ TFT_FRAMEWDT, TFT_FRAMEWDT, 2, WA_CENTER }, 140, false, MAX_WIDTH, 0, 3, 30 };
const ScrollConfig apSettConf PROGMEM = {{ TFT_FRAMEWDT, 80-TFT_FRAMEWDT-8, 1, WA_LEFT }, 140, false, MAX_WIDTH, 0, 3, 30 }; const ScrollConfig apSettConf PROGMEM = {{ TFT_FRAMEWDT, 80-TFT_FRAMEWDT-8, 1, WA_LEFT }, 140, false, MAX_WIDTH, 0, 3, 30 };
const ScrollConfig weatherConf PROGMEM = {{ TFT_FRAMEWDT, 80-13, 1, WA_LEFT }, 140, true, MAX_WIDTH-6*3-4, 0, 3, 30 }; // ПОГОДА!! const ScrollConfig weatherConf PROGMEM = {{ TFT_FRAMEWDT, 80-13, 1, WA_LEFT }, 140, true, MAX_WIDTH-6*3, 0, 3, 30 }; // ПОГОДА!!
/* BACKGROUNGC9106DS */ /* {{ left, top, fontsize, align }, width, height, outlined } */ /* BACKGROUNGC9106DS */ /* {{ left, top, fontsize, align }, width, height, outlined } */
const FillConfig metaBGConf PROGMEM = {{ 0, 0, 0, WA_LEFT }, DSP_WIDTH, 16, false }; const FillConfig metaBGConf PROGMEM = {{ 0, 0, 0, WA_LEFT }, DSP_WIDTH, 16, false };
@@ -63,7 +63,7 @@ const char bitrateFmt[] PROGMEM = "%d";
/* MOVES */ /* { left, top, width } */ /* MOVES */ /* { left, top, width } */
const MoveConfig clockMove PROGMEM = { 14, 29+34, 0}; const MoveConfig clockMove PROGMEM = { 14, 29+34, 0};
const MoveConfig weatherMove PROGMEM = { TFT_FRAMEWDT, 80-13, MAX_WIDTH-6*3-4-30 }; const MoveConfig weatherMove PROGMEM = { TFT_FRAMEWDT, 80-13, MAX_WIDTH-6*3-30 };
const MoveConfig weatherMoveVU PROGMEM = { 30, 80-13, MAX_WIDTH-6*3-4-30 }; const MoveConfig weatherMoveVU PROGMEM = { 30, 80-13, MAX_WIDTH-6*3-30 };
#endif #endif

View File

@@ -12,9 +12,6 @@
#define DSP_HEIGHT 320 #define DSP_HEIGHT 320
#define TFT_FRAMEWDT 10 #define TFT_FRAMEWDT 10
#define MAX_WIDTH DSP_WIDTH-TFT_FRAMEWDT*2 #define MAX_WIDTH DSP_WIDTH-TFT_FRAMEWDT*2
#define PLMITEMS 11
#define PLMITEMLENGHT 40
#define PLMITEMHEIGHT 32
#define bootLogoTop 110 #define bootLogoTop 110

View File

@@ -28,30 +28,35 @@ void DspCore::initDisplay() {
invert(); invert();
flip(); flip();
setTextWrap(false); setTextWrap(false);
plItemHeight = playlistConf.widget.textsize*(CHARHEIGHT-1)+playlistConf.widget.textsize*4;
plTtemsCount = round((float)height()/plItemHeight);
if(plTtemsCount%2==0) plTtemsCount++;
plCurrentPos = plTtemsCount/2;
plYStart = (height() / 2 - plItemHeight / 2) - plItemHeight * (plTtemsCount - 1) / 2 + playlistConf.widget.textsize*2;
} }
void DspCore::drawLogo(uint16_t top) { void DspCore::drawLogo(uint16_t top) {
drawRGBBitmap((width() - 62) / 2, 5, bootlogo40, 62, 40); drawRGBBitmap((width() - 62) / 2, 5, bootlogo40, 62, 40);
} }
void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) { void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){
for (byte i = 0; i < PLMITEMS; i++) { setTextSize(playlistConf.widget.textsize);
plMenu[i][0] = '\0'; if (pos == plCurrentPos) {
current.setText(item);
} else {
uint8_t plColor = (abs(pos - plCurrentPos)-1)>4?4:abs(pos - plCurrentPos)-1;
setTextColor(config.theme.playlist[plColor], config.theme.background);
setCursor(TFT_FRAMEWDT, plYStart + pos * plItemHeight);
fillRect(0, plYStart + pos * plItemHeight - 1, width(), plItemHeight - 2, config.theme.background);
print(utf8Rus(item, true));
} }
config.fillPlMenu(plMenu, currentItem - 3, PLMITEMS); }
setTextSize(2);
int yStart = (height() / 2 - PLMITEMHEIGHT / 2) - PLMITEMHEIGHT * (PLMITEMS - 1) / 2 + 3; void DspCore::drawPlaylist(uint16_t currentItem) {
for (byte i = 0; i < PLMITEMS; i++) { uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount);
if (abs(i - 3) == 3) setTextColor(config.theme.playlist[2], config.theme.background); if(lastPos<plTtemsCount){
if (abs(i - 3) == 2) setTextColor(config.theme.playlist[1], config.theme.background); fillRect(0, lastPos*plItemHeight+plYStart, width(), height()/2, config.theme.background);
if (abs(i - 3) == 1) setTextColor(config.theme.playlist[0], config.theme.background);
if (i == 3) {
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
} else {
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
fillRect(0, yStart + i * PLMITEMHEIGHT - 1, width(), PLMITEMHEIGHT - 4, config.theme.background);
print(utf8Rus(plMenu[i], true));
}
} }
} }

View File

@@ -32,27 +32,33 @@ void DspCore::initDisplay() {
setTextWrap(false); setTextWrap(false);
setTextSize(1); setTextSize(1);
fillScreen(0x0000); fillScreen(0x0000);
plItemHeight = playlistConf.widget.textsize*(CHARHEIGHT-1)+playlistConf.widget.textsize*4;
plTtemsCount = round((float)height()/plItemHeight);
if(plTtemsCount%2==0) plTtemsCount++;
plCurrentPos = plTtemsCount/2;
plYStart = (height() / 2 - plItemHeight / 2) - plItemHeight * (plTtemsCount - 1) / 2 + playlistConf.widget.textsize*2;
} }
void DspCore::drawLogo(uint16_t top) { drawRGBBitmap((width() - 99) / 2, top, bootlogo2, 99, 64); } void DspCore::drawLogo(uint16_t top) { drawRGBBitmap((width() - 99) / 2, top, bootlogo2, 99, 64); }
void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) { void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){
for (byte i = 0; i < PLMITEMS; i++) { setTextSize(playlistConf.widget.textsize);
plMenu[i][0] = '\0'; if (pos == plCurrentPos) {
current.setText(item);
} else {
uint8_t plColor = (abs(pos - plCurrentPos)-1)>4?4:abs(pos - plCurrentPos)-1;
setTextColor(config.theme.playlist[plColor], config.theme.background);
setCursor(TFT_FRAMEWDT, plYStart + pos * plItemHeight);
fillRect(0, plYStart + pos * plItemHeight - 1, width(), plItemHeight - 2, config.theme.background);
print(utf8Rus(item, true));
} }
config.fillPlMenu(plMenu, currentItem - 5, PLMITEMS); }
setTextSize(2);
int yStart = (height() / 2 - PLMITEMHEIGHT / 2) - PLMITEMHEIGHT * (PLMITEMS - 1) / 2 + 3;
for (byte i = 0; i < PLMITEMS; i++) { void DspCore::drawPlaylist(uint16_t currentItem) {
if (i == 5) { uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount);
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1); if(lastPos<plTtemsCount){
} else { fillRect(0, lastPos*plItemHeight+plYStart, width(), height()/2, config.theme.background);
setTextColor(config.theme.playlist[abs(i - 5)-1], config.theme.background);
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
fillRect(0, yStart + i * PLMITEMHEIGHT - 1, width(), PLMITEMHEIGHT - 2, config.theme.background);
print(utf8Rus(plMenu[i], true));
}
} }
} }

View File

@@ -33,27 +33,33 @@ void DspCore::initDisplay() {
fillScreen(0x0000); fillScreen(0x0000);
invert(); invert();
flip(); flip();
plItemHeight = playlistConf.widget.textsize*(CHARHEIGHT-1)+playlistConf.widget.textsize*4;
plTtemsCount = round((float)height()/plItemHeight);
if(plTtemsCount%2==0) plTtemsCount++;
plCurrentPos = plTtemsCount/2;
plYStart = (height() / 2 - plItemHeight / 2) - plItemHeight * (plTtemsCount - 1) / 2 + playlistConf.widget.textsize*2;
} }
void DspCore::drawLogo(uint16_t top) { drawRGBBitmap((width() - 99) / 2, top, bootlogo2, 99, 64); } void DspCore::drawLogo(uint16_t top) { drawRGBBitmap((width() - 99) / 2, top, bootlogo2, 99, 64); }
void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) { void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){
for (byte i = 0; i < PLMITEMS; i++) { setTextSize(playlistConf.widget.textsize);
plMenu[i][0] = '\0'; if (pos == plCurrentPos) {
current.setText(item);
} else {
uint8_t plColor = (abs(pos - plCurrentPos)-1)>4?4:abs(pos - plCurrentPos)-1;
setTextColor(config.theme.playlist[plColor], config.theme.background);
setCursor(TFT_FRAMEWDT, plYStart + pos * plItemHeight);
fillRect(0, plYStart + pos * plItemHeight - 1, width(), plItemHeight - 2, config.theme.background);
print(utf8Rus(item, true));
} }
config.fillPlMenu(plMenu, currentItem - 5, PLMITEMS); }
setTextSize(3);
int yStart = (height() / 2 - PLMITEMHEIGHT / 2) - PLMITEMHEIGHT * (PLMITEMS - 1) / 2 + 3;
for (byte i = 0; i < PLMITEMS; i++) { void DspCore::drawPlaylist(uint16_t currentItem) {
if (i == 5) { uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount);
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1); if(lastPos<plTtemsCount){
} else { fillRect(0, lastPos*plItemHeight+plYStart, width(), height()/2, config.theme.background);
setTextColor(config.theme.playlist[abs(i - 5)-1], config.theme.background);
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
fillRect(0, yStart + i * PLMITEMHEIGHT - 1, width(), PLMITEMHEIGHT - 6, config.theme.background);
print(utf8Rus(plMenu[i], true));
}
} }
} }

View File

@@ -54,28 +54,35 @@ void DspCore::initDisplay() {
flip(); flip();
invert(); invert();
setTextWrap(false); setTextWrap(false);
plItemHeight = playlistConf.widget.textsize*(CHARHEIGHT-1)+playlistConf.widget.textsize*4;
plTtemsCount = round((float)height()/plItemHeight);
if(plTtemsCount%2==0) plTtemsCount++;
plCurrentPos = plTtemsCount/2;
plYStart = (height() / 2 - plItemHeight / 2) - plItemHeight * (plTtemsCount - 1) / 2 + playlistConf.widget.textsize*2;
} }
void DspCore::drawLogo(uint16_t top) { void DspCore::drawLogo(uint16_t top) {
drawBitmap((width() - LOGO_WIDTH ) / 2, top, logo, LOGO_WIDTH, LOGO_HEIGHT, 1); drawBitmap((width() - LOGO_WIDTH ) / 2, top, logo, LOGO_WIDTH, LOGO_HEIGHT, 1);
} }
void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) { void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){
for (byte i = 0; i < PLMITEMS; i++) { setTextSize(playlistConf.widget.textsize);
plMenu[i][0] = '\0'; if (pos == plCurrentPos) {
current.setText(item);
} else {
uint8_t plColor = (abs(pos - plCurrentPos)-1)>4?4:abs(pos - plCurrentPos)-1;
setTextColor(config.theme.playlist[plColor], config.theme.background);
setCursor(TFT_FRAMEWDT, plYStart + pos * plItemHeight);
fillRect(0, plYStart + pos * plItemHeight - 1, width(), plItemHeight - 2, config.theme.background);
print(utf8Rus(item, true));
} }
config.fillPlMenu(plMenu, currentItem - 3, PLMITEMS); }
setTextSize(1);
int yStart = (height() / 2 - PLMITEMHEIGHT / 2) - PLMITEMHEIGHT * (PLMITEMS - 1) / 2 + 3; void DspCore::drawPlaylist(uint16_t currentItem) {
setTextColor(TFT_FG, TFT_BG); uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount);
for (byte i = 0; i < PLMITEMS; i++) { if(lastPos<plTtemsCount){
if (i == 3) { fillRect(0, lastPos*plItemHeight+plYStart, width(), height()/2, config.theme.background);
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
} else {
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
fillRect(0, yStart + i * PLMITEMHEIGHT, width(), PLMITEMHEIGHT - 1, TFT_BG);
print(utf8Rus(plMenu[i], true));
}
} }
} }

View File

@@ -59,6 +59,12 @@ void DspCore::initDisplay() {
flip(); flip();
invert(); invert();
setTextWrap(false); setTextWrap(false);
plItemHeight = playlistConf.widget.textsize*(CHARHEIGHT-1)+playlistConf.widget.textsize*4;
plTtemsCount = round((float)height()/plItemHeight);
if(plTtemsCount%2==0) plTtemsCount++;
plCurrentPos = plTtemsCount/2;
plYStart = (height() / 2 - plItemHeight / 2) - plItemHeight * (plTtemsCount - 1) / 2 + playlistConf.widget.textsize*2;
} }
void DspCore::drawLogo(uint16_t top) { void DspCore::drawLogo(uint16_t top) {
@@ -66,22 +72,23 @@ void DspCore::drawLogo(uint16_t top) {
display(); display();
} }
void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) { void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){
for (byte i = 0; i < PLMITEMS; i++) { setTextSize(playlistConf.widget.textsize);
plMenu[i][0] = '\0'; if (pos == plCurrentPos) {
current.setText(item);
} else {
uint8_t plColor = (abs(pos - plCurrentPos)-1)>4?4:abs(pos - plCurrentPos)-1;
setTextColor(config.theme.playlist[plColor], config.theme.background);
setCursor(TFT_FRAMEWDT, plYStart + pos * plItemHeight);
fillRect(0, plYStart + pos * plItemHeight - 1, width(), plItemHeight - 2, config.theme.background);
print(utf8Rus(item, true));
} }
config.fillPlMenu(plMenu, currentItem - 3, PLMITEMS); }
setTextSize(1);
int yStart = (height() / 2 - PLMITEMHEIGHT / 2) - PLMITEMHEIGHT * (PLMITEMS - 1) / 2 + 3; void DspCore::drawPlaylist(uint16_t currentItem) {
setTextColor(TFT_FG, TFT_BG); uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount);
for (byte i = 0; i < PLMITEMS; i++) { if(lastPos<plTtemsCount){
if (i == 3) { fillRect(0, lastPos*plItemHeight+plYStart, width(), height()/2, config.theme.background);
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
} else {
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
fillRect(0, yStart + i * PLMITEMHEIGHT, width(), PLMITEMHEIGHT - 1, TFT_BG);
print(utf8Rus(plMenu[i], true));
}
} }
} }

View File

@@ -56,30 +56,35 @@ void DspCore::initDisplay() {
flip(); flip();
invert(); invert();
setTextWrap(false); setTextWrap(false);
plItemHeight = playlistConf.widget.textsize*(CHARHEIGHT-1)+playlistConf.widget.textsize*4;
plTtemsCount = round((float)height()/plItemHeight);
if(plTtemsCount%2==0) plTtemsCount++;
plCurrentPos = plTtemsCount/2;
plYStart = (height() / 2 - plItemHeight / 2) - plItemHeight * (plTtemsCount - 1) / 2 + playlistConf.widget.textsize*2;
} }
void DspCore::drawLogo(uint16_t top) { void DspCore::drawLogo(uint16_t top) {
drawRGBBitmap((DSP_WIDTH - 62) / 2, top, bootlogo40, 62, 40); drawRGBBitmap((DSP_WIDTH - 62) / 2, top, bootlogo40, 62, 40);
} }
void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) { void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){
for (byte i = 0; i < PLMITEMS; i++) { setTextSize(playlistConf.widget.textsize);
plMenu[i][0] = '\0'; if (pos == plCurrentPos) {
current.setText(item);
} else {
uint8_t plColor = (abs(pos - plCurrentPos)-1)>4?4:abs(pos - plCurrentPos)-1;
setTextColor(config.theme.playlist[plColor], config.theme.background);
setCursor(TFT_FRAMEWDT, plYStart + pos * plItemHeight);
fillRect(0, plYStart + pos * plItemHeight - 1, width(), plItemHeight - 2, config.theme.background);
print(utf8Rus(item, true));
} }
config.fillPlMenu(plMenu, currentItem - 3, PLMITEMS); }
setTextSize(2);
int yStart = (height() / 2 - PLMITEMHEIGHT / 2) - PLMITEMHEIGHT * (PLMITEMS - 1) / 2 + 3; void DspCore::drawPlaylist(uint16_t currentItem) {
for (byte i = 0; i < PLMITEMS; i++) { uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount);
if (abs(i - 3) == 3) setTextColor(CLR_ITEM3, TFT_BG); if(lastPos<plTtemsCount){
if (abs(i - 3) == 2) setTextColor(CLR_ITEM2, TFT_BG); fillRect(0, lastPos*plItemHeight+plYStart, width(), height()/2, config.theme.background);
if (abs(i - 3) == 1) setTextColor(CLR_ITEM1, TFT_BG);
if (i == 3) {
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
} else {
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
fillRect(0, yStart + i * PLMITEMHEIGHT - 1, width(), PLMITEMHEIGHT - 4, TFT_BG);
print(utf8Rus(plMenu[i], true));
}
} }
} }

View File

@@ -32,27 +32,33 @@ void DspCore::initDisplay() {
setTextWrap(false); setTextWrap(false);
setTextSize(1); setTextSize(1);
fillScreen(0x0000); fillScreen(0x0000);
plItemHeight = playlistConf.widget.textsize*(CHARHEIGHT-1)+playlistConf.widget.textsize*4;
plTtemsCount = round((float)height()/plItemHeight);
if(plTtemsCount%2==0) plTtemsCount++;
plCurrentPos = plTtemsCount/2;
plYStart = (height() / 2 - plItemHeight / 2) - plItemHeight * (plTtemsCount - 1) / 2 + playlistConf.widget.textsize*2;
} }
void DspCore::drawLogo(uint16_t top) { drawRGBBitmap((width() - 99) / 2, top, bootlogo2, 99, 64); } void DspCore::drawLogo(uint16_t top) { drawRGBBitmap((width() - 99) / 2, top, bootlogo2, 99, 64); }
void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) { void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){
for (byte i = 0; i < PLMITEMS; i++) { setTextSize(playlistConf.widget.textsize);
plMenu[i][0] = '\0'; if (pos == plCurrentPos) {
current.setText(item);
} else {
uint8_t plColor = (abs(pos - plCurrentPos)-1)>4?4:abs(pos - plCurrentPos)-1;
setTextColor(config.theme.playlist[plColor], config.theme.background);
setCursor(TFT_FRAMEWDT, plYStart + pos * plItemHeight);
fillRect(0, plYStart + pos * plItemHeight - 1, width(), plItemHeight - 2, config.theme.background);
print(utf8Rus(item, true));
} }
config.fillPlMenu(plMenu, currentItem - 5, PLMITEMS); }
setTextSize(3);
int yStart = (height() / 2 - PLMITEMHEIGHT / 2) - PLMITEMHEIGHT * (PLMITEMS - 1) / 2 + 3;
for (byte i = 0; i < PLMITEMS; i++) { void DspCore::drawPlaylist(uint16_t currentItem) {
if (i == 5) { uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount);
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1); if(lastPos<plTtemsCount){
} else { fillRect(0, lastPos*plItemHeight+plYStart, width(), height()/2, config.theme.background);
setTextColor(config.theme.playlist[abs(i - 5)-1], config.theme.background);
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
fillRect(0, yStart + i * PLMITEMHEIGHT - 1, width(), PLMITEMHEIGHT - 6, config.theme.background);
print(utf8Rus(plMenu[i], true));
}
} }
} }

View File

@@ -42,18 +42,20 @@ void Nextion::begin(bool dummy) {
snprintf(_espcoreversion, sizeof(_espcoreversion) - 1, "%d.%d.%d", ESP_ARDUINO_VERSION_MAJOR, ESP_ARDUINO_VERSION_MINOR, ESP_ARDUINO_VERSION_PATCH); snprintf(_espcoreversion, sizeof(_espcoreversion) - 1, "%d.%d.%d", ESP_ARDUINO_VERSION_MAJOR, ESP_ARDUINO_VERSION_MINOR, ESP_ARDUINO_VERSION_PATCH);
putcmd(""); putcmd("");
putcmd("rest"); putcmd("rest");
delay(200); delay(300);
putcmd(""); putcmd("");
putcmd("bkcmd=0"); putcmd("bkcmd=0");
// putcmd("page boot"); // putcmd("page boot");
_displayQueue = xQueueCreate( 5, sizeof( requestParams_t ) ); _displayQueue = xQueueCreate( 10, sizeof( requestParams_t ) );
if(dummy) { if(dummy) {
xTaskCreatePinnedToCore(nextionCore0, "TaskCore0", CORE_STACK_SIZE, NULL, 4, &_TaskCore0, !xPortGetCoreID()); xTaskCreatePinnedToCore(nextionCore0, "TaskCore0", CORE_STACK_SIZE, NULL, 4, &_TaskCore0, !xPortGetCoreID());
} }
} }
void Nextion::start(){ void Nextion::start(){
Serial.print("##[BOOT]#\tNextion.start\t");
delay(100);
if (network.status != CONNECTED) { if (network.status != CONNECTED) {
apScreen(); apScreen();
return; return;
@@ -62,12 +64,11 @@ void Nextion::start(){
display.mode(PLAYER); display.mode(PLAYER);
config.setTitle(const_PlReady); config.setTitle(const_PlReady);
#endif #endif
mode = PLAYER; putRequest({NEWMODE, PLAYER});
putcmd("page player"); putRequest({NEWSTATION, 0});
delay(100); putRequest({NEWTITLE, 0});
newNameset(config.station.name); putRequest({DRAWVOL, 0});
newTitle(config.station.title); Serial.println("done");
setVol(config.store.volume, mode == VOL);
} }
void Nextion::apScreen() { void Nextion::apScreen() {
@@ -80,10 +81,14 @@ void Nextion::putRequest(requestParams_t request){
xQueueSend(_displayQueue, &request, portMAX_DELAY); xQueueSend(_displayQueue, &request, portMAX_DELAY);
} }
#ifndef NEXTION_QUEUE_TICKS
#define NEXTION_QUEUE_TICKS 8
#endif
void Nextion::processQueue(){ void Nextion::processQueue(){
if(_displayQueue==NULL) return; if(_displayQueue==NULL) return;
requestParams_t request; requestParams_t request;
if(xQueueReceive(_displayQueue, &request, 20)){ if(xQueueReceive(_displayQueue, &request, NEXTION_QUEUE_TICKS)){
switch (request.type){ switch (request.type){
case NEWMODE: swichMode((displayMode_e)request.payload); break; case NEWMODE: swichMode((displayMode_e)request.payload); break;
case CLOCK: printClock(network.timeinfo); break; case CLOCK: printClock(network.timeinfo); break;
@@ -427,26 +432,25 @@ void Nextion::localTime(struct tm timeinfo){
putcmd(timeStringBuff); putcmd(timeStringBuff);
} }
void Nextion::printPLitem(uint8_t pos, const char* item){
char cmd[60]={0};
snprintf(cmd, sizeof(cmd) - 1, "t%d.txt=\"%s\"", pos, nextion.utf8Rus((char*)item, true));
putcmd(cmd);
}
void Nextion::drawPlaylist(uint16_t currentPlItem){ void Nextion::drawPlaylist(uint16_t currentPlItem){
char plMenu[7][40]; mode=STATIONS;
for (byte i = 0; i < 7; i++) { uint8_t lastPos = config.fillPlMenu(currentPlItem - 3, 7, true);
plMenu[i][0] = '\0'; if(lastPos<7){
} for(int i=0;i<7-lastPos;i++){
config.fillPlMenu(plMenu, currentPlItem - 3, 7); nextion.printPLitem(lastPos+i, "");
char cmd[60]={0}; }
for (byte i = 0; i < 7; i++) {
snprintf(cmd, sizeof(cmd) - 1, "t%d.txt=\"%s\"", i, nextion.utf8Rus(plMenu[i], true));
putcmd(cmd);
} }
_volDelay = millis(); _volDelay = millis();
} }
void Nextion::drawNextStationNum(uint16_t num) {//dialog void Nextion::drawNextStationNum(uint16_t num) {//dialog
char plMenu[1][40]; putcmd("dialog.title.txt", utf8Rus(config.stationByNum(num), true));
char currentItemText[40] = {0};
config.fillPlMenu(plMenu, num, 1, true);
strlcpy(currentItemText, plMenu[0], 39);
putcmd("dialog.title.txt", utf8Rus(currentItemText, true));
putcmd("dialog.text.txt", num, true); putcmd("dialog.text.txt", num, true);
_volDelay = millis(); _volDelay = millis();
} }
@@ -455,7 +459,7 @@ void Nextion::swichMode(displayMode_e newmode){
if (newmode == VOL) { if (newmode == VOL) {
_volDelay = millis(); _volDelay = millis();
} }
if (newmode == mode) return; //if (newmode == mode) return;
mode = newmode; mode = newmode;
#ifdef DUMMYDISPLAY #ifdef DUMMYDISPLAY
display.mode(newmode); display.mode(newmode);

View File

@@ -57,6 +57,7 @@ class Nextion {
void weatherVisible(uint8_t vis); void weatherVisible(uint8_t vis);
void localTime(struct tm timeinfo); void localTime(struct tm timeinfo);
void drawPlaylist(uint16_t currentPlItem); void drawPlaylist(uint16_t currentPlItem);
void printPLitem(uint8_t pos, const char* item);
void swichMode(displayMode_e newmode); void swichMode(displayMode_e newmode);
void drawNextStationNum(uint16_t num); void drawNextStationNum(uint16_t num);
void putRequest(requestParams_t request); void putRequest(requestParams_t request);