pl_text_size_009

This commit is contained in:
e2002
2023-03-07 11:39:55 +03:00
parent 85002490ed
commit 617bbba589
18 changed files with 153 additions and 129 deletions

View File

@@ -423,20 +423,33 @@ void Config::loadStation(uint16_t ls) {
playlist.close();
}
void Config::fillPlMenu(char plmenu[][40], int from, byte count, bool removeNum) {
char * Config::stationByNum(uint16_t num){
File playlist = SPIFFS.open(REAL_PLAYL, "r");
File index = SPIFFS.open(REAL_INDEX, "r");
index.seek((num - 1) * 4, SeekSet);
uint32_t pos;
memset(_stationBuf, 0, BUFLEN/2);
index.readBytes((char *) &pos, 4);
index.close();
playlist.seek(pos, SeekSet);
strncpy(_stationBuf, playlist.readStringUntil('\t').c_str(), BUFLEN/2);
playlist.close();
return _stationBuf;
}
uint8_t Config::fillPlMenu(int from, uint8_t count) {
int ls = from;
byte c = 0;
uint8_t c = 0;
bool finded = false;
char sName[BUFLEN], sUrl[BUFLEN];
int sOvol;
if (store.countStation == 0) {
return;
return 0;
}
File playlist = SPIFFS.open(REAL_PLAYL, "r");
File index = SPIFFS.open(REAL_INDEX, "r");
while (true) {
if (ls < 1) {
ls++;
display.printPLitem(c, "");
c++;
continue;
}
@@ -449,24 +462,16 @@ void Config::fillPlMenu(char plmenu[][40], int from, byte count, bool removeNum)
playlist.seek(pos, SeekSet);
}
while (playlist.available()) {
if (parseCSV(playlist.readStringUntil('\n').c_str(), sName, sUrl, sOvol)) {
if(config.store.numplaylist){
if(removeNum){
strlcpy(plmenu[c], sName, 39);
}else{
char buf[BUFLEN+10];
sprintf(buf, "%d %s", (int)(from+c), sName);
strlcpy(plmenu[c], buf, 39);
}
}else{
strlcpy(plmenu[c], sName, 39);
}
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());
c++;
}
if (c >= count) break;
}
break;
}
return c;
playlist.close();
}

View File

