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);
_writeData(0x48); // MX, BGR == rotation 0
// PGAMCTRL(Positive Gamma Control)
#if DSP_MODEL==DSP_ILI9486
#if DSP_MODEL==DSP_ILI9486 && false
_writeCommand(0xE0);
_writeData(0x0F);
_writeData(0x1F);

View File

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

View File

@@ -186,7 +186,7 @@ class Config {
void setSmartStart(byte ss);
void initPlaylist();
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);
void setTimezone(int8_t tzh, int8_t tzm);
void setTimezoneOffset(uint16_t tzo);

View File

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

View File

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

View File

@@ -11,9 +11,6 @@
#define DSP_WIDTH 160
#define TFT_FRAMEWDT 1
#define MAX_WIDTH DSP_WIDTH-TFT_FRAMEWDT*2
#define PLMITEMS 7
#define PLMITEMLENGHT 40
#define PLMITEMHEIGHT 19
#define HIDE_IP
#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 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 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 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 } */
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 } */
const MoveConfig clockMove PROGMEM = { 14, 29+34, 0};
const MoveConfig weatherMove PROGMEM = { TFT_FRAMEWDT, 80-13, MAX_WIDTH-6*3-4-30 };
const MoveConfig weatherMoveVU PROGMEM = { 30, 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-30 };
#endif

View File

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

View File

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

View File

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

View File

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

View File

@@ -11,9 +11,6 @@
#define DSP_WIDTH 128
#define TFT_FRAMEWDT 4
#define MAX_WIDTH DSP_WIDTH-TFT_FRAMEWDT*2
#define PLMITEMS 7
#define PLMITEMLENGHT 40
#define PLMITEMHEIGHT 21
#define HIDE_HEAPBAR
#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 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 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 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 };

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 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 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 } */
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 } */
const MoveConfig clockMove PROGMEM = { 14, 29+34, 0};
const MoveConfig weatherMove PROGMEM = { TFT_FRAMEWDT, 80-13, MAX_WIDTH-6*3-4-30 };
const MoveConfig weatherMoveVU PROGMEM = { 30, 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-30 };
#endif

View File

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

View File

@@ -28,30 +28,35 @@ void DspCore::initDisplay() {
invert();
flip();
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) {
drawRGBBitmap((width() - 62) / 2, 5, bootlogo40, 62, 40);
}
void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
for (byte i = 0; i < PLMITEMS; i++) {
plMenu[i][0] = '\0';
void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){
setTextSize(playlistConf.widget.textsize);
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;
for (byte i = 0; i < PLMITEMS; i++) {
if (abs(i - 3) == 3) setTextColor(config.theme.playlist[2], config.theme.background);
if (abs(i - 3) == 2) setTextColor(config.theme.playlist[1], 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));
}
}
void DspCore::drawPlaylist(uint16_t currentItem) {
uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount);
if(lastPos<plTtemsCount){
fillRect(0, lastPos*plItemHeight+plYStart, width(), height()/2, config.theme.background);
}
}

View File

@@ -32,27 +32,33 @@ void DspCore::initDisplay() {
setTextWrap(false);
setTextSize(1);
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::drawPlaylist(uint16_t currentItem, char* currentItemText) {
for (byte i = 0; i < PLMITEMS; i++) {
plMenu[i][0] = '\0';
void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){
setTextSize(playlistConf.widget.textsize);
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++) {
if (i == 5) {
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
} else {
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));
}
void DspCore::drawPlaylist(uint16_t currentItem) {
uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount);
if(lastPos<plTtemsCount){
fillRect(0, lastPos*plItemHeight+plYStart, width(), height()/2, config.theme.background);
}
}

View File

@@ -33,27 +33,33 @@ void DspCore::initDisplay() {
fillScreen(0x0000);
invert();
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::drawPlaylist(uint16_t currentItem, char* currentItemText) {
for (byte i = 0; i < PLMITEMS; i++) {
plMenu[i][0] = '\0';
void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){
setTextSize(playlistConf.widget.textsize);
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++) {
if (i == 5) {
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
} else {
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));
}
void DspCore::drawPlaylist(uint16_t currentItem) {
uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount);
if(lastPos<plTtemsCount){
fillRect(0, lastPos*plItemHeight+plYStart, width(), height()/2, config.theme.background);
}
}

View File

@@ -54,28 +54,35 @@ void DspCore::initDisplay() {
flip();
invert();
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) {
drawBitmap((width() - LOGO_WIDTH ) / 2, top, logo, LOGO_WIDTH, LOGO_HEIGHT, 1);
}
void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
for (byte i = 0; i < PLMITEMS; i++) {
plMenu[i][0] = '\0';
void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){
setTextSize(playlistConf.widget.textsize);
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;
setTextColor(TFT_FG, TFT_BG);
for (byte i = 0; i < PLMITEMS; i++) {
if (i == 3) {
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));
}
}
void DspCore::drawPlaylist(uint16_t currentItem) {
uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount);
if(lastPos<plTtemsCount){
fillRect(0, lastPos*plItemHeight+plYStart, width(), height()/2, config.theme.background);
}
}

View File

@@ -59,6 +59,12 @@ void DspCore::initDisplay() {
flip();
invert();
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) {
@@ -66,22 +72,23 @@ void DspCore::drawLogo(uint16_t top) {
display();
}
void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
for (byte i = 0; i < PLMITEMS; i++) {
plMenu[i][0] = '\0';
void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){
setTextSize(playlistConf.widget.textsize);
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;
setTextColor(TFT_FG, TFT_BG);
for (byte i = 0; i < PLMITEMS; i++) {
if (i == 3) {
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));
}
}
void DspCore::drawPlaylist(uint16_t currentItem) {
uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount);
if(lastPos<plTtemsCount){
fillRect(0, lastPos*plItemHeight+plYStart, width(), height()/2, config.theme.background);
}
}

View File

@@ -56,30 +56,35 @@ void DspCore::initDisplay() {
flip();
invert();
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) {
drawRGBBitmap((DSP_WIDTH - 62) / 2, top, bootlogo40, 62, 40);
}
void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
for (byte i = 0; i < PLMITEMS; i++) {
plMenu[i][0] = '\0';
void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){
setTextSize(playlistConf.widget.textsize);
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;
for (byte i = 0; i < PLMITEMS; i++) {
if (abs(i - 3) == 3) setTextColor(CLR_ITEM3, TFT_BG);
if (abs(i - 3) == 2) setTextColor(CLR_ITEM2, TFT_BG);
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));
}
}
void DspCore::drawPlaylist(uint16_t currentItem) {
uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount);
if(lastPos<plTtemsCount){
fillRect(0, lastPos*plItemHeight+plYStart, width(), height()/2, config.theme.background);
}
}

View File

@@ -32,27 +32,33 @@ void DspCore::initDisplay() {
setTextWrap(false);
setTextSize(1);
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::drawPlaylist(uint16_t currentItem, char* currentItemText) {
for (byte i = 0; i < PLMITEMS; i++) {
plMenu[i][0] = '\0';
void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){
setTextSize(playlistConf.widget.textsize);
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++) {
if (i == 5) {
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
} else {
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));
}
void DspCore::drawPlaylist(uint16_t currentItem) {
uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount);
if(lastPos<plTtemsCount){
fillRect(0, lastPos*plItemHeight+plYStart, width(), height()/2, config.theme.background);
}
}

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

View File

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