This commit is contained in:
e2002
2022-03-30 10:23:16 +03:00
parent 110e25cb90
commit 22ba88d672
33 changed files with 1763 additions and 101 deletions

View File

@@ -8,10 +8,14 @@
#include "../../config.h"
#include "../../network.h"
#ifndef DEF_SPI_FREQ
#define DEF_SPI_FREQ 40000000UL /* set it to 0 for system default */
#endif
const char *dow[7] = {"вс","пн","вт","ср","чт","пт","сб"};
const char *mnths[12] = {"января","февраля","марта","апреля","мая","июня","июля","августа","сентября","октября","ноября","декабря"};
DspCore::DspCore(): Adafruit_ST7789(&SPI, TFT_CS, TFT_DC, TFT_RST) {
DspCore::DspCore(): Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST) {
}
@@ -110,6 +114,7 @@ void DspCore::apScreen() {
void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
init(240,320);
if(DEF_SPI_FREQ > 0) setSPISpeed(DEF_SPI_FREQ);
invertDisplay(TFT_INVERT);
cp437(true);
fillScreen(TFT_BG);
@@ -144,6 +149,7 @@ void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
print(utf8Rus(plMenu[i], true));
}
yield();
}
}
@@ -155,6 +161,7 @@ void DspCore::drawScrollFrame(uint16_t texttop, uint16_t textheight, uint16_t bg
if (TFT_FRAMEWDT==0) return;
fillRect(0, texttop, TFT_FRAMEWDT, textheight, bg);
fillRect(swidth - TFT_FRAMEWDT, texttop, TFT_FRAMEWDT, textheight, bg);
yield();
}
void DspCore::getScrolBbounds(const char* text, const char* separator, byte textsize, uint16_t &tWidth, uint16_t &tHeight, uint16_t &sWidth) {
@@ -170,6 +177,7 @@ void DspCore::getScrolBbounds(const char* text, const char* separator, byte text
void DspCore::clearScroll(uint16_t texttop, uint16_t textheight, uint16_t bg) {
fillRect(0, texttop, swidth, textheight, bg);
yield();
}
void DspCore::centerText(const char* text, uint16_t y, uint16_t fg, uint16_t bg) {
@@ -183,6 +191,7 @@ void DspCore::centerText(const char* text, uint16_t y, uint16_t fg, uint16_t bg)
setCursor((swidth - w) / 2, y);
fillRect((swidth-w)/2-5, y, w+10, h, bg);
print(txt);
yield();
}
void DspCore::rightText(const char* text, uint16_t y, uint16_t fg, uint16_t bg, bool fliprect, uint16_t delta) {
@@ -193,6 +202,7 @@ void DspCore::rightText(const char* text, uint16_t y, uint16_t fg, uint16_t bg,
setCursor(swidth - w - TFT_FRAMEWDT - delta, y);
fillRect(swidth - w - TFT_FRAMEWDT, fliprect?y-h:y, w, h, bg);
print(text);
yield();
}
void DspCore::displayHeapForDebug() {
@@ -213,6 +223,7 @@ void DspCore::displayHeapForDebug() {
byte sbw = map(aprcnt, 0, 100 , 0, swidth);
fillRect(0, sheight - 2, sbw, 2, SILVER);
#endif
yield();
}
void DspCore::printClock(const char* timestr) {
@@ -238,11 +249,13 @@ void DspCore::printClock(struct tm timeinfo, bool dots, bool redraw){
clwidth = wot+clsp+(swidth>240?46:34);
fillRect(swidth-TFT_FRAMEWDT-clwidth, cltop-hot, clwidth, hot+3, TFT_BG);
strlcpy(oldTimeBuf, timeBuf, 20);
setTextSize(1);
getTextBounds(timeBuf, 0, 0, &x1, &y1, &wot, &hot);
clwidth = wot+clsp+(swidth>240?46:34);
clleft=swidth-TFT_FRAMEWDT-clwidth;
setTextColor(TFT_LOGO, TFT_BG);
setCursor(clleft, cltop);
setTextSize(1);
print(timeBuf);
setFont();
@@ -264,13 +277,14 @@ void DspCore::printClock(struct tm timeinfo, bool dots, bool redraw){
setCursor(clleft+wot+clsp, cltop-hot+1);
sprintf(timeBuf, "%02d", timeinfo.tm_sec);
print(timeBuf);
yield();
}
void DspCore::drawVolumeBar(bool withNumber) {
int16_t vTop = sheight - TFT_FRAMEWDT * 2;
int16_t volTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT - 2;
int16_t vWidth = swidth - TFT_FRAMEWDT *2;
uint8_t ww = map(config.store.volume, 0, 254, 0, vWidth - 2);
uint16_t ww = map(config.store.volume, 0, 254, 0, vWidth - 2);
fillRect(TFT_FRAMEWDT, vTop - 2, vWidth, 6, TFT_BG);
drawRect(TFT_FRAMEWDT, vTop - 2, vWidth, 6, TFT_LOGO);
fillRect(TFT_FRAMEWDT + 1, vTop - 1, ww, 5, TFT_LOGO);
@@ -294,6 +308,7 @@ void DspCore::drawVolumeBar(bool withNumber) {
print(volstr);
setFont();
}
yield();
}
void DspCore::drawNextStationNum(uint16_t num) {
@@ -349,6 +364,7 @@ void DspCore::set_Cursor(int16_t x, int16_t y) {
void DspCore::printText(const char* txt) {
print(txt);
yield();
}
void DspCore::loop() {