This commit is contained in:
e2002
2022-04-07 09:06:28 +03:00
parent 40f194ab26
commit a9d77271b9
17 changed files with 1044 additions and 19 deletions

View File

@@ -1,9 +1,13 @@
#include "../../options.h"
#if DSP_MODEL==1
#if DSP_MODEL==DSP_ST7735
#include "displayST7735.h"
#include <SPI.h>
#ifdef DSP_MINI
#include "fonts/bootlogo40.h"
#else
#include "fonts/bootlogo.h"
#endif
#include "../../player.h"
#include "../../config.h"
#include "../../network.h"
@@ -107,6 +111,7 @@ void DspCore::apScreen() {
void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
initR(DTYPE);
cp437(true);
invertDisplay((DTYPE==INITR_MINI160x80)?TFT_INVERT:!TFT_INVERT);
fillScreen(TFT_BG);
setRotation(TFT_ROTATE);
setTextWrap(false);
@@ -118,7 +123,11 @@ void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
}
void DspCore::drawLogo() {
#ifdef DSP_MINI
drawRGBBitmap((swidth - 62) / 2, 5, bootlogo40, 62, 40);
#else
drawRGBBitmap((swidth - 99) / 2, 18, bootlogo2, 99, 64);
#endif
}
// http://greekgeeks.net/#maker-tools_convertColor
@@ -133,7 +142,7 @@ void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
config.fillPlMenu(plMenu, currentItem - 3, PLMITEMS);
setTextSize(2);
int yStart = (sheight / 2 - PLMITEMHEIGHT / 2) - PLMITEMHEIGHT * (PLMITEMS - 1) / 2 + 3;
fillRect(0, (sheight / 2 - PLMITEMHEIGHT / 2) - 1, swidth, PLMITEMHEIGHT + 2, TFT_LOGO);
//fillRect(0, (sheight / 2 - PLMITEMHEIGHT / 2) - 1, swidth, PLMITEMHEIGHT + 2, TFT_LOGO);
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);
@@ -169,7 +178,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);
fillRect(0, texttop-2, swidth, textheight+3, bg);
}
void DspCore::centerText(const char* text, byte y, uint16_t fg, uint16_t bg) {
@@ -194,6 +203,7 @@ void DspCore::rightText(const char* text, byte y, uint16_t fg, uint16_t bg) {
}
void DspCore::displayHeapForDebug() {
#ifndef DSP_MINI
int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT * 2 - 2;
setTextSize(1);
setTextColor(DARK_GRAY, TFT_BG);
@@ -211,6 +221,7 @@ void DspCore::displayHeapForDebug() {
byte sbw = map(aprcnt, 0, 100 , 0, swidth);
fillRect(0, sheight - 2, sbw, 2, SILVER);
#endif
#endif
}
void DspCore::setClockBounds(){
@@ -220,6 +231,7 @@ void DspCore::setClockBounds(){
uint16_t header = TFT_FRAMEWDT + 4 * TFT_LINEHGHT;
uint16_t footer = TFT_FRAMEWDT * 2 + TFT_LINEHGHT + 5;
clockY = header + (sheight - header - footer) / 2 - cheight / 2;
if(DTYPE==INITR_MINI160x80) clockY = clockY-6;
setFont();
}
@@ -275,14 +287,26 @@ void DspCore::printClock(struct tm timeinfo, bool dots, bool redraw){
setFont();
yield();
}
#ifdef DSP_MINI
#define VTOP TITLE_TOP1+6
#else
#define VTOP 48
#endif
void DspCore::drawVolumeBar(bool withNumber) {
int16_t vTop = sheight - TFT_FRAMEWDT * 2;
int16_t vWidth = swidth - TFT_FRAMEWDT - 4;
#ifdef DSP_MINI
int16_t vTop = sheight - TFT_FRAMEWDT - 2;
int16_t vWidth = swidth - TFT_FRAMEWDT * 2;
uint8_t ww = map(config.store.volume, 0, 254, 0, vWidth);
fillRect(TFT_FRAMEWDT, vTop, vWidth, 2, TFT_BG);
fillRect(TFT_FRAMEWDT, vTop, ww, 2, TFT_LOGO);
#else
int16_t vTop = sheight - TFT_FRAMEWDT - 6;
int16_t vWidth = swidth - TFT_FRAMEWDT * 2;
uint8_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);
#endif
if (withNumber) {
setTextSize(1);
setTextColor(TFT_FG);
@@ -292,8 +316,8 @@ void DspCore::drawVolumeBar(bool withNumber) {
int16_t x1, y1;
sprintf(volstr, "%d", config.store.volume);
getTextBounds(volstr, 0, 0, &x1, &y1, &wv, &hv);
fillRect(TFT_FRAMEWDT, 48, swidth - TFT_FRAMEWDT / 2, hv + 3, TFT_BG);
setCursor((swidth - wv) / 2, 48 + hv);
fillRect(TFT_FRAMEWDT, VTOP, swidth - TFT_FRAMEWDT / 2, hv + 3, TFT_BG);
setCursor((swidth - wv) / 2, VTOP + hv);
print(volstr);
setFont();
}
@@ -308,8 +332,8 @@ void DspCore::drawNextStationNum(uint16_t num) {
int16_t x1, y1;
sprintf(numstr, "%d", num);
getTextBounds(numstr, 0, 0, &x1, &y1, &wv, &hv);
fillRect(TFT_FRAMEWDT, 48, swidth - TFT_FRAMEWDT / 2, hv + 3, TFT_BG);
setCursor((swidth - wv) / 2, 48 + hv);
fillRect(TFT_FRAMEWDT, VTOP, swidth - TFT_FRAMEWDT / 2, hv + 3, TFT_BG);
setCursor((swidth - wv) / 2, VTOP + hv);
print(numstr);
setFont();
}