@@ -186,7 +186,8 @@ class Config {
void setSmartStart(byte ss);
void initPlaylist();
void indexPlaylist();
void fillPlMenu(char plmenu[][40], int from, byte count, bool removeNum = false);
uint8_t fillPlMenu(int from, uint8_t count);
char * stationByNum(uint16_t num);
void setTimezone(int8_t tzh, int8_t tzm);
void setTimezoneOffset(uint16_t tzo);
uint16_t getTimezoneOffset();
@@ -209,6 +210,7 @@ class Config {
bool checkNoMedia(const char* path);
void _initHW();
bool _isFSempty();
char _stationBuf[BUFLEN/2];
};
extern Config config;

View File

@@ -85,6 +85,7 @@ void Display::_buildPager(){
#else
_plcurrent.init("*", playlistConf, config.theme.plcurrent, config.theme.plcurrentbg);
#endif
_plcurrent.moveTo({TFT_FRAMEWDT, (uint16_t)(dsp.plYStart+dsp.plCurrentPos*dsp.plItemHeight), (int16_t)playlistConf.width});
#ifndef HIDE_TITLE2
_title2 = new ScrollWidget("*", title2Conf, config.theme.title2, config.theme.background);
#endif
@@ -153,7 +154,11 @@ void Display::_buildPager(){
pages[PG_DIALOG]->addPage(&_footer);
#endif
if(_plbackground) pages[PG_PLAYLIST]->addWidget( _plbackground);
if(_plbackground) {
pages[PG_PLAYLIST]->addWidget( _plbackground);
_plbackground->setHeight(dsp.plItemHeight);
_plbackground->moveTo({0,(uint16_t)(dsp.plYStart+dsp.plCurrentPos*dsp.plItemHeight-playlistConf.widget.textsize*2), (int16_t)playlBGConf.width});
}
pages[PG_PLAYLIST]->addWidget(&_plcurrent);
for(const auto& p: pages) _pager.addPage(p);
@@ -286,26 +291,18 @@ void Display::resetQueue(){
}
void Display::_drawPlaylist() {
char buf[PLMITEMLENGHT];
dsp.drawPlaylist(currentPlItem, buf);
_plcurrent.setText(buf);
/*#ifdef USE_NEXTION
nextion.drawPlaylist(currentPlItem);
#endif*/
dsp.drawPlaylist(currentPlItem);
_setReturnTicker(30);
}
void Display::_drawNextStationNum(uint16_t num) {
char plMenu[1][40];
char currentItemText[40] = {0};
config.fillPlMenu(plMenu, num, 1, true);
strlcpy(currentItemText, plMenu[0], 39);
_setReturnTicker(30);
_meta.setText(currentItemText);
_meta.setText(config.stationByNum(num));
_nums.setText(num, "%d");
/*#ifdef USE_NEXTION
nextion.drawNextStationNum(num);
#endif*/
}
void Display::printPLitem(uint8_t pos, const char* item){
dsp.printPLitem(pos, item, _plcurrent);
}
void Display::putRequest(displayRequestType_e type, int payload){

View File

@@ -47,6 +47,7 @@ class Display {
bool deepsleep();
void wakeup();
void setContrast();
void printPLitem(uint8_t pos, const char* item);
private:
ScrollWidget _meta, _title1, _plcurrent;
ScrollWidget *_weather;
@@ -105,6 +106,7 @@ class Display {
void setContrast(){}
bool deepsleep(){return true;}
void wakeup(){}
void printPLitem(uint8_t pos, const char* item){}
};
#endif

View File

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

View File

@@ -11,9 +11,6 @@
#define DSP_WIDTH 320
#define TFT_FRAMEWDT 8
#define MAX_WIDTH DSP_WIDTH-TFT_FRAMEWDT*2
#define PLMITEMS 11
#define PLMITEMLENGHT 40
#define PLMITEMHEIGHT 22
#define bootLogoTop 68

View File

@@ -11,9 +11,6 @@
#define DSP_WIDTH 84
#define TFT_FRAMEWDT 0
#define MAX_WIDTH DSP_WIDTH
#define PLMITEMS 7
#define PLMITEMLENGHT 40
#define PLMITEMHEIGHT 10
#define SCROLLDELAY 180
#define HIDE_TITLE2

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 bootLogoTop 68
@@ -21,7 +18,7 @@
const ScrollConfig metaConf PROGMEM = {{ TFT_FRAMEWDT, TFT_FRAMEWDT, 2, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 3, 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

@@ -10,9 +10,6 @@
#define DSP_WIDTH 160
#define TFT_FRAMEWDT 4
#define MAX_WIDTH DSP_WIDTH-TFT_FRAMEWDT*2
#define PLMITEMS 7
#define PLMITEMLENGHT 40
#define PLMITEMHEIGHT 21
#define bootLogoTop 68
@@ -20,7 +17,7 @@
const ScrollConfig metaConf PROGMEM = {{ TFT_FRAMEWDT, TFT_FRAMEWDT, 2, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 3, 30 };
const ScrollConfig title1Conf PROGMEM = {{ TFT_FRAMEWDT, 26, 1, WA_LEFT }, 140, true, MAX_WIDTH-24, 5000, 3, 30 };
const ScrollConfig title2Conf PROGMEM = {{ TFT_FRAMEWDT, 36, 1, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 3, 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, 3, 30 };
const ScrollConfig weatherConf PROGMEM = {{ TFT_FRAMEWDT, 42, 1, WA_LEFT }, 140, true, MAX_WIDTH, 0, 3, 30 };
@@ -36,8 +33,8 @@ const FillConfig heapbarConf PROGMEM = {{ 0, 127, 0, WA_LEFT }, DSP_WIDTH,
const WidgetConfig bootstrConf PROGMEM = { 0, 110, 1, WA_CENTER };
const WidgetConfig bitrateConf PROGMEM = { TFT_FRAMEWDT, 26, 1, WA_RIGHT };
//const WidgetConfig bitrateConf PROGMEM = { TFT_FRAMEWDT, 99, 1, WA_LEFT };
const WidgetConfig voltxtConf PROGMEM = { 32, 108, 1, WA_RIGHT };
const WidgetConfig iptxtConf PROGMEM = { TFT_FRAMEWDT, 108, 1, WA_LEFT };
const WidgetConfig voltxtConf PROGMEM = { TFT_FRAMEWDT, 108, 1, WA_LEFT };
const WidgetConfig iptxtConf PROGMEM = { TFT_FRAMEWDT, 108, 1, WA_CENTER };
const WidgetConfig rssiConf PROGMEM = { TFT_FRAMEWDT, 108, 1, WA_RIGHT };
const WidgetConfig numConf PROGMEM = { 0, 86, 35, WA_CENTER };
const WidgetConfig apNameConf PROGMEM = { 0, 40, 1, WA_CENTER };
@@ -57,8 +54,8 @@ const BitrateConfig fullbitrateConf PROGMEM = {{DSP_WIDTH-TFT_FRAMEWDT-19, 23, 1
/* STRINGS */
const char numtxtFmt[] PROGMEM = "%d";
const char rssiFmt[] PROGMEM = "%d";
const char iptxtFmt[] PROGMEM = "%s";
const char voltxtFmt[] PROGMEM = "%d";
const char iptxtFmt[] PROGMEM = " %s";
const char voltxtFmt[] PROGMEM = "\023\025%d";
const char bitrateFmt[] PROGMEM = "%d";
/* MOVES */ /* { left, top, width (0 - auto, -1 - lock } */
const MoveConfig clockMove PROGMEM = { 16, 94, 0};

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,7 +22,7 @@
const ScrollConfig metaConf PROGMEM = {{ TFT_FRAMEWDT, TFT_FRAMEWDT, 2, WA_LEFT }, 140, true, MAX_WIDTH, 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 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 }; // ПОГОДА!!

View File

@@ -11,9 +11,9 @@
#define DSP_WIDTH 320
#define TFT_FRAMEWDT 8
#define MAX_WIDTH DSP_WIDTH-TFT_FRAMEWDT*2
#define PLMITEMS 11
#define PLMITEMLENGHT 40
#define PLMITEMHEIGHT 22
//#define PLMITEMS 11
//#define PLMITEMLENGHT 40
//#define PLMITEMHEIGHT 22
#define bootLogoTop 68

View File

@@ -24,29 +24,35 @@ void DspCore::initDisplay() {
cp437(true);
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() - 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';
}
config.fillPlMenu(plMenu, currentItem - 5, PLMITEMS);
setTextSize(2);
int yStart = (height() / 2 - PLMITEMHEIGHT / 2) - PLMITEMHEIGHT * (PLMITEMS - 1) / 2 + 3;
//fillRect(0, (height() / 2 - PLMITEMHEIGHT / 2) - 1, width(), PLMITEMHEIGHT + 2, config.theme.meta);
for (byte i = 0; i < PLMITEMS; i++) {
if (i == 5) {
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){
setTextSize(playlistConf.widget.textsize);
if (pos == plCurrentPos) {
current.setText(item);
} 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-4, config.theme.background);
print(utf8Rus(plMenu[i], true));
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));
}
}
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

@@ -71,6 +71,12 @@ 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) {
@@ -78,22 +84,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';
}
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);
void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){
setTextSize(playlistConf.widget.textsize);
if (pos == plCurrentPos) {
current.setText(item);
} else {
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
fillRect(0, yStart + i * PLMITEMHEIGHT, width(), PLMITEMHEIGHT - 1, TFT_BG);
print(utf8Rus(plMenu[i], true));
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));
}
}
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

@@ -29,6 +29,12 @@ 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) {
@@ -40,24 +46,23 @@ void DspCore::drawLogo(uint16_t top) {
#endif
}
void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
for (byte i = 0; i < PLMITEMS; i++) {
plMenu[i][0] = '\0';
}
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);
void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){
setTextSize(playlistConf.widget.textsize);
if (pos == plCurrentPos) {
current.setText(item);
} else {
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
fillRect(0, yStart + i * PLMITEMHEIGHT - 1, DSP_WIDTH, PLMITEMHEIGHT - 4, config.theme.background);
print(utf8Rus(plMenu[i], true));
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));
}
}
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,34 @@ 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';
}
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);
void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){
setTextSize(playlistConf.widget.textsize);
if (pos == plCurrentPos) {
current.setText(item);
} 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));
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));
}
}
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

