v0.6.110
This commit is contained in:
@@ -30,7 +30,9 @@
|
||||
#include <FFat.h>
|
||||
#endif // SDFATFS_USED
|
||||
|
||||
#ifndef AUDIOBUFFER_MULTIPLIER
|
||||
#define AUDIOBUFFER_MULTIPLIER 13
|
||||
#endif
|
||||
|
||||
#ifdef SDFATFS_USED
|
||||
typedef File32 File;
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
#ifndef _vs1053_ext
|
||||
#define _vs1053_ext
|
||||
|
||||
#ifndef AUDIOBUFFER_MULTIPLIER
|
||||
#define AUDIOBUFFER_MULTIPLIER 13
|
||||
#endif
|
||||
|
||||
#define VS1053VOLM 128 // 128 or 96 only
|
||||
#define VS1053VOL(v) (VS1053VOLM==128?log10(((float)v+1)) * 50.54571334 + 128:log10(((float)v+1)) * 64.54571334 + 96)
|
||||
@@ -269,7 +271,7 @@ public:
|
||||
bool isRunning() {/*Serial.printf("m_f_running=%d\n", m_f_running); */return m_f_running;}
|
||||
void setBalance(int8_t bal = 0);
|
||||
void setTone(int8_t gainLowPass, int8_t gainBandPass, int8_t gainHighPass);
|
||||
|
||||
|
||||
// implement several function with respect to the index of string
|
||||
bool startsWith (const char* base, const char* str) { return (strstr(base, str) - base) == 0;}
|
||||
bool endsWith (const char* base, const char* str) {
|
||||
|
||||
@@ -169,7 +169,7 @@ void DspCore::printText(const char* txt) {
|
||||
|
||||
}
|
||||
|
||||
void DspCore::loop() {
|
||||
void DspCore::loop(bool force) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class DspCore {
|
||||
void rssi(const char* str);
|
||||
void ip(const char* str);
|
||||
void drawPlaylist(uint16_t currentItem, char* currentItemText);
|
||||
void loop();
|
||||
void loop(bool force=false);
|
||||
private:
|
||||
uint16_t swidth, sheight;
|
||||
|
||||
|
||||
@@ -109,7 +109,6 @@ void DspCore::apScreen() {
|
||||
}
|
||||
|
||||
void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
|
||||
//begin(26000000L); /*багиловим*/
|
||||
begin(); /* SPI_DEFAULT_FREQ 40000000 */
|
||||
invertDisplay(TFT_INVERT);
|
||||
cp437(true);
|
||||
@@ -143,6 +142,7 @@ void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
|
||||
} else {
|
||||
setTextColor(iclrs[abs(i - 4)-1], TFT_BG);
|
||||
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
|
||||
fillRect(0, yStart + i * PLMITEMHEIGHT-1, swidth, PLMITEMHEIGHT-4, TFT_BG);
|
||||
print(utf8Rus(plMenu[i], true));
|
||||
}
|
||||
}
|
||||
@@ -154,8 +154,8 @@ void DspCore::clearDsp() {
|
||||
|
||||
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);
|
||||
fillRect(0, texttop, TFT_FRAMEWDT, textheight, bg);
|
||||
}
|
||||
|
||||
void DspCore::getScrolBbounds(const char* text, const char* separator, byte textsize, uint16_t &tWidth, uint16_t &tHeight, uint16_t &sWidth) {
|
||||
@@ -365,7 +365,7 @@ void DspCore::printText(const char* txt) {
|
||||
print(txt);
|
||||
}
|
||||
|
||||
void DspCore::loop() {
|
||||
void DspCore::loop(bool force) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,10 @@
|
||||
#define TITLE_SIZE1 2
|
||||
#define TITLE_SIZE2 2
|
||||
|
||||
#if !defined(SCROLLDELTA) || !defined(SCROLLTIME)
|
||||
#define SCROLLDELTA 4
|
||||
#define SCROLLTIME 60
|
||||
#define SCROLLTIME 40
|
||||
#endif
|
||||
|
||||
#define PLMITEMS 9
|
||||
#define PLMITEMLENGHT 40
|
||||
@@ -53,7 +55,7 @@ class DspCore: public Adafruit_ILI9341 {
|
||||
void rssi(const char* str);
|
||||
void ip(const char* str);
|
||||
void drawPlaylist(uint16_t currentItem, char* currentItemText);
|
||||
void loop();
|
||||
void loop(bool force=false);
|
||||
private:
|
||||
uint16_t swidth, sheight;
|
||||
char oldTimeBuf[20];
|
||||
|
||||
@@ -52,6 +52,7 @@ void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
|
||||
for (byte i = 0; i < PLMITEMS; i++) {
|
||||
plMenu[i][0] = '\0';
|
||||
}
|
||||
|
||||
config.fillPlMenu(plMenu, currentItem, PLMITEMS);
|
||||
for (byte i = 0; i < PLMITEMS; i++) {
|
||||
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
|
||||
@@ -167,11 +168,10 @@ void DspCore::printText(const char* txt) {
|
||||
setCursor(nextX, yOffset);
|
||||
}
|
||||
|
||||
void DspCore::loop() {
|
||||
void DspCore::loop(bool force) {
|
||||
if (checkdelay(SCROLLTIME, loopdelay)) {
|
||||
//display();
|
||||
}
|
||||
yield();
|
||||
}
|
||||
|
||||
boolean DspCore::checkdelay(int m, unsigned long & tstamp) {
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#define SCROLLDELTA 1
|
||||
#define SCROLLTIME 250
|
||||
|
||||
#define BOOTSTR_TOP2 0
|
||||
#define BOOTSTR_TOP1 1
|
||||
#define STARTTIME_PL 2000
|
||||
@@ -57,7 +58,7 @@ class DspCore: public LiquidCrystal {
|
||||
void rssi(const char* str);
|
||||
void ip(const char* str);
|
||||
void drawPlaylist(uint16_t currentItem, char* currentItemText);
|
||||
void loop();
|
||||
void loop(bool force=false);
|
||||
private:
|
||||
uint16_t swidth, sheight, xOffset, yOffset;
|
||||
int16_t nextX;
|
||||
|
||||
@@ -153,6 +153,7 @@ void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
|
||||
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
|
||||
} else {
|
||||
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
|
||||
fillRect(0, yStart + i * PLMITEMHEIGHT, swidth, PLMITEMHEIGHT - 1, TFT_BG);
|
||||
print(utf8Rus(plMenu[i], true));
|
||||
}
|
||||
}
|
||||
@@ -309,11 +310,10 @@ void DspCore::printText(const char* txt) {
|
||||
print(txt);
|
||||
}
|
||||
|
||||
void DspCore::loop() {
|
||||
if (checkdelay(83, loopdelay)) {
|
||||
void DspCore::loop(bool force) {
|
||||
if (checkdelay(SCROLLTIME, loopdelay) || force) {
|
||||
display();
|
||||
}
|
||||
yield();
|
||||
}
|
||||
|
||||
boolean DspCore::checkdelay(int m, unsigned long &tstamp) {
|
||||
|
||||
@@ -11,8 +11,13 @@
|
||||
#define TFT_LINEHGHT 8
|
||||
#define TFT_FRAMEWDT 0
|
||||
|
||||
#define SCROLLDELTA 8
|
||||
#define SCROLLTIME 332
|
||||
#if !defined(SCROLLDELTA) || !defined(SCROLLTIME)
|
||||
//#define SCROLLDELTA 8
|
||||
//#define SCROLLTIME 332
|
||||
#define SCROLLDELTA 4
|
||||
#define SCROLLTIME 250
|
||||
#endif
|
||||
|
||||
#define META_SIZE 1
|
||||
#define TITLE_TOP1 TFT_FRAMEWDT + TFT_LINEHGHT+1
|
||||
#define TITLE_SIZE2 0
|
||||
@@ -50,7 +55,7 @@ class DspCore: public Adafruit_PCD8544 {
|
||||
void rssi(const char* str);
|
||||
void ip(const char* str);
|
||||
void drawPlaylist(uint16_t currentItem, char* currentItemText);
|
||||
void loop();
|
||||
void loop(bool force=false);
|
||||
private:
|
||||
uint16_t swidth, sheight;
|
||||
unsigned long loopdelay;
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
#define LOGO_WIDTH 21
|
||||
#define LOGO_HEIGHT 32
|
||||
|
||||
#ifndef I2CFREQ_HZ
|
||||
#define I2CFREQ_HZ 4000000UL
|
||||
#endif
|
||||
|
||||
const char *dow[7] = {"вс","пн","вт","ср","чт","пт","сб"};
|
||||
|
||||
const unsigned char logo [] PROGMEM=
|
||||
@@ -30,7 +34,7 @@ const unsigned char logo [] PROGMEM=
|
||||
|
||||
TwoWire I2CSH1106 = TwoWire(0);
|
||||
#if DSP_MODEL==DSP_SH1106
|
||||
DspCore::DspCore(): Adafruit_SH1106G(128, 64, &I2CSH1106, -1) {
|
||||
DspCore::DspCore(): Adafruit_SH1106G(128, 64, &I2CSH1106, -1, I2CFREQ_HZ) {
|
||||
|
||||
}
|
||||
#else
|
||||
@@ -177,9 +181,11 @@ void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
|
||||
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
|
||||
} else {
|
||||
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
|
||||
fillRect(0, yStart + i * PLMITEMHEIGHT, swidth, PLMITEMHEIGHT - 1, TFT_BG);
|
||||
print(utf8Rus(plMenu[i], true));
|
||||
}
|
||||
}
|
||||
display();
|
||||
}
|
||||
|
||||
void DspCore::clearDsp() {
|
||||
@@ -218,6 +224,7 @@ void DspCore::centerText(const char* text, byte y, uint16_t fg, uint16_t bg) {
|
||||
setCursor((swidth - w) / 2, y);
|
||||
fillRect(0, y, swidth, h, bg);
|
||||
print(txt);
|
||||
display();
|
||||
}
|
||||
|
||||
void DspCore::rightText(const char* text, byte y, uint16_t fg, uint16_t bg) {
|
||||
@@ -246,13 +253,14 @@ void DspCore::printClock(struct tm timeinfo, bool dots, bool redraw) {
|
||||
char timeStringBuff[20] = { 0 };
|
||||
strftime(timeStringBuff, sizeof(timeStringBuff), "%H:%M", &timeinfo);
|
||||
setTextSize(2);
|
||||
setCursor(CLCLF, 34);
|
||||
setCursor(CLCLF, (DSP_MODEL==DSP_SH1107)?30:34);
|
||||
setTextColor(TFT_FG, TFT_BG);
|
||||
print(timeStringBuff);
|
||||
setTextSize(1);
|
||||
setCursor(CLCLF + 6*2*5+1, 34+1);
|
||||
setCursor(CLCLF + 6*2*5+1, (DSP_MODEL==DSP_SH1107)?30+1:34+1);
|
||||
sprintf(timeStringBuff, "%02d", timeinfo.tm_sec);
|
||||
print(timeStringBuff);
|
||||
display();
|
||||
}
|
||||
|
||||
void DspCore::drawVolumeBar(bool withNumber) {
|
||||
@@ -270,10 +278,11 @@ 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, 24, swidth - TFT_FRAMEWDT / 2, hv + 3, TFT_BG);
|
||||
fillRect(TFT_FRAMEWDT, 24, swidth - TFT_FRAMEWDT / 2, hv + 3, TFT_BG);;
|
||||
setCursor((swidth - wv) / 2, 24);
|
||||
print(volstr);
|
||||
}
|
||||
display();
|
||||
}
|
||||
|
||||
void DspCore::drawNextStationNum(uint16_t num) {
|
||||
@@ -287,6 +296,7 @@ void DspCore::drawNextStationNum(uint16_t num) {
|
||||
fillRect(TFT_FRAMEWDT, 24, swidth - TFT_FRAMEWDT / 2, hv + 3, TFT_BG);
|
||||
setCursor((swidth - wv) / 2, 24);
|
||||
print(numstr);
|
||||
display();
|
||||
}
|
||||
|
||||
void DspCore::frameTitle(const char* str) {
|
||||
@@ -324,13 +334,13 @@ void DspCore::set_Cursor(int16_t x, int16_t y) {
|
||||
|
||||
void DspCore::printText(const char* txt) {
|
||||
print(txt);
|
||||
display();
|
||||
}
|
||||
|
||||
void DspCore::loop() {
|
||||
if (checkdelay(SCROLLTIME, loopdelay)) {
|
||||
display();
|
||||
void DspCore::loop(bool force) {
|
||||
if (checkdelay(SCROLLTIME, loopdelay) || force) {
|
||||
//display();
|
||||
}
|
||||
yield();
|
||||
}
|
||||
|
||||
boolean DspCore::checkdelay(int m, unsigned long &tstamp) {
|
||||
|
||||
@@ -14,8 +14,15 @@
|
||||
#define TITLE_TOP2 TFT_FRAMEWDT + 3 * TFT_LINEHGHT
|
||||
#define PLCURRENT_SIZE 1
|
||||
#define TFT_FULLTIME 1
|
||||
|
||||
#if DSP_MODEL==DSP_SH1107
|
||||
#define TITLE_SIZE2 0
|
||||
#endif
|
||||
|
||||
#if !defined(SCROLLDELTA) || !defined(SCROLLTIME)
|
||||
#define SCROLLDELTA 3
|
||||
#define SCROLLTIME 83
|
||||
#define SCROLLTIME 60
|
||||
#endif
|
||||
|
||||
#if DSP_MODEL==DSP_SH1106
|
||||
class DspCore: public Adafruit_SH1106G {
|
||||
@@ -49,7 +56,7 @@ class DspCore: public Adafruit_SH1107 {
|
||||
void rssi(const char* str);
|
||||
void ip(const char* str);
|
||||
void drawPlaylist(uint16_t currentItem, char* currentItemText);
|
||||
void loop();
|
||||
void loop(bool force=false);
|
||||
private:
|
||||
uint16_t swidth, sheight;
|
||||
unsigned long loopdelay;
|
||||
|
||||
@@ -13,6 +13,10 @@
|
||||
#define LOGO_WIDTH 21
|
||||
#define LOGO_HEIGHT 32
|
||||
|
||||
#ifndef DEF_SPI_FREQ
|
||||
#define DEF_SPI_FREQ 7000000UL /* set it to 0 for system default */
|
||||
#endif
|
||||
|
||||
const char *dow[7] = {"вс","пн","вт","ср","чт","пт","сб"};
|
||||
|
||||
const unsigned char logo [] PROGMEM=
|
||||
@@ -27,7 +31,7 @@ const unsigned char logo [] PROGMEM=
|
||||
0x1f, 0xff, 0xe0, 0x0f, 0xff, 0xe0, 0x03, 0xff, 0xc0, 0x00, 0xfe, 0x00
|
||||
};
|
||||
|
||||
DspCore::DspCore(): Adafruit_SSD1305(128, 64, &SPI, TFT_DC, TFT_RST, TFT_CS, 7000000UL) {
|
||||
DspCore::DspCore(): Adafruit_SSD1305(128, 64, &SPI, TFT_DC, TFT_RST, TFT_CS, DEF_SPI_FREQ) {
|
||||
|
||||
}
|
||||
|
||||
@@ -161,6 +165,7 @@ void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
|
||||
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
|
||||
} else {
|
||||
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
|
||||
fillRect(0, yStart + i * PLMITEMHEIGHT, swidth, PLMITEMHEIGHT - 1, TFT_BG);
|
||||
print(utf8Rus(plMenu[i], true));
|
||||
}
|
||||
}
|
||||
@@ -303,11 +308,10 @@ void DspCore::printText(const char* txt) {
|
||||
print(txt);
|
||||
}
|
||||
|
||||
void DspCore::loop() {
|
||||
if (checkdelay(FPS, loopdelay)) {
|
||||
void DspCore::loop(bool force) {
|
||||
if (checkdelay(SCROLLTIME, loopdelay) || force) {
|
||||
display();
|
||||
}
|
||||
yield();
|
||||
}
|
||||
|
||||
boolean DspCore::checkdelay(int m, unsigned long &tstamp) {
|
||||
|
||||
@@ -16,9 +16,11 @@
|
||||
#define TITLE_TOP2 TFT_FRAMEWDT + 2 * TFT_LINEHGHT
|
||||
#define PLCURRENT_SIZE 1
|
||||
#define TFT_FULLTIME 1
|
||||
|
||||
#if !defined(SCROLLDELTA) || !defined(SCROLLTIME)
|
||||
#define SCROLLDELTA 3
|
||||
#define SCROLLTIME 83
|
||||
#define FPS 50
|
||||
#endif
|
||||
|
||||
class DspCore: public Adafruit_SSD1305 {
|
||||
public:
|
||||
@@ -48,7 +50,7 @@ class DspCore: public Adafruit_SSD1305 {
|
||||
void rssi(const char* str);
|
||||
void ip(const char* str);
|
||||
void drawPlaylist(uint16_t currentItem, char* currentItemText);
|
||||
void loop();
|
||||
void loop(bool force=false);
|
||||
private:
|
||||
uint16_t swidth, sheight;
|
||||
unsigned long loopdelay;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#define LOGO_WIDTH 21
|
||||
#define LOGO_HEIGHT 32
|
||||
|
||||
const unsigned char logo [] PROGMEM=
|
||||
{
|
||||
0x06, 0x03, 0x00, 0x0f, 0x07, 0x80, 0x1f, 0x8f, 0xc0, 0x1f, 0x8f, 0xc0,
|
||||
@@ -28,9 +29,13 @@ const unsigned char logo [] PROGMEM=
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef I2CFREQ_HZ
|
||||
#define I2CFREQ_HZ 4000000UL
|
||||
#endif
|
||||
|
||||
TwoWire I2CSSD1306 = TwoWire(0);
|
||||
|
||||
DspCore::DspCore(): Adafruit_SSD1306(128, ((DSP_MODEL==DSP_SSD1306)?64:32), &I2CSSD1306, I2C_RST) {
|
||||
DspCore::DspCore(): Adafruit_SSD1306(128, ((DSP_MODEL==DSP_SSD1306)?64:32), &I2CSSD1306, I2C_RST, I2CFREQ_HZ) {
|
||||
|
||||
}
|
||||
|
||||
@@ -177,6 +182,7 @@ void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
|
||||
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
|
||||
} else {
|
||||
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
|
||||
fillRect(0, yStart + i * PLMITEMHEIGHT, swidth, PLMITEMHEIGHT - 1, TFT_BG);
|
||||
print(utf8Rus(plMenu[i], true));
|
||||
}
|
||||
}
|
||||
@@ -330,8 +336,8 @@ void DspCore::printText(const char* txt) {
|
||||
print(txt);
|
||||
}
|
||||
|
||||
void DspCore::loop() {
|
||||
if (checkdelay(83, loopdelay)) {
|
||||
void DspCore::loop(bool force) {
|
||||
if (checkdelay(83, loopdelay) || force) {
|
||||
#if DSP_MODEL==DSP_SSD1306x32
|
||||
if(fillSpaces) printClock(insideClc);
|
||||
#endif
|
||||
|
||||
@@ -9,6 +9,11 @@
|
||||
#define TFT_FRAMEWDT 0
|
||||
#define PLMITEMLENGHT 40
|
||||
|
||||
#if !defined(SCROLLDELTA) || !defined(SCROLLTIME)
|
||||
#define SCROLLDELTA 2
|
||||
#define SCROLLTIME 40
|
||||
#endif
|
||||
|
||||
#if DSP_MODEL==DSP_SSD1306
|
||||
|
||||
#define PLMITEMS 5
|
||||
@@ -65,7 +70,7 @@ class DspCore: public Adafruit_SSD1306 {
|
||||
void rssi(const char* str);
|
||||
void ip(const char* str);
|
||||
void drawPlaylist(uint16_t currentItem, char* currentItemText);
|
||||
void loop();
|
||||
void loop(bool force=false);
|
||||
private:
|
||||
uint16_t swidth, sheight;
|
||||
unsigned long loopdelay;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
|
||||
#ifndef I2CFREQ_HZ
|
||||
#define I2CFREQ_HZ 4000000UL
|
||||
#define I2CFREQ_HZ 6000000UL
|
||||
#endif
|
||||
|
||||
TwoWire tw = TwoWire(0);
|
||||
@@ -155,10 +155,11 @@ void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
|
||||
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
|
||||
} else {
|
||||
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
|
||||
fillRect(0, yStart + i * PLMITEMHEIGHT - 1, swidth, PLMITEMHEIGHT - 4, TFT_BG);
|
||||
print(utf8Rus(plMenu[i], true));
|
||||
}
|
||||
}
|
||||
//display();
|
||||
display();
|
||||
}
|
||||
|
||||
void DspCore::clearDsp() {
|
||||
@@ -196,6 +197,7 @@ void DspCore::centerText(const char* text, byte y, uint16_t fg, uint16_t bg) {
|
||||
setCursor((swidth - w) / 2, y);
|
||||
fillRect(0, y, swidth, h, bg);
|
||||
print(txt);
|
||||
display();
|
||||
}
|
||||
|
||||
void DspCore::rightText(const char* text, byte y, uint16_t fg, uint16_t bg) {
|
||||
@@ -206,7 +208,7 @@ void DspCore::rightText(const char* text, byte y, uint16_t fg, uint16_t bg) {
|
||||
setCursor(swidth - w - TFT_FRAMEWDT, y);
|
||||
fillRect(swidth - w - TFT_FRAMEWDT, y, w, h, bg);
|
||||
print(text);
|
||||
display();
|
||||
//display();
|
||||
}
|
||||
|
||||
void DspCore::displayHeapForDebug() {
|
||||
@@ -242,6 +244,7 @@ void DspCore::printClock(const char* timestr) {
|
||||
}
|
||||
|
||||
void DspCore::drawVolumeBar(bool withNumber) {
|
||||
if (withNumber) delay(150); /* buuuut iiiiit's toooooo faaaast 0000__oooo !!111 ommm____nomm____nomm */
|
||||
int16_t vTop = sheight - TFT_FRAMEWDT * 2;
|
||||
int16_t vWidth = swidth - TFT_FRAMEWDT - 4;
|
||||
uint8_t ww = map(config.store.volume, 0, 254, 0, vWidth - 2);
|
||||
@@ -249,6 +252,7 @@ void DspCore::drawVolumeBar(bool withNumber) {
|
||||
drawRect(TFT_FRAMEWDT, vTop - 2, vWidth, 6, TFT_LOGO);
|
||||
fillRect(TFT_FRAMEWDT + 1, vTop - 1, ww, 5, TFT_LOGO);
|
||||
if (withNumber) {
|
||||
|
||||
setTextSize(1);
|
||||
setTextColor(TFT_FG);
|
||||
setFont(&DS_DIGI28pt7b);
|
||||
@@ -258,11 +262,12 @@ void DspCore::drawVolumeBar(bool withNumber) {
|
||||
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);
|
||||
//fillRect(24, 48, 80, hv + 3, TFT_BG);
|
||||
setCursor((swidth - wv) / 2, 48 + hv);
|
||||
print(volstr);
|
||||
setFont();
|
||||
display();
|
||||
}
|
||||
display();
|
||||
}
|
||||
|
||||
void DspCore::drawNextStationNum(uint16_t num) {
|
||||
@@ -278,11 +283,13 @@ void DspCore::drawNextStationNum(uint16_t num) {
|
||||
setCursor((swidth - wv) / 2, 48 + hv);
|
||||
print(numstr);
|
||||
setFont();
|
||||
display();
|
||||
}
|
||||
|
||||
void DspCore::frameTitle(const char* str) {
|
||||
setTextSize(2);
|
||||
centerText(str, TFT_FRAMEWDT, TFT_LOGO, TFT_BG);
|
||||
//display();
|
||||
}
|
||||
|
||||
void DspCore::rssi(const char* str) {
|
||||
@@ -313,11 +320,12 @@ void DspCore::set_Cursor(int16_t x, int16_t y) {
|
||||
|
||||
void DspCore::printText(const char* txt) {
|
||||
print(txt);
|
||||
display();
|
||||
}
|
||||
|
||||
void DspCore::loop() {
|
||||
if (checkdelay(LOOP_DELAY, loopdelay)) {
|
||||
display();
|
||||
void DspCore::loop(bool force) {
|
||||
if (checkdelay(LOOP_DELAY, loopdelay) || force) {
|
||||
//display();
|
||||
}
|
||||
yield();
|
||||
}
|
||||
|
||||
@@ -13,10 +13,27 @@
|
||||
#define PLMITEMLENGHT 40
|
||||
#define PLMITEMHEIGHT 22
|
||||
#define TITLE_TOP2 TFT_FRAMEWDT + 3 * TFT_LINEHGHT
|
||||
|
||||
/*
|
||||
#ifdef DSP_FPS
|
||||
#if DSP_FPS!=0
|
||||
#define SCROLLDELTA (DSP_FPS>30)?3:(80/DSP_FPS)
|
||||
#define SCROLLTIME (DSP_FPS>30)?34:(1000/DSP_FPS)
|
||||
#else
|
||||
#define SCROLLDELTA 4
|
||||
#define SCROLLTIME 83
|
||||
#define LOOP_DELAY 83
|
||||
#endif
|
||||
#else
|
||||
#define SCROLLDELTA 4
|
||||
#define SCROLLTIME 83
|
||||
#define LOOP_DELAY 40
|
||||
#endif
|
||||
*/
|
||||
#if !defined(SCROLLDELTA) || !defined(SCROLLTIME)
|
||||
#define SCROLLDELTA 4
|
||||
#define SCROLLTIME 83
|
||||
#define LOOP_DELAY 60
|
||||
#endif
|
||||
|
||||
class DspCore: public Adafruit_SSD1327 {
|
||||
public:
|
||||
@@ -46,7 +63,7 @@ class DspCore: public Adafruit_SSD1327 {
|
||||
void rssi(const char* str);
|
||||
void ip(const char* str);
|
||||
void drawPlaylist(uint16_t currentItem, char* currentItemText);
|
||||
void loop();
|
||||
void loop(bool force=false);
|
||||
private:
|
||||
uint16_t swidth, sheight;
|
||||
int16_t x, y;
|
||||
@@ -60,12 +77,18 @@ class DspCore: public Adafruit_SSD1327 {
|
||||
|
||||
extern DspCore dsp;
|
||||
|
||||
/*
|
||||
SSD1327_GRAYTABLE,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
|
||||
0x07, 0x08, 0x10, 0x18, 0x20, 0x2f, 0x38, 0x3f,
|
||||
*/
|
||||
|
||||
/*
|
||||
* TFT COLORS
|
||||
*/
|
||||
#define SILVER 0x7
|
||||
#define TFT_BG 0x0
|
||||
#define TFT_FG 0x8
|
||||
#define TFT_LOGO 0xF
|
||||
#define SILVER 0x07
|
||||
#define TFT_BG 0x00
|
||||
#define TFT_FG 0x08
|
||||
#define TFT_LOGO 0x3f
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,42 +8,6 @@
|
||||
#include "../../config.h"
|
||||
#include "../../network.h"
|
||||
|
||||
class GFXClock {
|
||||
public:
|
||||
GFXClock() {};
|
||||
uint16_t init(Adafruit_ST7735 &tftd, const GFXfont *font, uint16_t fgcolor, uint16_t bgcolor ) {
|
||||
_dsp = &tftd;
|
||||
tftd.setFont(font);
|
||||
tftd.getTextBounds("88:88", 0, 0, &x, &y, &cwidth, &cheight);
|
||||
tftd.setFont();
|
||||
fg = fgcolor;
|
||||
bg = bgcolor;
|
||||
swidth = tftd.width();
|
||||
_canvas = new GFXcanvas1(swidth, cheight + 3);
|
||||
_canvas->setFont(font);
|
||||
_canvas->setTextWrap(false);
|
||||
_canvas->setTextColor(WHITE);
|
||||
uint16_t header = TFT_FRAMEWDT + 4 * TFT_LINEHGHT;
|
||||
uint16_t footer = TFT_FRAMEWDT * 2 + TFT_LINEHGHT + 5;
|
||||
clockY = header + (tftd.height() - header - footer) / 2 - cheight / 2;
|
||||
return cheight;
|
||||
}
|
||||
void print(const char* timestr) {
|
||||
_canvas->fillScreen(BLACK);
|
||||
_canvas->getTextBounds(timestr, 0, 0, &x, &y, &cwidth, &cheight);
|
||||
_canvas->setCursor((swidth - cwidth) / 2 - 4, cheight);
|
||||
_canvas->print(timestr);
|
||||
_dsp->drawBitmap(0, clockY , _canvas->getBuffer(), swidth, cheight + 3, fg, bg);
|
||||
}
|
||||
private:
|
||||
int16_t x, y;
|
||||
uint16_t cwidth, cheight, fg, bg, clockY, swidth;
|
||||
GFXcanvas1 *_canvas;
|
||||
Adafruit_ST7735 *_dsp;
|
||||
};
|
||||
|
||||
GFXClock gclock;
|
||||
|
||||
DspCore::DspCore(): Adafruit_ST7735(&SPI, TFT_CS, TFT_DC, TFT_RST) {
|
||||
|
||||
}
|
||||
@@ -150,7 +114,7 @@ void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
|
||||
screenheight = height();
|
||||
swidth = screenwidth;
|
||||
sheight = screenheight;
|
||||
gclock.init(dsp, &DS_DIGI28pt7b, TFT_LOGO, BLACK);
|
||||
setClockBounds();
|
||||
}
|
||||
|
||||
void DspCore::drawLogo() {
|
||||
@@ -178,6 +142,7 @@ void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
|
||||
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
|
||||
} else {
|
||||
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
|
||||
fillRect(0, yStart + i * PLMITEMHEIGHT - 1, swidth, PLMITEMHEIGHT - 4, TFT_BG);
|
||||
print(utf8Rus(plMenu[i], true));
|
||||
}
|
||||
}
|
||||
@@ -248,8 +213,67 @@ void DspCore::displayHeapForDebug() {
|
||||
#endif
|
||||
}
|
||||
|
||||
void DspCore::setClockBounds(){
|
||||
setFont(&DS_DIGI28pt7b);
|
||||
setTextSize(1);
|
||||
getTextBounds("88:88", 0, 0, &x, &y, &cwidth, &cheight);
|
||||
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;
|
||||
setFont();
|
||||
}
|
||||
|
||||
void DspCore::printClock(const char* timestr) {
|
||||
gclock.print(timestr);
|
||||
|
||||
}
|
||||
|
||||
byte DspCore::getPw(uint16_t ncwidth){
|
||||
byte pw = 6;
|
||||
if(ncwidth<35) pw = 7;
|
||||
if(ncwidth<20) pw = 8;
|
||||
return pw;
|
||||
}
|
||||
|
||||
void DspCore::printClock(struct tm timeinfo, bool dots, bool redraw){
|
||||
char timeBuf[50] = { 0 };
|
||||
char tmpBuf[4] = { 0 };
|
||||
uint16_t ncwidth, ncheight;
|
||||
strftime(timeBuf, sizeof(timeBuf), "%H %M", &timeinfo);
|
||||
setTextSize(1);
|
||||
setFont(&DS_DIGI28pt7b);
|
||||
if(strstr(oldTimeBuf, timeBuf)==NULL || redraw){
|
||||
getTextBounds(oldTimeBuf, 0, 0, &x, &y, &wot, &hot);
|
||||
setCursor((swidth - wot) / 2 - 4, clockY+28+6);
|
||||
setTextColor(TFT_BG);
|
||||
print(oldTimeBuf);
|
||||
dot = (swidth - wot) / 2 - 4;
|
||||
/* dots */
|
||||
strlcpy(tmpBuf, oldTimeBuf, 3);
|
||||
getTextBounds(tmpBuf, 0, 0, &x, &y, &ncwidth, &ncheight);
|
||||
dot = dot + ncwidth + getPw(ncwidth);
|
||||
setCursor(dot, clockY+28+6);
|
||||
print(":");
|
||||
/* dots */
|
||||
|
||||
strlcpy(oldTimeBuf, timeBuf, 20);
|
||||
setTextSize(1);
|
||||
getTextBounds(timeBuf, 0, 0, &x, &y, &ncwidth, &ncheight);
|
||||
setTextColor(TFT_LOGO);
|
||||
setCursor((swidth - ncwidth) / 2 - 4, clockY+28+6);
|
||||
dot = (swidth - ncwidth) / 2 - 4;
|
||||
setTextSize(1);
|
||||
print(timeBuf);
|
||||
/* dots */
|
||||
strftime(timeBuf, sizeof(timeBuf), "%H", &timeinfo);
|
||||
getTextBounds(timeBuf, 0, 0, &x, &y, &ncwidth, &ncheight);
|
||||
dot = dot + ncwidth + getPw(ncwidth);
|
||||
/* dots */
|
||||
}
|
||||
setCursor(dot, clockY+28+6);
|
||||
setTextColor(dots?TFT_BG:TFT_LOGO);
|
||||
print(":");
|
||||
setFont();
|
||||
yield();
|
||||
}
|
||||
|
||||
void DspCore::drawVolumeBar(bool withNumber) {
|
||||
@@ -325,7 +349,7 @@ void DspCore::printText(const char* txt) {
|
||||
print(txt);
|
||||
}
|
||||
|
||||
void DspCore::loop() {
|
||||
void DspCore::loop(bool force) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,12 @@
|
||||
#define TITLE_TOP2 TFT_FRAMEWDT + 3 * TFT_LINEHGHT
|
||||
#define TITLE_FG2 SILVER
|
||||
|
||||
#if !defined(SCROLLDELTA) || !defined(SCROLLTIME)
|
||||
#define SCROLLDELTA 3
|
||||
#define SCROLLTIME 67
|
||||
#define SCROLLTIME 65
|
||||
#endif
|
||||
|
||||
#define TFT_FULLTIME 1
|
||||
|
||||
class DspCore: public Adafruit_ST7735 {
|
||||
public:
|
||||
@@ -34,6 +38,7 @@ class DspCore: public Adafruit_ST7735 {
|
||||
void set_Cursor(int16_t x, int16_t y);
|
||||
void printText(const char* txt);
|
||||
void printClock(const char* timestr);
|
||||
void printClock(struct tm timeinfo, bool dots, bool redraw = false);
|
||||
void displayHeapForDebug();
|
||||
void drawVolumeBar(bool withNumber);
|
||||
void drawNextStationNum(uint16_t num);
|
||||
@@ -45,10 +50,15 @@ class DspCore: public Adafruit_ST7735 {
|
||||
void rssi(const char* str);
|
||||
void ip(const char* str);
|
||||
void drawPlaylist(uint16_t currentItem, char* currentItemText);
|
||||
void loop();
|
||||
void loop(bool force=false);
|
||||
private:
|
||||
uint16_t swidth, sheight;
|
||||
|
||||
char oldTimeBuf[20];
|
||||
uint16_t wot, hot, dot;
|
||||
int16_t x, y;
|
||||
uint16_t cwidth, cheight;
|
||||
void setClockBounds();
|
||||
byte getPw(uint16_t ncwidth);
|
||||
};
|
||||
|
||||
extern DspCore dsp;
|
||||
|
||||
@@ -140,16 +140,17 @@ void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
|
||||
config.fillPlMenu(plMenu, currentItem - 4, 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);
|
||||
|
||||
for (byte i = 0; i < PLMITEMS; i++) {
|
||||
if (i == 4) {
|
||||
//fillRect(0, (sheight / 2 - PLMITEMHEIGHT / 2) - 1, swidth, PLMITEMHEIGHT + 2, TFT_LOGO);
|
||||
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
|
||||
} else {
|
||||
setTextColor(iclrs[abs(i - 4)-1], TFT_BG);
|
||||
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
|
||||
fillRect(0, yStart + i * PLMITEMHEIGHT - 1, swidth, PLMITEMHEIGHT - 2, TFT_BG);
|
||||
print(utf8Rus(plMenu[i], true));
|
||||
}
|
||||
yield();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,9 +160,8 @@ void DspCore::clearDsp() {
|
||||
|
||||
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();
|
||||
fillRect(0, texttop, TFT_FRAMEWDT, textheight, bg);
|
||||
}
|
||||
|
||||
void DspCore::getScrolBbounds(const char* text, const char* separator, byte textsize, uint16_t &tWidth, uint16_t &tHeight, uint16_t &sWidth) {
|
||||
@@ -176,7 +176,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-4, swidth, textheight+7, bg);
|
||||
yield();
|
||||
}
|
||||
|
||||
@@ -364,10 +364,9 @@ void DspCore::set_Cursor(int16_t x, int16_t y) {
|
||||
|
||||
void DspCore::printText(const char* txt) {
|
||||
print(txt);
|
||||
yield();
|
||||
}
|
||||
|
||||
void DspCore::loop() {
|
||||
void DspCore::loop(bool force) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,10 @@
|
||||
#define TITLE_SIZE1 2
|
||||
#define TITLE_SIZE2 2
|
||||
|
||||
#define SCROLLDELTA 6
|
||||
#define SCROLLTIME 83
|
||||
#if !defined(SCROLLDELTA) || !defined(SCROLLTIME)
|
||||
#define SCROLLDELTA 5
|
||||
#define SCROLLTIME 50
|
||||
#endif
|
||||
|
||||
#define PLMITEMS 9
|
||||
#define PLMITEMLENGHT 40
|
||||
@@ -53,7 +55,7 @@ class DspCore: public Adafruit_ST7789 {
|
||||
void rssi(const char* str);
|
||||
void ip(const char* str);
|
||||
void drawPlaylist(uint16_t currentItem, char* currentItemText);
|
||||
void loop();
|
||||
void loop(bool force=false);
|
||||
private:
|
||||
uint16_t swidth, sheight;
|
||||
char oldTimeBuf[20];
|
||||
|
||||
Reference in New Issue
Block a user