v0.6.010
This commit is contained in:
372
yoRadio/src/displays/displayILI9341.cpp
Normal file
372
yoRadio/src/displays/displayILI9341.cpp
Normal file
@@ -0,0 +1,372 @@
|
||||
#include "../../options.h"
|
||||
#if DSP_MODEL==DSP_ILI9341
|
||||
|
||||
#include "displayILI9341.h"
|
||||
#include <SPI.h>
|
||||
#include "fonts/bootlogo.h"
|
||||
#include "../../player.h"
|
||||
#include "../../config.h"
|
||||
#include "../../network.h"
|
||||
|
||||
const char *dow[7] = {"вс","пн","вт","ср","чт","пт","сб"};
|
||||
const char *mnths[12] = {"января","февраля","марта","апреля","мая","июня","июля","августа","сентября","октября","ноября","декабря"};
|
||||
|
||||
DspCore::DspCore(): Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST) {
|
||||
|
||||
}
|
||||
|
||||
char* DspCore::utf8Rus(const char* str, bool uppercase) {
|
||||
int index = 0;
|
||||
static char strn[BUFLEN];
|
||||
bool E = false;
|
||||
strlcpy(strn, str, BUFLEN);
|
||||
if (uppercase) {
|
||||
bool next = false;
|
||||
for (char *iter = strn; *iter != '\0'; ++iter)
|
||||
{
|
||||
if (E) {
|
||||
E = false;
|
||||
continue;
|
||||
}
|
||||
byte rus = (byte) * iter;
|
||||
if (rus == 208 && (byte) * (iter + 1) == 129) { // ёКостыли
|
||||
*iter = (char)209;
|
||||
*(iter + 1) = (char)145;
|
||||
E = true;
|
||||
continue;
|
||||
}
|
||||
if (rus == 209 && (byte) * (iter + 1) == 145) {
|
||||
*iter = (char)209;
|
||||
*(iter + 1) = (char)145;
|
||||
E = true;
|
||||
continue;
|
||||
}
|
||||
if (next) {
|
||||
if (rus >= 128 && rus <= 143) *iter = (char)(rus + 32);
|
||||
if (rus >= 176 && rus <= 191) *iter = (char)(rus - 32);
|
||||
next = false;
|
||||
}
|
||||
if (rus == 208) next = true;
|
||||
if (rus == 209) {
|
||||
*iter = (char)208;
|
||||
next = true;
|
||||
}
|
||||
*iter = toupper(*iter);
|
||||
}
|
||||
}
|
||||
while (strn[index])
|
||||
{
|
||||
if (strn[index] >= 0xBF)
|
||||
{
|
||||
switch (strn[index]) {
|
||||
case 0xD0: {
|
||||
if (strn[index + 1] == 0x81) {
|
||||
strn[index] = 0xA8;
|
||||
break;
|
||||
}
|
||||
if (strn[index + 1] >= 0x90 && strn[index + 1] <= 0xBF) strn[index] = strn[index + 1] + 0x30;
|
||||
break;
|
||||
}
|
||||
case 0xD1: {
|
||||
if (strn[index + 1] == 0x91) {
|
||||
//strn[index] = 0xB7;
|
||||
strn[index] = 0xB8;
|
||||
break;
|
||||
}
|
||||
if (strn[index + 1] >= 0x80 && strn[index + 1] <= 0x8F) strn[index] = strn[index + 1] + 0x70;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int sind = index + 2;
|
||||
while (strn[sind]) {
|
||||
strn[sind - 1] = strn[sind];
|
||||
sind++;
|
||||
}
|
||||
strn[sind - 1] = 0;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
return strn;
|
||||
}
|
||||
|
||||
void DspCore::apScreen() {
|
||||
setTextSize(TITLE_SIZE1);
|
||||
setTextColor(TFT_FG, TFT_BG);
|
||||
setCursor(TFT_FRAMEWDT, TITLE_TOP1);
|
||||
print("AP NAME: ");
|
||||
print(apSsid);
|
||||
setCursor(TFT_FRAMEWDT, TITLE_TOP2);
|
||||
print("PASSWORD: ");
|
||||
print(apPassword);
|
||||
setTextColor(SILVER, TFT_BG);
|
||||
setCursor(TFT_FRAMEWDT, sheight-TFT_FRAMEWDT-TFT_LINEHGHT*4);
|
||||
print("SETTINGS PAGE ON: ");
|
||||
setCursor(TFT_FRAMEWDT, sheight-TFT_FRAMEWDT-TFT_LINEHGHT*2);
|
||||
print("http://");
|
||||
print(WiFi.softAPIP().toString().c_str());
|
||||
print("/");
|
||||
drawFastHLine(TFT_FRAMEWDT, TITLE_TOP1-8, swidth-TFT_FRAMEWDT*2, SILVER);
|
||||
}
|
||||
|
||||
void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
|
||||
//begin(26000000L); /*багиловим*/
|
||||
begin(); /* SPI_DEFAULT_FREQ 40000000 */
|
||||
invertDisplay(TFT_INVERT);
|
||||
cp437(true);
|
||||
fillScreen(TFT_BG);
|
||||
setRotation(TFT_ROTATE);
|
||||
setTextWrap(false);
|
||||
setTextSize(1);
|
||||
screenwidth = width();
|
||||
screenheight = height();
|
||||
swidth = screenwidth;
|
||||
sheight = screenheight;
|
||||
}
|
||||
|
||||
void DspCore::drawLogo() {
|
||||
drawRGBBitmap((swidth - 99) / 2, (sheight-64)/2 - TFT_LINEHGHT*2, bootlogo2, 99, 64);
|
||||
}
|
||||
|
||||
// http://greekgeeks.net/#maker-tools_convertColor
|
||||
uint16_t iclrs[] = { 0x738E /*707070*/, 0x52AA /*575757*/, 0x39C7, 0x18E3 };
|
||||
void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
|
||||
for (byte i = 0; i < PLMITEMS; i++) {
|
||||
plMenu[i][0] = '\0';
|
||||
}
|
||||
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) {
|
||||
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
|
||||
} else {
|
||||
setTextColor(iclrs[abs(i - 4)-1], TFT_BG);
|
||||
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
|
||||
print(utf8Rus(plMenu[i], true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DspCore::clearDsp() {
|
||||
fillScreen(TFT_BG);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void DspCore::getScrolBbounds(const char* text, const char* separator, byte textsize, uint16_t &tWidth, uint16_t &tHeight, uint16_t &sWidth) {
|
||||
int16_t x1, y1;
|
||||
uint16_t w, h;
|
||||
setTextSize(textsize);
|
||||
getTextBounds(text, 0, 0, &x1, &y1, &w, &h);
|
||||
tWidth = w;
|
||||
tHeight = h;
|
||||
getTextBounds(separator, 0, 0, &x1, &y1, &w, &h);
|
||||
sWidth = w;
|
||||
}
|
||||
|
||||
void DspCore::clearScroll(uint16_t texttop, uint16_t textheight, uint16_t bg) {
|
||||
fillRect(0, texttop, swidth, textheight, bg);
|
||||
}
|
||||
|
||||
void DspCore::centerText(const char* text, uint16_t y, uint16_t fg, uint16_t bg) {
|
||||
int16_t x1, y1;
|
||||
uint16_t w, h;
|
||||
const char* txt = text;
|
||||
if(y==90) y=(sheight-64)/2 + 64 + TFT_LINEHGHT;
|
||||
if(y==110) y=(sheight-64)/2 + 64 + TFT_LINEHGHT*3;
|
||||
getTextBounds(txt, 0, 0, &x1, &y1, &w, &h);
|
||||
setTextColor(fg);
|
||||
setCursor((swidth - w) / 2, y);
|
||||
fillRect((swidth-w)/2-5, y, w+10, h, bg);
|
||||
print(txt);
|
||||
}
|
||||
|
||||
void DspCore::rightText(const char* text, uint16_t y, uint16_t fg, uint16_t bg, bool fliprect, uint16_t delta) {
|
||||
int16_t x1, y1;
|
||||
uint16_t w, h;
|
||||
getTextBounds(text, 0, 0, &x1, &y1, &w, &h);
|
||||
setTextColor(fg,bg);
|
||||
setCursor(swidth - w - TFT_FRAMEWDT - delta, y);
|
||||
//fillRect(swidth - w - TFT_FRAMEWDT, fliprect?y-h:y, w, h, bg);
|
||||
print(text);
|
||||
}
|
||||
|
||||
void DspCore::displayHeapForDebug() {
|
||||
int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT * 2 - 2;
|
||||
setTextSize(1);
|
||||
setTextColor(DARK_GRAY, TFT_BG);
|
||||
setCursor(TFT_FRAMEWDT, vTop);
|
||||
fillRect(TFT_FRAMEWDT, vTop, swidth - TFT_FRAMEWDT / 2, 7, TFT_BG);
|
||||
print(ESP.getFreeHeap());
|
||||
print(" / ");
|
||||
print(ESP.getMaxAllocHeap());
|
||||
#if VS1053_CS==255
|
||||
// audio buffer;
|
||||
fillRect(0, sheight - 2, swidth, 2, TFT_BG);
|
||||
int astored = player.inBufferFilled();
|
||||
int afree = player.inBufferFree();
|
||||
int aprcnt = 100 * astored / (astored + afree);
|
||||
byte sbw = map(aprcnt, 0, 100 , 0, swidth);
|
||||
fillRect(0, sheight - 2, sbw, 2, SILVER);
|
||||
#endif
|
||||
}
|
||||
|
||||
void DspCore::printClock(const char* timestr) {
|
||||
|
||||
}
|
||||
|
||||
uint16_t cltop = 0;
|
||||
uint8_t clsp = 24;
|
||||
uint16_t clleft = 0;
|
||||
uint16_t clwidth = 0;
|
||||
|
||||
void DspCore::printClock(struct tm timeinfo, bool dots, bool redraw){
|
||||
char timeBuf[50] = { 0 };
|
||||
strftime(timeBuf, sizeof(timeBuf), "%H:%M", &timeinfo);
|
||||
if(strstr(oldTimeBuf, timeBuf)==NULL || redraw){
|
||||
int16_t x1, y1;
|
||||
setTextSize(1);
|
||||
setFont(&DS_DIGI42pt7b);
|
||||
getTextBounds(oldTimeBuf, 0, 0, &x1, &y1, &wot, &hot);
|
||||
if(cltop==0){
|
||||
cltop=sheight-(TFT_FRAMEWDT * 2 + TFT_LINEHGHT + 38) - hot;
|
||||
}
|
||||
clwidth = wot+clsp+(swidth>240?46:34);
|
||||
clleft=swidth-TFT_FRAMEWDT-clwidth;
|
||||
//fillRect(swidth-TFT_FRAMEWDT-clwidth, cltop-hot, clwidth, hot+3, TFT_BG);
|
||||
setCursor(clleft, cltop);
|
||||
setTextColor(TFT_BG);
|
||||
print(oldTimeBuf);
|
||||
strlcpy(oldTimeBuf, timeBuf, 20);
|
||||
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);
|
||||
print(timeBuf);
|
||||
|
||||
setFont();
|
||||
setTextSize(3);
|
||||
setTextColor(TFT_FG, TFT_BG);
|
||||
setCursor(clleft+wot+clsp, cltop-hot+32);
|
||||
print(utf8Rus(dow[timeinfo.tm_wday], false));
|
||||
|
||||
sprintf(timeBuf, "%2d %s %d", timeinfo.tm_mday,mnths[timeinfo.tm_mon], timeinfo.tm_year+1900);
|
||||
setTextSize(1);
|
||||
rightText(utf8Rus(timeBuf,true), cltop+10, TFT_FG, TFT_BG, false, swidth>240?12:0);
|
||||
drawFastVLine(clleft+wot+clsp/2+3, cltop-hot, hot+3, SILVER);
|
||||
drawFastHLine(clleft+wot+clsp/2+3, cltop-hot+29, 42, SILVER);
|
||||
|
||||
drawFastHLine(TFT_FRAMEWDT, TITLE_TOP1-8, swidth-TFT_FRAMEWDT*2, SILVER);
|
||||
}
|
||||
setTextSize(3);
|
||||
setTextColor(TFT_LOGO, TFT_BG);
|
||||
setCursor(clleft+wot+clsp, cltop-hot+1);
|
||||
sprintf(timeBuf, "%02d", timeinfo.tm_sec);
|
||||
print(timeBuf);
|
||||
}
|
||||
|
||||
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;
|
||||
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);
|
||||
if(swidth>240){
|
||||
char buf[20];
|
||||
sprintf(buf, "VOL %d", config.store.volume);
|
||||
setTextSize(1);
|
||||
centerText(buf, volTop, SILVER, TFT_BG);
|
||||
}
|
||||
if (withNumber) {
|
||||
setTextSize(1);
|
||||
setTextColor(TFT_FG);
|
||||
setFont(&DS_DIGI42pt7b);
|
||||
char volstr[4];
|
||||
uint16_t wv, hv;
|
||||
int16_t x1, y1;
|
||||
|
||||
setTextColor(TFT_BG);
|
||||
sprintf(volstr, "%d", oldVolume);
|
||||
getTextBounds(volstr, 0, 0, &x1, &y1, &wv, &hv);
|
||||
setCursor((swidth - wv) / 2, (sheight-hv)/2 + hv);
|
||||
print(volstr);
|
||||
|
||||
setTextColor(TFT_FG);
|
||||
sprintf(volstr, "%d", config.store.volume);
|
||||
getTextBounds(volstr, 0, 0, &x1, &y1, &wv, &hv);
|
||||
//fillRect(TFT_FRAMEWDT, (sheight-hv)/2, swidth - TFT_FRAMEWDT / 2, hv + 3, TFT_BG);
|
||||
setCursor((swidth - wv) / 2, (sheight-hv)/2 + hv);
|
||||
print(volstr);
|
||||
oldVolume=config.store.volume;
|
||||
setFont();
|
||||
}
|
||||
}
|
||||
|
||||
void DspCore::drawNextStationNum(uint16_t num) {
|
||||
setTextSize(1);
|
||||
setTextColor(TFT_FG);
|
||||
setFont(&DS_DIGI42pt7b);
|
||||
char numstr[7];
|
||||
uint16_t wv, hv;
|
||||
int16_t x1, y1;
|
||||
sprintf(numstr, "%d", num);
|
||||
getTextBounds(numstr, 0, 0, &x1, &y1, &wv, &hv);
|
||||
fillRect(TFT_FRAMEWDT, (sheight-hv)/2, swidth - TFT_FRAMEWDT / 2, hv + 3, TFT_BG);
|
||||
setCursor((swidth - wv) / 2, (sheight-hv)/2 + hv);
|
||||
print(numstr);
|
||||
setFont();
|
||||
}
|
||||
|
||||
void DspCore::frameTitle(const char* str) {
|
||||
setTextSize(META_SIZE);
|
||||
centerText(str, TFT_FRAMEWDT, TFT_LOGO, TFT_BG);
|
||||
drawFastHLine(TFT_FRAMEWDT, TITLE_TOP1-8, swidth-TFT_FRAMEWDT*2, SILVER);
|
||||
}
|
||||
|
||||
void DspCore::rssi(const char* str) {
|
||||
int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT - 2;
|
||||
char buf[20];
|
||||
sprintf(buf, "RSSI:%s", str);
|
||||
setTextSize(1);
|
||||
rightText(buf, vTop, SILVER, TFT_BG);
|
||||
}
|
||||
|
||||
void DspCore::ip(const char* str) {
|
||||
int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT - 2;
|
||||
char buf[30];
|
||||
sprintf(buf, "IP: %s", str);
|
||||
setTextSize(1);
|
||||
setTextColor(SILVER, TFT_BG);
|
||||
setCursor(TFT_FRAMEWDT, vTop);
|
||||
print(buf);
|
||||
}
|
||||
|
||||
void DspCore::set_TextSize(uint8_t s) {
|
||||
setTextSize(s);
|
||||
}
|
||||
|
||||
void DspCore::set_TextColor(uint16_t fg, uint16_t bg) {
|
||||
setTextColor(fg, bg);
|
||||
}
|
||||
|
||||
void DspCore::set_Cursor(int16_t x, int16_t y) {
|
||||
setCursor(x, y);
|
||||
}
|
||||
|
||||
void DspCore::printText(const char* txt) {
|
||||
print(txt);
|
||||
}
|
||||
|
||||
void DspCore::loop() {
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
99
yoRadio/src/displays/displayILI9341.h
Normal file
99
yoRadio/src/displays/displayILI9341.h
Normal file
@@ -0,0 +1,99 @@
|
||||
#ifndef displayILI9341_h
|
||||
#define displayILI9341_h
|
||||
|
||||
#include "Arduino.h"
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_ILI9341.h>
|
||||
// https://tchapi.github.io/Adafruit-GFX-Font-Customiser/
|
||||
#include "fonts/DS_DIGI42pt7b.h"
|
||||
|
||||
#define TFT_LINEHGHT 10
|
||||
#define TFT_FRAMEWDT 8
|
||||
#define META_SIZE 3
|
||||
#define TITLE_SIZE1 2
|
||||
#define TITLE_SIZE2 2
|
||||
|
||||
#define SCROLLDELTA 4
|
||||
#define SCROLLTIME 60
|
||||
|
||||
#define PLMITEMS 9
|
||||
#define PLMITEMLENGHT 40
|
||||
#define PLMITEMHEIGHT 22
|
||||
#define TFT_FULLTIME 1
|
||||
|
||||
#define TITLE_TOP1 TFT_FRAMEWDT + META_SIZE * TFT_LINEHGHT + 8
|
||||
#define TITLE_TOP2 TFT_FRAMEWDT + (META_SIZE+2) * TFT_LINEHGHT + 8
|
||||
#define TITLE_FG2 SILVER
|
||||
|
||||
class DspCore: public Adafruit_ILI9341 {
|
||||
public:
|
||||
DspCore();
|
||||
char plMenu[PLMITEMS][PLMITEMLENGHT];
|
||||
uint16_t clockY;
|
||||
void initD(uint16_t &screenwidth, uint16_t &screenheight);
|
||||
void apScreen();
|
||||
void drawLogo();
|
||||
void clearDsp();
|
||||
void centerText(const char* text, uint16_t y, uint16_t fg, uint16_t bg);
|
||||
void rightText(const char* text, uint16_t y, uint16_t fg, uint16_t bg, bool fliprect=false, uint16_t delta = 0);
|
||||
void set_TextSize(uint8_t s);
|
||||
void set_TextColor(uint16_t fg, uint16_t bg);
|
||||
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);
|
||||
char* utf8Rus(const char* str, bool uppercase);
|
||||
void drawScrollFrame(uint16_t texttop, uint16_t textheight, uint16_t bg);
|
||||
void getScrolBbounds(const char* text, const char* separator, byte textsize, uint16_t &tWidth, uint16_t &tHeight, uint16_t &sWidth);
|
||||
void clearScroll(uint16_t texttop, uint16_t textheight, uint16_t bg);
|
||||
void frameTitle(const char* str);
|
||||
void rssi(const char* str);
|
||||
void ip(const char* str);
|
||||
void drawPlaylist(uint16_t currentItem, char* currentItemText);
|
||||
void loop();
|
||||
private:
|
||||
uint16_t swidth, sheight;
|
||||
char oldTimeBuf[20];
|
||||
uint8_t oldVolume;
|
||||
uint16_t wot, hot;
|
||||
|
||||
};
|
||||
|
||||
extern DspCore dsp;
|
||||
|
||||
/*
|
||||
* TFT COLORS
|
||||
*/
|
||||
#define BLACK 0x0000
|
||||
#define BLUE 0x001F
|
||||
#define RED 0xF800
|
||||
#define GREEN 0x07E0
|
||||
#define MAGENTA 0xF81F
|
||||
#define YELLOW 0xFFE0
|
||||
#define WHITE 0xFFFF
|
||||
#define GRAY 0x7BEF
|
||||
#define DARK_GRAY 0x2945
|
||||
#define LIGHT_GRAY 0xC618
|
||||
#define LIME 0x87E0
|
||||
#define AQUA 0x5D1C
|
||||
#define CYAN 0x07FF
|
||||
#define DARK_CYAN 0x03EF
|
||||
#define ORANGE 0xFCA0
|
||||
#define PINK 0xF97F
|
||||
#define BROWN 0x8200
|
||||
#define VIOLET 0x9199
|
||||
#define SILVER 0xA510
|
||||
#define GOLD 0xA508
|
||||
#define NAVY 0x000F
|
||||
#define MAROON 0x7800
|
||||
#define PURPLE 0x780F
|
||||
#define OLIVE 0x7BE0
|
||||
|
||||
#define TFT_BG BLACK
|
||||
#define TFT_FG WHITE
|
||||
#define TFT_LOGO 0xE68B // 224, 209, 92
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "../../options.h"
|
||||
|
||||
#if DSP_MODEL==DSP_1602I2C
|
||||
#if DSP_MODEL==DSP_1602I2C || DSP_MODEL==DSP_1602
|
||||
|
||||
#include "displayLC1602.h"
|
||||
#include "../../player.h"
|
||||
@@ -13,10 +13,15 @@
|
||||
|
||||
const byte controlspaces[] = { CLOCK_SPACE, VOL_SPACE };
|
||||
|
||||
#if DSP_MODEL==DSP_1602I2C
|
||||
DspCore::DspCore(): LiquidCrystal_I2C(SCREEN_ADDRESS, 16, 2, I2C_SDA, I2C_SCL) {
|
||||
|
||||
}
|
||||
#else
|
||||
DspCore::DspCore(): LiquidCrystal(LCD_RS, LCD_E, LCD_D4, LCD_D5, LCD_D6, LCD_D7) {
|
||||
|
||||
}
|
||||
#endif
|
||||
void DspCore::apScreen() {
|
||||
setCursor(0,0);
|
||||
print("YORADIO AP MODE");
|
||||
@@ -25,8 +30,12 @@ void DspCore::apScreen() {
|
||||
}
|
||||
|
||||
void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
|
||||
#if DSP_MODEL==DSP_1602I2C
|
||||
init();
|
||||
backlight();
|
||||
#else
|
||||
begin(16, 2);
|
||||
#endif
|
||||
screenwidth = 16;
|
||||
screenheight = 2;
|
||||
swidth = screenwidth;
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
#define displayLC1602_h
|
||||
|
||||
#include "Arduino.h"
|
||||
#if DSP_MODEL==DSP_1602I2C
|
||||
#include "../LiquidCrystalI2C/LiquidCrystalI2CEx.h"
|
||||
|
||||
#else
|
||||
#include <LiquidCrystal.h>
|
||||
#endif
|
||||
#define TFT_LINEHGHT 1
|
||||
#define TFT_FRAMEWDT 0
|
||||
|
||||
@@ -21,7 +24,11 @@
|
||||
#define BOOTSTR_TOP1 1
|
||||
#define STARTTIME_PL 2000
|
||||
|
||||
#if DSP_MODEL==DSP_1602I2C
|
||||
class DspCore: public LiquidCrystal_I2C {
|
||||
#else
|
||||
class DspCore: public LiquidCrystal {
|
||||
#endif
|
||||
public:
|
||||
bool fillSpaces;
|
||||
DspCore();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../../options.h"
|
||||
#if DSP_MODEL==5
|
||||
#if DSP_MODEL==DSP_SH1106 || DSP_MODEL==DSP_SH1107
|
||||
|
||||
#include "displaySH1106.h"
|
||||
#include <Wire.h>
|
||||
@@ -29,11 +29,15 @@ const unsigned char logo [] PROGMEM=
|
||||
};
|
||||
|
||||
TwoWire I2CSH1106 = TwoWire(0);
|
||||
|
||||
#if DSP_MODEL==DSP_SH1106
|
||||
DspCore::DspCore(): Adafruit_SH1106G(128, 64, &I2CSH1106, -1) {
|
||||
|
||||
}
|
||||
#else
|
||||
DspCore::DspCore(): Adafruit_SH1107(64, 128, &I2CSH1106, -1) {
|
||||
|
||||
}
|
||||
#endif
|
||||
char* DspCore::utf8Rus(const char* str, bool uppercase) {
|
||||
int index = 0;
|
||||
static char strn[BUFLEN];
|
||||
@@ -127,14 +131,22 @@ void DspCore::apScreen() {
|
||||
}
|
||||
|
||||
void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
|
||||
I2CSH1106.begin(I2C_SDA, I2C_SCL, (uint32_t)100000);
|
||||
I2CSH1106.begin(I2C_SDA, I2C_SCL);
|
||||
if (!begin(SCREEN_ADDRESS, true)) {
|
||||
Serial.println(F("SH1106 allocation failed"));
|
||||
Serial.println(F("SH110X allocation failed"));
|
||||
for (;;); // Don't proceed, loop forever
|
||||
}
|
||||
cp437(true);
|
||||
fillScreen(TFT_BG);
|
||||
setRotation(TFT_ROTATE);
|
||||
byte tftRotate = TFT_ROTATE;
|
||||
#if DSP_MODEL==DSP_SH1106
|
||||
if(tftRotate>2) tftRotate=2;
|
||||
if(tftRotate==1) tftRotate=0;
|
||||
#else
|
||||
if(tftRotate>=2) tftRotate=3;
|
||||
if(tftRotate==0) tftRotate=1;
|
||||
#endif
|
||||
setRotation(tftRotate);
|
||||
setTextWrap(false);
|
||||
screenwidth = width();
|
||||
screenheight = height();
|
||||
|
||||
@@ -10,14 +10,18 @@
|
||||
|
||||
#define PLMITEMS 7
|
||||
#define PLMITEMLENGHT 40
|
||||
#define PLMITEMHEIGHT 9
|
||||
#define PLMITEMHEIGHT 10
|
||||
#define TITLE_TOP2 TFT_FRAMEWDT + 3 * TFT_LINEHGHT
|
||||
#define PLCURRENT_SIZE 1
|
||||
#define TFT_FULLTIME 1
|
||||
#define SCROLLDELTA 5
|
||||
#define SCROLLTIME 110
|
||||
#define SCROLLDELTA 3
|
||||
#define SCROLLTIME 83
|
||||
|
||||
#if DSP_MODEL==DSP_SH1106
|
||||
class DspCore: public Adafruit_SH1106G {
|
||||
#else
|
||||
class DspCore: public Adafruit_SH1107 {
|
||||
#endif
|
||||
public:
|
||||
DspCore();
|
||||
char plMenu[PLMITEMS][PLMITEMLENGHT];
|
||||
|
||||
322
yoRadio/src/displays/displaySSD1305.cpp
Normal file
322
yoRadio/src/displays/displaySSD1305.cpp
Normal file
@@ -0,0 +1,322 @@
|
||||
#include "../../options.h"
|
||||
#if DSP_MODEL==DSP_SSD1305
|
||||
|
||||
#include "displaySSD1305.h"
|
||||
#include "../../player.h"
|
||||
#include "../../config.h"
|
||||
#include "../../network.h"
|
||||
|
||||
#ifndef SCREEN_ADDRESS
|
||||
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32 or scan it https://create.arduino.cc/projecthub/abdularbi17/how-to-scan-i2c-address-in-arduino-eaadda
|
||||
#endif
|
||||
|
||||
#define LOGO_WIDTH 21
|
||||
#define LOGO_HEIGHT 32
|
||||
|
||||
const char *dow[7] = {"вс","пн","вт","ср","чт","пт","сб"};
|
||||
|
||||
const unsigned char logo [] PROGMEM=
|
||||
{
|
||||
0x06, 0x03, 0x00, 0x0f, 0x07, 0x80, 0x1f, 0x8f, 0xc0, 0x1f, 0x8f, 0xc0,
|
||||
0x0f, 0x07, 0x80, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x03, 0xff, 0x00, 0x0f, 0xff, 0x80,
|
||||
0x1f, 0xff, 0xc0, 0x1f, 0xff, 0xc0, 0x3f, 0x8f, 0xe0, 0x7e, 0x03, 0xf0,
|
||||
0x7c, 0x01, 0xf0, 0x7c, 0x01, 0xf0, 0x7f, 0xff, 0xf0, 0xff, 0xff, 0xf8,
|
||||
0xff, 0xff, 0xf8, 0xff, 0xff, 0xf8, 0x7c, 0x00, 0x00, 0x7c, 0x00, 0x00,
|
||||
0x7e, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x3f, 0xc0, 0xe0, 0x3f, 0xff, 0xe0,
|
||||
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) {
|
||||
|
||||
}
|
||||
|
||||
char* DspCore::utf8Rus(const char* str, bool uppercase) {
|
||||
int index = 0;
|
||||
static char strn[BUFLEN];
|
||||
bool E = false;
|
||||
strlcpy(strn, str, BUFLEN);
|
||||
if (uppercase) {
|
||||
bool next = false;
|
||||
for (char *iter = strn; *iter != '\0'; ++iter)
|
||||
{
|
||||
if (E) {
|
||||
E = false;
|
||||
continue;
|
||||
}
|
||||
byte rus = (byte) * iter;
|
||||
if (rus == 208 && (byte) * (iter + 1) == 129) { // ёКостыли
|
||||
*iter = (char)209;
|
||||
*(iter + 1) = (char)145;
|
||||
E = true;
|
||||
continue;
|
||||
}
|
||||
if (rus == 209 && (byte) * (iter + 1) == 145) {
|
||||
*iter = (char)209;
|
||||
*(iter + 1) = (char)145;
|
||||
E = true;
|
||||
continue;
|
||||
}
|
||||
if (next) {
|
||||
if (rus >= 128 && rus <= 143) *iter = (char)(rus + 32);
|
||||
if (rus >= 176 && rus <= 191) *iter = (char)(rus - 32);
|
||||
next = false;
|
||||
}
|
||||
if (rus == 208) next = true;
|
||||
if (rus == 209) {
|
||||
*iter = (char)208;
|
||||
next = true;
|
||||
}
|
||||
*iter = toupper(*iter);
|
||||
}
|
||||
}
|
||||
while (strn[index])
|
||||
{
|
||||
if (strn[index] >= 0xBF)
|
||||
{
|
||||
switch (strn[index]) {
|
||||
case 0xD0: {
|
||||
if (strn[index + 1] == 0x81) {
|
||||
strn[index] = 0xA8;
|
||||
break;
|
||||
}
|
||||
if (strn[index + 1] >= 0x90 && strn[index + 1] <= 0xBF) strn[index] = strn[index + 1] + 0x30;
|
||||
break;
|
||||
}
|
||||
case 0xD1: {
|
||||
if (strn[index + 1] == 0x91) {
|
||||
//strn[index] = 0xB7;
|
||||
strn[index] = 0xB8;
|
||||
break;
|
||||
}
|
||||
if (strn[index + 1] >= 0x80 && strn[index + 1] <= 0x8F) strn[index] = strn[index + 1] + 0x70;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int sind = index + 2;
|
||||
while (strn[sind]) {
|
||||
strn[sind - 1] = strn[sind];
|
||||
sind++;
|
||||
}
|
||||
strn[sind - 1] = 0;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
return strn;
|
||||
}
|
||||
|
||||
void DspCore::apScreen() {
|
||||
setTextSize(1);
|
||||
setTextColor(TFT_FG, TFT_BG);
|
||||
setCursor(TFT_FRAMEWDT, TFT_FRAMEWDT + 2 * TFT_LINEHGHT);
|
||||
print("AP NAME: ");
|
||||
print(apSsid);
|
||||
setCursor(TFT_FRAMEWDT, TFT_FRAMEWDT + 3 * TFT_LINEHGHT);
|
||||
print("PASSWORD: ");
|
||||
print(apPassword);
|
||||
setTextColor(SILVER, TFT_BG);
|
||||
setCursor(TFT_FRAMEWDT, sheight - TFT_LINEHGHT * 2);
|
||||
print("SETTINGS PAGE ON: ");
|
||||
setCursor(TFT_FRAMEWDT, sheight - TFT_LINEHGHT);
|
||||
print("http://");
|
||||
print(WiFi.softAPIP().toString().c_str());
|
||||
print("/");
|
||||
}
|
||||
|
||||
void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
|
||||
if (!begin(SCREEN_ADDRESS)) {
|
||||
Serial.println(F("SH1106 allocation failed"));
|
||||
for (;;); // Don't proceed, loop forever
|
||||
}
|
||||
cp437(true);
|
||||
fillScreen(TFT_BG);
|
||||
setRotation(TFT_ROTATE);
|
||||
setTextWrap(false);
|
||||
screenwidth = width();
|
||||
screenheight = height();
|
||||
swidth = screenwidth;
|
||||
sheight = screenheight;
|
||||
}
|
||||
|
||||
void DspCore::drawLogo() {
|
||||
clearDisplay();
|
||||
drawBitmap(
|
||||
(width() - LOGO_WIDTH ) / 2,
|
||||
8,
|
||||
logo, LOGO_WIDTH, LOGO_HEIGHT, 1);
|
||||
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 = (sheight / 2 - PLMITEMHEIGHT / 2) - PLMITEMHEIGHT * (PLMITEMS - 1) / 2 + 3;
|
||||
fillRect(0, (sheight / 2 - PLMITEMHEIGHT / 2) + 2, swidth, PLMITEMHEIGHT-1, TFT_LOGO);
|
||||
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);
|
||||
print(utf8Rus(plMenu[i], true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DspCore::clearDsp() {
|
||||
fillScreen(TFT_BG);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void DspCore::getScrolBbounds(const char* text, const char* separator, byte textsize, uint16_t &tWidth, uint16_t &tHeight, uint16_t &sWidth) {
|
||||
int16_t x1, y1;
|
||||
uint16_t w, h;
|
||||
setTextSize(textsize);
|
||||
getTextBounds(text, 0, 0, &x1, &y1, &w, &h);
|
||||
tWidth = w;
|
||||
tHeight = h;
|
||||
getTextBounds(separator, 0, 0, &x1, &y1, &w, &h);
|
||||
sWidth = w;
|
||||
}
|
||||
|
||||
void DspCore::clearScroll(uint16_t texttop, uint16_t textheight, uint16_t bg) {
|
||||
fillRect(0, texttop, swidth, textheight, bg);
|
||||
}
|
||||
|
||||
void DspCore::centerText(const char* text, byte y, uint16_t fg, uint16_t bg) {
|
||||
int16_t x1, y1;
|
||||
uint16_t w, h;
|
||||
const char* txt = text;
|
||||
getTextBounds(txt, 0, 0, &x1, &y1, &w, &h);
|
||||
setTextColor(fg,bg);
|
||||
if(y==90) y=sheight-TFT_LINEHGHT*2-5;
|
||||
if(y==110) y=sheight-TFT_LINEHGHT;
|
||||
setCursor((swidth - w) / 2, y);
|
||||
fillRect(0, y, swidth, h, bg);
|
||||
print(txt);
|
||||
}
|
||||
|
||||
void DspCore::rightText(const char* text, byte y, uint16_t fg, uint16_t bg) {
|
||||
int16_t x1, y1;
|
||||
uint16_t w, h;
|
||||
getTextBounds(text, 0, 0, &x1, &y1, &w, &h);
|
||||
setTextColor(fg,bg);
|
||||
setCursor(swidth - w - TFT_FRAMEWDT, y);
|
||||
fillRect(swidth - w - TFT_FRAMEWDT, y, w, h, bg);
|
||||
print(text);
|
||||
}
|
||||
|
||||
void DspCore::displayHeapForDebug() {
|
||||
|
||||
}
|
||||
|
||||
void DspCore::printClock(const char* timestr) {
|
||||
setTextSize(2);
|
||||
centerText(timestr, 34, TFT_FG, TFT_BG);
|
||||
setTextSize(1);
|
||||
}
|
||||
|
||||
void DspCore::printClock(struct tm timeinfo, bool dots, bool redraw) {
|
||||
char timeStringBuff[20] = { 0 };
|
||||
strftime(timeStringBuff, sizeof(timeStringBuff), "%H:%M:%S", &timeinfo);
|
||||
setTextSize(2);
|
||||
centerText(timeStringBuff, 30, TFT_FG, TFT_BG);
|
||||
|
||||
}
|
||||
|
||||
void DspCore::drawVolumeBar(bool withNumber) {
|
||||
int16_t vTop = sheight - 4;
|
||||
int16_t vWidth = swidth;
|
||||
uint8_t ww = map(config.store.volume, 0, 254, 0, vWidth - 2);
|
||||
fillRect(TFT_FRAMEWDT, vTop, vWidth, 3, TFT_BG);
|
||||
drawRect(TFT_FRAMEWDT, vTop, vWidth, 3, TFT_LOGO);
|
||||
fillRect(TFT_FRAMEWDT + 1, vTop + 1, ww, 1, TFT_LOGO);
|
||||
if (withNumber) {
|
||||
setTextSize(2);
|
||||
setTextColor(TFT_FG);
|
||||
char volstr[4];
|
||||
uint16_t wv, hv;
|
||||
int16_t x1, y1;
|
||||
sprintf(volstr, "%d", config.store.volume);
|
||||
getTextBounds(volstr, 0, 0, &x1, &y1, &wv, &hv);
|
||||
fillRect(TFT_FRAMEWDT, 22, swidth - TFT_FRAMEWDT / 2, hv + 3, TFT_BG);
|
||||
setCursor((swidth - wv) / 2, 22);
|
||||
print(volstr);
|
||||
}
|
||||
}
|
||||
|
||||
void DspCore::drawNextStationNum(uint16_t num) {
|
||||
setTextSize(2);
|
||||
setTextColor(TFT_FG);
|
||||
char numstr[7];
|
||||
uint16_t wv, hv;
|
||||
int16_t x1, y1;
|
||||
sprintf(numstr, "%d", num);
|
||||
getTextBounds(numstr, 0, 0, &x1, &y1, &wv, &hv);
|
||||
fillRect(TFT_FRAMEWDT, 22, swidth - TFT_FRAMEWDT / 2, hv + 3, TFT_BG);
|
||||
setCursor((swidth - wv) / 2, 22);
|
||||
print(numstr);
|
||||
}
|
||||
|
||||
void DspCore::frameTitle(const char* str) {
|
||||
setTextSize(1);
|
||||
centerText(str, TFT_FRAMEWDT, TFT_LOGO, TFT_BG);
|
||||
}
|
||||
|
||||
void DspCore::rssi(const char* str) {
|
||||
char buf[4];
|
||||
strlcpy(buf, str, strlen(str)-2);
|
||||
int16_t vTop = sheight - TFT_LINEHGHT - 4;
|
||||
setTextSize(1);
|
||||
rightText(buf, vTop, SILVER, TFT_BG);
|
||||
}
|
||||
|
||||
void DspCore::ip(const char* str) {
|
||||
int16_t vTop = sheight - TFT_LINEHGHT - 4;
|
||||
setTextSize(1);
|
||||
setTextColor(SILVER, TFT_BG);
|
||||
setCursor(0, vTop);
|
||||
print(str);
|
||||
}
|
||||
|
||||
void DspCore::set_TextSize(uint8_t s) {
|
||||
setTextSize(s);
|
||||
}
|
||||
|
||||
void DspCore::set_TextColor(uint16_t fg, uint16_t bg) {
|
||||
setTextColor(fg, bg);
|
||||
}
|
||||
|
||||
void DspCore::set_Cursor(int16_t x, int16_t y) {
|
||||
setCursor(x, y);
|
||||
}
|
||||
|
||||
void DspCore::printText(const char* txt) {
|
||||
print(txt);
|
||||
}
|
||||
|
||||
void DspCore::loop() {
|
||||
if (checkdelay(FPS, loopdelay)) {
|
||||
display();
|
||||
}
|
||||
yield();
|
||||
}
|
||||
|
||||
boolean DspCore::checkdelay(int m, unsigned long &tstamp) {
|
||||
if (millis() - tstamp > m) {
|
||||
tstamp = millis();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
68
yoRadio/src/displays/displaySSD1305.h
Normal file
68
yoRadio/src/displays/displaySSD1305.h
Normal file
@@ -0,0 +1,68 @@
|
||||
#ifndef displaySSD1305_h
|
||||
#define displaySSD1305_h
|
||||
|
||||
#include "Arduino.h"
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1305.h>
|
||||
|
||||
#define TFT_LINEHGHT 8
|
||||
#define TFT_FRAMEWDT 0
|
||||
|
||||
#define PLMITEMS 7
|
||||
#define PLMITEMLENGHT 40
|
||||
#define PLMITEMHEIGHT 10
|
||||
#define META_SIZE 1
|
||||
#define TITLE_TOP1 TFT_FRAMEWDT + TFT_LINEHGHT
|
||||
#define TITLE_TOP2 TFT_FRAMEWDT + 2 * TFT_LINEHGHT
|
||||
#define PLCURRENT_SIZE 1
|
||||
#define TFT_FULLTIME 1
|
||||
#define SCROLLDELTA 3
|
||||
#define SCROLLTIME 83
|
||||
#define FPS 50
|
||||
|
||||
class DspCore: public Adafruit_SSD1305 {
|
||||
public:
|
||||
DspCore();
|
||||
char plMenu[PLMITEMS][PLMITEMLENGHT];
|
||||
uint16_t clockY;
|
||||
void initD(uint16_t &screenwidth, uint16_t &screenheight);
|
||||
void apScreen();
|
||||
void drawLogo();
|
||||
void clearDsp();
|
||||
void centerText(const char* text, byte y, uint16_t fg, uint16_t bg);
|
||||
void rightText(const char* text, byte y, uint16_t fg, uint16_t bg);
|
||||
void set_TextSize(uint8_t s);
|
||||
void set_TextColor(uint16_t fg, uint16_t bg);
|
||||
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);
|
||||
char* utf8Rus(const char* str, bool uppercase);
|
||||
void drawScrollFrame(uint16_t texttop, uint16_t textheight, uint16_t bg);
|
||||
void getScrolBbounds(const char* text, const char* separator, byte textsize, uint16_t &tWidth, uint16_t &tHeight, uint16_t &sWidth);
|
||||
void clearScroll(uint16_t texttop, uint16_t textheight, uint16_t bg);
|
||||
void frameTitle(const char* str);
|
||||
void rssi(const char* str);
|
||||
void ip(const char* str);
|
||||
void drawPlaylist(uint16_t currentItem, char* currentItemText);
|
||||
void loop();
|
||||
private:
|
||||
uint16_t swidth, sheight;
|
||||
unsigned long loopdelay;
|
||||
boolean checkdelay(int m, unsigned long &tstamp);
|
||||
};
|
||||
|
||||
extern DspCore dsp;
|
||||
|
||||
/*
|
||||
* TFT COLORS
|
||||
*/
|
||||
#define SILVER WHITE
|
||||
#define TFT_BG BLACK
|
||||
#define TFT_FG WHITE
|
||||
#define TFT_LOGO WHITE
|
||||
|
||||
#endif
|
||||
@@ -129,7 +129,7 @@ void DspCore::apScreen() {
|
||||
}
|
||||
|
||||
void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
|
||||
I2CSSD1306.begin(I2C_SDA, I2C_SCL, (uint32_t)100000);
|
||||
I2CSSD1306.begin(I2C_SDA, I2C_SCL);
|
||||
if (!begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
|
||||
Serial.println(F("SSD1306 allocation failed"));
|
||||
for (;;); // Don't proceed, loop forever
|
||||
|
||||
334
yoRadio/src/displays/displaySSD1327.cpp
Normal file
334
yoRadio/src/displays/displaySSD1327.cpp
Normal file
@@ -0,0 +1,334 @@
|
||||
#include "../../options.h"
|
||||
#if DSP_MODEL==DSP_SSD1327
|
||||
|
||||
#include "displaySSD1327.h"
|
||||
#include <Wire.h>
|
||||
#include "fonts/bootlogo.h"
|
||||
#include "../../player.h"
|
||||
#include "../../config.h"
|
||||
#include "../../network.h"
|
||||
|
||||
#ifndef SCREEN_ADDRESS
|
||||
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; or scan it https://create.arduino.cc/projecthub/abdularbi17/how-to-scan-i2c-address-in-arduino-eaadda
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef I2CFREQ_HZ
|
||||
#define I2CFREQ_HZ 4000000UL
|
||||
#endif
|
||||
|
||||
TwoWire tw = TwoWire(0);
|
||||
|
||||
DspCore::DspCore(): Adafruit_SSD1327(128, 128, &tw, I2C_RST, I2CFREQ_HZ) {
|
||||
|
||||
}
|
||||
|
||||
char* DspCore::utf8Rus(const char* str, bool uppercase) {
|
||||
int index = 0;
|
||||
static char strn[BUFLEN];
|
||||
bool E = false;
|
||||
strlcpy(strn, str, BUFLEN);
|
||||
if (uppercase) {
|
||||
bool next = false;
|
||||
for (char *iter = strn; *iter != '\0'; ++iter)
|
||||
{
|
||||
if (E) {
|
||||
E = false;
|
||||
continue;
|
||||
}
|
||||
byte rus = (byte) * iter;
|
||||
if (rus == 208 && (byte) * (iter + 1) == 129) { // ёКостыли
|
||||
*iter = (char)209;
|
||||
*(iter + 1) = (char)145;
|
||||
E = true;
|
||||
continue;
|
||||
}
|
||||
if (rus == 209 && (byte) * (iter + 1) == 145) {
|
||||
*iter = (char)209;
|
||||
*(iter + 1) = (char)145;
|
||||
E = true;
|
||||
continue;
|
||||
}
|
||||
if (next) {
|
||||
if (rus >= 128 && rus <= 143) *iter = (char)(rus + 32);
|
||||
if (rus >= 176 && rus <= 191) *iter = (char)(rus - 32);
|
||||
next = false;
|
||||
}
|
||||
if (rus == 208) next = true;
|
||||
if (rus == 209) {
|
||||
*iter = (char)208;
|
||||
next = true;
|
||||
}
|
||||
*iter = toupper(*iter);
|
||||
}
|
||||
}
|
||||
while (strn[index])
|
||||
{
|
||||
if (strn[index] >= 0xBF)
|
||||
{
|
||||
switch (strn[index]) {
|
||||
case 0xD0: {
|
||||
if (strn[index + 1] == 0x81) {
|
||||
strn[index] = 0xA8;
|
||||
break;
|
||||
}
|
||||
if (strn[index + 1] >= 0x90 && strn[index + 1] <= 0xBF) strn[index] = strn[index + 1] + 0x30;
|
||||
break;
|
||||
}
|
||||
case 0xD1: {
|
||||
if (strn[index + 1] == 0x91) {
|
||||
//strn[index] = 0xB7;
|
||||
strn[index] = 0xB8;
|
||||
break;
|
||||
}
|
||||
if (strn[index + 1] >= 0x80 && strn[index + 1] <= 0x8F) strn[index] = strn[index + 1] + 0x70;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int sind = index + 2;
|
||||
while (strn[sind]) {
|
||||
strn[sind - 1] = strn[sind];
|
||||
sind++;
|
||||
}
|
||||
strn[sind - 1] = 0;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
return strn;
|
||||
}
|
||||
|
||||
void DspCore::apScreen() {
|
||||
setTextSize(1);
|
||||
setTextColor(TFT_FG, TFT_BG);
|
||||
setCursor(TFT_FRAMEWDT, TFT_FRAMEWDT + ((DSP_MODEL==DSP_SSD1306)?2:1) * TFT_LINEHGHT);
|
||||
print("AP NAME: ");
|
||||
print(apSsid);
|
||||
setCursor(TFT_FRAMEWDT, TFT_FRAMEWDT + ((DSP_MODEL==DSP_SSD1306)?3:2) * TFT_LINEHGHT);
|
||||
print("PASSWORD: ");
|
||||
print(apPassword);
|
||||
setTextColor(SILVER, TFT_BG);
|
||||
setCursor(TFT_FRAMEWDT, sheight - TFT_LINEHGHT * 2);
|
||||
print("SETTINGS PAGE ON: ");
|
||||
setCursor(TFT_FRAMEWDT, sheight - TFT_LINEHGHT);
|
||||
print("http://");
|
||||
print(WiFi.softAPIP().toString().c_str());
|
||||
print("/");
|
||||
}
|
||||
|
||||
void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
|
||||
tw.begin(I2C_SDA, I2C_SCL);
|
||||
if (!begin(SCREEN_ADDRESS)) {
|
||||
Serial.println(F("SSD1327 allocation failed"));
|
||||
for (;;);
|
||||
}
|
||||
cp437(true);
|
||||
fillScreen(TFT_BG);
|
||||
setRotation(TFT_ROTATE);
|
||||
setTextWrap(false);
|
||||
screenwidth = width();
|
||||
screenheight = height();
|
||||
swidth = screenwidth;
|
||||
sheight = screenheight;
|
||||
setClockBounds();
|
||||
}
|
||||
|
||||
void DspCore::drawLogo() {
|
||||
drawRGBBitmap((swidth - 99) / 2, 18, bootlogo2, 99, 64);
|
||||
}
|
||||
|
||||
#define CLR_ITEM1 0xA
|
||||
#define CLR_ITEM2 0x8
|
||||
#define CLR_ITEM3 0x5
|
||||
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 = (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 (abs(i - 3) == 3) setTextColor(CLR_ITEM3, TFT_BG);
|
||||
if (abs(i - 3) == 2) setTextColor(CLR_ITEM2, TFT_BG);
|
||||
if (abs(i - 3) == 1) setTextColor(CLR_ITEM1, TFT_BG);
|
||||
if (i == 3) {
|
||||
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
|
||||
} else {
|
||||
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
|
||||
print(utf8Rus(plMenu[i], true));
|
||||
}
|
||||
}
|
||||
//display();
|
||||
}
|
||||
|
||||
void DspCore::clearDsp() {
|
||||
fillScreen(TFT_BG);
|
||||
//clearDisplay();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
void DspCore::getScrolBbounds(const char* text, const char* separator, byte textsize, uint16_t &tWidth, uint16_t &tHeight, uint16_t &sWidth) {
|
||||
int16_t x1, y1;
|
||||
uint16_t w, h;
|
||||
setTextSize(textsize);
|
||||
getTextBounds(text, 0, 0, &x1, &y1, &w, &h);
|
||||
tWidth = w;
|
||||
tHeight = h;
|
||||
getTextBounds(separator, 0, 0, &x1, &y1, &w, &h);
|
||||
sWidth = w;
|
||||
}
|
||||
|
||||
void DspCore::clearScroll(uint16_t texttop, uint16_t textheight, uint16_t bg) {
|
||||
fillRect(0, texttop, swidth, textheight, bg);
|
||||
}
|
||||
|
||||
void DspCore::centerText(const char* text, byte y, uint16_t fg, uint16_t bg) {
|
||||
int16_t x1, y1;
|
||||
uint16_t w, h;
|
||||
const char* txt = text;
|
||||
getTextBounds(txt, 0, 0, &x1, &y1, &w, &h);
|
||||
setTextColor(fg);
|
||||
setCursor((swidth - w) / 2, y);
|
||||
fillRect(0, y, swidth, h, bg);
|
||||
print(txt);
|
||||
}
|
||||
|
||||
void DspCore::rightText(const char* text, byte y, uint16_t fg, uint16_t bg) {
|
||||
int16_t x1, y1;
|
||||
uint16_t w, h;
|
||||
getTextBounds(text, 0, 0, &x1, &y1, &w, &h);
|
||||
setTextColor(fg, bg);
|
||||
setCursor(swidth - w - TFT_FRAMEWDT, y);
|
||||
fillRect(swidth - w - TFT_FRAMEWDT, y, w, h, bg);
|
||||
print(text);
|
||||
display();
|
||||
}
|
||||
|
||||
void DspCore::displayHeapForDebug() {
|
||||
|
||||
}
|
||||
|
||||
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) {
|
||||
uint16_t ncwidth, ncheight;
|
||||
setFont(&DS_DIGI28pt7b);
|
||||
setTextSize(1);
|
||||
getTextBounds(oldTimeBuf, 0, 0, &x, &y, &wot, &hot);
|
||||
setCursor((swidth - wot) / 2 - 4, clockY+28+6);
|
||||
setTextColor(TFT_BG);
|
||||
print(oldTimeBuf);
|
||||
strlcpy(oldTimeBuf, timestr, 20);
|
||||
setTextColor(TFT_LOGO);
|
||||
//fillRect(0, clockY, swidth, cheight + 3, TFT_BG);
|
||||
getTextBounds(timestr, 0, 0, &x, &y, &ncwidth, &ncheight);
|
||||
setCursor((swidth - ncwidth) / 2 - 4, clockY+28+6);
|
||||
print(timestr);
|
||||
setFont();
|
||||
display();
|
||||
}
|
||||
|
||||
void DspCore::drawVolumeBar(bool withNumber) {
|
||||
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);
|
||||
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);
|
||||
if (withNumber) {
|
||||
setTextSize(1);
|
||||
setTextColor(TFT_FG);
|
||||
setFont(&DS_DIGI28pt7b);
|
||||
char volstr[4];
|
||||
uint16_t wv, hv;
|
||||
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);
|
||||
print(volstr);
|
||||
setFont();
|
||||
display();
|
||||
}
|
||||
}
|
||||
|
||||
void DspCore::drawNextStationNum(uint16_t num) {
|
||||
setTextSize(1);
|
||||
setTextColor(TFT_FG);
|
||||
setFont(&DS_DIGI28pt7b);
|
||||
char numstr[7];
|
||||
uint16_t wv, hv;
|
||||
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);
|
||||
print(numstr);
|
||||
setFont();
|
||||
}
|
||||
|
||||
void DspCore::frameTitle(const char* str) {
|
||||
setTextSize(2);
|
||||
centerText(str, TFT_FRAMEWDT, TFT_LOGO, TFT_BG);
|
||||
}
|
||||
|
||||
void DspCore::rssi(const char* str) {
|
||||
int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT - 2;
|
||||
setTextSize(1);
|
||||
rightText(str, vTop, SILVER, TFT_BG);
|
||||
}
|
||||
|
||||
void DspCore::ip(const char* str) {
|
||||
int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT - 2;
|
||||
setTextSize(1);
|
||||
setTextColor(SILVER, TFT_BG);
|
||||
setCursor(4, vTop);
|
||||
print(str);
|
||||
}
|
||||
|
||||
void DspCore::set_TextSize(uint8_t s) {
|
||||
setTextSize(s);
|
||||
}
|
||||
|
||||
void DspCore::set_TextColor(uint16_t fg, uint16_t bg) {
|
||||
setTextColor(fg, bg);
|
||||
}
|
||||
|
||||
void DspCore::set_Cursor(int16_t x, int16_t y) {
|
||||
setCursor(x, y);
|
||||
}
|
||||
|
||||
void DspCore::printText(const char* txt) {
|
||||
print(txt);
|
||||
}
|
||||
|
||||
void DspCore::loop() {
|
||||
if (checkdelay(LOOP_DELAY, loopdelay)) {
|
||||
display();
|
||||
}
|
||||
yield();
|
||||
}
|
||||
|
||||
boolean DspCore::checkdelay(int m, unsigned long &tstamp) {
|
||||
if (millis() - tstamp > m) {
|
||||
tstamp = millis();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
71
yoRadio/src/displays/displaySSD1327.h
Normal file
71
yoRadio/src/displays/displaySSD1327.h
Normal file
@@ -0,0 +1,71 @@
|
||||
#ifndef displaySSD1327_h
|
||||
#define displaySSD1327_h
|
||||
|
||||
#include "Arduino.h"
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1327.h>
|
||||
#include "fonts/DS_DIGI28pt7b.h"
|
||||
|
||||
#define TFT_LINEHGHT 10
|
||||
#define TFT_FRAMEWDT 4
|
||||
|
||||
#define PLMITEMS 7
|
||||
#define PLMITEMLENGHT 40
|
||||
#define PLMITEMHEIGHT 22
|
||||
#define TITLE_TOP2 TFT_FRAMEWDT + 3 * TFT_LINEHGHT
|
||||
|
||||
#define SCROLLDELTA 4
|
||||
#define SCROLLTIME 83
|
||||
#define LOOP_DELAY 83
|
||||
|
||||
class DspCore: public Adafruit_SSD1327 {
|
||||
public:
|
||||
bool fillSpaces;
|
||||
DspCore();
|
||||
char plMenu[PLMITEMS][PLMITEMLENGHT];
|
||||
uint16_t clockY;
|
||||
void initD(uint16_t &screenwidth, uint16_t &screenheight);
|
||||
void apScreen();
|
||||
void drawLogo();
|
||||
void clearDsp();
|
||||
void centerText(const char* text, byte y, uint16_t fg, uint16_t bg);
|
||||
void rightText(const char* text, byte y, uint16_t fg, uint16_t bg);
|
||||
void set_TextSize(uint8_t s);
|
||||
void set_TextColor(uint16_t fg, uint16_t bg);
|
||||
void set_Cursor(int16_t x, int16_t y);
|
||||
void printText(const char* txt);
|
||||
void printClock(const char* timestr);
|
||||
void displayHeapForDebug();
|
||||
void drawVolumeBar(bool withNumber);
|
||||
void drawNextStationNum(uint16_t num);
|
||||
char* utf8Rus(const char* str, bool uppercase);
|
||||
void drawScrollFrame(uint16_t texttop, uint16_t textheight, uint16_t bg);
|
||||
void getScrolBbounds(const char* text, const char* separator, byte textsize, uint16_t &tWidth, uint16_t &tHeight, uint16_t &sWidth);
|
||||
void clearScroll(uint16_t texttop, uint16_t textheight, uint16_t bg);
|
||||
void frameTitle(const char* str);
|
||||
void rssi(const char* str);
|
||||
void ip(const char* str);
|
||||
void drawPlaylist(uint16_t currentItem, char* currentItemText);
|
||||
void loop();
|
||||
private:
|
||||
uint16_t swidth, sheight;
|
||||
int16_t x, y;
|
||||
uint16_t cwidth, cheight;
|
||||
unsigned long loopdelay;
|
||||
char oldTimeBuf[20];
|
||||
uint16_t wot, hot;
|
||||
boolean checkdelay(int m, unsigned long &tstamp);
|
||||
void setClockBounds();
|
||||
};
|
||||
|
||||
extern DspCore dsp;
|
||||
|
||||
/*
|
||||
* TFT COLORS
|
||||
*/
|
||||
#define SILVER 0x7
|
||||
#define TFT_BG 0x0
|
||||
#define TFT_FG 0x8
|
||||
#define TFT_LOGO 0xF
|
||||
|
||||
#endif
|
||||
@@ -13,6 +13,10 @@
|
||||
#define PLMITEMLENGHT 40
|
||||
#define PLMITEMHEIGHT 22
|
||||
#define TITLE_TOP2 TFT_FRAMEWDT + 3 * TFT_LINEHGHT
|
||||
#define TITLE_FG2 SILVER
|
||||
|
||||
#define SCROLLDELTA 3
|
||||
#define SCROLLTIME 67
|
||||
|
||||
class DspCore: public Adafruit_ST7735 {
|
||||
public:
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user