v0.8.00b
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
#include "../../options.h"
|
||||
#include "../core/options.h"
|
||||
#if DSP_MODEL==DSP_ILI9225
|
||||
|
||||
#include "displayILI9225.h"
|
||||
#include <SPI.h>
|
||||
#include "fonts/bootlogo.h"
|
||||
#include "../../player.h"
|
||||
#include "../../config.h"
|
||||
#include "../../network.h"
|
||||
#include "../core/player.h"
|
||||
#include "../core/config.h"
|
||||
#include "../core/network.h"
|
||||
|
||||
const char *dow[7] = {"вс","пн","вт","ср","чт","пт","сб"};
|
||||
const char *mnths[12] = {"января","февраля","марта","апреля","мая","июня","июля","августа","сентября","октября","ноября","декабря"};
|
||||
extern unsigned char yofont5x7[];
|
||||
extern unsigned char yofont10x14[];
|
||||
|
||||
@@ -21,102 +19,7 @@ DspCore::DspCore(): TFT_22_ILI9225(TFT_RST, TFT_DC, TFT_CS, 0) {
|
||||
|
||||
}
|
||||
|
||||
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() {
|
||||
started = true;
|
||||
clearDsp();
|
||||
setTextSize(TITLE_SIZE1);
|
||||
setTextColor(config.theme.title1, config.theme.background);
|
||||
setCursor(TFT_FRAMEWDT, TITLE_TOP1);
|
||||
print("AP NAME: ");
|
||||
print(apSsid);
|
||||
setCursor(TFT_FRAMEWDT, TITLE_TOP2);
|
||||
print("PASSWORD: ");
|
||||
print(apPassword);
|
||||
setTextColor(config.theme.title2, config.theme.background);
|
||||
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("/");
|
||||
TAKE_MUTEX();
|
||||
drawLine(TFT_FRAMEWDT, TITLE_TOP1-8, swidth-TFT_FRAMEWDT*2, TITLE_TOP1-8, config.theme.div);
|
||||
GIVE_MUTEX();
|
||||
}
|
||||
#include "tools/utf8RusGFX.h"
|
||||
|
||||
void DspCore::setTextSize(uint8_t s){
|
||||
if(s==2){
|
||||
@@ -127,59 +30,44 @@ void DspCore::setTextSize(uint8_t s){
|
||||
}
|
||||
|
||||
void DspCore::setTextColor(uint16_t fg, uint16_t bg){
|
||||
bgcolor=bg;
|
||||
setBackgroundColor(bgcolor);
|
||||
fgcolor=fg;
|
||||
_bgcolor=bg;
|
||||
setBackgroundColor(_bgcolor);
|
||||
_fgcolor=fg;
|
||||
}
|
||||
|
||||
void DspCore::setCursor(int16_t x, int16_t y){
|
||||
cursorx=x;
|
||||
cursory=y;
|
||||
_cursorx=x;
|
||||
_cursory=y;
|
||||
}
|
||||
|
||||
uint16_t DspCore::print(const char* s){
|
||||
TAKE_MUTEX();
|
||||
if(gFont){
|
||||
drawGFXText(cursorx, cursory, s, fgcolor);
|
||||
if(_gFont){
|
||||
drawGFXText(_cursorx, _cursory, s, _fgcolor);
|
||||
GIVE_MUTEX();
|
||||
return 0;
|
||||
}else{
|
||||
cursorx=drawText(cursorx, cursory, s, fgcolor);
|
||||
_cursorx=drawText(_cursorx, _cursory, s, _fgcolor);
|
||||
GIVE_MUTEX();
|
||||
return cursorx;
|
||||
}
|
||||
}
|
||||
|
||||
void DspCore::getTextBounds(const char *string, int16_t x, int16_t y, int16_t *x1,
|
||||
int16_t *y1, uint16_t *w, uint16_t *h){
|
||||
if(!gFont){
|
||||
_currentFont cfont = getFont();
|
||||
*w = getTextWidth(string);
|
||||
*h = cfont.height;
|
||||
}else{
|
||||
int16_t iw, ih;
|
||||
getGFXTextExtent(string, x, y, &iw, &ih);
|
||||
*w = (uint16_t)iw;
|
||||
*h = (uint16_t)ih;
|
||||
return _cursorx;
|
||||
}
|
||||
}
|
||||
|
||||
void DspCore::setFont(uint8_t* font, bool monoSp) {
|
||||
gFont = false;
|
||||
_gFont = false;
|
||||
TFT_22_ILI9225::setFont(font, monoSp);
|
||||
}
|
||||
|
||||
void DspCore::setFont(const GFXfont *f) {
|
||||
if (f) {
|
||||
gFont = true;
|
||||
_gFont = true;
|
||||
setGFXFont(f);
|
||||
} else {
|
||||
setFont(yofont5x7, false);
|
||||
}
|
||||
}
|
||||
|
||||
void DspCore::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
||||
uint16_t color) {
|
||||
void DspCore::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) {
|
||||
if(y<0){
|
||||
h=h+y;
|
||||
y=0;
|
||||
@@ -189,24 +77,37 @@ void DspCore::fillRect(int16_t x, int16_t y, int16_t w, int16_t h,
|
||||
GIVE_MUTEX();
|
||||
}
|
||||
|
||||
void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
|
||||
//hspi.begin();
|
||||
started = false;
|
||||
begin();
|
||||
invert();
|
||||
// clear(0x0000);
|
||||
flip();
|
||||
setTextSize(1);
|
||||
screenwidth = maxX();
|
||||
screenheight = maxY();
|
||||
swidth = screenwidth;
|
||||
sheight = screenheight;
|
||||
void DspCore::drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color){
|
||||
TAKE_MUTEX();
|
||||
drawRectangle(x, y, x+w, y+h, color);
|
||||
GIVE_MUTEX();
|
||||
}
|
||||
|
||||
void DspCore::drawLogo() {
|
||||
// setBackgroundColor(0x0000);
|
||||
drawBitmap((swidth - 99) / 2, (sheight-64)/2 - TFT_LINEHGHT*2, bootlogo2, 99, 64);
|
||||
// setBackgroundColor(config.theme.background);
|
||||
void DspCore::drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color){
|
||||
TAKE_MUTEX();
|
||||
drawLine(x, y, x, y+h, color);
|
||||
GIVE_MUTEX();
|
||||
}
|
||||
|
||||
void DspCore::drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color){
|
||||
TAKE_MUTEX();
|
||||
drawLine(x, y, x+w, y, color);
|
||||
GIVE_MUTEX();
|
||||
}
|
||||
|
||||
void DspCore::initDisplay() {
|
||||
TAKE_MUTEX();
|
||||
begin();
|
||||
invert();
|
||||
flip();
|
||||
setTextSize(1);
|
||||
GIVE_MUTEX();
|
||||
}
|
||||
|
||||
void DspCore::drawLogo(uint16_t top) {
|
||||
TAKE_MUTEX();
|
||||
drawBitmap((width() - 99) / 2, top, bootlogo2, 99, 64);
|
||||
GIVE_MUTEX();
|
||||
}
|
||||
|
||||
void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
|
||||
@@ -215,242 +116,124 @@ 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, config.theme.meta);
|
||||
int yStart = (height() / 2 - PLMITEMHEIGHT / 2) - PLMITEMHEIGHT * (PLMITEMS - 1) / 2 + 3;
|
||||
for (byte i = 0; i < PLMITEMS; i++) {
|
||||
if (i == 4) {
|
||||
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
|
||||
} else {
|
||||
setTextColor(config.theme.playlist[abs(i - 4)-1], config.theme.background);
|
||||
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
|
||||
fillRect(0, yStart + i * PLMITEMHEIGHT-1, swidth, PLMITEMHEIGHT-7, config.theme.background);
|
||||
fillRect(0, yStart + i * PLMITEMHEIGHT-1, width(), PLMITEMHEIGHT-7, config.theme.background);
|
||||
print(utf8Rus(plMenu[i], true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DspCore::clearDsp() {
|
||||
//fillRect(0, 0, swidth, sheight, config.theme.background);
|
||||
void DspCore::clearDsp(bool black) {
|
||||
TAKE_MUTEX();
|
||||
clear(started?config.theme.background:0x0000);
|
||||
clear(black?0x0000:config.theme.background);
|
||||
GIVE_MUTEX();
|
||||
}
|
||||
|
||||
void DspCore::drawScrollFrame(uint16_t texttop, uint16_t textheight, uint16_t bg) {
|
||||
if (TFT_FRAMEWDT==0) return;
|
||||
fillRect(swidth - TFT_FRAMEWDT, texttop, TFT_FRAMEWDT, textheight, bg);
|
||||
fillRect(0, texttop, TFT_FRAMEWDT-1, textheight, bg);
|
||||
GFXglyph *pgm_read_glyph_ptr(const GFXfont *gfxFont, uint8_t c) {
|
||||
return gfxFont->glyph + c;
|
||||
}
|
||||
|
||||
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;
|
||||
uint8_t DspCore::_charWidth(unsigned char c){
|
||||
GFXglyph *glyph = pgm_read_glyph_ptr(&DS_DIGI28pt7b, c - 0x20);
|
||||
return pgm_read_byte(&glyph->xAdvance);
|
||||
}
|
||||
|
||||
void DspCore::clearScroll(uint16_t texttop, uint16_t textheight, uint16_t bg) {
|
||||
fillRect(0, texttop, swidth, textheight, bg);
|
||||
uint16_t DspCore::textWidth(const char *txt){
|
||||
uint16_t w = 0, l=strlen(txt);
|
||||
for(uint16_t c=0;c<l;c++) w+=_charWidth(txt[c]);
|
||||
return w;
|
||||
}
|
||||
|
||||
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, bg);
|
||||
setCursor((swidth - w) / 2, y);
|
||||
fillRect((swidth-w)/2-5, y, w+10, h, bg);
|
||||
print(txt);
|
||||
void DspCore::_getTimeBounds() {
|
||||
_timewidth = textWidth(_timeBuf);
|
||||
char buf[4];
|
||||
strftime(buf, 4, "%H", &network.timeinfo);
|
||||
_dotsLeft=textWidth(buf);
|
||||
}
|
||||
|
||||
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);
|
||||
print(text);
|
||||
}
|
||||
|
||||
void DspCore::displayHeapForDebug() {
|
||||
int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT * 2 - 2;
|
||||
char buf[50];
|
||||
setTextSize(1);
|
||||
setTextColor(config.theme.heap, config.theme.background);
|
||||
setCursor(TFT_FRAMEWDT, vTop);
|
||||
fillRect(TFT_FRAMEWDT, vTop, swidth - TFT_FRAMEWDT / 2, 7, config.theme.background);
|
||||
sprintf(buf, "%d / %d", ESP.getFreeHeap(), ESP.getMaxAllocHeap());
|
||||
print(buf);
|
||||
// audio buffer;
|
||||
fillRect(0, sheight - 2, swidth, 2, config.theme.background);
|
||||
int astored = player.inBufferFilled();
|
||||
int afree = player.inBufferFree();
|
||||
int aprcnt = 100 * astored / (astored + afree);
|
||||
uint16_t sbw = map(aprcnt, 0, 100 , 0, swidth);
|
||||
fillRect(0, sheight - 2, sbw, 2, config.theme.buffer);
|
||||
}
|
||||
|
||||
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;
|
||||
gFont=true;
|
||||
setGFXFont(&DS_DIGI28pt7b);
|
||||
getTextBounds(oldTimeBuf, 0, 0, &x1, &y1, &wot, &hot);
|
||||
if(cltop==0){
|
||||
cltop=sheight-(TFT_FRAMEWDT * 2 + TFT_LINEHGHT + 38) - hot;
|
||||
}
|
||||
clwidth = wot+clsp+34;
|
||||
clleft=swidth-TFT_FRAMEWDT-clwidth;
|
||||
setCursor(clleft, cltop);
|
||||
setTextColor(config.theme.background, config.theme.background);
|
||||
print(oldTimeBuf);
|
||||
strlcpy(oldTimeBuf, timeBuf, 20);
|
||||
getTextBounds(timeBuf, 0, 0, &x1, &y1, &wot, &hot);
|
||||
clwidth = wot+clsp+34;
|
||||
clleft=swidth-TFT_FRAMEWDT-clwidth;
|
||||
setTextColor(config.theme.clock, config.theme.background);
|
||||
setCursor(clleft, cltop);
|
||||
print(timeBuf);
|
||||
gFont=false;
|
||||
setTextSize(2);
|
||||
setTextColor(config.theme.dow, config.theme.background);
|
||||
setCursor(clleft+wot+clsp, cltop-hot+22);
|
||||
print(utf8Rus(dow[timeinfo.tm_wday], false));
|
||||
TAKE_MUTEX();
|
||||
drawLine(clleft+wot+clsp/2, cltop-34, clleft+wot+clsp/2, cltop+1, config.theme.div); //vert
|
||||
drawLine(clleft+wot+clsp/2, cltop-hot+20, clleft+wot+clsp/2+35, cltop-hot+20, config.theme.div); //hor
|
||||
drawLine(TFT_FRAMEWDT, TITLE_TOP1-8, swidth-TFT_FRAMEWDT*2, TITLE_TOP1-8, config.theme.div);
|
||||
GIVE_MUTEX();
|
||||
sprintf(timeBuf, "%2d %s %d", timeinfo.tm_mday,mnths[timeinfo.tm_mon], timeinfo.tm_year+1900);
|
||||
uint16_t wdate, hdate;
|
||||
getTextBounds(timeBuf, 0, 0, &x1, &y1, &wdate, &hdate);
|
||||
fillRect(swidth - wdate - TFT_FRAMEWDT-20, cltop+10, wdate+20, hdate, config.theme.background);
|
||||
setTextSize(1);
|
||||
rightText(utf8Rus(timeBuf,true), cltop+10, config.theme.date, config.theme.background, false, 12);
|
||||
}
|
||||
void DspCore::_clockSeconds(){
|
||||
setTextSize(2);
|
||||
setTextColor(config.theme.seconds, config.theme.background);
|
||||
setCursor(clleft+wot+clsp, cltop-hot+1);
|
||||
sprintf(timeBuf, "%02d", timeinfo.tm_sec);
|
||||
print(timeBuf);
|
||||
setCursor(width() - 8 - clockRightSpace - CHARWIDTH*2*2, clockTop-clockTimeHeight+1);
|
||||
sprintf(_bufforseconds, "%02d", network.timeinfo.tm_sec);
|
||||
print(_bufforseconds); /* print seconds */
|
||||
}
|
||||
|
||||
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;
|
||||
(void)volTop;
|
||||
uint16_t ww = map(config.store.volume, 0, 254, 0, vWidth - 2);
|
||||
fillRect(TFT_FRAMEWDT, vTop - 2, vWidth, 6, config.theme.background);
|
||||
fillRect(TFT_FRAMEWDT + 1, vTop - 1, ww, 5, config.theme.volbarin);
|
||||
drawRectangle(TFT_FRAMEWDT, vTop - 2, TFT_FRAMEWDT+vWidth, 6+vTop - 2, config.theme.volbarout);
|
||||
|
||||
if (withNumber) {
|
||||
setTextSize(1);
|
||||
setTextColor(config.theme.digit, config.theme.background);
|
||||
setFont(&DS_DIGI28pt7b);
|
||||
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);*/
|
||||
sprintf(volstr, "%d", oldVolume);
|
||||
getTextBounds(volstr, 0, 0, &x1, &y1, &wv, &hv);
|
||||
fillRect((swidth - wv) / 2 - 12, (sheight-hv)/2, wv+24, hv, config.theme.background);
|
||||
|
||||
setTextColor(config.theme.vol, config.theme.background);
|
||||
sprintf(volstr, "%d", config.store.volume);
|
||||
getTextBounds(volstr, 0, 0, &x1, &y1, &wv, &hv);
|
||||
setCursor((swidth - wv) / 2, (sheight-hv)/2 + hv);
|
||||
print(volstr);
|
||||
oldVolume=config.store.volume;
|
||||
}
|
||||
void DspCore::_clockDate(){
|
||||
if(_olddateleft>0)
|
||||
fillRect(_olddateleft, clockTop+10, _olddatewidth, CHARHEIGHT, config.theme.background);
|
||||
setTextColor(config.theme.date, config.theme.background);
|
||||
setCursor(_dateleft, clockTop+10);
|
||||
print(_dateBuf); /* print date */
|
||||
strlcpy(_oldDateBuf, _dateBuf, sizeof(_dateBuf));
|
||||
_olddatewidth = _datewidth;
|
||||
_olddateleft = _dateleft;
|
||||
setTextSize(2);
|
||||
setTextColor(config.theme.dow, config.theme.background);
|
||||
setCursor(width() - 8 - clockRightSpace - CHARWIDTH*2*2, clockTop-CHARHEIGHT*2+4);
|
||||
print(utf8Rus(dow[network.timeinfo.tm_wday], false)); /* print dow */
|
||||
}
|
||||
|
||||
void DspCore::drawNextStationNum(uint16_t num) {
|
||||
void DspCore::_clockTime(){
|
||||
if(_oldtimeleft>0) fillRect(_oldtimeleft, clockTop-clockTimeHeight+1, _oldtimewidth, clockTimeHeight, config.theme.background);
|
||||
_timeleft = width()-clockRightSpace-CHARWIDTH*2*2-24-_timewidth;
|
||||
setTextSize(1);
|
||||
setTextColor(config.theme.digit, config.theme.background);
|
||||
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, (sheight-hv)/2, swidth - TFT_FRAMEWDT / 2, hv + 3, config.theme.background);
|
||||
setCursor((swidth - wv) / 2, (sheight-hv)/2 + hv);
|
||||
print(numstr);
|
||||
setTextColor(config.theme.clock, config.theme.background);
|
||||
setCursor(_timeleft, clockTop);
|
||||
print(_timeBuf);
|
||||
setFont();
|
||||
strlcpy(_oldTimeBuf, _timeBuf, sizeof(_timeBuf));
|
||||
_oldtimewidth = _timewidth;
|
||||
_oldtimeleft = _timeleft;
|
||||
drawFastVLine(width()-clockRightSpace-CHARWIDTH*2*2-18, clockTop-clockTimeHeight, clockTimeHeight+3, config.theme.div); /*divider vert*/
|
||||
drawFastHLine(width()-clockRightSpace-CHARWIDTH*2*2-18, clockTop-clockTimeHeight+21, 32, config.theme.div); /*divider hor*/
|
||||
sprintf(_buffordate, "%2d %s %d", network.timeinfo.tm_mday,mnths[network.timeinfo.tm_mon], network.timeinfo.tm_year+1900);
|
||||
strlcpy(_dateBuf, utf8Rus(_buffordate, true), sizeof(_dateBuf));
|
||||
_datewidth = strlen(_dateBuf) * CHARWIDTH;
|
||||
_dateleft = width() - 8 - clockRightSpace - _datewidth;
|
||||
}
|
||||
|
||||
void DspCore::frameTitle(const char* str) {
|
||||
setTextSize(META_SIZE);
|
||||
centerText(str, TFT_FRAMEWDT, config.theme.meta, config.theme.background);
|
||||
TAKE_MUTEX();
|
||||
drawLine(TFT_FRAMEWDT, TITLE_TOP1-8, swidth-TFT_FRAMEWDT*2, TITLE_TOP1-8, config.theme.div);
|
||||
GIVE_MUTEX();
|
||||
}
|
||||
|
||||
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, config.theme.rssi, config.theme.background);
|
||||
}
|
||||
|
||||
void DspCore::ip(const char* str) {
|
||||
if(!started){
|
||||
started = true;
|
||||
clear(config.theme.background);
|
||||
void DspCore::printClock(uint16_t top, uint16_t rightspace, uint16_t timeheight, bool redraw){
|
||||
clockTop = top;
|
||||
clockRightSpace = rightspace;
|
||||
clockTimeHeight = timeheight;
|
||||
strftime(_timeBuf, sizeof(_timeBuf), "%H:%M", &network.timeinfo);
|
||||
if(strcmp(_oldTimeBuf, _timeBuf)!=0 || redraw){
|
||||
_getTimeBounds();
|
||||
_clockTime();
|
||||
if(strcmp(_oldDateBuf, _dateBuf)!=0 || redraw) _clockDate();
|
||||
}
|
||||
int16_t vTop = sheight - TFT_FRAMEWDT * 2 - TFT_LINEHGHT - 2;
|
||||
char buf[30];
|
||||
sprintf(buf, "IP: %s", str);
|
||||
setTextSize(1);
|
||||
setTextColor(config.theme.ip, config.theme.background);
|
||||
setCursor(TFT_FRAMEWDT, vTop);
|
||||
print(buf);
|
||||
_clockSeconds();
|
||||
}
|
||||
|
||||
void DspCore::set_TextSize(uint8_t s) {
|
||||
setTextSize(s);
|
||||
void DspCore::clearClock(){
|
||||
fillRect(_timeleft, clockTop-clockTimeHeight, _timewidth+CHARWIDTH*3*2+24, clockTimeHeight+10+CHARHEIGHT, config.theme.background);
|
||||
}
|
||||
|
||||
void DspCore::set_TextColor(uint16_t fg, uint16_t bg) {
|
||||
setTextColor(fg, bg);
|
||||
void DspCore::startWrite(void) {
|
||||
//TAKE_MUTEX();
|
||||
TFT_22_ILI9225::startWrite();
|
||||
}
|
||||
|
||||
void DspCore::set_Cursor(int16_t x, int16_t y) {
|
||||
setCursor(x, y);
|
||||
void DspCore::endWrite(void) {
|
||||
TFT_22_ILI9225::endWrite();
|
||||
//GIVE_MUTEX();
|
||||
}
|
||||
|
||||
void DspCore::printText(const char* txt) {
|
||||
print(txt);
|
||||
void DspCore::loop(bool force) {
|
||||
//delay(5);
|
||||
}
|
||||
|
||||
void DspCore::loop(bool force) {
|
||||
|
||||
void DspCore::charSize(uint8_t textsize, uint8_t& width, uint16_t& height){
|
||||
width = textsize * CHARWIDTH;
|
||||
height = textsize * CHARHEIGHT;
|
||||
}
|
||||
|
||||
void DspCore::drawRGBBitmap(int16_t x, int16_t y, const uint16_t *bitmap, int16_t w, int16_t h) {
|
||||
@@ -458,14 +241,46 @@ void DspCore::drawRGBBitmap(int16_t x, int16_t y, const uint16_t *bitmap, int16_
|
||||
drawBitmap(x, y, bitmap, w, h);
|
||||
GIVE_MUTEX();
|
||||
}
|
||||
|
||||
void DspCore::flip(){
|
||||
TAKE_MUTEX();
|
||||
setOrientation(config.store.flipscreen?3:1);
|
||||
GIVE_MUTEX();
|
||||
}
|
||||
void DspCore::invert(){
|
||||
TAKE_MUTEX();
|
||||
invertDisplay(config.store.invertdisplay);
|
||||
GIVE_MUTEX();
|
||||
}
|
||||
|
||||
void DspCore::sleep(void) { setDisplay(false); }
|
||||
void DspCore::wake(void) { setDisplay(true); }
|
||||
void DspCore::sleep(void) { TAKE_MUTEX(); setDisplay(false); GIVE_MUTEX(); }
|
||||
void DspCore::wake(void) { TAKE_MUTEX(); setDisplay(true); GIVE_MUTEX(); }
|
||||
|
||||
void DspCore::writePixel(int16_t x, int16_t y, uint16_t color) { }
|
||||
|
||||
void DspCore::writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) { }
|
||||
|
||||
uint16_t DspCore::drawChar(uint16_t x, uint16_t y, uint16_t ch, uint16_t color) {
|
||||
if(_clipping){
|
||||
if ((x < _cliparea.left) || (x >= _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) {
|
||||
return cfont.width;
|
||||
}
|
||||
}
|
||||
return TFT_22_ILI9225::drawChar(x, y, ch, color);
|
||||
}
|
||||
|
||||
void DspCore::setClipping(clipArea ca){
|
||||
_cliparea = ca;
|
||||
_clipping = true;
|
||||
}
|
||||
|
||||
void DspCore::clearClipping(){
|
||||
_clipping = false;
|
||||
}
|
||||
|
||||
void DspCore::setNumFont(){
|
||||
setTextSize(1);
|
||||
setFont(&DS_DIGI28pt7b);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user