@@ -1,9 +1,11 @@
#ifndef common_gfx_h
#define common_gfx_h
public:
uint16_t plItemHeight, plTtemsCount, plCurrentPos;
int plYStart;
public:
DspCore();
char plMenu[PLMITEMS][PLMITEMLENGHT];
//char plMenu[PLMITEMS][PLMITEMLENGHT];
void initDisplay();
void drawLogo(uint16_t top);
void clearDsp(bool black=false);
@@ -11,7 +13,7 @@
void printClock(uint16_t top, uint16_t rightspace, uint16_t timeheight, bool redraw);
void clearClock();
char* utf8Rus(const char* str, bool uppercase);
void drawPlaylist(uint16_t currentItem, char* currentItemText);
void drawPlaylist(uint16_t currentItem);
void loop(bool force=false);
void charSize(uint8_t textsize, uint8_t& width, uint16_t& height);
#ifndef DSP_LCD
@@ -62,6 +64,7 @@
void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
uint16_t drawChar(uint16_t x, uint16_t y, uint16_t ch, uint16_t color = COLOR_WHITE);
#endif
void printPLitem(uint8_t pos, const char* item, ScrollWidget& current);
private:
char _timeBuf[20], _dateBuf[20], _oldTimeBuf[20], _oldDateBuf[20], _bufforseconds[4], _buffordate[40];
uint16_t _timewidth, _timeleft, _datewidth, _dateleft, _oldtimeleft, _oldtimewidth, _olddateleft, _olddatewidth, clockTop, clockRightSpace, clockTimeHeight, _dotsLeft;

View File

@@ -19,6 +19,10 @@ void FillWidget::_draw(){
dsp.fillRect(_config.left, _config.top, _width, _height, _bgcolor);
}
void FillWidget::setHeight(uint16_t newHeight){
_height = newHeight;
//_draw();
}
/************************
TEXT WIDGET
************************/

View File

@@ -140,6 +140,7 @@ class FillWidget: public Widget {
FillWidget() {}
FillWidget(FillConfig conf, uint16_t bgcolor) { init(conf, bgcolor); }
void init(FillConfig conf, uint16_t bgcolor);
void setHeight(uint16_t newHeight);
protected:
uint16_t _height;
void _draw();