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

@@ -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';
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;
//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);
} 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));
}
}
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';
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

@@ -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';
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, DSP_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,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';
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

@@ -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();