From 06d9c9ae3a5c99eb5baaf6327465cdadfe21b19b Mon Sep 17 00:00:00 2001 From: e2002 Date: Tue, 7 Mar 2023 13:10:26 +0300 Subject: [PATCH] pl_text_size_010 --- yoRadio/src/core/options.h | 2 +- .../src/displays/conf/displayILI9225conf.h | 11 +++--- yoRadio/src/displays/displayILI9225.cpp | 36 +++++++++++-------- yoRadio/src/displays/fonts/yofont5x7.c | 36 +++++++++---------- 4 files changed, 44 insertions(+), 41 deletions(-) diff --git a/yoRadio/src/core/options.h b/yoRadio/src/core/options.h index 875e12b..aee7d36 100644 --- a/yoRadio/src/core/options.h +++ b/yoRadio/src/core/options.h @@ -1,7 +1,7 @@ #ifndef options_h #define options_h -#define YOVERSION "0.9.009" +#define YOVERSION "0.9.010" /******************************************************* DO NOT EDIT THIS FILE. diff --git a/yoRadio/src/displays/conf/displayILI9225conf.h b/yoRadio/src/displays/conf/displayILI9225conf.h index 944fb32..a364b70 100644 --- a/yoRadio/src/displays/conf/displayILI9225conf.h +++ b/yoRadio/src/displays/conf/displayILI9225conf.h @@ -12,9 +12,6 @@ #define DSP_HEIGHT 176 #define TFT_FRAMEWDT 4 #define MAX_WIDTH DSP_WIDTH-TFT_FRAMEWDT*2 -#define PLMITEMS 9 -#define PLMITEMLENGHT 40 -#define PLMITEMHEIGHT 22 #define bootLogoTop 28 //#define DSP_QUEUE_TICKS 5 @@ -38,8 +35,8 @@ const FillConfig heapbarConf PROGMEM = {{ 0, DSP_HEIGHT-1, 0, WA_LEFT }, DS /* WIDGETS */ /* { left, top, fontsize, align } */ const WidgetConfig bootstrConf PROGMEM = { 0, 150, 1, WA_CENTER }; const WidgetConfig bitrateConf PROGMEM = { TFT_FRAMEWDT+6, DSP_HEIGHT-TFT_FRAMEWDT-14-14, 1, WA_RIGHT }; -const WidgetConfig voltxtConf PROGMEM = { 80, DSP_HEIGHT-TFT_FRAMEWDT-14, 1, WA_RIGHT }; -const WidgetConfig iptxtConf PROGMEM = { TFT_FRAMEWDT, DSP_HEIGHT-TFT_FRAMEWDT-14, 1, WA_LEFT }; +const WidgetConfig voltxtConf PROGMEM = { TFT_FRAMEWDT, DSP_HEIGHT-TFT_FRAMEWDT-14, 1, WA_LEFT }; +const WidgetConfig iptxtConf PROGMEM = { TFT_FRAMEWDT, DSP_HEIGHT-TFT_FRAMEWDT-14, 1, WA_CENTER }; const WidgetConfig rssiConf PROGMEM = { TFT_FRAMEWDT, DSP_HEIGHT-TFT_FRAMEWDT-14, 1, WA_RIGHT }; const WidgetConfig numConf PROGMEM = { 0, 110, 35, WA_CENTER }; const WidgetConfig apNameConf PROGMEM = { TFT_FRAMEWDT, 38, 2, WA_CENTER }; @@ -57,8 +54,8 @@ const VUBandsConfig bandsConf PROGMEM = { 19, 90, 2, 2, 10, 2 }; /* STRINGS */ const char numtxtFmt[] PROGMEM = "%d"; const char rssiFmt[] PROGMEM = "WiFi %d"; -const char iptxtFmt[] PROGMEM = "\010 %s"; -const char voltxtFmt[] PROGMEM = "%d"; +const char iptxtFmt[] PROGMEM = "%s"; +const char voltxtFmt[] PROGMEM = "\023\025%d"; const char bitrateFmt[] PROGMEM = "%d kBs"; /* MOVES */ /* { left, top, width } */ diff --git a/yoRadio/src/displays/displayILI9225.cpp b/yoRadio/src/displays/displayILI9225.cpp index 9e80e8a..7f1be4f 100644 --- a/yoRadio/src/displays/displayILI9225.cpp +++ b/yoRadio/src/displays/displayILI9225.cpp @@ -103,6 +103,11 @@ void DspCore::initDisplay() { flip(); setTextSize(1); // GIVE_MUTEX(); + 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) { @@ -111,22 +116,23 @@ void DspCore::drawLogo(uint16_t top) { GIVE_MUTEX(); } -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 - 4, PLMITEMS); - setTextSize(2); - int yStart = (height() / 2 - PLMITEMHEIGHT / 2) - PLMITEMHEIGHT * (PLMITEMS - 1) / 2 + 3; - for (byte i = 0; i < PLMITEMS; i++) { - if (i == 4) { - strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1); - } else { - setTextColor(config.theme.playlist[abs(i - 4)-1], config.theme.background); - setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT); - fillRect(0, yStart + i * PLMITEMHEIGHT-1, width(), PLMITEMHEIGHT-7, config.theme.background); - print(utf8Rus(plMenu[i], true)); - } +} + +void DspCore::drawPlaylist(uint16_t currentItem) { + uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount); + if(lastPos