diff --git a/README.md b/README.md index 5c35f8d..9ee3f7b 100644 --- a/README.md +++ b/README.md @@ -235,6 +235,19 @@ Work is in progress... --- ## Version history +#### v0.9.670 +- display performance optimization +- to improve rendering smoothness, a framebuffer has been added for TFT SPI displays **ST7735, ST7789, ILI9341, GC9106, ST7796, GC9A01A, ILI9488, ILI9486** \ + the framebuffer is applied only to moving elements (scrolling text, VU meter, clock) \ + the framebuffer works on modules with additional **PSRAM** \ + on such modules, the framebuffer is enabled automatically, no extra steps required \ + to disable the framebuffer, add `#define USE_FBUFFER false` in **myoptions.h** \ + on modules without PSRAM, the framebuffer is disabled by default. It can be forced on by adding `#define SFBUFFER` in **myoptions.h** \ + but in that case, free memory (as well as HTTPS streams) will be severely limited \ +- fixed compilation error for Nextion displays +- code cleanup, optimization, and refactoring +- bug fixes + #### v0.9.574 - fixed compilation error for certain displays when `#define DSP_INVERT_TITLE false` is set - fixed compilation error for `DSP_DUMMY` diff --git a/yoRadio/src/ILI9225Fix/TFT_22_ILI9225Fix.h b/yoRadio/src/ILI9225Fix/TFT_22_ILI9225Fix.h index ed4f950..75e6178 100644 --- a/yoRadio/src/ILI9225Fix/TFT_22_ILI9225Fix.h +++ b/yoRadio/src/ILI9225Fix/TFT_22_ILI9225Fix.h @@ -8,7 +8,7 @@ //#define SPI_CHANNEL SPI_2 #endif -#define USE_STRING_CLASS +//#define USE_STRING_CLASS #ifdef USE_STRING_CLASS #define STRING String diff --git a/yoRadio/src/ILI9488/ILI9486_SPI.cpp b/yoRadio/src/ILI9488/ILI9486_SPI.cpp index 77464ab..1cc8c8f 100644 --- a/yoRadio/src/ILI9488/ILI9486_SPI.cpp +++ b/yoRadio/src/ILI9488/ILI9486_SPI.cpp @@ -161,6 +161,12 @@ void ILI9486_SPI::drawPixel(int16_t x, int16_t y, uint16_t color) #endif +void ILI9486_SPI::writePixels(uint16_t *colors, uint32_t len) { + _startTransaction(); + _writeColor16(colors, len); + _endTransaction(); +} + void ILI9486_SPI::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) { // if ((x < 0) || (y < 0) || (w < 1) || (h < 1) || (x + w > _width) || (y + h > _height)) diff --git a/yoRadio/src/ILI9488/ILI9486_SPI.h b/yoRadio/src/ILI9488/ILI9486_SPI.h index bd76240..6d8147e 100644 --- a/yoRadio/src/ILI9488/ILI9486_SPI.h +++ b/yoRadio/src/ILI9488/ILI9486_SPI.h @@ -23,6 +23,7 @@ class ILI9486_SPI : public Adafruit_GFX ILI9486_SPI(SPIClass *spiClass, int8_t cs, int8_t dc, int8_t rst); // (overridden) virtual methods virtual void drawPixel(int16_t x, int16_t y, uint16_t color); + void writePixels(uint16_t *colors, uint32_t len); virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); @@ -33,6 +34,7 @@ class ILI9486_SPI : public Adafruit_GFX void setSpiKludge(bool rpi_spi16_mode = true); // call with false before init to disable void init(void); void setWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h); + void setAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h) {setWindow(x, y, w, h);} void pushColors(const uint16_t* data, uint16_t n); // fast one void setBackLight(bool lit); uint16_t color565(uint8_t r, uint8_t g, uint8_t b); @@ -42,6 +44,8 @@ class ILI9486_SPI : public Adafruit_GFX virtual void _endTransaction(); void _writeCommand(uint8_t cmd); void sendCommand(uint8_t cmd); + void startWrite(void){} + void endWrite(void){} private: void _setWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h); void _writeCommand16(uint16_t cmd); diff --git a/yoRadio/src/audioVS1053/audioVS1053Ex.cpp b/yoRadio/src/audioVS1053/audioVS1053Ex.cpp index 00f6e3a..3723cc8 100644 --- a/yoRadio/src/audioVS1053/audioVS1053Ex.cpp +++ b/yoRadio/src/audioVS1053/audioVS1053Ex.cpp @@ -1687,23 +1687,24 @@ void Audio::setVUmeter() { * * \warning This feature is only available with patches that support VU meter. */ -const uint8_t everyn = 4; +//const uint8_t everyn = 4; void Audio::computeVUlevel() { - if(!VS_PATCH_ENABLE) return; + /*if(!VS_PATCH_ENABLE) return; static uint8_t cc = 0; cc++; if(!_vuInitalized || !config.store.vumeter || cc!=everyn) return; - if(cc==everyn) cc=0; + if(cc==everyn) cc=0;*/ int16_t reg = read_register(SCI_AICTRL3); vuLeft = map((uint8_t)(reg & 0x00FF), 85, 92, 0, 255); vuRight = map((uint8_t)(reg >> 8), 85, 92, 0, 255); - if(vuLeft>config.vuThreshold) config.vuThreshold = vuLeft; + if(vuLeft>config.vuThreshold) config.vuThreshold=vuLeft; if(vuRight>config.vuThreshold) config.vuThreshold=vuRight; } uint16_t Audio::get_VUlevel(uint16_t dimension){ if(!VS_PATCH_ENABLE) return 0; - if(!_vuInitalized || !config.store.vumeter || config.vuThreshold==0) return 0; + if(!_vuInitalized || !config.store.vumeter/* || config.vuThreshold==0*/) return 0; + computeVUlevel(); uint8_t L = map(vuLeft, config.vuThreshold, 0, 0, dimension); uint8_t R = map(vuRight, config.vuThreshold, 0, 0, dimension); return (L << 8) | R; diff --git a/yoRadio/src/core/audiohandlers.h b/yoRadio/src/core/audiohandlers.h index 737648d..bdeb8a8 100644 --- a/yoRadio/src/core/audiohandlers.h +++ b/yoRadio/src/core/audiohandlers.h @@ -51,7 +51,6 @@ bool printable(const char *info) { void audio_showstation(const char *info) { bool p = printable(info) && (strlen(info) > 0);(void)p; - //config.setTitle(p?info:config.station.name); if(player.remoteStationName){ config.setStation(p?info:config.station.name); display.putRequest(NEWSTATION); @@ -60,7 +59,6 @@ void audio_showstation(const char *info) { } void audio_showstreamtitle(const char *info) { - DBGH(); if (strstr(info, "Account already in use") != NULL || strstr(info, "HTTP/1.0 401") != NULL || strstr(info, "HTTP/1.1 401") != NULL) player.setError(info); bool p = printable(info) && (strlen(info) > 0); #ifdef DEBUG_TITLES @@ -71,9 +69,7 @@ void audio_showstreamtitle(const char *info) { } void audio_error(const char *info) { - //config.setTitle(info); player.setError(info); - //telnet.printf("##ERROR#:\t%s\n", info); } void audio_id3artist(const char *info){ diff --git a/yoRadio/src/core/commandhandler.cpp b/yoRadio/src/core/commandhandler.cpp index deea5b4..b793d9f 100644 --- a/yoRadio/src/core/commandhandler.cpp +++ b/yoRadio/src/core/commandhandler.cpp @@ -1,12 +1,17 @@ +#include +#include "options.h" #include "commandhandler.h" #include "player.h" #include "display.h" #include "netserver.h" #include "config.h" #include "controls.h" -#include "options.h" #include "telnet.h" +#if DSP_MODEL==DSP_DUMMY +#define DUMMYDISPLAY +#endif + CommandHandler cmd; bool CommandHandler::exec(const char *command, const char *value, uint8_t cid) { diff --git a/yoRadio/src/core/commandhandler.h b/yoRadio/src/core/commandhandler.h index c835426..41dd9a4 100644 --- a/yoRadio/src/core/commandhandler.h +++ b/yoRadio/src/core/commandhandler.h @@ -1,8 +1,6 @@ #ifndef commandhandler_h #define commandhandler_h -#include - class CommandHandler { public: bool exec(const char *command, const char *value, uint8_t cid=0); diff --git a/yoRadio/src/core/common.h b/yoRadio/src/core/common.h index 30a7fbf..ff8643b 100644 --- a/yoRadio/src/core/common.h +++ b/yoRadio/src/core/common.h @@ -1,10 +1,11 @@ #ifndef COMMON_H #define COMMON_H +#pragma once enum displayMode_e { PLAYER, VOL, STATIONS, NUMBERS, LOST, UPDATING, INFO, SETTINGS, TIMEZONE, WIFI, CLEAR, SLEEPING, SDCHANGE, SCREENSAVER, SCREENBLANK }; enum pages_e : uint8_t { PG_PLAYER=0, PG_DIALOG=1, PG_PLAYLIST=2, PG_SCREENSAVER=3 }; -enum displayRequestType_e { BOOTSTRING, NEWMODE, CLOCK, NEWTITLE, NEWSTATION, NEXTSTATION, DRAWPLAYLIST, DRAWVOL, DBITRATE, AUDIOINFO, SHOWVUMETER, DSPRSSI, SHOWWEATHER, NEWWEATHER, PSTOP, PSTART, DSP_START, WAITFORSD, SDFILEINDEX, NEWIP, NOPE }; +enum displayRequestType_e { BOOTSTRING, NEWMODE, CLOCK, NEWTITLE, NEWSTATION, NEXTSTATION, DRAWPLAYLIST, CLOSEPLAYLIST, DRAWVOL, DBITRATE, AUDIOINFO, SHOWVUMETER, DSPRSSI, SHOWWEATHER, NEWWEATHER, PSTOP, PSTART, DSP_START, WAITFORSD, SDFILEINDEX, NEWIP, NOPE }; struct requestParams_t { displayRequestType_e type; diff --git a/yoRadio/src/core/config.cpp b/yoRadio/src/core/config.cpp index 039c0cc..1469524 100644 --- a/yoRadio/src/core/config.cpp +++ b/yoRadio/src/core/config.cpp @@ -1,32 +1,28 @@ +#include "options.h" #include "config.h" - -//#include #include "display.h" #include "player.h" #include "network.h" #include "netserver.h" #include "controls.h" #include "timekeeper.h" +#include "telnet.h" +#include "rtcsupport.h" +#include "../displays/tools/l10n.h" #ifdef USE_SD #include "sdmanager.h" #endif +#ifdef USE_NEXTION +#include "../displays/nextion.h" +#endif #include -Config config; - -#ifdef HEAP_DBG -void printHeapFragmentationInfo(const char* title){ - size_t freeHeap = heap_caps_get_free_size(MALLOC_CAP_DEFAULT); - size_t largestBlock = heap_caps_get_largest_free_block(MALLOC_CAP_DEFAULT); - float fragmentation = 100.0 * (1.0 - ((float)largestBlock / (float)freeHeap)); - Serial.printf("\n****** %s ******\n", title); - Serial.printf("* Free heap: %u bytes\n", freeHeap); - Serial.printf("* Largest free block: %u bytes\n", largestBlock); - Serial.printf("* Fragmentation: %.2f%%\n", fragmentation); - Serial.printf("*************************************\n\n"); -} +#if DSP_MODEL==DSP_DUMMY +#define DUMMYDISPLAY #endif +Config config; + void u8fix(char *src){ char last = src[strlen(src)-1]; if ((uint8_t)last >= 0xC2) src[strlen(src)-1]='\0'; @@ -143,9 +139,8 @@ void Config::_setupVersion(){ saveValue(&store.version, currentVersion); } -#ifdef USE_SD - void Config::changeMode(int newmode){ +#ifdef USE_SD bool pir = player.isRunning(); if(SDC_CS==255) return; if(getMode()==PM_SDCARD) { @@ -196,9 +191,11 @@ void Config::changeMode(int newmode){ display.resetQueue(); display.putRequest(NEWMODE, PLAYER); display.putRequest(NEWSTATION); +#endif } void Config::initSDPlaylist() { +#ifdef USE_SD //store.countStation = 0; bool doIndex = !sdman.exists(INDEX_SD_PATH); if(doIndex) sdman.indexSDPlaylist(); @@ -212,9 +209,8 @@ void Config::initSDPlaylist() { index.close(); //saveValue(&store.countStation, store.countStation, true, true); } -} - #endif //#ifdef USE_SD +} bool Config::spiffsCleanup(){ bool ret = (SPIFFS.exists(PLAYLIST_SD_PATH)) || (SPIFFS.exists(INDEX_SD_PATH)) || (SPIFFS.exists(INDEX_PATH)); @@ -243,9 +239,9 @@ bool Config::prepareForPlaying(uint16_t stationId){ } if(!loadStation(stationId)) return false; - setTitle(getMode()==PM_WEB?const_PlConnect:"[next track]"); + setTitle(getMode()==PM_WEB?LANG::const_PlConnect:"[next track]"); station.bitrate=0; - setBitrateFormat(BF_UNCNOWN); + setBitrateFormat(BF_UNKNOWN); display.putRequest(DBITRATE); display.putRequest(NEWSTATION); display.putRequest(NEWMODE, PLAYER); @@ -782,52 +778,6 @@ char * Config::stationByNum(uint16_t num){ return _stationBuf; } -uint8_t Config::fillPlMenu(int from, uint8_t count, bool fromNextion) { - int ls = from; - uint8_t c = 0; - bool finded = false; - if (playlistLength() == 0) { - return 0; - } - File playlist = SDPLFS()->open(REAL_PLAYL, "r"); - File index = SDPLFS()->open(REAL_INDEX, "r"); - while (true) { - if (ls < 1) { - ls++; - if(!fromNextion) display.printPLitem(c, ""); - #ifdef USE_NEXTION - if(fromNextion) nextion.printPLitem(c, ""); - #endif - c++; - continue; - } - if (!finded) { - index.seek((ls - 1) * 4, SeekSet); - uint32_t pos; - index.readBytes((char *) &pos, 4); - finded = true; - index.close(); - playlist.seek(pos, SeekSet); - } - bool pla = true; - while (pla) { - pla = playlist.available(); - String stationName = playlist.readStringUntil('\n'); - stationName = stationName.substring(0, stationName.indexOf('\t')); - if(config.store.numplaylist && stationName.length()>0) stationName = String(from+c)+" "+stationName; - if(!fromNextion) display.printPLitem(c, stationName.c_str()); - #ifdef USE_NEXTION - if(fromNextion) nextion.printPLitem(c, stationName.c_str()); - #endif - c++; - if (c >= count) break; - } - break; - } - playlist.close(); - return c; -} - void Config::escapeQuotes(const char* input, char* output, size_t maxLen) { size_t j = 0; for (size_t i = 0; input[i] != '\0' && j < maxLen - 1; ++i) { diff --git a/yoRadio/src/core/config.h b/yoRadio/src/core/config.h index feeb4d0..b9a7231 100644 --- a/yoRadio/src/core/config.h +++ b/yoRadio/src/core/config.h @@ -1,22 +1,16 @@ #ifndef config_h #define config_h +#pragma once #include "Arduino.h" #include #include #include -//#include "SD.h" -#include "options.h" -#include "telnet.h" -#include "rtcsupport.h" -#include "../pluginsManager/pluginsManager.h" +#include "../displays/widgets/widgetsconfig.h" //BitrateFormat #define EEPROM_SIZE 768 #define EEPROM_START 500 #define EEPROM_START_IR 0 #define EEPROM_START_2 10 -#ifndef BUFLEN - #define BUFLEN 170 -#endif #define PLAYLIST_PATH "/data/playlist.csv" #define SSIDS_PATH "/data/wifi.csv" #define TMP_PATH "/data/tmpfile.txt" @@ -25,39 +19,20 @@ #define PLAYLIST_SD_PATH "/data/playlistsd.csv" #define INDEX_SD_PATH "/data/indexsd.dat" -#ifdef DEBUG_V -#define DBGH() { Serial.printf("[%s:%s:%d] Heap: %d\n", __PRETTY_FUNCTION__, __FILE__, __LINE__, xPortGetFreeHeapSize()); } -#define DBGVB( ... ) { char buf[200]; sprintf( buf, __VA_ARGS__ ) ; Serial.print("[DEBUG]\t"); Serial.println(buf); } -#else -#define DBGVB( ... ) -#define DBGH() -#endif -#define BOOTLOG( ... ) { char buf[120]; sprintf( buf, __VA_ARGS__ ) ; telnet.print("##[BOOT]#\t"); telnet.printf("%s\n",buf); } -#define EVERY_MS(x) static uint32_t tmr; bool flag = millis() - tmr >= (x); if (flag) tmr += (x); if (flag) -#define REAL_PLAYL getMode()==PM_WEB?PLAYLIST_PATH:PLAYLIST_SD_PATH -#define REAL_INDEX getMode()==PM_WEB?INDEX_PATH:INDEX_SD_PATH +#define REAL_PLAYL config.getMode()==PM_WEB?PLAYLIST_PATH:PLAYLIST_SD_PATH +#define REAL_INDEX config.getMode()==PM_WEB?INDEX_PATH:INDEX_SD_PATH #define MAX_PLAY_MODE 1 #define WEATHERKEY_LENGTH 58 #define MDNS_LENGTH 24 -#if SDC_CS!=255 - #define USE_SD -#endif + #if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0) #define ESP_ARDUINO_3 1 #endif -#ifdef HEAP_DBG - #define HEAP_INFO() printHeapFragmentationInfo(__PRETTY_FUNCTION__) - void printHeapFragmentationInfo(const char* title); -#else - #define HEAP_INFO() -#endif - #define CONFIG_VERSION 5 enum playMode_e : uint8_t { PM_WEB=0, PM_SDCARD=1 }; -enum BitrateFormat { BF_UNCNOWN, BF_MP3, BF_AAC, BF_FLAC, BF_OGG, BF_WAV }; void u8fix(char *src); @@ -193,7 +168,7 @@ class Config { uint8_t irchck; ircodes_t ircodes; #endif - BitrateFormat configFmt = BF_UNCNOWN; + BitrateFormat configFmt = BF_UNKNOWN; neworkItem ssids[5]; uint8_t ssidsCount; uint16_t sleepfor; @@ -239,10 +214,8 @@ class Config { void setBitrateFormat(BitrateFormat fmt) { configFmt = fmt; } void initPlaylist(); void indexPlaylist(); - #ifdef USE_SD - void initSDPlaylist(); - void changeMode(int newmode=-1); - #endif + void initSDPlaylist(); + void changeMode(int newmode=-1); uint16_t playlistLength(); uint16_t lastStation(){ return getMode()==PM_WEB?store.lastStation:store.lastSdStation; @@ -251,7 +224,6 @@ class Config { if(getMode()==PM_WEB) saveValue(&store.lastStation, newstation); else saveValue(&store.lastSdStation, newstation); } - uint8_t fillPlMenu(int from, uint8_t count, bool fromNextion=false); char * stationByNum(uint16_t num); void setTimezone(int8_t tzh, int8_t tzm); void setTimezoneOffset(uint16_t tzo); @@ -285,9 +257,7 @@ class Config { bool prepareForPlaying(uint16_t stationId); void configPostPlaying(uint16_t stationId); FS* SDPLFS(){ return _SDplaylistFS; } - #if RTCSUPPORTED - bool isRTCFound(){ return _rtcFound; }; - #endif + bool isRTCFound(){ return _rtcFound; }; template size_t getAddr(const T *field) const { return (size_t)((const uint8_t *)field - (const uint8_t *)&store) + EEPROM_START; @@ -321,9 +291,7 @@ class Config { template int eepromWrite(int ee, const T& value); template int eepromRead(int ee, T& value); bool _bootDone; - #if RTCSUPPORTED - bool _rtcFound; - #endif + bool _rtcFound; FS* _SDplaylistFS; void setDefaults(); static void doSleep(); diff --git a/yoRadio/src/core/controls.cpp b/yoRadio/src/core/controls.cpp index 2175c5d..31568ce 100644 --- a/yoRadio/src/core/controls.cpp +++ b/yoRadio/src/core/controls.cpp @@ -1,16 +1,21 @@ #include "Arduino.h" -#include "controls.h" #include "options.h" +#include "controls.h" #include "config.h" #include "player.h" #include "display.h" #include "network.h" #include "netserver.h" +#include "../pluginsManager/pluginsManager.h" long encOldPosition = 0; long enc2OldPosition = 0; int lpId = -1; +#if DSP_MODEL==DSP_DUMMY +#define DUMMYDISPLAY +#endif + #define ISPUSHBUTTONS BTN_LEFT!=255 || BTN_CENTER!=255 || BTN_RIGHT!=255 || ENC_BTNB!=255 || BTN_UP!=255 || BTN_DOWN!=255 || ENC2_BTNB!=255 || BTN_MODE!=255 #if ISPUSHBUTTONS #include "../OneButton/OneButton.h" @@ -34,6 +39,7 @@ constexpr uint8_t nrOfButtons = sizeof(button) / sizeof(button[0]); #endif #if (ENC_BTNL!=255 && ENC_BTNR!=255) || (ENC2_BTNL!=255 && ENC2_BTNR!=255) + #include "../yoEncoder/yoEncoder.h" #if (ENC_BTNL!=255 && ENC_BTNR!=255) yoEncoder encoder = yoEncoder(ENC_BTNL, ENC_BTNR, ENCODER_STEPS, ENC_INTERNALPULLUP); #endif @@ -115,7 +121,7 @@ void initControls() { } #endif #if (TS_MODEL!=TS_MODEL_UNDEFINED) && (DSP_MODEL!=DSP_DUMMY) - touchscreen.init(); + touchscreen.init(display.width(), display.height()); #endif #if IR_PIN!=255 pinMode(IR_PIN, INPUT); @@ -502,7 +508,8 @@ void onBtnClick(int id) { #ifdef DSP_LCD delay(200); #endif - player.sendCommand({PR_PLAY, display.currentPlItem}); + display.putRequest(CLOSEPLAYLIST, display.currentPlItem); + //player.sendCommand({PR_PLAY, display.currentPlItem}); } if(network.status==SOFT_AP || display.mode()==LOST){ #ifdef USE_SD diff --git a/yoRadio/src/core/controls.h b/yoRadio/src/core/controls.h index bf2919d..30ca3f5 100644 --- a/yoRadio/src/core/controls.h +++ b/yoRadio/src/core/controls.h @@ -1,14 +1,7 @@ #ifndef controls_h #define controls_h -#include "options.h" #include "common.h" -#if (ENC_BTNL!=255 && ENC_BTNR!=255) || (ENC2_BTNL!=255 && ENC2_BTNR!=255) - #include "../yoEncoder/yoEncoder.h" -#endif - -//enum tsDirection_e { TSD_STAY, TSD_LEFT, TSD_RIGHT, TSD_UP, TSD_DOWN, TDS_REQUEST }; - #if IR_PIN!=255 enum : uint8_t { IR_UP=0, IR_PREV=1, IR_PLAY=2, IR_NEXT=3, IR_DOWN=4, IR_1=5, IR_2=6, IR_3=7, IR_4=8, IR_5=9, IR_6=10, IR_7=11, IR_8=12, IR_9=13, IR_AST=14, IR_0=15, IR_HASH=16 }; #endif @@ -18,12 +11,12 @@ boolean checklpdelay(int m, unsigned long &tstamp); void initControls(); void loopControls(); #if (ENC_BTNL!=255 && ENC_BTNR!=255) || (ENC2_BTNL!=255 && ENC2_BTNR!=255) +class yoEncoder; void encodersLoop(yoEncoder *enc, bool first=true); #endif void encoder1Loop(); void encoder2Loop(); void irLoop(); -//void touchLoop(); void irNumber(uint8_t num); void irBlink(); void controlsEvent(bool toRight, int8_t volDelta = 0); @@ -33,7 +26,6 @@ void onBtnDoubleClick(int id); void onBtnDuringLongPress(int id); void onBtnLongPressStart(int id); void onBtnLongPressStop(int id); -//tsDirection_e tsDirection(uint16_t x, uint16_t y); void setIRTolerance(uint8_t tl); void setEncAcceleration(uint16_t acc); diff --git a/yoRadio/src/core/display.cpp b/yoRadio/src/core/display.cpp index f8ee071..6fcee31 100644 --- a/yoRadio/src/core/display.cpp +++ b/yoRadio/src/core/display.cpp @@ -1,15 +1,22 @@ +#include "Arduino.h" #include "options.h" - #include "WiFi.h" #include "time.h" +#include "config.h" #include "display.h" #include "player.h" #include "network.h" #include "netserver.h" #include "timekeeper.h" +#include "../pluginsManager/pluginsManager.h" +#include "../displays/dspcore.h" +#include "../displays/widgets/widgets.h" +#include "../displays/widgets/pages.h" +#include "../displays/tools/l10n.h" Display display; #ifdef USE_NEXTION +#include "../displays/nextion.h" Nextion nextion; #endif @@ -76,6 +83,18 @@ void returnPlayer(){ display.putRequest(NEWMODE, PLAYER); } +Display::~Display() { + delete _pager; + delete _footer; + delete _plwidget; + delete _nums; + delete _clock; + delete _meta; + delete _title1; + delete _title2; + delete _plcurrent; +} + void Display::init() { Serial.print("##[BOOT]#\tdisplay.init\t"); #ifdef USE_NEXTION @@ -93,30 +112,57 @@ void Display::init() { while(!_bootStep==0) { delay(10); } //_pager.begin(); //_bootScreen(); + _pager = new Pager(); + _footer = new Page(); + _plwidget = new PlayListWidget(); + _nums = new NumWidget(); + _clock = new ClockWidget(); + _meta = new ScrollWidget(); + _title1 = new ScrollWidget(); + _plcurrent = new ScrollWidget(); Serial.println("done"); } +uint16_t Display::width(){ return dsp.width(); } +uint16_t Display::height(){ return dsp.height(); } +#if TIME_SIZE>19 + #if DSP_MODEL==DSP_SSD1322 + #define BOOT_PRG_COLOR WHITE + #define BOOT_TXT_COLOR WHITE + #define PINK WHITE + #elif DSP_MODEL==DSP_SSD1327 + #define BOOT_PRG_COLOR 0x07 + #define BOOT_TXT_COLOR 0x3f + #define PINK 0x02 + #else + #define BOOT_PRG_COLOR 0xE68B + #define BOOT_TXT_COLOR 0xFFFF + #define PINK 0xF97F + #endif +#endif + void Display::_bootScreen(){ _boot = new Page(); _boot->addWidget(new ProgressWidget(bootWdtConf, bootPrgConf, BOOT_PRG_COLOR, 0)); _bootstring = (TextWidget*) &_boot->addWidget(new TextWidget(bootstrConf, 50, true, BOOT_TXT_COLOR, 0)); - _pager.addPage(_boot); - _pager.setPage(_boot, true); + _pager->addPage(_boot); + _pager->setPage(_boot, true); dsp.drawLogo(bootLogoTop); _bootStep = 1; } void Display::_buildPager(){ - _meta.init("*", metaConf, config.theme.meta, config.theme.metabg); - _title1.init("*", title1Conf, config.theme.title1, config.theme.background); - _clock.init(clockConf, 0, 0); + _meta->init("*", metaConf, config.theme.meta, config.theme.metabg); + _title1->init("*", title1Conf, config.theme.title1, config.theme.background); + _clock->init(clockConf, 0, 0); #if DSP_MODEL==DSP_NOKIA5110 - _plcurrent.init("*", playlistConf, 0, 1); + _plcurrent->init("*", playlistConf, 0, 1); #else - _plcurrent.init("*", playlistConf, config.theme.plcurrent, config.theme.plcurrentbg); + _plcurrent->init("*", playlistConf, config.theme.plcurrent, config.theme.plcurrentbg); #endif + _plwidget->init(_plcurrent); #if !defined(DSP_LCD) - _plcurrent.moveTo({TFT_FRAMEWDT, (uint16_t)(dsp.plYStart+dsp.plCurrentPos*dsp.plItemHeight), (int16_t)playlistConf.width}); + _plcurrent->moveTo({TFT_FRAMEWDT, (uint16_t)(_plwidget->currentTop()), (int16_t)playlistConf.width}); #endif #ifndef HIDE_TITLE2 _title2 = new ScrollWidget("*", title2Conf, config.theme.title2, config.theme.background); @@ -151,20 +197,20 @@ void Display::_buildPager(){ #ifndef HIDE_RSSI _rssi = new TextWidget(rssiConf, 20, false, config.theme.rssi, config.theme.background); #endif - _nums.init(numConf, 10, false, config.theme.digit, config.theme.background); + _nums->init(numConf, 10, false, config.theme.digit, config.theme.background); #ifndef HIDE_WEATHER _weather = new ScrollWidget("\007", weatherConf, config.theme.weather, config.theme.background); #endif - if(_volbar) _footer.addWidget( _volbar); - if(_voltxt) _footer.addWidget( _voltxt); - if(_volip) _footer.addWidget( _volip); - if(_rssi) _footer.addWidget( _rssi); - if(_heapbar) _footer.addWidget( _heapbar); + if(_volbar) _footer->addWidget( _volbar); + if(_voltxt) _footer->addWidget( _voltxt); + if(_volip) _footer->addWidget( _volip); + if(_rssi) _footer->addWidget( _rssi); + if(_heapbar) _footer->addWidget( _heapbar); if(_metabackground) pages[PG_PLAYER]->addWidget( _metabackground); - pages[PG_PLAYER]->addWidget(&_meta); - pages[PG_PLAYER]->addWidget(&_title1); + pages[PG_PLAYER]->addWidget(_meta); + pages[PG_PLAYER]->addWidget(_title1); if(_title2) pages[PG_PLAYER]->addWidget(_title2); if(_weather) pages[PG_PLAYER]->addWidget(_weather); #if BITRATE_FULL @@ -175,31 +221,31 @@ void Display::_buildPager(){ pages[PG_PLAYER]->addWidget( _bitrate); #endif if(_vuwidget) pages[PG_PLAYER]->addWidget( _vuwidget); - pages[PG_PLAYER]->addWidget(&_clock); - pages[PG_SCREENSAVER]->addWidget(&_clock); - pages[PG_PLAYER]->addPage(&_footer); + pages[PG_PLAYER]->addWidget(_clock); + pages[PG_SCREENSAVER]->addWidget(_clock); + pages[PG_PLAYER]->addPage(_footer); if(_metabackground) pages[PG_DIALOG]->addWidget( _metabackground); - pages[PG_DIALOG]->addWidget(&_meta); - pages[PG_DIALOG]->addWidget(&_nums); + pages[PG_DIALOG]->addWidget(_meta); + pages[PG_DIALOG]->addWidget(_nums); #if !defined(DSP_LCD) && DSP_MODEL!=DSP_NOKIA5110 - pages[PG_DIALOG]->addPage(&_footer); + pages[PG_DIALOG]->addPage(_footer); #endif #if !defined(DSP_LCD) if(_plbackground) { pages[PG_PLAYLIST]->addWidget( _plbackground); - _plbackground->setHeight(dsp.plItemHeight); - _plbackground->moveTo({0,(uint16_t)(dsp.plYStart+dsp.plCurrentPos*dsp.plItemHeight-playlistConf.widget.textsize*2), (int16_t)playlBGConf.width}); + _plbackground->setHeight(_plwidget->itemHeight()); + _plbackground->moveTo({0,(uint16_t)(_plwidget->currentTop()-playlistConf.widget.textsize*2), (int16_t)playlBGConf.width}); } #endif - pages[PG_PLAYLIST]->addWidget(&_plcurrent); - - for(const auto& p: pages) _pager.addPage(p); + pages[PG_PLAYLIST]->addWidget(_plcurrent); + pages[PG_PLAYLIST]->addWidget(_plwidget); + for(const auto& p: pages) _pager->addPage(p); } void Display::_apScreen() { - if(_boot) _pager.removePage(_boot); + if(_boot) _pager->removePage(_boot); #ifndef DSP_LCD _boot = new Page(); #if DSP_MODEL!=DSP_NOKIA5110 @@ -212,24 +258,24 @@ void Display::_apScreen() { ScrollWidget *bootTitle = (ScrollWidget*) &_boot->addWidget(new ScrollWidget("*", apTitleConf, config.theme.meta, config.theme.metabg)); bootTitle->setText("ёRadio AP Mode"); TextWidget *apname = (TextWidget*) &_boot->addWidget(new TextWidget(apNameConf, 30, false, config.theme.title1, config.theme.background)); - apname->setText(apNameTxt); + apname->setText(LANG::apNameTxt); TextWidget *apname2 = (TextWidget*) &_boot->addWidget(new TextWidget(apName2Conf, 30, false, config.theme.clock, config.theme.background)); apname2->setText(apSsid); TextWidget *appass = (TextWidget*) &_boot->addWidget(new TextWidget(apPassConf, 30, false, config.theme.title1, config.theme.background)); - appass->setText(apPassTxt); + appass->setText(LANG::apPassTxt); TextWidget *appass2 = (TextWidget*) &_boot->addWidget(new TextWidget(apPass2Conf, 30, false, config.theme.clock, config.theme.background)); appass2->setText(apPassword); ScrollWidget *bootSett = (ScrollWidget*) &_boot->addWidget(new ScrollWidget("*", apSettConf, config.theme.title2, config.theme.background)); - bootSett->setText(config.ipToStr(WiFi.softAPIP()), apSettFmt); - _pager.addPage(_boot); - _pager.setPage(_boot); + bootSett->setText(config.ipToStr(WiFi.softAPIP()), LANG::apSettFmt); + _pager->addPage(_boot); + _pager->setPage(_boot); #else dsp.apScreen(); #endif } void Display::_start() { - if(_boot) _pager.removePage(_boot); + if(_boot) _pager->removePage(_boot); #ifdef USE_NEXTION nextion.wake(); #endif @@ -247,19 +293,19 @@ void Display::_start() { #endif _buildPager(); _mode = PLAYER; - config.setTitle(const_PlReady); + config.setTitle(LANG::const_PlReady); if(_heapbar) _heapbar->lock(!config.store.audioinfo); if(_weather) _weather->lock(!config.store.showweather); - if(_weather && config.store.showweather) _weather->setText(const_getWeather); + if(_weather && config.store.showweather) _weather->setText(LANG::const_getWeather); if(_vuwidget) _vuwidget->lock(); if(_rssi) _setRSSI(WiFi.RSSI()); #ifndef HIDE_IP if(_volip) _volip->setText(config.ipToStr(WiFi.localIP()), iptxtFmt); #endif - _pager.setPage( pages[PG_PLAYER]); + _pager->setPage( pages[PG_PLAYER]); _volume(); _station(); _time(false); @@ -269,12 +315,12 @@ void Display::_start() { void Display::_showDialog(const char *title){ dsp.setScrollId(NULL); - _pager.setPage( pages[PG_DIALOG]); + _pager->setPage( pages[PG_DIALOG]); #ifdef META_MOVE - _meta.moveTo(metaMove); + _meta->moveTo(metaMove); #endif - _meta.setAlign(WA_CENTER); - _meta.setText(title); + _meta->setAlign(WA_CENTER); + _meta->setText(title); } void Display::_swichMode(displayMode_e newmode) { @@ -287,29 +333,30 @@ void Display::_swichMode(displayMode_e newmode) { dsp.setScrollId(NULL); if (newmode == PLAYER) { if(player.isRunning()) - _clock.moveTo(clockMove); + _clock->moveTo(clockMove); else - _clock.moveBack(); + _clock->moveBack(); #ifdef DSP_LCD dsp.clearDsp(); #endif numOfNextStation = 0; #ifdef META_MOVE - _meta.moveBack(); + _meta->moveBack(); #endif - _meta.setAlign(metaConf.widget.align); - _meta.setText(config.station.name); - _nums.setText(""); + _meta->setAlign(metaConf.widget.align); + _meta->setText(config.station.name); + _nums->setText(""); config.isScreensaver = false; - _pager.setPage( pages[PG_PLAYER]); + _pager->setPage( pages[PG_PLAYER]); config.setDspOn(config.store.dspon, false); pm.on_display_player(); } if (newmode == SCREENSAVER || newmode == SCREENBLANK) { config.isScreensaver = true; - _pager.setPage( pages[PG_SCREENSAVER]); + _pager->setPage( pages[PG_SCREENSAVER]); if (newmode == SCREENBLANK) { - dsp.clearClock(); + //dsp.clearClock(); + _clock->clear(); config.setDspOn(false, false); } }else{ @@ -319,21 +366,21 @@ void Display::_swichMode(displayMode_e newmode) { } if (newmode == VOL) { #ifndef HIDE_IP - _showDialog(const_DlgVolume); + _showDialog(LANG::const_DlgVolume); #else _showDialog(config.ipToStr(WiFi.localIP())); #endif - _nums.setText(config.store.volume, numtxtFmt); + _nums->setText(config.store.volume, numtxtFmt); } - if (newmode == LOST) _showDialog(const_DlgLost); - if (newmode == UPDATING) _showDialog(const_DlgUpdate); + if (newmode == LOST) _showDialog(LANG::const_DlgLost); + if (newmode == UPDATING) _showDialog(LANG::const_DlgUpdate); if (newmode == SLEEPING) _showDialog("SLEEPING"); - if (newmode == SDCHANGE) _showDialog(const_waitForSD); - if (newmode == INFO || newmode == SETTINGS || newmode == TIMEZONE || newmode == WIFI) _showDialog(const_DlgNextion); + if (newmode == SDCHANGE) _showDialog(LANG::const_waitForSD); + if (newmode == INFO || newmode == SETTINGS || newmode == TIMEZONE || newmode == WIFI) _showDialog(LANG::const_DlgNextion); if (newmode == NUMBERS) _showDialog(""); if (newmode == STATIONS) { - _pager.setPage( pages[PG_PLAYLIST]); - _plcurrent.setText(""); + _pager->setPage( pages[PG_PLAYLIST]); + _plcurrent->setText(""); currentPlItem = config.lastStation(); _drawPlaylist(); } @@ -345,18 +392,15 @@ void Display::resetQueue(){ } void Display::_drawPlaylist() { - dsp.drawPlaylist(currentPlItem); + //dsp.drawPlaylist(currentPlItem); + _plwidget->drawPlaylist(currentPlItem); timekeeper.waitAndReturnPlayer(30); } void Display::_drawNextStationNum(uint16_t num) { timekeeper.waitAndReturnPlayer(30); - _meta.setText(config.stationByNum(num)); - _nums.setText(num, "%d"); -} - -void Display::printPLitem(uint8_t pos, const char* item){ - dsp.printPLitem(pos, item, _plcurrent); + _meta->setText(config.stationByNum(num)); + _nums->setText(num, "%d"); } void Display::putRequest(displayRequestType_e type, int payload){ @@ -374,32 +418,32 @@ void Display::_layoutChange(bool played){ if(config.store.vumeter){ if(played){ if(_vuwidget) _vuwidget->unlock(); - _clock.moveTo(clockMove); + _clock->moveTo(clockMove); if(_weather) _weather->moveTo(weatherMoveVU); }else{ if(_vuwidget) if(!_vuwidget->locked()) _vuwidget->lock(); - _clock.moveBack(); + _clock->moveBack(); if(_weather) _weather->moveBack(); } }else{ if(played){ if(_weather) _weather->moveTo(weatherMove); - _clock.moveBack(); + _clock->moveBack(); }else{ if(_weather) _weather->moveBack(); - _clock.moveBack(); + _clock->moveBack(); } } } void Display::loop() { if(_bootStep==0) { - _pager.begin(); + _pager->begin(); _bootScreen(); return; } if(displayQueue==NULL || _locked) return; - _pager.loop(); + _pager->loop(); #ifdef USE_NEXTION nextion.loop(); #endif @@ -410,6 +454,7 @@ void Display::loop() { if(pm_result) switch (request.type){ case NEWMODE: _swichMode((displayMode_e)request.payload); break; + case CLOSEPLAYLIST: player.sendCommand({PR_PLAY, request.payload}); case CLOCK: if(_mode==PLAYER || _mode==SCREENSAVER) _time(); /*#ifdef USE_NEXTION @@ -447,7 +492,7 @@ void Display::loop() { if(_volip) _volip->setText(config.ipToStr(WiFi.localIP()), iptxtFmt); #endif }else{ - if(_weather) _weather->setText(const_getWeather); + if(_weather) _weather->setText(LANG::const_getWeather); } break; } @@ -456,7 +501,7 @@ void Display::loop() { break; } case BOOTSTRING: { - if(_bootstring) _bootstring->setText(config.ssids[request.payload].ssid, bootstrFmt); + if(_bootstring) _bootstring->setText(config.ssids[request.payload].ssid, LANG::bootstrFmt); /*#ifdef USE_NEXTION char buf[50]; snprintf(buf, 50, bootstrFmt, config.ssids[request.payload].ssid); @@ -465,11 +510,11 @@ void Display::loop() { break; } case WAITFORSD: { - if(_bootstring) _bootstring->setText(const_waitForSD); + if(_bootstring) _bootstring->setText(LANG::const_waitForSD); break; } case SDFILEINDEX: { - if(_mode == SDCHANGE) _nums.setText(request.payload, "%d"); + if(_mode == SDCHANGE) _nums->setText(request.payload, "%d"); break; } case DSPRSSI: if(_rssi){ _setRSSI(request.payload); } if (_heapbar && config.store.audioinfo) _heapbar->setValue(player.isRunning()?player.inBufferFilled():0); break; @@ -492,9 +537,11 @@ void Display::loop() { } dsp.loop(); +/* #if I2S_DOUT==255 player.computeVUlevel(); #endif +*/ } void Display::_setRSSI(int rssi) { @@ -514,8 +561,8 @@ void Display::_setRSSI(int rssi) { } void Display::_station() { - _meta.setAlign(metaConf.widget.align); - _meta.setText(config.station.name); + _meta->setAlign(metaConf.widget.align); + _meta->setText(config.station.name); /*#ifdef USE_NEXTION nextion.newNameset(config.station.name); nextion.bitrate(config.station.bitrate); @@ -536,10 +583,10 @@ void Display::_title() { strlcpy(tmpbuf, config.station.title, strlen(config.station.title)+1); char *stitle = split(tmpbuf, " - "); if(stitle && _title2){ - _title1.setText(tmpbuf); + _title1->setText(tmpbuf); _title2->setText(stitle); }else{ - _title1.setText(config.station.title); + _title1->setText(config.station.title); if(_title2) _title2->setText(""); } /*#ifdef USE_NEXTION @@ -547,7 +594,7 @@ void Display::_title() { #endif*/ }else{ - _title1.setText(""); + _title1->setText(""); if(_title2) _title2->setText(""); } if (player_on_track_change) player_on_track_change(); @@ -563,14 +610,17 @@ void Display::_time(bool redraw) { } #endif if(config.isScreensaver && network.timeinfo.tm_sec % 60 == 0){ - #ifdef GXCLOCKFONT - uint16_t ft=static_cast(random(TFT_FRAMEWDT, (dsp.height()-dsp.plItemHeight-TFT_FRAMEWDT*2-clockConf.textsize))); + #if TIME_SIZE<19 + uint16_t ft=static_cast(random(TFT_FRAMEWDT, (dsp.height()-TIME_SIZE*CHARHEIGHT-TFT_FRAMEWDT))); #else - uint16_t ft=static_cast(random(TFT_FRAMEWDT+clockConf.textsize, (dsp.height()-dsp.plItemHeight-TFT_FRAMEWDT*2))); + uint16_t ft=static_cast(random(TFT_FRAMEWDT+TIME_SIZE, (dsp.height()-_clock->dateSize()-TFT_FRAMEWDT*2))); #endif - _clock.moveTo({clockConf.left, ft, 0}); + uint16_t lt=static_cast(random(TFT_FRAMEWDT, (dsp.width()-_clock->clockWidth()-TFT_FRAMEWDT))); + if(clockConf.align==WA_CENTER) lt-=(dsp.width()-_clock->clockWidth())/2; + //_clock->moveTo({clockConf.left, ft, 0}); + _clock->moveTo({lt, ft, 0}); } - _clock.draw(); + _clock->draw(); /*#ifdef USE_NEXTION nextion.printClock(network.timeinfo); #endif*/ @@ -583,7 +633,7 @@ void Display::_volume() { #endif if(_mode==VOL) { timekeeper.waitAndReturnPlayer(3); - _nums.setText(config.store.volume, numtxtFmt); + _nums->setText(config.store.volume, numtxtFmt); } /*#ifdef USE_NEXTION nextion.setVol(config.store.volume, _mode == VOL); @@ -617,6 +667,7 @@ void Display::wakeup(){ #else // !DUMMYDISPLAY //============================================================================================================================ void Display::init(){ + _createDspTask(); #ifdef USE_NEXTION nextion.begin(true); #endif @@ -626,8 +677,9 @@ void Display::_start(){ //nextion.putcmd("page player"); nextion.start(); #endif - config.setTitle(const_PlReady); + config.setTitle(LANG::const_PlReady); } + void Display::putRequest(displayRequestType_e type, int payload){ if(type==DSP_START) _start(); #ifdef USE_NEXTION diff --git a/yoRadio/src/core/display.h b/yoRadio/src/core/display.h index 4f056d7..3cdb805 100644 --- a/yoRadio/src/core/display.h +++ b/yoRadio/src/core/display.h @@ -1,21 +1,24 @@ #ifndef display_h #define display_h -#include "options.h" - -#include "Arduino.h" -#include "config.h" #include "common.h" -#include "../displays/dspcore.h" -#if NEXTION_RX!=255 && NEXTION_TX!=255 - #define USE_NEXTION - #include "../displays/nextion.h" +#if DSP_MODEL==DSP_DUMMY +#define DUMMYDISPLAY #endif -//static void loopDspTask(void * pvParameters); - #ifndef DUMMYDISPLAY - +class ScrollWidget; +class PlayListWidget; +class BitrateWidget; +class FillWidget; +class SliderWidget; +class Pager; +class Page; +class VuWidget; +class NumWidget; +class ClockWidget; +class TextWidget; + class Display { public: uint16_t currentPlItem; @@ -23,6 +26,7 @@ class Display { displayMode_e _mode; public: Display() {}; + ~Display(); displayMode_e mode() { return _mode; } void mode(displayMode_e m) { _mode=m; } void init(); @@ -36,22 +40,21 @@ class Display { bool deepsleep(); void wakeup(); void setContrast(); - void printPLitem(uint8_t pos, const char* item); void lock() { _locked=true; } void unlock() { _locked=false; } + uint16_t width(); + uint16_t height(); private: - ScrollWidget _meta, _title1, _plcurrent; - ScrollWidget *_weather; - ScrollWidget *_title2; + ScrollWidget *_meta, *_title1, *_plcurrent, *_weather, *_title2; + PlayListWidget *_plwidget; BitrateWidget *_fullbitrate; FillWidget *_metabackground, *_plbackground; SliderWidget *_volbar, *_heapbar; - Pager _pager; - Page _footer; + Pager *_pager; + Page *_footer; VuWidget *_vuwidget; - NumWidget _nums; - ProgressWidget _testprogress; - ClockWidget _clock; + NumWidget *_nums; + ClockWidget *_clock; Page *_boot; TextWidget *_bootstring, *_volip, *_voltxt, *_rssi, *_bitrate; bool _locked = false; @@ -99,6 +102,8 @@ class Display { void printPLitem(uint8_t pos, const char* item){} void lock() {} void unlock() {} + uint16_t width(){ return 0; } + uint16_t height(){ return 0; } private: void _createDspTask(); }; diff --git a/yoRadio/src/core/mqtt.cpp b/yoRadio/src/core/mqtt.cpp index c818bed..83377c1 100644 --- a/yoRadio/src/core/mqtt.cpp +++ b/yoRadio/src/core/mqtt.cpp @@ -1,11 +1,10 @@ -#include "mqtt.h" - +#include "options.h" #ifdef MQTT_ROOT_TOPIC -#include "WiFi.h" -#include "telnet.h" -#include "player.h" #include "config.h" +#include "mqtt.h" +#include "WiFi.h" +#include "player.h" AsyncMqttClient mqttClient; TimerHandle_t mqttReconnectTimer; diff --git a/yoRadio/src/core/mqtt.h b/yoRadio/src/core/mqtt.h index bc76960..6df410a 100644 --- a/yoRadio/src/core/mqtt.h +++ b/yoRadio/src/core/mqtt.h @@ -1,6 +1,5 @@ #ifndef mqtt_h #define mqtt_h -#include "options.h" #ifdef MQTT_ROOT_TOPIC #include "../async-mqtt-client/AsyncMqttClient.h" diff --git a/yoRadio/src/core/netserver.cpp b/yoRadio/src/core/netserver.cpp index c83d7c8..375967f 100644 --- a/yoRadio/src/core/netserver.cpp +++ b/yoRadio/src/core/netserver.cpp @@ -1,18 +1,22 @@ -#include "netserver.h" +#include "options.h" +#include "Arduino.h" #include - +#include +#include "config.h" +#include "netserver.h" #include "player.h" #include "telnet.h" #include "display.h" -#include "options.h" #include "network.h" #include "mqtt.h" #include "controls.h" #include "commandhandler.h" #include "timekeeper.h" -#include +#include "../displays/widgets/widgetsconfig.h" //BitrateFormat -//#include +#if DSP_MODEL==DSP_DUMMY +#define DUMMYDISPLAY +#endif #ifdef USE_SD #include "sdmanager.h" @@ -29,6 +33,12 @@ #define NS_QUEUE_TICKS 0 #endif +#ifdef DEBUG_V +#define DBGVB( ... ) { char buf[200]; sprintf( buf, __VA_ARGS__ ) ; Serial.print("[DEBUG]\t"); Serial.println(buf); } +#else +#define DBGVB( ... ) +#endif + //#define CORS_DEBUG //Enable CORS policy: 'Access-Control-Allow-Origin' (for testing) NetServer netserver; diff --git a/yoRadio/src/core/netserver.h b/yoRadio/src/core/netserver.h index 1ab21a6..79e2465 100644 --- a/yoRadio/src/core/netserver.h +++ b/yoRadio/src/core/netserver.h @@ -1,9 +1,6 @@ #ifndef netserver_h #define netserver_h -#include "Arduino.h" -#include "config.h" #include "../AsyncWebServer/ESPAsyncWebServer.h" - #define APPEND_GROUP(name) strcat(nsBuf, "\"" name "\",") enum requestType_e : uint8_t { PLAYLIST=1, STATION=2, STATIONNAME=3, ITEM=4, TITLE=5, VOLUME=6, NRSSI=7, BITRATE=8, MODE=9, EQUALIZER=10, BALANCE=11, PLAYLISTSAVED=12, STARTUP=13, GETINDEX=14, GETACTIVE=15, GETSYSTEM=16, GETSCREEN=17, GETTIMEZONE=18, GETWEATHER=19, GETCONTROLS=20, DSPON=21, SDPOS=22, SDLEN=23, SDSNUFFLE=24, SDINIT=25, GETPLAYERMODE=26, CHANGEMODE=27 }; diff --git a/yoRadio/src/core/network.cpp b/yoRadio/src/core/network.cpp index 5eac81e..4bd7ba1 100644 --- a/yoRadio/src/core/network.cpp +++ b/yoRadio/src/core/network.cpp @@ -1,13 +1,16 @@ +#include "options.h" +#include +#include "time.h" +#include "rtcsupport.h" #include "network.h" #include "display.h" -#include "options.h" #include "config.h" #include "telnet.h" #include "netserver.h" #include "player.h" #include "mqtt.h" #include "timekeeper.h" -#include +#include "../pluginsManager/pluginsManager.h" #ifndef WIFI_ATTEMPTS #define WIFI_ATTEMPTS 16 diff --git a/yoRadio/src/core/network.h b/yoRadio/src/core/network.h index 3a2d35c..d3653c4 100644 --- a/yoRadio/src/core/network.h +++ b/yoRadio/src/core/network.h @@ -1,11 +1,6 @@ #ifndef network_h #define network_h -#include "time.h" -#include "WiFi.h" -#include "rtcsupport.h" - -#define apSsid "yoRadioAP" -#define apPassword "12345987" +#include enum n_Status_e { CONNECTED, SOFT_AP, FAILED, SDREADY }; diff --git a/yoRadio/src/core/options.h b/yoRadio/src/core/options.h index 8a11e75..395bdfc 100644 --- a/yoRadio/src/core/options.h +++ b/yoRadio/src/core/options.h @@ -1,7 +1,8 @@ #ifndef options_h #define options_h +#pragma once -#define YOVERSION "0.9.574" +#define YOVERSION "0.9.670" /******************************************************* DO NOT EDIT THIS FILE. @@ -73,7 +74,12 @@ The connection tables are located here https://github.com/e2002/yoradio#connecti #ifndef TFT_DC #define TFT_DC 4 #endif - +#ifndef USE_FBUFFER + #define USE_FBUFFER true +#endif +#ifndef FULL_SCR_CLOCK + #define FULL_SCR_CLOCK true +#endif /* NEXTION */ #ifndef NEXTION_RX #define NEXTION_RX 255 @@ -81,7 +87,9 @@ The connection tables are located here https://github.com/e2002/yoradio#connecti #ifndef NEXTION_TX #define NEXTION_TX 255 #endif - +#if NEXTION_RX!=255 && NEXTION_TX!=255 + #define USE_NEXTION +#endif /* OLED I2C DISPLAY */ #ifndef I2C_SDA #define I2C_SDA 21 @@ -128,7 +136,9 @@ The connection tables are located here https://github.com/e2002/yoradio#connecti #ifndef SD_HSPI #define SD_HSPI false // use HSPI for SD (miso=12, mosi=13, clk=14) instead of VSPI (by default) #endif - +#if SDC_CS!=255 + #define USE_SD +#endif /* ENCODER */ #ifndef ENC_BTNL #define ENC_BTNL 255 @@ -408,7 +418,7 @@ The connection tables are located here https://github.com/e2002/yoradio#connecti #define COLOR_DAY_OF_W 255, 255, 255 #endif #ifndef COLOR_DATE - #define COLOR_DATE 255, 255, 255 + #define COLOR_DATE 165, 162, 132 #endif #ifndef COLOR_HEAP #define COLOR_HEAP 41, 40, 41 @@ -513,5 +523,14 @@ The connection tables are located here https://github.com/e2002/yoradio#connecti #ifndef CONNECTION_TIMEOUT_SSL #define CONNECTION_TIMEOUT_SSL 5700 #endif +#ifndef apSsid + #define apSsid "yoRadioAP" +#endif +#ifndef apPassword + #define apPassword "12345987" +#endif +#ifndef BUFLEN + #define BUFLEN 170 +#endif #endif diff --git a/yoRadio/src/core/player.cpp b/yoRadio/src/core/player.cpp index fd69b75..48fea4d 100644 --- a/yoRadio/src/core/player.cpp +++ b/yoRadio/src/core/player.cpp @@ -6,7 +6,11 @@ #include "sdmanager.h" #include "netserver.h" #include "timekeeper.h" - +#include "../displays/tools/l10n.h" +#include "../pluginsManager/pluginsManager.h" +#ifdef USE_NEXTION +#include "../displays/nextion.h" +#endif Player player; QueueHandle_t playerQueue; @@ -97,9 +101,9 @@ void Player::_stop(bool alreadyStopped){ if(config.getMode()==PM_SDCARD && !alreadyStopped) config.sdResumePos = player.getFilePos(); _status = STOPPED; setOutputPins(false); - if(!_hasError) config.setTitle((display.mode()==LOST || display.mode()==UPDATING)?"":const_PlStopped); + if(!_hasError) config.setTitle((display.mode()==LOST || display.mode()==UPDATING)?"":LANG::const_PlStopped); config.station.bitrate = 0; - config.setBitrateFormat(BF_UNCNOWN); + config.setBitrateFormat(BF_UNKNOWN); #ifdef USE_NEXTION nextion.bitrate(config.station.bitrate); #endif @@ -250,7 +254,7 @@ void Player::browseUrl(){ resumeAfterUrl = _status==PLAYING; display.putRequest(PSTOP); setOutputPins(false); - config.setTitle(const_PlConnect); + config.setTitle(LANG::const_PlConnect); if (connecttohost(burl)){ _status = PLAYING; config.setTitle(""); diff --git a/yoRadio/src/core/player.h b/yoRadio/src/core/player.h index d7dbef5..8619895 100644 --- a/yoRadio/src/core/player.h +++ b/yoRadio/src/core/player.h @@ -1,6 +1,5 @@ #ifndef player_h #define player_h -#include "options.h" #if I2S_DOUT!=255 || I2S_INTERNAL #include "../audioI2S/AudioEx.h" @@ -13,13 +12,9 @@ #endif #ifndef PLQ_SEND_DELAY - //#define PLQ_SEND_DELAY portMAX_DELAY - #define PLQ_SEND_DELAY pdMS_TO_TICKS(1000) + #define PLQ_SEND_DELAY pdMS_TO_TICKS(1000) //portMAX_DELAY #endif -//#define PLERR_LN 64 -//#define SET_PLAY_ERROR(...) {char buff[512 + 64]; sprintf(buff,__VA_ARGS__); setError(buff);} - enum playerRequestType_e : uint8_t { PR_PLAY = 1, PR_STOP = 2, PR_PREV = 3, PR_NEXT = 4, PR_VOL = 5, PR_CHECKSD = 6, PR_VUTONUS = 7, PR_BURL = 8, PR_TOGGLE = 9 }; struct playerRequestParams_t { diff --git a/yoRadio/src/core/rtcsupport.cpp b/yoRadio/src/core/rtcsupport.cpp index ecb6970..936e306 100644 --- a/yoRadio/src/core/rtcsupport.cpp +++ b/yoRadio/src/core/rtcsupport.cpp @@ -1,3 +1,4 @@ +#include "options.h" #include "rtcsupport.h" #if RTCSUPPORTED diff --git a/yoRadio/src/core/rtcsupport.h b/yoRadio/src/core/rtcsupport.h index 89e6a8c..a21fe55 100644 --- a/yoRadio/src/core/rtcsupport.h +++ b/yoRadio/src/core/rtcsupport.h @@ -1,8 +1,7 @@ #ifndef rtcsupport_h #define rtcsupport_h -#include "options.h" -#define RTCSUPPORTED (RTC_SDA!=255 && RTC_SCL!=255 && (RTC_MODULE==DS3231 || RTC_MODULE==DS1307)) +#define RTCSUPPORTED (RTC_SDA!=255 && RTC_SCL!=255 && (RTC_MODULE==DS3231 || RTC_MODULE==DS1307)) #if RTCSUPPORTED #include "RTClib.h" diff --git a/yoRadio/src/core/sdmanager.cpp b/yoRadio/src/core/sdmanager.cpp index 90a908d..a081947 100644 --- a/yoRadio/src/core/sdmanager.cpp +++ b/yoRadio/src/core/sdmanager.cpp @@ -1,6 +1,12 @@ +#include "options.h" #if SDC_CS!=255 - -#define USE_SD +#include +#include +#include +#include "vfs_api.h" +#include "sd_diskio.h" +//#define USE_SD +#include "config.h" #include "sdmanager.h" #include "display.h" #include "player.h" diff --git a/yoRadio/src/core/sdmanager.h b/yoRadio/src/core/sdmanager.h index 413c703..b7e7d0d 100644 --- a/yoRadio/src/core/sdmanager.h +++ b/yoRadio/src/core/sdmanager.h @@ -1,11 +1,5 @@ #ifndef sdmanager_h #define sdmanager_h -#include -#include -#include -#include "vfs_api.h" -#include "sd_diskio.h" -#include "options.h" class SDManager : public SDFS { public: diff --git a/yoRadio/src/core/telnet.cpp b/yoRadio/src/core/telnet.cpp index 2d672f7..056f8ef 100644 --- a/yoRadio/src/core/telnet.cpp +++ b/yoRadio/src/core/telnet.cpp @@ -1,11 +1,10 @@ +#include "options.h" #include -#include "WiFi.h" - #include "config.h" #include "player.h" #include "network.h" #include "telnet.h" -#include "esp_heap_caps.h" +//#include "esp_heap_caps.h" Telnet telnet; diff --git a/yoRadio/src/core/telnet.h b/yoRadio/src/core/telnet.h index 6e45ebd..b43242f 100644 --- a/yoRadio/src/core/telnet.h +++ b/yoRadio/src/core/telnet.h @@ -1,9 +1,9 @@ #ifndef telnet_h #define telnet_h - #include #define MAX_TLN_CLIENTS 5 +#define BOOTLOG( ... ) { char buf[120]; sprintf( buf, __VA_ARGS__ ) ; telnet.printf("##[BOOT]#\t%s\n",buf); } class Telnet { public: diff --git a/yoRadio/src/core/timekeeper.cpp b/yoRadio/src/core/timekeeper.cpp index 8abdb76..f9f7d93 100644 --- a/yoRadio/src/core/timekeeper.cpp +++ b/yoRadio/src/core/timekeeper.cpp @@ -1,11 +1,20 @@ -#include "timekeeper.h" #include "options.h" +#include "Arduino.h" +#include "timekeeper.h" #include "config.h" #include "network.h" #include "display.h" #include "player.h" #include "netserver.h" #include "rtcsupport.h" +#include "../displays/tools/l10n.h" +#include "../pluginsManager/pluginsManager.h" +#ifdef USE_NEXTION +#include "../displays/nextion.h" +#endif +#if DSP_MODEL==DSP_DUMMY +#define DUMMYDISPLAY +#endif #if RTCSUPPORTED //#define TIME_SYNC_INTERVAL 24*60*60*1000 @@ -17,7 +26,24 @@ #define SYNC_STACK_SIZE 1024 * 4 #define SYNC_TASK_CORE 0 -#define SYNC_TASK_PRIORITY 1 +#define SYNC_TASK_PRIORITY 3 +#define WEATHER_STRING_L 254 + +#ifdef HEAP_DBG + void printHeapFragmentationInfo(const char* title){ + size_t freeHeap = heap_caps_get_free_size(MALLOC_CAP_DEFAULT); + size_t largestBlock = heap_caps_get_largest_free_block(MALLOC_CAP_DEFAULT); + float fragmentation = 100.0 * (1.0 - ((float)largestBlock / (float)freeHeap)); + Serial.printf("\n****** %s ******\n", title); + Serial.printf("* Free heap: %u bytes\n", freeHeap); + Serial.printf("* Largest free block: %u bytes\n", largestBlock); + Serial.printf("* Fragmentation: %.2f%%\n", fragmentation); + Serial.printf("*************************************\n\n"); + } + #define HEAP_INFO() printHeapFragmentationInfo(__PRETTY_FUNCTION__) +#else + #define HEAP_INFO() +#endif TimeKeeper timekeeper; @@ -55,7 +81,8 @@ bool TimeKeeper::loop0(){ // core0 (display) static uint32_t _last5s = 0; if (currentTime - _last1s >= 1000) { // 1sec _last1s = currentTime; -#ifndef DUMMYDISPLAY +//#ifndef DUMMYDISPLAY +#if !defined(DUMMYDISPLAY) || defined(USE_NEXTION) #ifndef UPCLOCK_CORE1 _upClock(); #endif @@ -80,7 +107,8 @@ bool TimeKeeper::loop1(){ // core1 (player) if (currentTime - _last1s >= 1000) { // 1sec pm.on_ticker(); _last1s = currentTime; -#ifndef DUMMYDISPLAY +//#ifndef DUMMYDISPLAY +#if !defined(DUMMYDISPLAY) || defined(USE_NEXTION) #ifdef UPCLOCK_CORE1 _upClock(); #endif @@ -94,7 +122,8 @@ bool TimeKeeper::loop1(){ // core1 (player) _last2s = currentTime; } - #ifdef DUMMYDISPLAY + //#ifdef DUMMYDISPLAY + #if defined(DUMMYDISPLAY) && !defined(USE_NEXTION) return true; #endif // Sync weather & time @@ -150,8 +179,10 @@ void TimeKeeper::_upClock(){ #if RTCSUPPORTED if(config.isRTCFound()){ rtc.getTime(&network.timeinfo); - mktime(&network.timeinfo); - if(display.ready()) display.putRequest(CLOCK); + if(network.timeinfo.tm_year>100){ + mktime(&network.timeinfo); + if(display.ready()) display.putRequest(CLOCK); + } } #else if(network.timeinfo.tm_year>100 || network.status == SDREADY) { @@ -173,6 +204,7 @@ void TimeKeeper::_upScreensaver(){ }else{ display.putRequest(NEWMODE, SCREENSAVER); } + config.screensaverTicks=SCREENSAVERSTARTUPDELAY; } } if(config.store.screensaverPlayingEnabled && display.mode()==PLAYER && player.isRunning()){ @@ -183,6 +215,7 @@ void TimeKeeper::_upScreensaver(){ }else{ display.putRequest(NEWMODE, SCREENSAVER); } + config.screensaverPlayingTicks=SCREENSAVERSTARTUPDELAY; } } #endif @@ -251,7 +284,7 @@ bool _getWeather() { weatherClient->onDisconnect([](void * arg, AsyncClient * c){ weatherClient = NULL; delete c; }, NULL); char httpget[250] = {0}; - sprintf(httpget, "GET /data/2.5/weather?lat=%s&lon=%s&units=%s&lang=%s&appid=%s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n", config.store.weatherlat, config.store.weatherlon, weatherUnits, weatherLang, config.store.weatherkey, host); + sprintf(httpget, "GET /data/2.5/weather?lat=%s&lon=%s&units=%s&lang=%s&appid=%s HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n", config.store.weatherlat, config.store.weatherlon, LANG::weatherUnits, LANG::weatherLang, config.store.weatherkey, host); client->write(httpget); client->onData([](void * arg, AsyncClient * c, void * data, size_t len){ @@ -318,9 +351,9 @@ bool _getWeather() { sprintf(timekeeper.weatherBuf, weatherFmt, tempf, press, hum); #else #if EXT_WEATHER - sprintf(timekeeper.weatherBuf, weatherFmt, desc, tempf, tempfl, press, hum, wind_speed, wind[(int)(wind_deg/22.5)]); + sprintf(timekeeper.weatherBuf, LANG::weatherFmt, desc, tempf, tempfl, press, hum, wind_speed, LANG::wind[(int)(wind_deg/22.5)]); #else - sprintf(timekeeper.weatherBuf, weatherFmt, desc, tempf, press, hum); + sprintf(timekeeper.weatherBuf, LANG::weatherFmt, desc, tempf, press, hum); #endif #endif display.putRequest(NEWWEATHER); diff --git a/yoRadio/src/core/timekeeper.h b/yoRadio/src/core/timekeeper.h index 3241b57..bd1aa85 100644 --- a/yoRadio/src/core/timekeeper.h +++ b/yoRadio/src/core/timekeeper.h @@ -1,8 +1,6 @@ #ifndef timekeeper_h #define timekeeper_h -#include "Arduino.h" - -#define WEATHER_STRING_L 254 +#pragma once void _syncTask(void * pvParameters); bool _getWeather(); diff --git a/yoRadio/src/core/touchscreen.cpp b/yoRadio/src/core/touchscreen.cpp index 17d9835..78ddf5a 100644 --- a/yoRadio/src/core/touchscreen.cpp +++ b/yoRadio/src/core/touchscreen.cpp @@ -1,6 +1,6 @@ #include "options.h" #if (TS_MODEL!=TS_MODEL_UNDEFINED) && (DSP_MODEL!=DSP_DUMMY) - +#include "Arduino.h" #include "touchscreen.h" #include "config.h" #include "controls.h" @@ -36,7 +36,7 @@ typedef TP_Point TSPoint; #endif -void TouchScreen::init(){ +void TouchScreen::init(uint16_t w, uint16_t h){ #if TS_MODEL==TS_MODEL_XPT2046 #ifdef TS_SPIPINS @@ -55,8 +55,8 @@ void TouchScreen::init(){ ts.begin(); ts.setRotation(config.store.fliptouch?0:2); #endif - _width = dsp.width(); - _height = dsp.height(); + _width = w; + _height = h; #if TS_MODEL==TS_MODEL_GT911 ts.setResolution(_width, _height); #endif diff --git a/yoRadio/src/core/touchscreen.h b/yoRadio/src/core/touchscreen.h index 23233cd..430cd3e 100644 --- a/yoRadio/src/core/touchscreen.h +++ b/yoRadio/src/core/touchscreen.h @@ -1,13 +1,12 @@ #ifndef touchscreen_h #define touchscreen_h -#include "Arduino.h" enum tsDirection_e { TSD_STAY, TSD_LEFT, TSD_RIGHT, TSD_UP, TSD_DOWN, TDS_REQUEST }; class TouchScreen { public: TouchScreen() {} - void init(); + void init(uint16_t w, uint16_t h); void loop(); void flip(); private: diff --git a/yoRadio/src/displays/conf/displayGC9106conf.h b/yoRadio/src/displays/conf/displayGC9106conf.h index 2295069..ad5e087 100644 --- a/yoRadio/src/displays/conf/displayGC9106conf.h +++ b/yoRadio/src/displays/conf/displayGC9106conf.h @@ -16,7 +16,7 @@ #define HIDE_TITLE2 #define HIDE_VOL -#define bootLogoTop 68 +#define bootLogoTop 5 /* SROLLS */ /* {{ left, top, fontsize, align }, buffsize, uppercase, width, scrolldelay, scrolldelta, scrolltime } */ const ScrollConfig metaConf PROGMEM = {{ TFT_FRAMEWDT, TFT_FRAMEWDT, 2, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 4, 30 }; @@ -40,12 +40,12 @@ const WidgetConfig bitrateConf PROGMEM = { TFT_FRAMEWDT, 19, 1, WA_RIGHT }; //const WidgetConfig voltxtConf PROGMEM = { 32, 108, 1, WA_RIGHT }; //const WidgetConfig iptxtConf PROGMEM = { TFT_FRAMEWDT, 108, 1, WA_LEFT }; const WidgetConfig rssiConf PROGMEM = { TFT_FRAMEWDT, 80-13, 1, WA_RIGHT }; -const WidgetConfig numConf PROGMEM = { 0, 29+32, 35, WA_CENTER }; +const WidgetConfig numConf PROGMEM = { 0, 29+32, 0, WA_CENTER }; const WidgetConfig apNameConf PROGMEM = { 0, 20, 1, WA_CENTER }; const WidgetConfig apName2Conf PROGMEM = { 0, 32, 1, WA_CENTER }; const WidgetConfig apPassConf PROGMEM = { 0, 46, 1, WA_CENTER }; const WidgetConfig apPass2Conf PROGMEM = { 0, 58, 1, WA_CENTER }; -const WidgetConfig clockConf PROGMEM = { 0, 29+34, 35, WA_RIGHT }; /* 35 is a fixed font size. do not change */ +const WidgetConfig clockConf PROGMEM = { 20, 29+34, 0, WA_RIGHT }; /* 35 is a fixed font size. do not change */ const WidgetConfig vuConf PROGMEM = { 1, 28, 1, WA_LEFT }; const WidgetConfig bootWdtConf PROGMEM = { 0, 50, 1, WA_CENTER }; @@ -62,7 +62,7 @@ const char rssiFmt[] PROGMEM = "%d"; const char bitrateFmt[] PROGMEM = "%d"; /* MOVES */ /* { left, top, width } */ -const MoveConfig clockMove PROGMEM = { 14, 29+34, 0}; +const MoveConfig clockMove PROGMEM = { 6, 29+34, 0}; const MoveConfig weatherMove PROGMEM = { TFT_FRAMEWDT, 80-13, MAX_WIDTH-6*3-30 }; const MoveConfig weatherMoveVU PROGMEM = { 30, 80-13, MAX_WIDTH-6*3-30 }; diff --git a/yoRadio/src/displays/conf/displayGC9A01Aconf.h b/yoRadio/src/displays/conf/displayGC9A01Aconf.h index 41d2d9a..bae76d4 100644 --- a/yoRadio/src/displays/conf/displayGC9A01Aconf.h +++ b/yoRadio/src/displays/conf/displayGC9A01Aconf.h @@ -37,12 +37,12 @@ const WidgetConfig bitrateConf PROGMEM = { 134, 23, 1, WA_RIGHT }; const WidgetConfig voltxtConf PROGMEM = { 80, 12, 1, WA_CENTER }; const WidgetConfig iptxtConf PROGMEM = { TFT_FRAMEWDT, 214, 1, WA_CENTER }; const WidgetConfig rssiConf PROGMEM = { 134, 23, 1, WA_LEFT }; -const WidgetConfig numConf PROGMEM = { 0, 120+30+20, 52, WA_CENTER }; +const WidgetConfig numConf PROGMEM = { 0, 120+30+20, 0, WA_CENTER }; const WidgetConfig apNameConf PROGMEM = { TFT_FRAMEWDT, 96, 2, WA_CENTER }; const WidgetConfig apName2Conf PROGMEM = { TFT_FRAMEWDT, 118, 2, WA_CENTER }; const WidgetConfig apPassConf PROGMEM = { TFT_FRAMEWDT, 146, 2, WA_CENTER }; const WidgetConfig apPass2Conf PROGMEM = { TFT_FRAMEWDT, 168, 2, WA_CENTER }; -const WidgetConfig clockConf PROGMEM = { 0, 176, 52, WA_CENTER }; /* 52 is a fixed font size. do not change */ +const WidgetConfig clockConf PROGMEM = { 0, 176, 0, WA_CENTER }; const WidgetConfig vuConf PROGMEM = { TFT_FRAMEWDT+20, 188, 1, WA_CENTER }; const WidgetConfig bootWdtConf PROGMEM = { 0, 162, 1, WA_CENTER }; diff --git a/yoRadio/src/displays/conf/displayILI9225conf.h b/yoRadio/src/displays/conf/displayILI9225conf.h index 0a32ad6..649f44d 100644 --- a/yoRadio/src/displays/conf/displayILI9225conf.h +++ b/yoRadio/src/displays/conf/displayILI9225conf.h @@ -28,7 +28,7 @@ const ScrollConfig title2Conf PROGMEM = {{ TFT_FRAMEWDT, 40, 1, WA_LEFT }, 1 const ScrollConfig playlistConf PROGMEM = {{ TFT_FRAMEWDT, 80, 2, WA_LEFT }, 140, true, DSP_WIDTH+10, 1000, 4, 30 }; const ScrollConfig apTitleConf PROGMEM = {{ TFT_FRAMEWDT, TFT_FRAMEWDT, 2, WA_CENTER }, 140, false, MAX_WIDTH, 0, 4, 30 }; const ScrollConfig apSettConf PROGMEM = {{ TFT_FRAMEWDT, DSP_HEIGHT-TFT_FRAMEWDT-16, 2, WA_LEFT }, 140, false, DSP_WIDTH+10, 0, 3, 25 }; -const ScrollConfig weatherConf PROGMEM = {{ TFT_FRAMEWDT, 50, 2, WA_LEFT }, 140, true, DSP_WIDTH+10, 0, 4, 30 }; +const ScrollConfig weatherConf PROGMEM = {{ TFT_FRAMEWDT, 56, 2, WA_LEFT }, 140, true, DSP_WIDTH+10, 0, 4, 30 }; /* BACKGROUNDS */ /* {{ left, top, fontsize, align }, width, height, outlined } */ const FillConfig metaBGConf PROGMEM = {{ 0, 0, 0, WA_LEFT }, DSP_WIDTH, 22, false }; @@ -43,12 +43,12 @@ const WidgetConfig bitrateConf PROGMEM = { TFT_FRAMEWDT+6, DSP_HEIGHT-TFT_FRA const WidgetConfig voltxtConf PROGMEM = { TFT_FRAMEWDT, DSP_HEIGHT-TFT_FRAMEWDT-14, 1, WA_LEFT }; const WidgetConfig iptxtConf PROGMEM = { TFT_FRAMEWDT, DSP_HEIGHT-TFT_FRAMEWDT-14, 1, WA_CENTER }; const WidgetConfig rssiConf PROGMEM = { TFT_FRAMEWDT, DSP_HEIGHT-TFT_FRAMEWDT-14, 1, WA_RIGHT }; -const WidgetConfig numConf PROGMEM = { 0, 110, 35, WA_CENTER }; +const WidgetConfig numConf PROGMEM = { 0, 110, 0, WA_CENTER }; const WidgetConfig apNameConf PROGMEM = { TFT_FRAMEWDT, 38, 2, WA_CENTER }; const WidgetConfig apName2Conf PROGMEM = { TFT_FRAMEWDT, 62, 2, WA_CENTER }; const WidgetConfig apPassConf PROGMEM = { TFT_FRAMEWDT, 102, 2, WA_CENTER }; const WidgetConfig apPass2Conf PROGMEM = { TFT_FRAMEWDT, 126, 2, WA_CENTER }; -const WidgetConfig clockConf PROGMEM = { 12, 120, 35, WA_RIGHT }; /* 35 is a fixed font size. do not change */ +const WidgetConfig clockConf PROGMEM = { TFT_FRAMEWDT*3, 130, 0, WA_RIGHT }; const WidgetConfig vuConf PROGMEM = { TFT_FRAMEWDT, 58, 1, WA_LEFT }; const WidgetConfig bootWdtConf PROGMEM = { 0, 130, 1, WA_CENTER }; @@ -65,8 +65,8 @@ const char voltxtFmt[] PROGMEM = "\023\025%d"; const char bitrateFmt[] PROGMEM = "%d kBs"; /* MOVES */ /* { left, top, width } */ -const MoveConfig clockMove PROGMEM = { 2, 120, 0 }; -const MoveConfig weatherMove PROGMEM = { TFT_FRAMEWDT, 58, DSP_WIDTH+10 }; +const MoveConfig clockMove PROGMEM = { TFT_FRAMEWDT*2, 130, 0 }; +const MoveConfig weatherMove PROGMEM = { TFT_FRAMEWDT, 64, DSP_WIDTH+10 }; const MoveConfig weatherMoveVU PROGMEM = { TFT_FRAMEWDT+46, 58, DSP_WIDTH+10-46 }; #endif diff --git a/yoRadio/src/displays/conf/displayILI9341conf.h b/yoRadio/src/displays/conf/displayILI9341conf.h index 2c55f83..e0da814 100644 --- a/yoRadio/src/displays/conf/displayILI9341conf.h +++ b/yoRadio/src/displays/conf/displayILI9341conf.h @@ -41,12 +41,12 @@ const WidgetConfig bitrateConf PROGMEM = { 70, 191, 1, WA_LEFT }; const WidgetConfig voltxtConf PROGMEM = { 0, 214, 1, WA_CENTER }; const WidgetConfig iptxtConf PROGMEM = { TFT_FRAMEWDT, 214, 1, WA_LEFT }; const WidgetConfig rssiConf PROGMEM = { TFT_FRAMEWDT, 214-6, 2, WA_RIGHT }; -const WidgetConfig numConf PROGMEM = { 0, 120+30, 52, WA_CENTER }; +const WidgetConfig numConf PROGMEM = { 0, 120+30, 0, WA_CENTER }; const WidgetConfig apNameConf PROGMEM = { TFT_FRAMEWDT, 66, 2, WA_CENTER }; const WidgetConfig apName2Conf PROGMEM = { TFT_FRAMEWDT, 90, 2, WA_CENTER }; const WidgetConfig apPassConf PROGMEM = { TFT_FRAMEWDT, 130, 2, WA_CENTER }; const WidgetConfig apPass2Conf PROGMEM = { TFT_FRAMEWDT, 154, 2, WA_CENTER }; -const WidgetConfig clockConf PROGMEM = { 12, 176, 52, WA_RIGHT }; /* 52 is a fixed font size. do not change */ +const WidgetConfig clockConf PROGMEM = { TFT_FRAMEWDT*2, 176, 0, WA_RIGHT }; const WidgetConfig vuConf PROGMEM = { TFT_FRAMEWDT, 100, 1, WA_LEFT }; const WidgetConfig bootWdtConf PROGMEM = { 0, 162, 1, WA_CENTER }; diff --git a/yoRadio/src/displays/conf/displayILI9488conf.h b/yoRadio/src/displays/conf/displayILI9488conf.h index 72824b9..4f9da44 100644 --- a/yoRadio/src/displays/conf/displayILI9488conf.h +++ b/yoRadio/src/displays/conf/displayILI9488conf.h @@ -42,12 +42,12 @@ const WidgetConfig bitrateConf PROGMEM = { 6, 62, 2, WA_RIGHT }; const WidgetConfig voltxtConf PROGMEM = { 0, DSP_HEIGHT-38, 2, WA_CENTER }; const WidgetConfig iptxtConf PROGMEM = { TFT_FRAMEWDT, DSP_HEIGHT-38, 2, WA_LEFT }; const WidgetConfig rssiConf PROGMEM = { TFT_FRAMEWDT, DSP_HEIGHT-38-6, 3, WA_RIGHT }; -const WidgetConfig numConf PROGMEM = { 0, 200, 70, WA_CENTER }; +const WidgetConfig numConf PROGMEM = { 0, 200, 0, WA_CENTER }; const WidgetConfig apNameConf PROGMEM = { TFT_FRAMEWDT, 88, 3, WA_CENTER }; const WidgetConfig apName2Conf PROGMEM = { TFT_FRAMEWDT, 120, 3, WA_CENTER }; const WidgetConfig apPassConf PROGMEM = { TFT_FRAMEWDT, 173, 3, WA_CENTER }; const WidgetConfig apPass2Conf PROGMEM = { TFT_FRAMEWDT, 205, 3, WA_CENTER }; -const WidgetConfig clockConf PROGMEM = { 16, 224, 70, WA_RIGHT }; /* 52 is a fixed font size. do not change */ +const WidgetConfig clockConf PROGMEM = { TFT_FRAMEWDT*2, 230, 0, WA_RIGHT }; const WidgetConfig vuConf PROGMEM = { TFT_FRAMEWDT, 136, 1, WA_LEFT }; const WidgetConfig bootWdtConf PROGMEM = { 0, 216, 1, WA_CENTER }; @@ -65,7 +65,7 @@ const char voltxtFmt[] PROGMEM = "\023\025%d"; const char bitrateFmt[] PROGMEM = "%d kBs"; /* MOVES */ /* { left, top, width } */ -const MoveConfig clockMove PROGMEM = { 0, 176, -1 }; +const MoveConfig clockMove PROGMEM = { 0, 230, -1 }; const MoveConfig weatherMove PROGMEM = { 8, 120, MAX_WIDTH }; const MoveConfig weatherMoveVU PROGMEM = { 89, 120, 381 }; diff --git a/yoRadio/src/displays/conf/displayN5110conf.h b/yoRadio/src/displays/conf/displayN5110conf.h index d36b475..bfc2061 100644 --- a/yoRadio/src/displays/conf/displayN5110conf.h +++ b/yoRadio/src/displays/conf/displayN5110conf.h @@ -39,12 +39,12 @@ const FillConfig volbarConf PROGMEM = {{ 0, 45, 0, WA_LEFT }, MAX_WIDTH, 3 const WidgetConfig bootstrConf PROGMEM = { 0, 48-7, 1, WA_CENTER }; const WidgetConfig bitrateConf PROGMEM = { TFT_FRAMEWDT, 8, 1, WA_RIGHT }; const WidgetConfig voltxtConf PROGMEM = { 0, 48-11, 1, WA_RIGHT }; -const WidgetConfig numConf PROGMEM = { 0, 34, 19, WA_CENTER }; +const WidgetConfig numConf PROGMEM = { 0, 34, 0, WA_CENTER }; const WidgetConfig apNameConf PROGMEM = { 0, 8, 1, WA_CENTER }; const WidgetConfig apName2Conf PROGMEM = { 0, 16, 1, WA_CENTER }; const WidgetConfig apPassConf PROGMEM = { 0, 24, 1, WA_CENTER }; const WidgetConfig apPass2Conf PROGMEM = { 0, 32, 1, WA_CENTER }; -const WidgetConfig clockConf PROGMEM = { 4, 35, 19, WA_RIGHT }; /* 19 is a fixed font size. do not change */ +const WidgetConfig clockConf PROGMEM = { 4, 35, 0, WA_RIGHT }; const WidgetConfig vuConf PROGMEM = { TFT_FRAMEWDT, 50, 1, WA_LEFT }; const WidgetConfig bootWdtConf PROGMEM = { 0, 48-7-10, 1, WA_CENTER }; diff --git a/yoRadio/src/displays/conf/displaySH1106conf.h b/yoRadio/src/displays/conf/displaySH1106conf.h index c2be6bf..f73c1e7 100644 --- a/yoRadio/src/displays/conf/displaySH1106conf.h +++ b/yoRadio/src/displays/conf/displaySH1106conf.h @@ -40,12 +40,12 @@ const WidgetConfig bitrateConf PROGMEM = { 0, 19, 1, WA_RIGHT }; //const WidgetConfig voltxtConf PROGMEM = { 32, 108, 1, WA_RIGHT }; const WidgetConfig iptxtConf PROGMEM = { TFT_FRAMEWDT, 64-9, 1, WA_LEFT }; const WidgetConfig rssiConf PROGMEM = { 0, 64-9, 1, WA_RIGHT }; -const WidgetConfig numConf PROGMEM = { 0, 28, 2, WA_CENTER }; +const WidgetConfig numConf PROGMEM = { 0, 28, 0, WA_CENTER }; const WidgetConfig apNameConf PROGMEM = { 0, 18, 1, WA_CENTER }; const WidgetConfig apName2Conf PROGMEM = { 0, 26, 1, WA_CENTER }; const WidgetConfig apPassConf PROGMEM = { 0, 37, 1, WA_CENTER }; const WidgetConfig apPass2Conf PROGMEM = { 0, 45, 1, WA_CENTER }; -const WidgetConfig clockConf PROGMEM = { 6, 38, 2, WA_CENTER }; +const WidgetConfig clockConf PROGMEM = { 6, 38, 0, WA_CENTER }; const WidgetConfig vuConf PROGMEM = { 1, 28, 1, WA_LEFT }; const WidgetConfig bootWdtConf PROGMEM = { 0, 64-8*2-5, 1, WA_CENTER }; diff --git a/yoRadio/src/displays/conf/displaySSD1305conf.h b/yoRadio/src/displays/conf/displaySSD1305conf.h index f02a8a1..5192e2a 100644 --- a/yoRadio/src/displays/conf/displaySSD1305conf.h +++ b/yoRadio/src/displays/conf/displaySSD1305conf.h @@ -16,7 +16,7 @@ #define HIDE_VOL #define HIDE_VU -#define bootLogoTop 68 +#define bootLogoTop 8 /* SROLLS */ /* {{ left, top, fontsize, align }, buffsize, uppercase, width, scrolldelay, scrolldelta, scrolltime } */ const ScrollConfig metaConf PROGMEM = {{ TFT_FRAMEWDT+1, TFT_FRAMEWDT+1, 1, WA_LEFT }, 140, true, MAX_WIDTH-2, 5000, 2, 25 }; @@ -40,12 +40,12 @@ const WidgetConfig bitrateConf PROGMEM = { 0, 13, 1, WA_RIGHT }; //const WidgetConfig voltxtConf PROGMEM = { 32, 108, 1, WA_RIGHT }; const WidgetConfig iptxtConf PROGMEM = { 0, 64-11, 1, WA_LEFT }; const WidgetConfig rssiConf PROGMEM = { 0, 64-11, 1, WA_RIGHT }; -const WidgetConfig numConf PROGMEM = { 0, 26, 2, WA_CENTER }; +const WidgetConfig numConf PROGMEM = { 0, 26, 0, WA_CENTER }; const WidgetConfig apNameConf PROGMEM = { 0, 18, 1, WA_CENTER }; const WidgetConfig apName2Conf PROGMEM = { 0, 26, 1, WA_CENTER }; const WidgetConfig apPassConf PROGMEM = { 0, 37, 1, WA_CENTER }; const WidgetConfig apPass2Conf PROGMEM = { 0, 45, 1, WA_CENTER }; -const WidgetConfig clockConf PROGMEM = { 6, 34, 2, WA_CENTER }; +const WidgetConfig clockConf PROGMEM = { 6, 34, 0, WA_CENTER }; const WidgetConfig vuConf PROGMEM = { 1, 28, 1, WA_LEFT }; const WidgetConfig bootWdtConf PROGMEM = { 0, 64-8*2-5, 1, WA_CENTER }; diff --git a/yoRadio/src/displays/conf/displaySSD1306conf.h b/yoRadio/src/displays/conf/displaySSD1306conf.h index e5142dd..ec2724c 100644 --- a/yoRadio/src/displays/conf/displaySSD1306conf.h +++ b/yoRadio/src/displays/conf/displaySSD1306conf.h @@ -16,7 +16,7 @@ #define HIDE_VOL #define HIDE_VU -#define bootLogoTop 68 +#define bootLogoTop 8 /* SROLLS */ /* {{ left, top, fontsize, align }, buffsize, uppercase, width, scrolldelay, scrolldelta, scrolltime } */ const ScrollConfig metaConf PROGMEM = {{ TFT_FRAMEWDT, 0, 2, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 3, 15 }; @@ -40,12 +40,12 @@ const WidgetConfig bitrateConf PROGMEM = { 0, 17, 1, WA_RIGHT }; //const WidgetConfig voltxtConf PROGMEM = { 32, 108, 1, WA_RIGHT }; const WidgetConfig iptxtConf PROGMEM = { 0, 64-11, 1, WA_LEFT }; const WidgetConfig rssiConf PROGMEM = { 0, 64-11, 1, WA_RIGHT }; -const WidgetConfig numConf PROGMEM = { 0, 28, 2, WA_CENTER }; +const WidgetConfig numConf PROGMEM = { 0, 28, 0, WA_CENTER }; const WidgetConfig apNameConf PROGMEM = { 0, 18, 1, WA_CENTER }; const WidgetConfig apName2Conf PROGMEM = { 0, 26, 1, WA_CENTER }; const WidgetConfig apPassConf PROGMEM = { 0, 37, 1, WA_CENTER }; const WidgetConfig apPass2Conf PROGMEM = { 0, 45, 1, WA_CENTER }; -const WidgetConfig clockConf PROGMEM = { 6, 36, 2, WA_CENTER }; +const WidgetConfig clockConf PROGMEM = { 6, 36, 0, WA_CENTER }; const WidgetConfig vuConf PROGMEM = { 1, 28, 1, WA_LEFT }; const WidgetConfig bootWdtConf PROGMEM = { 0, 64-8*2-5, 1, WA_CENTER }; diff --git a/yoRadio/src/displays/conf/displaySSD1306x32conf.h b/yoRadio/src/displays/conf/displaySSD1306x32conf.h index 87beec0..fe8d97d 100644 --- a/yoRadio/src/displays/conf/displaySSD1306x32conf.h +++ b/yoRadio/src/displays/conf/displaySSD1306x32conf.h @@ -41,12 +41,12 @@ const WidgetConfig bitrateConf PROGMEM = { 0, 11, 1, WA_RIGHT }; const WidgetConfig voltxtConf PROGMEM = { 0, 20, 1, WA_RIGHT }; const WidgetConfig iptxtConf PROGMEM = { 0, 64-11, 1, WA_LEFT }; const WidgetConfig rssiConf PROGMEM = { 0, 64-11, 1, WA_RIGHT }; -const WidgetConfig numConf PROGMEM = { 0, 12, 2, WA_CENTER }; +const WidgetConfig numConf PROGMEM = { 0, 12, 0, WA_CENTER }; const WidgetConfig apNameConf PROGMEM = { 0, 9, 1, WA_LEFT }; const WidgetConfig apName2Conf PROGMEM = { 0, 9, 1, WA_RIGHT }; const WidgetConfig apPassConf PROGMEM = { 0, 17, 1, WA_LEFT }; const WidgetConfig apPass2Conf PROGMEM = { 0, 17, 1, WA_RIGHT }; -const WidgetConfig clockConf PROGMEM = { 0, 1, 1, WA_RIGHT }; +const WidgetConfig clockConf PROGMEM = { 0, 1, 0, WA_RIGHT }; //const WidgetConfig vuConf PROGMEM = { 1, 28, 1, WA_LEFT }; const WidgetConfig bootWdtConf PROGMEM = { 0, 32-8*2-5, 1, WA_CENTER }; diff --git a/yoRadio/src/displays/conf/displaySSD1322conf.h b/yoRadio/src/displays/conf/displaySSD1322conf.h index 67a4701..b740396 100644 --- a/yoRadio/src/displays/conf/displaySSD1322conf.h +++ b/yoRadio/src/displays/conf/displaySSD1322conf.h @@ -17,7 +17,7 @@ #define HIDE_VU //#define HIDE_TITLE2 -#define bootLogoTop 68 +#define bootLogoTop 8 /* SROLLS */ /* {{ left, top, fontsize, align }, buffsize, uppercase, width, scrolldelay, scrolldelta, scrolltime } */ const ScrollConfig metaConf PROGMEM = {{ TFT_FRAMEWDT+1, TFT_FRAMEWDT+1, 2, WA_LEFT }, 140, true, MAX_WIDTH-2, 5000, 2, 25 }; @@ -41,13 +41,13 @@ const WidgetConfig bitrateConf PROGMEM = { TFT_FRAMEWDT+20, 64-11-10, 1, WA_L //const WidgetConfig voltxtConf PROGMEM = { 32, 108, 1, WA_RIGHT }; const WidgetConfig iptxtConf PROGMEM = { 0, 64-12, 1, WA_LEFT }; const WidgetConfig rssiConf PROGMEM = { 0, 64-11-10, 1, WA_LEFT }; -const WidgetConfig numConf PROGMEM = { TFT_FRAMEWDT, 57, 35, WA_CENTER }; +const WidgetConfig numConf PROGMEM = { TFT_FRAMEWDT, 57, 0, WA_CENTER }; const WidgetConfig apNameConf PROGMEM = { 0, 18, 1, WA_CENTER }; const WidgetConfig apName2Conf PROGMEM = { 0, 26, 1, WA_CENTER }; const WidgetConfig apPassConf PROGMEM = { 0, 37, 1, WA_CENTER }; const WidgetConfig apPass2Conf PROGMEM = { 0, 45, 1, WA_CENTER }; //const WidgetConfig clockConf PROGMEM = { 6, 34, 2, WA_CENTER }; -const WidgetConfig clockConf PROGMEM = { 0, 57, 35, WA_RIGHT }; /* 35 is a fixed font size. do not change */ +const WidgetConfig clockConf PROGMEM = { 0, 57, 0, WA_RIGHT }; const WidgetConfig vuConf PROGMEM = { 1, 28, 1, WA_LEFT }; const WidgetConfig bootWdtConf PROGMEM = { 0, 64-8*2-5, 1, WA_CENTER }; diff --git a/yoRadio/src/displays/conf/displaySSD1327conf.h b/yoRadio/src/displays/conf/displaySSD1327conf.h index f34bbd3..c4f4632 100644 --- a/yoRadio/src/displays/conf/displaySSD1327conf.h +++ b/yoRadio/src/displays/conf/displaySSD1327conf.h @@ -40,12 +40,12 @@ const WidgetConfig bitrateConf PROGMEM = { TFT_FRAMEWDT, 36, 1, WA_RIGHT }; const WidgetConfig voltxtConf PROGMEM = { TFT_FRAMEWDT, 128-10, 1, WA_RIGHT }; const WidgetConfig iptxtConf PROGMEM = { TFT_FRAMEWDT, 108, 1, WA_LEFT }; const WidgetConfig rssiConf PROGMEM = { TFT_FRAMEWDT, 108, 1, WA_RIGHT }; -const WidgetConfig numConf PROGMEM = { 0, 86, 35, WA_CENTER }; +const WidgetConfig numConf PROGMEM = { 0, 86, 0, WA_CENTER }; const WidgetConfig apNameConf PROGMEM = { 0, 40, 1, WA_CENTER }; const WidgetConfig apName2Conf PROGMEM = { 0, 54, 1, WA_CENTER }; const WidgetConfig apPassConf PROGMEM = { 0, 74, 1, WA_CENTER }; const WidgetConfig apPass2Conf PROGMEM = { 0, 88, 1, WA_CENTER }; -const WidgetConfig clockConf PROGMEM = { 0, 94, 35, WA_RIGHT }; /* 35 is a fixed font size. do not change */ +const WidgetConfig clockConf PROGMEM = { 0, 94, 0, WA_RIGHT }; const WidgetConfig vuConf PROGMEM = { TFT_FRAMEWDT, 99, 1, WA_CENTER }; const WidgetConfig bootWdtConf PROGMEM = { 0, 90, 1, WA_CENTER }; diff --git a/yoRadio/src/displays/conf/displayST7735_144conf.h b/yoRadio/src/displays/conf/displayST7735_144conf.h index 2f42c70..4170192 100644 --- a/yoRadio/src/displays/conf/displayST7735_144conf.h +++ b/yoRadio/src/displays/conf/displayST7735_144conf.h @@ -12,7 +12,7 @@ #define TFT_FRAMEWDT 4 #define MAX_WIDTH DSP_WIDTH-TFT_FRAMEWDT*2 -#define bootLogoTop 68 +#define bootLogoTop 34 /* SROLLS */ /* {{ left, top, fontsize, align }, buffsize, uppercase, width, scrolldelay, scrolldelta, scrolltime } */ const ScrollConfig metaConf PROGMEM = {{ TFT_FRAMEWDT, TFT_FRAMEWDT, 2, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 3, 30 }; @@ -37,12 +37,12 @@ const WidgetConfig bitrateConf PROGMEM = { TFT_FRAMEWDT, 36, 1, WA_RIGHT }; const WidgetConfig voltxtConf PROGMEM = { TFT_FRAMEWDT, 128-10, 1, WA_RIGHT }; const WidgetConfig iptxtConf PROGMEM = { TFT_FRAMEWDT, 108, 1, WA_LEFT }; const WidgetConfig rssiConf PROGMEM = { TFT_FRAMEWDT, 108, 1, WA_RIGHT }; -const WidgetConfig numConf PROGMEM = { 0, 86, 35, WA_CENTER }; +const WidgetConfig numConf PROGMEM = { 0, 86, 0, WA_CENTER }; const WidgetConfig apNameConf PROGMEM = { 0, 40, 1, WA_CENTER }; const WidgetConfig apName2Conf PROGMEM = { 0, 54, 1, WA_CENTER }; const WidgetConfig apPassConf PROGMEM = { 0, 74, 1, WA_CENTER }; const WidgetConfig apPass2Conf PROGMEM = { 0, 88, 1, WA_CENTER }; -const WidgetConfig clockConf PROGMEM = { 0, 94, 35, WA_RIGHT }; /* 35 is a fixed font size. do not change */ +const WidgetConfig clockConf PROGMEM = { 0, 94, 0, WA_RIGHT }; const WidgetConfig vuConf PROGMEM = { TFT_FRAMEWDT, 99, 1, WA_CENTER }; const WidgetConfig bootWdtConf PROGMEM = { 0, 90, 1, WA_CENTER }; diff --git a/yoRadio/src/displays/conf/displayST7735_blackconf.h b/yoRadio/src/displays/conf/displayST7735_blackconf.h index 4aed22d..07dbce8 100644 --- a/yoRadio/src/displays/conf/displayST7735_blackconf.h +++ b/yoRadio/src/displays/conf/displayST7735_blackconf.h @@ -16,7 +16,7 @@ #else #define TITLE_FIX 0 #endif -#define bootLogoTop 68 +#define bootLogoTop 34 /* SROLLS */ /* {{ left, top, fontsize, align }, buffsize, uppercase, width, scrolldelay, scrolldelta, scrolltime } */ const ScrollConfig metaConf PROGMEM = {{ TFT_FRAMEWDT, TFT_FRAMEWDT, 2, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 3, 30 }; @@ -41,12 +41,12 @@ const WidgetConfig bitrateConf PROGMEM = { TFT_FRAMEWDT, 26, 1, WA_RIGHT }; const WidgetConfig voltxtConf PROGMEM = { TFT_FRAMEWDT, 108, 1, WA_LEFT }; const WidgetConfig iptxtConf PROGMEM = { TFT_FRAMEWDT, 108, 1, WA_CENTER }; const WidgetConfig rssiConf PROGMEM = { TFT_FRAMEWDT, 108, 1, WA_RIGHT }; -const WidgetConfig numConf PROGMEM = { 0, 86, 35, WA_CENTER }; +const WidgetConfig numConf PROGMEM = { 0, 86, 0, WA_CENTER }; const WidgetConfig apNameConf PROGMEM = { 0, 40, 1, WA_CENTER }; const WidgetConfig apName2Conf PROGMEM = { 0, 54, 1, WA_CENTER }; const WidgetConfig apPassConf PROGMEM = { 0, 74, 1, WA_CENTER }; const WidgetConfig apPass2Conf PROGMEM = { 0, 88, 1, WA_CENTER }; -const WidgetConfig clockConf PROGMEM = { 0, 94, 35, WA_RIGHT }; /* 35 is a fixed font size. do not change */ +const WidgetConfig clockConf PROGMEM = { 0, 94, 0, WA_CENTER }; const WidgetConfig vuConf PROGMEM = { TFT_FRAMEWDT, 54, 1, WA_LEFT }; const WidgetConfig bootWdtConf PROGMEM = { 0, 90, 1, WA_CENTER }; diff --git a/yoRadio/src/displays/conf/displayST7735_miniconf.h b/yoRadio/src/displays/conf/displayST7735_miniconf.h index 159ca38..d889256 100644 --- a/yoRadio/src/displays/conf/displayST7735_miniconf.h +++ b/yoRadio/src/displays/conf/displayST7735_miniconf.h @@ -16,7 +16,7 @@ #define HIDE_TITLE2 #define HIDE_VOL -#define bootLogoTop 68 +#define bootLogoTop 5 /* SROLLS */ /* {{ left, top, fontsize, align }, buffsize, uppercase, width, scrolldelay, scrolldelta, scrolltime } */ const ScrollConfig metaConf PROGMEM = {{ TFT_FRAMEWDT, TFT_FRAMEWDT, 2, WA_LEFT }, 140, true, MAX_WIDTH, 5000, 3, 30 }; @@ -40,12 +40,12 @@ const WidgetConfig bitrateConf PROGMEM = { TFT_FRAMEWDT, 19, 1, WA_RIGHT }; //const WidgetConfig voltxtConf PROGMEM = { 32, 108, 1, WA_RIGHT }; //const WidgetConfig iptxtConf PROGMEM = { TFT_FRAMEWDT, 108, 1, WA_LEFT }; const WidgetConfig rssiConf PROGMEM = { TFT_FRAMEWDT, 80-13, 1, WA_RIGHT }; -const WidgetConfig numConf PROGMEM = { 0, 29+32, 35, WA_CENTER }; +const WidgetConfig numConf PROGMEM = { 0, 29+32, 0, WA_CENTER }; const WidgetConfig apNameConf PROGMEM = { 0, 20, 1, WA_CENTER }; const WidgetConfig apName2Conf PROGMEM = { 0, 32, 1, WA_CENTER }; const WidgetConfig apPassConf PROGMEM = { 0, 46, 1, WA_CENTER }; const WidgetConfig apPass2Conf PROGMEM = { 0, 58, 1, WA_CENTER }; -const WidgetConfig clockConf PROGMEM = { 0, 29+34, 35, WA_RIGHT }; /* 35 is a fixed font size. do not change */ +const WidgetConfig clockConf PROGMEM = { 20, 29+34, 0, WA_RIGHT }; const WidgetConfig vuConf PROGMEM = { 1, 28, 1, WA_LEFT }; const WidgetConfig bootWdtConf PROGMEM = { 0, 50, 1, WA_CENTER }; @@ -62,7 +62,7 @@ const char rssiFmt[] PROGMEM = "%d"; const char bitrateFmt[] PROGMEM = "%d"; /* MOVES */ /* { left, top, width } */ -const MoveConfig clockMove PROGMEM = { 14, 29+34, 0}; +const MoveConfig clockMove PROGMEM = { 6, 29+34, 0}; const MoveConfig weatherMove PROGMEM = { TFT_FRAMEWDT, 80-13, MAX_WIDTH-6*3-30 }; const MoveConfig weatherMoveVU PROGMEM = { 30, 80-13, MAX_WIDTH-6*3-30 }; diff --git a/yoRadio/src/displays/conf/displayST7789_240conf.h b/yoRadio/src/displays/conf/displayST7789_240conf.h index a06acb6..9d54494 100644 --- a/yoRadio/src/displays/conf/displayST7789_240conf.h +++ b/yoRadio/src/displays/conf/displayST7789_240conf.h @@ -38,12 +38,12 @@ const WidgetConfig bitrateConf PROGMEM = { TFT_FRAMEWDT, 188, 1, WA_LEFT }; const WidgetConfig voltxtConf PROGMEM = { 80, 214, 1, WA_RIGHT }; const WidgetConfig iptxtConf PROGMEM = { TFT_FRAMEWDT, 214, 1, WA_LEFT }; const WidgetConfig rssiConf PROGMEM = { TFT_FRAMEWDT, 214-6, 2, WA_RIGHT }; -const WidgetConfig numConf PROGMEM = { 0, 120+30, 52, WA_CENTER }; +const WidgetConfig numConf PROGMEM = { 0, 120+30, 0, WA_CENTER }; const WidgetConfig apNameConf PROGMEM = { TFT_FRAMEWDT, 66, 2, WA_CENTER }; const WidgetConfig apName2Conf PROGMEM = { TFT_FRAMEWDT, 90, 2, WA_CENTER }; const WidgetConfig apPassConf PROGMEM = { TFT_FRAMEWDT, 130, 2, WA_CENTER }; const WidgetConfig apPass2Conf PROGMEM = { TFT_FRAMEWDT, 154, 2, WA_CENTER }; -const WidgetConfig clockConf PROGMEM = { 0, 168, 52, WA_RIGHT }; /* 52 is a fixed font size. do not change */ +const WidgetConfig clockConf PROGMEM = { 0, 168, 0, WA_RIGHT }; const WidgetConfig vuConf PROGMEM = { TFT_FRAMEWDT, 94, 1, WA_CENTER }; const WidgetConfig bootWdtConf PROGMEM = { 0, 162, 1, WA_CENTER }; diff --git a/yoRadio/src/displays/conf/displayST7789_76conf.h b/yoRadio/src/displays/conf/displayST7789_76conf.h index c0a0236..226fa65 100644 --- a/yoRadio/src/displays/conf/displayST7789_76conf.h +++ b/yoRadio/src/displays/conf/displayST7789_76conf.h @@ -18,7 +18,7 @@ //#define HIDE_VU //#define HIDE_TITLE2 -#define bootLogoTop 68 +#define bootLogoTop 8 /* SROLLS */ /* {{ left, top, fontsize, align }, buffsize, uppercase, width, scrolldelay, scrolldelta, scrolltime } */ const ScrollConfig metaConf PROGMEM = {{ TFT_FRAMEWDT+1, TFT_FRAMEWDT+1, 2, WA_LEFT }, 140, true, MAX_WIDTH-2, 5000, 2, 25 }; @@ -42,13 +42,12 @@ const WidgetConfig bitrateConf PROGMEM = { TFT_FRAMEWDT+20, 64-11-10, 1, WA_L //const WidgetConfig voltxtConf PROGMEM = { 32, 108, 1, WA_RIGHT }; const WidgetConfig iptxtConf PROGMEM = { TFT_FRAMEWDT, 64-12, 1, WA_LEFT }; const WidgetConfig rssiConf PROGMEM = { TFT_FRAMEWDT, 64-11-10, 1, WA_LEFT }; -const WidgetConfig numConf PROGMEM = { TFT_FRAMEWDT, 57, 35, WA_CENTER }; +const WidgetConfig numConf PROGMEM = { TFT_FRAMEWDT, 57, 0, WA_CENTER }; const WidgetConfig apNameConf PROGMEM = { 0, 18, 1, WA_CENTER }; const WidgetConfig apName2Conf PROGMEM = { 0, 26, 1, WA_CENTER }; const WidgetConfig apPassConf PROGMEM = { 0, 37, 1, WA_CENTER }; const WidgetConfig apPass2Conf PROGMEM = { 0, 45, 1, WA_CENTER }; -//const WidgetConfig clockConf PROGMEM = { 6, 34, 2, WA_CENTER }; -const WidgetConfig clockConf PROGMEM = { 0, 57, 35, WA_RIGHT }; /* 35 is a fixed font size. do not change */ +const WidgetConfig clockConf PROGMEM = { 0, 57, 0, WA_RIGHT }; const WidgetConfig vuConf PROGMEM = { 2, DSP_HEIGHT-14, 1, WA_CENTER }; const WidgetConfig bootWdtConf PROGMEM = { 0, DSP_HEIGHT-8*2-5, 1, WA_CENTER }; diff --git a/yoRadio/src/displays/conf/displayST7789conf.h b/yoRadio/src/displays/conf/displayST7789conf.h index 5a8f8f9..8e44d85 100644 --- a/yoRadio/src/displays/conf/displayST7789conf.h +++ b/yoRadio/src/displays/conf/displayST7789conf.h @@ -44,12 +44,12 @@ const WidgetConfig bitrateConf PROGMEM = { 70, 191, 1, WA_LEFT }; const WidgetConfig voltxtConf PROGMEM = { 0, 214, 1, WA_CENTER }; const WidgetConfig iptxtConf PROGMEM = { TFT_FRAMEWDT, 214, 1, WA_LEFT }; const WidgetConfig rssiConf PROGMEM = { TFT_FRAMEWDT, 208, 2, WA_RIGHT }; -const WidgetConfig numConf PROGMEM = { 0, 120+30, 52, WA_CENTER }; +const WidgetConfig numConf PROGMEM = { 0, 120+30, 0, WA_CENTER }; const WidgetConfig apNameConf PROGMEM = { TFT_FRAMEWDT, 66, 2, WA_CENTER }; const WidgetConfig apName2Conf PROGMEM = { TFT_FRAMEWDT, 90, 2, WA_CENTER }; const WidgetConfig apPassConf PROGMEM = { TFT_FRAMEWDT, 130, 2, WA_CENTER }; const WidgetConfig apPass2Conf PROGMEM = { TFT_FRAMEWDT, 154, 2, WA_CENTER }; -const WidgetConfig clockConf PROGMEM = { 8, 176, 52, WA_RIGHT }; /* 52 is a fixed font size. do not change */ +const WidgetConfig clockConf PROGMEM = { 8, 176, 0, WA_RIGHT }; const WidgetConfig vuConf PROGMEM = { TFT_FRAMEWDT, 100, 1, WA_LEFT }; const WidgetConfig bootWdtConf PROGMEM = { 0, 162, 1, WA_CENTER }; diff --git a/yoRadio/src/displays/conf/displayST7796conf.h b/yoRadio/src/displays/conf/displayST7796conf.h index 6858749..6de3a7b 100644 --- a/yoRadio/src/displays/conf/displayST7796conf.h +++ b/yoRadio/src/displays/conf/displayST7796conf.h @@ -42,12 +42,12 @@ const WidgetConfig bitrateConf PROGMEM = { 6, 62, 2, WA_RIGHT }; const WidgetConfig voltxtConf PROGMEM = { 0, DSP_HEIGHT-38, 2, WA_CENTER }; const WidgetConfig iptxtConf PROGMEM = { TFT_FRAMEWDT, DSP_HEIGHT-38, 2, WA_LEFT }; const WidgetConfig rssiConf PROGMEM = { TFT_FRAMEWDT, DSP_HEIGHT-38-6, 3, WA_RIGHT }; -const WidgetConfig numConf PROGMEM = { 0, 200, 70, WA_CENTER }; +const WidgetConfig numConf PROGMEM = { 0, 200, 0, WA_CENTER }; const WidgetConfig apNameConf PROGMEM = { TFT_FRAMEWDT, 88, 3, WA_CENTER }; const WidgetConfig apName2Conf PROGMEM = { TFT_FRAMEWDT, 120, 3, WA_CENTER }; const WidgetConfig apPassConf PROGMEM = { TFT_FRAMEWDT, 173, 3, WA_CENTER }; const WidgetConfig apPass2Conf PROGMEM = { TFT_FRAMEWDT, 205, 3, WA_CENTER }; -const WidgetConfig clockConf PROGMEM = { 16, 224, 70, WA_RIGHT }; /* 52 is a fixed font size. do not change */ +const WidgetConfig clockConf PROGMEM = { TFT_FRAMEWDT*2, 230, 0, WA_RIGHT }; const WidgetConfig vuConf PROGMEM = { TFT_FRAMEWDT, 136, 1, WA_LEFT }; const WidgetConfig bootWdtConf PROGMEM = { 0, 216, 1, WA_CENTER }; diff --git a/yoRadio/src/displays/conf/displayST7920conf.h b/yoRadio/src/displays/conf/displayST7920conf.h index 9bf2657..6e5e387 100644 --- a/yoRadio/src/displays/conf/displayST7920conf.h +++ b/yoRadio/src/displays/conf/displayST7920conf.h @@ -16,7 +16,7 @@ #define HIDE_VOL #define HIDE_VU -#define bootLogoTop 68 +#define bootLogoTop 8 /* SROLLS */ /* {{ left, top, fontsize, align }, buffsize, uppercase, width, scrolldelay, scrolldelta, scrolltime } */ const ScrollConfig metaConf PROGMEM = {{ TFT_FRAMEWDT+1, TFT_FRAMEWDT+1, 1, WA_LEFT }, 140, true, MAX_WIDTH-2, 5000, 6, 250 }; @@ -40,12 +40,12 @@ const WidgetConfig bitrateConf PROGMEM = { 0, 13, 1, WA_RIGHT }; //const WidgetConfig voltxtConf PROGMEM = { 32, 108, 1, WA_RIGHT }; const WidgetConfig iptxtConf PROGMEM = { 0, 64-11, 1, WA_LEFT }; const WidgetConfig rssiConf PROGMEM = { 0, 64-11, 1, WA_RIGHT }; -const WidgetConfig numConf PROGMEM = { 0, 26, 2, WA_CENTER }; +const WidgetConfig numConf PROGMEM = { 0, 26, 0, WA_CENTER }; const WidgetConfig apNameConf PROGMEM = { 0, 18, 1, WA_CENTER }; const WidgetConfig apName2Conf PROGMEM = { 0, 26, 1, WA_CENTER }; const WidgetConfig apPassConf PROGMEM = { 0, 37, 1, WA_CENTER }; const WidgetConfig apPass2Conf PROGMEM = { 0, 45, 1, WA_CENTER }; -const WidgetConfig clockConf PROGMEM = { 0, 34, 2, WA_CENTER }; +const WidgetConfig clockConf PROGMEM = { 0, 34, 0, WA_CENTER }; const WidgetConfig vuConf PROGMEM = { 1, 28, 1, WA_LEFT }; const WidgetConfig bootWdtConf PROGMEM = { 0, 64-8*2-5, 1, WA_CENTER }; diff --git a/yoRadio/src/displays/displayGC9106.cpp b/yoRadio/src/displays/displayGC9106.cpp index 7c87239..6e9f3e4 100644 --- a/yoRadio/src/displays/displayGC9106.cpp +++ b/yoRadio/src/displays/displayGC9106.cpp @@ -1,10 +1,7 @@ #include "../core/options.h" #if DSP_MODEL==DSP_GC9106 - -#include "displayGC9106.h" -#include "fonts/bootlogo40.h" +#include "dspcore.h" #include "../core/config.h" -#include "../core/network.h" #ifndef DEF_SPI_FREQ #define DEF_SPI_FREQ 24000000 /* set it to 0 for system default */ @@ -16,176 +13,18 @@ DspCore::DspCore(): Adafruit_GC9106Ex(&SPI2, TFT_DC, TFT_CS, TFT_RST) {} DspCore::DspCore(): Adafruit_GC9106Ex(TFT_CS, TFT_DC, TFT_RST) {} #endif -#include "tools/utf8RusGFX.h" - void DspCore::initDisplay() { begin(DEF_SPI_FREQ); cp437(true); invert(); flip(); setTextWrap(false); - - plItemHeight = playlistConf.widget.textsize*(CHARHEIGHT-1)+playlistConf.widget.textsize*4; - plTtemsCount = round((float)height()/plItemHeight); - if(plTtemsCount%2==0) plTtemsCount++; - plCurrentPos = plTtemsCount/2; - plYStart = (height() / 2 - plItemHeight / 2) - plItemHeight * (plTtemsCount - 1) / 2 + playlistConf.widget.textsize*2; } -void DspCore::drawLogo(uint16_t top) { - drawRGBBitmap((width() - 62) / 2, 5, bootlogo40, 62, 40); -} - -void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){ - setTextSize(playlistConf.widget.textsize); - if (pos == plCurrentPos) { - current.setText(item); - } else { - uint8_t plColor = (abs(pos - plCurrentPos)-1)>4?4:abs(pos - plCurrentPos)-1; - setTextColor(config.theme.playlist[plColor], config.theme.background); - setCursor(TFT_FRAMEWDT, plYStart + pos * plItemHeight); - fillRect(0, plYStart + pos * plItemHeight - 1, width(), plItemHeight - 2, config.theme.background); - print(utf8Rus(item, true)); - } -} - -void DspCore::drawPlaylist(uint16_t currentItem) { - uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount); - if(lastPosglyph + c; -} - -uint8_t DspCore::_charWidth(unsigned char c){ - GFXglyph *glyph = pgm_read_glyph_ptr(&DS_DIGI28pt7b, c - 0x20); - return pgm_read_byte(&glyph->xAdvance); -} - -uint16_t DspCore::textWidth(const char *txt){ - uint16_t w = 0, l=strlen(txt); - for(uint16_t c=0;c0 && !CLOCKFONT_MONO) dsp.fillRect(_oldtimeleft, clockTop-clockTimeHeight+1, _oldtimewidth, clockTimeHeight, config.theme.background); - _timeleft = (width()/2 - _timewidth/2)+clockRightSpace; - setTextSize(1); - setFont(&DS_DIGI28pt7b); - - if(CLOCKFONT_MONO) { - setCursor(_timeleft, clockTop); - setTextColor(config.theme.clockbg, config.theme.background); - print("88:88"); - } - setTextColor(config.theme.clock, config.theme.background); - setCursor(_timeleft, clockTop); - print(_timeBuf); - setFont(); - strlcpy(_oldTimeBuf, _timeBuf, sizeof(_timeBuf)); - _oldtimewidth = _timewidth; - _oldtimeleft = _timeleft; -} - -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(); - } - _clockSeconds(); -} - -void DspCore::clearClock(){ - dsp.fillRect(_timeleft, clockTop-clockTimeHeight, _timewidth+CHARWIDTH*3*2+24, clockTimeHeight+11+CHARHEIGHT, config.theme.background); -} - -void DspCore::startWrite(void) { - Adafruit_GC9106Ex::startWrite(); -} - -void DspCore::endWrite(void) { - Adafruit_GC9106Ex::endWrite(); -} - -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::setTextSize(uint8_t s){ - Adafruit_GFX::setTextSize(s); -} - -void DspCore::flip(){ - setRotation(config.store.flipscreen?1:3); -} - -void DspCore::invert(){ - invertDisplay(config.store.invertdisplay); -} - -void DspCore::sleep(void) { sendCommand(GC9106_SLPIN); delay(150); sendCommand(GC9106_DISPOFF); delay(150); } -void DspCore::wake(void) { sendCommand(GC9106_DISPON); delay(150); sendCommand(GC9106_SLPOUT); delay(150); } - - -void DspCore::writePixel(int16_t x, int16_t y, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x > _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - Adafruit_GC9106Ex::writePixel(x, y, color); -} - -void DspCore::writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x >= _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - Adafruit_GC9106Ex::writeFillRect(x, y, w, h, color); -} - -void DspCore::setClipping(clipArea ca){ - _cliparea = ca; - _clipping = true; -} - -void DspCore::clearClipping(){ - _clipping = false; -} - -void DspCore::setNumFont(){ - setFont(&DS_DIGI28pt7b); - setTextSize(1); -} +void DspCore::clearDsp(bool black){ fillScreen(black?0:config.theme.background); } +void DspCore::flip(){ setRotation(config.store.flipscreen?1:3); } +void DspCore::invert(){ invertDisplay(config.store.invertdisplay); } +void DspCore::sleep(void){ sendCommand(GC9106_SLPIN); delay(150); sendCommand(GC9106_DISPOFF); delay(150); } +void DspCore::wake(void){ sendCommand(GC9106_DISPON); delay(150); sendCommand(GC9106_SLPOUT); delay(150); } #endif diff --git a/yoRadio/src/displays/displayGC9106.h b/yoRadio/src/displays/displayGC9106.h index e423331..408008d 100644 --- a/yoRadio/src/displays/displayGC9106.h +++ b/yoRadio/src/displays/displayGC9106.h @@ -5,20 +5,13 @@ #include "Arduino.h" #include #include "../Adafruit_GC9106Ex/Adafruit_GC9106Ex.h" // https://github.com/prenticedavid/Adafruit_GC9102_kbv - -#if CLOCKFONT_MONO - #include "fonts/DS_DIGI28pt7b_mono.h" // https://tchapi.github.io/Adafruit-GFX-Font-Customiser/ -#else - #include "fonts/DS_DIGI28pt7b.h" -#endif -#include "tools/l10n.h" - -#define CHARWIDTH 6 -#define CHARHEIGHT 8 +#include "fonts/bootlogo62x40.h" +#include "fonts/dsfont35.h" typedef GFXcanvas16 Canvas; -#include "widgets/widgets.h" -#include "widgets/pages.h" +typedef Adafruit_GC9106Ex yoDisplay; + +#include "tools/commongfx.h" #if __has_include("conf/displayGC9106conf_custom.h") #include "conf/displayGC9106conf_custom.h" @@ -26,14 +19,4 @@ typedef GFXcanvas16 Canvas; #include "conf/displayGC9106conf.h" #endif -#define BOOT_PRG_COLOR 0xE68B -#define BOOT_TXT_COLOR 0xFFFF -#define PINK 0xF97F - -class DspCore: public Adafruit_GC9106Ex { -#include "tools/commongfx.h" -}; - -extern DspCore dsp; - #endif diff --git a/yoRadio/src/displays/displayGC9A01A.cpp b/yoRadio/src/displays/displayGC9A01A.cpp index d4b2194..81ef6b8 100644 --- a/yoRadio/src/displays/displayGC9A01A.cpp +++ b/yoRadio/src/displays/displayGC9A01A.cpp @@ -1,11 +1,7 @@ #include "../core/options.h" #if DSP_MODEL==DSP_GC9A01A - -#include "displayGC9A01A.h" -//#include -#include "fonts/bootlogo.h" +#include "dspcore.h" #include "../core/config.h" -#include "../core/network.h" #ifndef DEF_SPI_FREQ #define DEF_SPI_FREQ 40000000UL /* set it to 0 for system default */ @@ -17,8 +13,6 @@ DspCore::DspCore(): Adafruit_GC9A01A(&SPI2, TFT_CS, TFT_DC, TFT_RST) {} DspCore::DspCore(): Adafruit_GC9A01A(TFT_CS, TFT_DC, TFT_RST) {} #endif -#include "tools/utf8RusGFX.h" - void DspCore::initDisplay() { begin(); if(DEF_SPI_FREQ > 0) setSPISpeed(DEF_SPI_FREQ); @@ -28,206 +22,12 @@ void DspCore::initDisplay() { setTextWrap(false); setTextSize(1); fillScreen(0x0000); - - plItemHeight = playlistConf.widget.textsize*(CHARHEIGHT-1)+playlistConf.widget.textsize*4; - plTtemsCount = round((float)height()/plItemHeight); - if(plTtemsCount%2==0) plTtemsCount++; - plCurrentPos = plTtemsCount/2; - plYStart = (height() / 2 - plItemHeight / 2) - plItemHeight * (plTtemsCount - 1) / 2 + playlistConf.widget.textsize*2; } -void DspCore::drawLogo(uint16_t top) { drawRGBBitmap((width() - 99) / 2, top, bootlogo2, 99, 64); } +void DspCore::clearDsp(bool black){ fillScreen(black?0:config.theme.background); } +void DspCore::flip(){ if(ROTATE_90) setRotation(config.store.flipscreen?3:1); else setRotation(config.store.flipscreen?2:0); } +void DspCore::invert(){ invertDisplay(!config.store.invertdisplay); } +void DspCore::sleep(void){enableSleep(true); delay(150); enableDisplay(false); delay(150); } +void DspCore::wake(void){ enableDisplay(true); delay(150); enableSleep(false); delay(150); } -void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){ - setTextSize(playlistConf.widget.textsize); - if (pos == plCurrentPos) { - current.setText(item); - } else { - uint8_t plColor = (abs(pos - plCurrentPos)-1)>4?4:abs(pos - plCurrentPos)-1; - setTextColor(config.theme.playlist[plColor], config.theme.background); - setCursor(TFT_FRAMEWDT, plYStart + pos * plItemHeight); - fillRect(0, plYStart + pos * plItemHeight - 1, width(), plItemHeight - 2, config.theme.background); - print(utf8Rus(item, true)); - } -} - -void DspCore::drawPlaylist(uint16_t currentItem) { - uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount); - if(lastPosglyph + c; -} - -uint8_t DspCore::_charWidth(unsigned char c){ - GFXglyph *glyph = pgm_read_glyph_ptr(&DS_DIGI42pt7b, c - 0x20); - return pgm_read_byte(&glyph->xAdvance); -} - -uint16_t DspCore::textWidth(const char *txt){ - uint16_t w = 0, l=strlen(txt); - for(uint16_t c=0;c0) - dsp.fillRect(_olddateleft, clockTop+10, _olddatewidth, CHARHEIGHT, config.theme.background); - setTextColor(config.theme.date, config.theme.background); - setCursor(_dateleft, clockTop+10); - if(!config.isScreensaver) print(_dateBuf); /* print date */ - strlcpy(_oldDateBuf, _dateBuf, sizeof(_dateBuf)); - _olddatewidth = _datewidth; - _olddateleft = _dateleft; - setTextSize(3); - setTextColor(config.theme.dow, config.theme.background); - setCursor(width() - 8 - clockRightSpace - CHARWIDTH*3*2, clockTop-CHARHEIGHT*3+4); - print(utf8Rus(dow[network.timeinfo.tm_wday], false)); /* print dow */ -} - -void DspCore::_clockTime(){ - if(_oldtimeleft>0 && !CLOCKFONT_MONO) dsp.fillRect(_oldtimeleft, clockTop-clockTimeHeight+1, _oldtimewidth, clockTimeHeight, config.theme.background); - _timeleft = width()-clockRightSpace-CHARWIDTH*3*2-24-_timewidth; - clearClock(); - setTextSize(1); - setFont(&DS_DIGI42pt7b); - - if(CLOCKFONT_MONO) { - setCursor(_timeleft, clockTop); - setTextColor(config.theme.clockbg, config.theme.background); - print("88:88"); - } - setTextColor(config.theme.clock, config.theme.background); - setCursor(_timeleft, clockTop); - print(_timeBuf); - setFont(); - strlcpy(_oldTimeBuf, _timeBuf, sizeof(_timeBuf)); - _oldtimewidth = _timewidth; - _oldtimeleft = _timeleft; - if(!config.isScreensaver) drawFastVLine(width()-clockRightSpace-CHARWIDTH*3*2-18, clockTop-clockTimeHeight, clockTimeHeight+3, config.theme.div); /*divider vert*/ - if(!config.isScreensaver) drawFastHLine(width()-clockRightSpace-CHARWIDTH*3*2-18, clockTop-clockTimeHeight+29, 44, 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; - _dateleft = (width() - _datewidth)/2; -} - -void DspCore::printClock(uint16_t top, uint16_t rightspace, uint16_t timeheight, bool redraw){ - clockTop = top; - clockRightSpace = (width()-_timewidth-CHARWIDTH*3*2-36)/2;//rightspace; - clockTimeHeight = timeheight; - strftime(_timeBuf, sizeof(_timeBuf), "%H:%M", &network.timeinfo); - if(strcmp(_oldTimeBuf, _timeBuf)!=0 || redraw){ - _getTimeBounds(); - clockRightSpace = (width()-_timewidth-CHARWIDTH*3*2-36)/2; - _clockTime(); - if(!config.isScreensaver) - /*if(strcmp(_oldDateBuf, _dateBuf)!=0 || redraw) */_clockDate(); - } - _clockSeconds(); -} - -void DspCore::clearClock(){ - if(_oldtimeleft>0){ - dsp.fillRect(_oldtimeleft, clockTop-clockTimeHeight, _oldtimewidth+CHARWIDTH*3*2+24, clockTimeHeight+10+CHARHEIGHT, config.theme.background); - }else{ - dsp.fillRect(_timeleft, clockTop-clockTimeHeight, _timewidth+CHARWIDTH*3*2+24, clockTimeHeight+10+CHARHEIGHT, config.theme.background); - } -} - -void DspCore::startWrite(void) { - Adafruit_GC9A01A::startWrite(); -} - -void DspCore::endWrite(void) { - Adafruit_GC9A01A::endWrite(); -} - -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::setTextSize(uint8_t s){ - Adafruit_GFX::setTextSize(s); -} - -void DspCore::flip(){ - if(ROTATE_90){ - setRotation(config.store.flipscreen?3:1); - }else{ - setRotation(config.store.flipscreen?2:0); - } -} - -void DspCore::invert(){ - invertDisplay(!config.store.invertdisplay); -} - -void DspCore::sleep(void) { - enableSleep(true); delay(150); enableDisplay(false); delay(150); -} -void DspCore::wake(void) { - enableDisplay(true); delay(150); enableSleep(false); delay(150); -} - - -void DspCore::writePixel(int16_t x, int16_t y, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x > _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - Adafruit_GC9A01A::writePixel(x, y, color); -} - -void DspCore::writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x >= _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - Adafruit_GC9A01A::writeFillRect(x, y, w, h, color); -} - -void DspCore::setClipping(clipArea ca){ - _cliparea = ca; - _clipping = true; -} - -void DspCore::clearClipping(){ - _clipping = false; -} - -void DspCore::setNumFont(){ - setFont(&DS_DIGI42pt7b); - setTextSize(1); -} #endif diff --git a/yoRadio/src/displays/displayGC9A01A.h b/yoRadio/src/displays/displayGC9A01A.h index 94c0c85..b8c5911 100644 --- a/yoRadio/src/displays/displayGC9A01A.h +++ b/yoRadio/src/displays/displayGC9A01A.h @@ -5,20 +5,13 @@ #include "Arduino.h" #include #include "../Adafruit_GC9A01A/Adafruit_GC9A01A.h" - -#if CLOCKFONT_MONO - #include "fonts/DS_DIGI42pt7b_mono.h" // https://tchapi.github.io/Adafruit-GFX-Font-Customiser/ -#else - #include "fonts/DS_DIGI42pt7b.h" -#endif -#include "tools/l10n.h" - -#define CHARWIDTH 6 -#define CHARHEIGHT 8 +#include "fonts/bootlogo99x64.h" +#include "fonts/dsfont52.h" typedef GFXcanvas16 Canvas; -#include "widgets/widgets.h" -#include "widgets/pages.h" +typedef Adafruit_GC9A01A yoDisplay; + +#include "tools/commongfx.h" #if __has_include("conf/displayGC9A01Aconf_custom.h") #include "conf/displayGC9A01Aconf_custom.h" @@ -26,14 +19,4 @@ typedef GFXcanvas16 Canvas; #include "conf/displayGC9A01Aconf.h" #endif -#define BOOT_PRG_COLOR 0xE68B -#define BOOT_TXT_COLOR 0xFFFF -#define PINK 0xF97F - -class DspCore: public Adafruit_GC9A01A { -#include "tools/commongfx.h" -}; - -extern DspCore dsp; - #endif diff --git a/yoRadio/src/displays/displayILI9225.cpp b/yoRadio/src/displays/displayILI9225.cpp index 1948b52..14750f4 100644 --- a/yoRadio/src/displays/displayILI9225.cpp +++ b/yoRadio/src/displays/displayILI9225.cpp @@ -1,19 +1,14 @@ #include "../core/options.h" #if DSP_MODEL==DSP_ILI9225 - -#include "displayILI9225.h" +#include "dspcore.h" #include -#include "fonts/bootlogo.h" #include "../core/config.h" -#include "../core/network.h" extern unsigned char yofont5x7[]; extern unsigned char yofont10x14[]; DspCore::DspCore(): TFT_22_ILI9225(TFT_RST, TFT_DC, TFT_CS, 0) {} -#include "tools/utf8RusGFX.h" - void DspCore::setTextSize(uint8_t s){ if(s==2){ setFont(yofont10x14, true); @@ -87,187 +82,12 @@ void DspCore::initDisplay() { invert(); flip(); setTextSize(1); - plItemHeight = playlistConf.widget.textsize*(CHARHEIGHT-1)+playlistConf.widget.textsize*4; - plTtemsCount = round((float)height()/plItemHeight); - if(plTtemsCount%2==0) plTtemsCount++; - plCurrentPos = plTtemsCount/2; - plYStart = (height() / 2 - plItemHeight / 2) - plItemHeight * (plTtemsCount - 1) / 2 + playlistConf.widget.textsize*2; } -void DspCore::drawLogo(uint16_t top) { - drawBitmap((width() - 99) / 2, top, bootlogo2, 99, 64); -} - -void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){ - setTextSize(playlistConf.widget.textsize); - if (pos == plCurrentPos) { - current.setText(item); - } else { - uint8_t plColor = (abs(pos - plCurrentPos)-1)>4?4:abs(pos - plCurrentPos)-1; - setTextColor(config.theme.playlist[plColor], config.theme.background); - setCursor(TFT_FRAMEWDT, plYStart + pos * plItemHeight); - fillRect(0, plYStart + pos * plItemHeight - 1, width(), plItemHeight - 2, config.theme.background); - print(utf8Rus(item, true)); - } -} - -void DspCore::drawPlaylist(uint16_t currentItem) { - uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount); - if(lastPosglyph + c; -} - -uint8_t DspCore::_charWidth(unsigned char c){ - GFXglyph *glyph = pgm_read_glyph_ptr(&DS_DIGI28pt7b, c - 0x20); - return pgm_read_byte(&glyph->xAdvance); -} - -uint16_t DspCore::textWidth(const char *txt){ - uint16_t w = 0, l=strlen(txt); - for(uint16_t c=0;c0) - fillRect(_olddateleft, clockTop+10, _olddatewidth, CHARHEIGHT, config.theme.background); - setTextColor(config.theme.date, config.theme.background); - setCursor(_dateleft, clockTop+10); - if(!config.isScreensaver) 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::_clockTime(){ - if(_oldtimeleft>0 && !CLOCKFONT_MONO) fillRect(_oldtimeleft, clockTop-clockTimeHeight+1, _oldtimewidth, clockTimeHeight, config.theme.background); - _timeleft = width()-clockRightSpace-CHARWIDTH*2*2-24-_timewidth; - setTextSize(1); - setFont(&DS_DIGI28pt7b); - - if(CLOCKFONT_MONO) { - setCursor(_timeleft, clockTop); - setTextColor(config.theme.clockbg, config.theme.background); - print("88:88"); - } - setTextColor(config.theme.clock, config.theme.background); - setCursor(_timeleft, clockTop); - print(_timeBuf); - setFont(); - strlcpy(_oldTimeBuf, _timeBuf, sizeof(_timeBuf)); - _oldtimewidth = _timewidth; - _oldtimeleft = _timeleft; - if(!config.isScreensaver) drawFastVLine(width()-clockRightSpace-CHARWIDTH*2*2-18, clockTop-clockTimeHeight, clockTimeHeight+3, config.theme.div); /*divider vert*/ - if(!config.isScreensaver) 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::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(!config.isScreensaver) - if(strcmp(_oldDateBuf, _dateBuf)!=0 || redraw) _clockDate(); - } - _clockSeconds(); -} - -void DspCore::clearClock(){ - fillRect(_timeleft, clockTop-clockTimeHeight, _timewidth+CHARWIDTH*3*2+24, clockTimeHeight+11+CHARHEIGHT, config.theme.background); -} - -void DspCore::startWrite(void) { - TFT_22_ILI9225::startWrite(); -} - -void DspCore::endWrite(void) { - TFT_22_ILI9225::endWrite(); -} - -void DspCore::loop(bool force) { - //delay(5); -} - -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) { - drawBitmap(x, y, bitmap, w, h); -} - -void DspCore::flip(){ - setOrientation(config.store.flipscreen?3:1); -} -void DspCore::invert(){ - invertDisplay(config.store.invertdisplay); -} - -void DspCore::sleep(void) { setDisplay(false); } -void DspCore::wake(void) { setDisplay(true); } - -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; - } - } - uint16_t ret=TFT_22_ILI9225::drawChar(x, y, ch, color); - return ret; -} - -void DspCore::setClipping(clipArea ca){ - _cliparea = ca; - _clipping = true; -} - -void DspCore::clearClipping(){ - _clipping = false; -} - -void DspCore::setNumFont(){ - setTextSize(1); - setFont(&DS_DIGI28pt7b); -} +void DspCore::clearDsp(bool black){ clear(black?0x0000:config.theme.background); } +void DspCore::flip(){ setOrientation(config.store.flipscreen?3:1); } +void DspCore::invert(){ invertDisplay(config.store.invertdisplay); } +void DspCore::sleep(void){ setDisplay(false); } +void DspCore::wake(void){ setDisplay(true); } #endif diff --git a/yoRadio/src/displays/displayILI9225.h b/yoRadio/src/displays/displayILI9225.h index 5062b4e..ffb23da 100644 --- a/yoRadio/src/displays/displayILI9225.h +++ b/yoRadio/src/displays/displayILI9225.h @@ -4,20 +4,13 @@ //================================================== #include "Arduino.h" #include "../ILI9225Fix/TFT_22_ILI9225Fix.h" - -#if CLOCKFONT_MONO - #include "fonts/DS_DIGI28pt7b_mono.h" // https://tchapi.github.io/Adafruit-GFX-Font-Customiser/ -#else - #include "fonts/DS_DIGI28pt7b.h" -#endif -#include "tools/l10n.h" - -#define CHARWIDTH 6 -#define CHARHEIGHT 8 +#include "fonts/bootlogo99x64.h" +#include "fonts/dsfont35.h" typedef GFXcanvas16 Canvas; -#include "widgets/widgets.h" -#include "widgets/pages.h" +typedef TFT_22_ILI9225 yoDisplay; + +#include "tools/commongfx.h" #if __has_include("conf/displayILI9225conf_custom.h") #include "conf/displayILI9225conf_custom.h" @@ -25,14 +18,4 @@ typedef GFXcanvas16 Canvas; #include "conf/displayILI9225conf.h" #endif -#define BOOT_PRG_COLOR 0xE68B -#define BOOT_TXT_COLOR 0xFFFF -#define PINK 0xF97F - -class DspCore: public TFT_22_ILI9225 { -#include "tools/commongfx.h" -}; - -extern DspCore dsp; - #endif diff --git a/yoRadio/src/displays/displayILI9341.cpp b/yoRadio/src/displays/displayILI9341.cpp index e97f2ba..4c39cf4 100644 --- a/yoRadio/src/displays/displayILI9341.cpp +++ b/yoRadio/src/displays/displayILI9341.cpp @@ -1,10 +1,7 @@ #include "../core/options.h" #if DSP_MODEL==DSP_ILI9341 - -#include "displayILI9341.h" -#include "fonts/bootlogo.h" +#include "dspcore.h" #include "../core/config.h" -#include "../core/network.h" #if DSP_HSPI DspCore::DspCore(): Adafruit_ILI9341(&SPI2, TFT_DC, TFT_CS, TFT_RST) {} @@ -12,198 +9,18 @@ DspCore::DspCore(): Adafruit_ILI9341(&SPI2, TFT_DC, TFT_CS, TFT_RST) {} DspCore::DspCore(): Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST) {} #endif -#include "tools/utf8RusGFX.h" - void DspCore::initDisplay() { begin(); /* SPI_DEFAULT_FREQ 40000000 */ invert(); cp437(true); flip(); setTextWrap(false); - - plItemHeight = playlistConf.widget.textsize*(CHARHEIGHT-1)+playlistConf.widget.textsize*4; - plTtemsCount = round((float)height()/plItemHeight); - if(plTtemsCount%2==0) plTtemsCount++; - plCurrentPos = plTtemsCount/2; - plYStart = (height() / 2 - plItemHeight / 2) - plItemHeight * (plTtemsCount - 1) / 2 + playlistConf.widget.textsize*2; } -void DspCore::drawLogo(uint16_t top) { - drawRGBBitmap((width() - 99) / 2, top, bootlogo2, 99, 64); -} +void DspCore::clearDsp(bool black){ fillScreen(black?0:config.theme.background); } +void DspCore::flip(){ setRotation(config.store.flipscreen?1:3); } +void DspCore::invert(){ invertDisplay(config.store.invertdisplay); } +void DspCore::sleep(void){ sendCommand(ILI9341_SLPIN); delay(150); sendCommand(ILI9341_DISPOFF); delay(150);} +void DspCore::wake(void){ sendCommand(ILI9341_DISPON); delay(150); sendCommand(ILI9341_SLPOUT); delay(150);} -void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){ - setTextSize(playlistConf.widget.textsize); - if (pos == plCurrentPos) { - current.setText(item); - } else { - uint8_t plColor = (abs(pos - plCurrentPos)-1)>4?4:abs(pos - plCurrentPos)-1; - setTextColor(config.theme.playlist[plColor], config.theme.background); - setCursor(TFT_FRAMEWDT, plYStart + pos * plItemHeight); - fillRect(0, plYStart + pos * plItemHeight - 1, width(), plItemHeight - 2, config.theme.background); - print(utf8Rus(item, true)); - } -} - -void DspCore::drawPlaylist(uint16_t currentItem) { - uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount); - if(lastPosglyph + c; -} - -uint8_t DspCore::_charWidth(unsigned char c){ - GFXglyph *glyph = pgm_read_glyph_ptr(&DS_DIGI42pt7b, c - 0x20); - return pgm_read_byte(&glyph->xAdvance); -} - -uint16_t DspCore::textWidth(const char *txt){ - uint16_t w = 0, l=strlen(txt); - for(uint16_t c=0;c0) - dsp.fillRect(_olddateleft, clockTop+10, _olddatewidth, CHARHEIGHT, config.theme.background); - setTextColor(config.theme.date, config.theme.background); - setCursor(_dateleft, clockTop+10); - if(!config.isScreensaver) print(_dateBuf); /* print date */ - strlcpy(_oldDateBuf, _dateBuf, sizeof(_dateBuf)); - _olddatewidth = _datewidth; - _olddateleft = _dateleft; - setTextSize(3); - setTextColor(config.theme.dow, config.theme.background); - setCursor(width() - 8 - clockRightSpace - CHARWIDTH*3*2, clockTop-CHARHEIGHT*3+4); - print(utf8Rus(dow[network.timeinfo.tm_wday], false)); /* print dow */ -} - -void DspCore::_clockTime(){ - if(_oldtimeleft>0 && !CLOCKFONT_MONO) dsp.fillRect(_oldtimeleft, clockTop-clockTimeHeight+1, _oldtimewidth, clockTimeHeight, config.theme.background); - _timeleft = width()-clockRightSpace-CHARWIDTH*3*2-24-_timewidth; - setTextSize(1); - setFont(&DS_DIGI42pt7b); - - if(CLOCKFONT_MONO) { - setCursor(_timeleft, clockTop); - setTextColor(config.theme.clockbg, config.theme.background); - print("88:88"); - } - setTextColor(config.theme.clock, config.theme.background); - setCursor(_timeleft, clockTop); - print(_timeBuf); - setFont(); - strlcpy(_oldTimeBuf, _timeBuf, sizeof(_timeBuf)); - _oldtimewidth = _timewidth; - _oldtimeleft = _timeleft; - if(!config.isScreensaver) drawFastVLine(width()-clockRightSpace-CHARWIDTH*3*2-18, clockTop-clockTimeHeight, clockTimeHeight+3, config.theme.div); /*divider vert*/ - if(!config.isScreensaver) drawFastHLine(width()-clockRightSpace-CHARWIDTH*3*2-18, clockTop-clockTimeHeight+29, 44, 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::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(!config.isScreensaver) - if(strcmp(_oldDateBuf, _dateBuf)!=0 || redraw) _clockDate(); - } - _clockSeconds(); -} - -void DspCore::clearClock(){ - dsp.fillRect(_timeleft, clockTop-clockTimeHeight, _timewidth+CHARWIDTH*3*2+24, clockTimeHeight+10+CHARHEIGHT, config.theme.background); -} - -void DspCore::startWrite(void) { - Adafruit_ILI9341::startWrite(); -} - -void DspCore::endWrite(void) { - Adafruit_ILI9341::endWrite(); -} - -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::setTextSize(uint8_t s){ - Adafruit_GFX::setTextSize(s); -} - -void DspCore::flip(){ - setRotation(config.store.flipscreen?1:3); -} - -void DspCore::invert(){ - invertDisplay(config.store.invertdisplay); -} - -void DspCore::sleep(void) { sendCommand(ILI9341_SLPIN); delay(150); sendCommand(ILI9341_DISPOFF); delay(150);} -void DspCore::wake(void) { sendCommand(ILI9341_DISPON); delay(150); sendCommand(ILI9341_SLPOUT); delay(150);} - -void DspCore::writePixel(int16_t x, int16_t y, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x > _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - Adafruit_ILI9341::writePixel(x, y, color); -} - -void DspCore::writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x >= _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - Adafruit_ILI9341::writeFillRect(x, y, w, h, color); -} - -void DspCore::setClipping(clipArea ca){ - _cliparea = ca; - _clipping = true; -} - -void DspCore::clearClipping(){ - _clipping = false; -} - -void DspCore::setNumFont(){ - setFont(&DS_DIGI42pt7b); - setTextSize(1); -} #endif diff --git a/yoRadio/src/displays/displayILI9341.h b/yoRadio/src/displays/displayILI9341.h index 88c80d2..a4961f0 100644 --- a/yoRadio/src/displays/displayILI9341.h +++ b/yoRadio/src/displays/displayILI9341.h @@ -1,24 +1,16 @@ #ifndef displayILI9341_h #define displayILI9341_h -#include "../core/options.h" #include "Arduino.h" #include #include - -#if CLOCKFONT_MONO - #include "fonts/DS_DIGI42pt7b_mono.h" // https://tchapi.github.io/Adafruit-GFX-Font-Customiser/ -#else - #include "fonts/DS_DIGI42pt7b.h" -#endif -#include "tools/l10n.h" - -#define CHARWIDTH 6 -#define CHARHEIGHT 8 +#include "fonts/bootlogo99x64.h" +#include "fonts/dsfont52.h" typedef GFXcanvas16 Canvas; -#include "widgets/widgets.h" -#include "widgets/pages.h" +typedef Adafruit_ILI9341 yoDisplay; + +#include "tools/commongfx.h" #if __has_include("conf/displayILI9341conf_custom.h") #include "conf/displayILI9341conf_custom.h" @@ -26,14 +18,4 @@ typedef GFXcanvas16 Canvas; #include "conf/displayILI9341conf.h" #endif -#define BOOT_PRG_COLOR 0xE68B -#define BOOT_TXT_COLOR 0xFFFF -#define PINK 0xF97F - -class DspCore: public Adafruit_ILI9341 { -#include "tools/commongfx.h" -}; - -extern DspCore dsp; - #endif diff --git a/yoRadio/src/displays/displayILI9488.cpp b/yoRadio/src/displays/displayILI9488.cpp index 528c1f2..a425088 100644 --- a/yoRadio/src/displays/displayILI9488.cpp +++ b/yoRadio/src/displays/displayILI9488.cpp @@ -1,11 +1,7 @@ #include "../core/options.h" #if DSP_MODEL==DSP_ILI9488 || DSP_MODEL==DSP_ILI9486 - -#include "displayILI9488.h" -//#include -#include "fonts/bootlogo.h" +#include "dspcore.h" #include "../core/config.h" -#include "../core/network.h" #ifndef DEF_SPI_FREQ #define DEF_SPI_FREQ 40000000UL /* set it to 0 for system default */ @@ -17,8 +13,6 @@ DspCore::DspCore(): ILI9486_SPI(TFT_CS, TFT_DC, TFT_RST) {} #endif -#include "tools/utf8RusGFX.h" - void DspCore::initDisplay() { setSpiKludge(false); init(); @@ -29,196 +23,12 @@ void DspCore::initDisplay() { fillScreen(0x0000); invert(); flip(); - - plItemHeight = playlistConf.widget.textsize*(CHARHEIGHT-1)+playlistConf.widget.textsize*4; - plTtemsCount = round((float)height()/plItemHeight); - if(plTtemsCount%2==0) plTtemsCount++; - plCurrentPos = plTtemsCount/2; - plYStart = (height() / 2 - plItemHeight / 2) - plItemHeight * (plTtemsCount - 1) / 2 + playlistConf.widget.textsize*2; } -void DspCore::drawLogo(uint16_t top) { drawRGBBitmap((width() - 99) / 2, top, bootlogo2, 99, 64); } +void DspCore::clearDsp(bool black){ fillScreen(black?0:config.theme.background); } +void DspCore::flip(){ setRotation(config.store.flipscreen?3:1); } +void DspCore::invert(){ invertDisplay(config.store.invertdisplay); } +void DspCore::sleep(void){ sendCommand(ILI9488_SLPIN); delay(150); sendCommand(ILI9488_DISPOFF); delay(150); } +void DspCore::wake(void){ sendCommand(ILI9488_DISPON); delay(150); sendCommand(ILI9488_SLPOUT); delay(150); } -void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){ - setTextSize(playlistConf.widget.textsize); - if (pos == plCurrentPos) { - current.setText(item); - } else { - uint8_t plColor = (abs(pos - plCurrentPos)-1)>4?4:abs(pos - plCurrentPos)-1; - setTextColor(config.theme.playlist[plColor], config.theme.background); - setCursor(TFT_FRAMEWDT, plYStart + pos * plItemHeight); - fillRect(0, plYStart + pos * plItemHeight - 1, width(), plItemHeight - 2, config.theme.background); - print(utf8Rus(item, true)); - } -} - -void DspCore::drawPlaylist(uint16_t currentItem) { - uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount); - if(lastPosglyph + c; -} - -uint8_t DspCore::_charWidth(unsigned char c){ - GFXglyph *glyph = pgm_read_glyph_ptr(&DS_DIGI56pt7b, c - 0x20); - return pgm_read_byte(&glyph->xAdvance); -} - -uint16_t DspCore::textWidth(const char *txt){ - uint16_t w = 0, l=strlen(txt); - for(uint16_t c=0;c0) - dsp.fillRect(_olddateleft, clockTop+14, _olddatewidth, CHARHEIGHT*2, config.theme.background); - setTextColor(config.theme.date, config.theme.background); - setCursor(_dateleft, clockTop+15); - setTextSize(2); - if(!config.isScreensaver) print(_dateBuf); /* print date */ - strlcpy(_oldDateBuf, _dateBuf, sizeof(_dateBuf)); - _olddatewidth = _datewidth; - _olddateleft = _dateleft; - setTextSize(4); - setTextColor(config.theme.dow, config.theme.background); - setCursor(width() - 8 - clockRightSpace - CHARWIDTH*4*2, clockTop-CHARHEIGHT*4+4); - print(utf8Rus(dow[network.timeinfo.tm_wday], false)); /* print dow */ -} - -void DspCore::_clockTime(){ - if(_oldtimeleft>0 && !CLOCKFONT_MONO) dsp.fillRect(_oldtimeleft, clockTop-clockTimeHeight+1, _oldtimewidth, clockTimeHeight, config.theme.background); - _timeleft = width()-clockRightSpace-CHARWIDTH*4*2-24-_timewidth; - setTextSize(1); - setFont(&DS_DIGI56pt7b); - - if(CLOCKFONT_MONO) { - setCursor(_timeleft, clockTop); - setTextColor(config.theme.clockbg, config.theme.background); - print("88:88"); - } - setTextColor(config.theme.clock, config.theme.background); - setCursor(_timeleft, clockTop); - print(_timeBuf); - setFont(); - strlcpy(_oldTimeBuf, _timeBuf, sizeof(_timeBuf)); - _oldtimewidth = _timewidth; - _oldtimeleft = _timeleft; - if(!config.isScreensaver) drawFastVLine(width()-clockRightSpace-CHARWIDTH*4*2-18, clockTop-clockTimeHeight, clockTimeHeight+4, config.theme.div); /*divider vert*/ - if(!config.isScreensaver) drawFastHLine(width()-clockRightSpace-CHARWIDTH*4*2-18, clockTop-clockTimeHeight+37, 59, 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*2; - _dateleft = width() - 10 - clockRightSpace - _datewidth; -} - -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(!config.isScreensaver) - if(strcmp(_oldDateBuf, _dateBuf)!=0 || redraw) _clockDate(); - } - _clockSeconds(); -} - -void DspCore::clearClock(){ - dsp.fillRect(_timeleft, clockTop-clockTimeHeight, _timewidth+CHARWIDTH*3*2+24, clockTimeHeight+12+CHARHEIGHT, config.theme.background); -} - -void DspCore::startWrite(void) { - ILI9486_SPI::startWrite(); -} - -void DspCore::endWrite(void) { - ILI9486_SPI::endWrite(); -} - -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::setTextSize(uint8_t s){ - Adafruit_GFX::setTextSize(s); -} - -void DspCore::flip(){ - setRotation(config.store.flipscreen?3:1); -} - -void DspCore::invert(){ - invertDisplay(config.store.invertdisplay); -} - -void DspCore::sleep(void) { - sendCommand(ILI9488_SLPIN); delay(150); sendCommand(ILI9488_DISPOFF); delay(150); -} - -void DspCore::wake(void) { - sendCommand(ILI9488_DISPON); delay(150); sendCommand(ILI9488_SLPOUT); delay(150); -} - -void DspCore::writePixel(int16_t x, int16_t y, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x > _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - ILI9486_SPI::drawPixel(x, y, color); -} - -void DspCore::writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x >= _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - ILI9486_SPI::writeFillRect(x, y, w, h, color); -} - -void DspCore::setClipping(clipArea ca){ - _cliparea = ca; - _clipping = true; -} - -void DspCore::clearClipping(){ - _clipping = false; -} - -void DspCore::setNumFont(){ - setFont(&DS_DIGI56pt7b); - setTextSize(1); -} #endif diff --git a/yoRadio/src/displays/displayILI9488.h b/yoRadio/src/displays/displayILI9488.h index 4f96317..7d528d3 100644 --- a/yoRadio/src/displays/displayILI9488.h +++ b/yoRadio/src/displays/displayILI9488.h @@ -1,24 +1,16 @@ #ifndef displayILI9488_h #define displayILI9488_h -#include "../core/options.h" #include "Arduino.h" #include #include "../ILI9488/ILI9486_SPI.h" - -#if CLOCKFONT_MONO - #include "fonts/DS_DIGI56pt7b_mono.h" // https://tchapi.github.io/Adafruit-GFX-Font-Customiser/ -#else - #include "fonts/DS_DIGI56pt7b.h" -#endif -#include "tools/l10n.h" - -#define CHARWIDTH 6 -#define CHARHEIGHT 8 +#include "fonts/bootlogo99x64.h" +#include "fonts/dsfont70.h" typedef GFXcanvas16 Canvas; -#include "widgets/widgets.h" -#include "widgets/pages.h" +typedef ILI9486_SPI yoDisplay; + +#include "tools/commongfx.h" #if __has_include("conf/displayILI9488conf_custom.h") #include "conf/displayILI9488conf_custom.h" @@ -26,19 +18,9 @@ typedef GFXcanvas16 Canvas; #include "conf/displayILI9488conf.h" #endif -#define BOOT_PRG_COLOR 0xE68B -#define BOOT_TXT_COLOR 0xFFFF -#define PINK 0xF97F - #define ILI9488_SLPIN 0x10 #define ILI9488_SLPOUT 0x11 #define ILI9488_DISPOFF 0x28 #define ILI9488_DISPON 0x29 -class DspCore: public ILI9486_SPI { -#include "tools/commongfx.h" -}; - -extern DspCore dsp; - #endif diff --git a/yoRadio/src/displays/displayLC1602.cpp b/yoRadio/src/displays/displayLC1602.cpp index 7078505..37b9fe0 100644 --- a/yoRadio/src/displays/displayLC1602.cpp +++ b/yoRadio/src/displays/displayLC1602.cpp @@ -1,11 +1,8 @@ #include "../core/options.h" - #if DSP_MODEL==DSP_1602I2C || DSP_MODEL==DSP_1602 || DSP_MODEL==DSP_2004 || DSP_MODEL==DSP_2004I2C - -#include "displayLC1602.h" -#include "../core/player.h" +#include "dspcore.h" +#include #include "../core/config.h" -#include "../core/network.h" #ifndef SCREEN_ADDRESS #define SCREEN_ADDRESS 0x27 ///< See datasheet for Address or scan it https://create.arduino.cc/projecthub/abdularbi17/how-to-scan-i2c-address-in-arduino-eaadda @@ -13,14 +10,12 @@ DspCore::DspCore(): DSP_INIT {} -#include "tools/utf8RusLCD.h" - void DspCore::apScreen() { clear(); setCursor(0,0); print(utf8Rus(const_lcdApMode, false)); setCursor(0,1); - print(WiFi.softAPIP().toString().c_str()); + print(config.ipToStr(WiFi.softAPIP())); #ifdef LCD_2004 setCursor(0, 2); print(utf8Rus(const_lcdApName, false)); @@ -43,33 +38,6 @@ void DspCore::initDisplay() { #endif #endif clearClipping(); - - plTtemsCount = PLMITEMS; - plCurrentPos = 1; -} - -void DspCore::drawLogo(uint16_t top) { } - -void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){ - if (pos == plCurrentPos) { - current.setText(item); - } else { - setCursor(1, pos); - char tmp[width()] = {0}; - strlcpy(tmp, utf8Rus(item, true), width()); - print(tmp); - } -} - -void DspCore::drawPlaylist(uint16_t currentItem) { - clear(); - config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount); - setCursor(0,1); - write(uint8_t(126)); -} - -void DspCore::clearDsp(bool black) { - clear(); } void DspCore::fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color){ @@ -97,55 +65,9 @@ uint16_t DspCore::height(){ #endif } -uint8_t DspCore::_charWidth(unsigned char c){ - return 1; -} - -uint16_t DspCore::textWidth(const char *txt){ - uint16_t w = 0, l=strlen(txt); - for(uint16_t c=0;c #include "../core/config.h" -#include "../core/network.h" - -#define LOGO_WIDTH 21 -#define LOGO_HEIGHT 28 - -const unsigned char logo [] PROGMEM= -{ - 0x07, 0x03, 0x80, 0x0f, 0x87, 0xc0, 0x0f, 0x87, 0xc0, 0x0f, 0x87, 0xc0, 0x0f, 0x87, 0xc0, 0x07, - 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xfe, 0x00, 0x07, 0xff, 0x80, 0x1f, 0xff, - 0xc0, 0x1f, 0xff, 0xe0, 0x3f, 0xff, 0xf0, 0x7f, 0x07, 0xf0, 0x7e, 0x03, 0xf0, 0x7e, 0x01, 0xf8, - 0x7f, 0xff, 0xf8, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xf8, 0x7f, 0xff, 0xf8, 0x7e, 0x00, 0x00, 0x7f, - 0x00, 0x00, 0x7f, 0x80, 0x20, 0x3f, 0xff, 0xe0, 0x3f, 0xff, 0xe0, 0x1f, 0xff, 0xe0, 0x0f, 0xff, - 0xe0, 0x01, 0xff, 0xc0 -}; #if DSP_HSPI DspCore::DspCore(): Adafruit_PCD8544(TFT_DC, TFT_CS, TFT_RST, &SPI2) {} @@ -25,16 +10,6 @@ DspCore::DspCore(): Adafruit_PCD8544(TFT_DC, TFT_CS, TFT_RST, &SPI2) {} DspCore::DspCore(): Adafruit_PCD8544(TFT_DC, TFT_CS, TFT_RST) {} #endif -#include "tools/utf8RusGFX.h" - -void DspCore::command(uint8_t c) { - Adafruit_PCD8544::command(c); -} - -void DspCore::data(uint8_t c) { - Adafruit_PCD8544::data(c); -} - void DspCore::initDisplay() { begin(); setReinitInterval(0); @@ -63,166 +38,12 @@ void DspCore::initDisplay() { invert(); flip(); setTextWrap(false); - - plItemHeight = playlistConf.widget.textsize*(CHARHEIGHT-1)+playlistConf.widget.textsize*4; - plTtemsCount = round((float)height()/plItemHeight); - if(plTtemsCount%2==0) plTtemsCount++; - plCurrentPos = plTtemsCount/2; - plYStart = (height() / 2 - plItemHeight / 2) - plItemHeight * (plTtemsCount - 1) / 2 + playlistConf.widget.textsize*2; } -void DspCore::drawLogo(uint16_t top) { - drawBitmap((width() - LOGO_WIDTH ) / 2, top, logo, LOGO_WIDTH, LOGO_HEIGHT, 1); - display(); -} - -void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){ - setTextSize(playlistConf.widget.textsize); - if (pos == plCurrentPos) { - current.setText(item); - } else { - uint8_t plColor = (abs(pos - plCurrentPos)-1)>4?4:abs(pos - plCurrentPos)-1; - setTextColor(config.theme.playlist[plColor], config.theme.background); - setCursor(TFT_FRAMEWDT, plYStart + pos * plItemHeight); - fillRect(0, plYStart + pos * plItemHeight - 1, width(), plItemHeight - 2, config.theme.background); - print(utf8Rus(item, true)); - } -} - -void DspCore::drawPlaylist(uint16_t currentItem) { - uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount); - if(lastPosglyph + c; -} - -uint8_t DspCore::_charWidth(unsigned char c){ - GFXglyph *glyph = pgm_read_glyph_ptr(&DS_DIGI15pt7b, c - 0x20); - return pgm_read_byte(&glyph->xAdvance); -} - -uint16_t DspCore::textWidth(const char *txt){ - uint16_t w = 0, l=strlen(txt); - for(uint16_t c=0;c0) dsp.fillRect(_oldtimeleft, clockTop-clockTimeHeight+1, _oldtimewidth+CHARWIDTH*2+2, clockTimeHeight, config.theme.background); - //if(_oldtimeleft>0) dsp.fillRect(_oldtimeleft, clockTop-clockTimeHeight+1, _oldtimewidth, clockTimeHeight, config.theme.background); - _timeleft = (width()/2 - _timewidth/2)-clockRightSpace; - setTextSize(1); - setFont(&DS_DIGI15pt7b); - setTextColor(config.theme.clock, config.theme.background); - setCursor(_timeleft, clockTop); - print(_timeBuf); - setFont(); - strlcpy(_oldTimeBuf, _timeBuf, sizeof(_timeBuf)); - _oldtimewidth = _timewidth; - _oldtimeleft = _timeleft; -} - -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(); - } - _clockSeconds(); -} - -void DspCore::clearClock(){ - dsp.fillRect(_timeleft, clockTop-clockTimeHeight, _timewidth+CHARWIDTH*2+2, clockTimeHeight+2, config.theme.background); - //dsp.fillRect(_timeleft, clockTop-clockTimeHeight, _timewidth+CHARWIDTH*3*2+24, clockTimeHeight+10+CHARHEIGHT, config.theme.background); -} - - -void DspCore::loop(bool force) { - if(digitalRead(TFT_CS)==LOW) return; - display(); - delay(10); -} - -void DspCore::charSize(uint8_t textsize, uint8_t& width, uint16_t& height){ - width = textsize * CHARWIDTH; - height = textsize * CHARHEIGHT; -} - -void DspCore::setTextSize(uint8_t s){ - Adafruit_GFX::setTextSize(s); -} - -void DspCore::flip(){ - setRotation(config.store.flipscreen?2:0); -} - -void DspCore::invert(){ - invertDisplay(config.store.invertdisplay); -} - -void DspCore::sleep(void) { command( PCD8544_FUNCTIONSET | PCD8544_POWERDOWN); } -void DspCore::wake(void) { initDisplay(); } - -void DspCore::writePixel(int16_t x, int16_t y, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x > _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - Adafruit_PCD8544::writePixel(x, y, color); -} - -void DspCore::writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x >= _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - Adafruit_PCD8544::writeFillRect(x, y, w, h, color); -} - -void DspCore::setClipping(clipArea ca){ - _cliparea = ca; - _clipping = true; -} - -void DspCore::clearClipping(){ - _clipping = false; -} - -void DspCore::setNumFont(){ - setFont(&DS_DIGI15pt7b); - setTextSize(1); -} +void DspCore::clearDsp(bool black){ fillScreen(TFT_BG); } +void DspCore::flip(){ setRotation(config.store.flipscreen?2:0); } +void DspCore::invert(){ invertDisplay(config.store.invertdisplay); } +void DspCore::sleep(void){ command( PCD8544_FUNCTIONSET | PCD8544_POWERDOWN); } +void DspCore::wake(void){ initDisplay(); } #endif diff --git a/yoRadio/src/displays/displayN5110.h b/yoRadio/src/displays/displayN5110.h index 9e7d65d..b2705db 100644 --- a/yoRadio/src/displays/displayN5110.h +++ b/yoRadio/src/displays/displayN5110.h @@ -1,28 +1,18 @@ #ifndef displayN5110_h #define displayN5110_h -#include "../core/options.h" #include "Arduino.h" #include #include #include "fonts/TinyFont5.h" #include "fonts/TinyFont6.h" - -#if CLOCKFONT_MONO - #include "fonts/DS_DIGI15pt7b_mono.h" -#else - #include "fonts/DS_DIGI15pt7b.h" -#endif -#include "tools/l10n.h" - -#define CHARWIDTH 6 -#define CHARHEIGHT 8 - -#define DSP_OLED +#include "fonts/bootlogo21x28.h" +#include "fonts/bootlogo35.h" typedef GFXcanvas1 Canvas; -#include "widgets/widgets.h" -#include "widgets/pages.h" +typedef Adafruit_PCD8544 yoDisplay; + +#include "tools/commongfx.h" #if __has_include("conf/displayN5110conf_custom.h") #include "conf/displayN5110conf_custom.h" @@ -30,12 +20,6 @@ typedef GFXcanvas1 Canvas; #include "conf/displayN5110conf.h" #endif -class DspCore: public Adafruit_PCD8544 { -#include "tools/commongfx.h" -}; - -extern DspCore dsp; - /* * TFT COLORS */ diff --git a/yoRadio/src/displays/displaySH1106.cpp b/yoRadio/src/displays/displaySH1106.cpp index 8425b5e..f79a411 100644 --- a/yoRadio/src/displays/displaySH1106.cpp +++ b/yoRadio/src/displays/displaySH1106.cpp @@ -1,35 +1,17 @@ #include "../core/options.h" #if DSP_MODEL==DSP_SH1106 || DSP_MODEL==DSP_SH1107 - -#include "displaySH1106.h" +#include "dspcore.h" #include -#include "../core/player.h" #include "../core/config.h" -#include "../core/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 - #ifndef I2CFREQ_HZ #define I2CFREQ_HZ 4000000UL #endif -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 -}; - TwoWire I2CSH1106 = TwoWire(0); #if DSP_MODEL==DSP_SH1106 DspCore::DspCore(): Adafruit_SH1106G(128, 64, &I2CSH1106, -1, I2CFREQ_HZ) { @@ -41,8 +23,6 @@ DspCore::DspCore(): Adafruit_SH1107(64, 128, &I2CSH1106, -1) { } #endif -#include "tools/utf8RusGFX.h" - void DspCore::initDisplay() { I2CSH1106.begin(I2C_SDA, I2C_SCL); if (!begin(SCREEN_ADDRESS, true)) { @@ -54,119 +34,9 @@ void DspCore::initDisplay() { flip(); invert(); setTextWrap(false); - - plItemHeight = playlistConf.widget.textsize*(CHARHEIGHT-1)+playlistConf.widget.textsize*4; - plTtemsCount = round((float)height()/plItemHeight); - if(plTtemsCount%2==0) plTtemsCount++; - plCurrentPos = plTtemsCount/2; - plYStart = (height() / 2 - plItemHeight / 2) - plItemHeight * (plTtemsCount - 1) / 2 + playlistConf.widget.textsize*2; -} - -void DspCore::drawLogo(uint16_t top) { - drawBitmap((width() - LOGO_WIDTH ) / 2, top, logo, LOGO_WIDTH, LOGO_HEIGHT, 1); -} - -void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){ - setTextSize(playlistConf.widget.textsize); - if (pos == plCurrentPos) { - current.setText(item); - } else { - uint8_t plColor = (abs(pos - plCurrentPos)-1)>4?4:abs(pos - plCurrentPos)-1; - setTextColor(config.theme.playlist[plColor], config.theme.background); - setCursor(TFT_FRAMEWDT, plYStart + pos * plItemHeight); - fillRect(0, plYStart + pos * plItemHeight - 1, width(), plItemHeight - 2, config.theme.background); - print(utf8Rus(item, true)); - } -} - -void DspCore::drawPlaylist(uint16_t currentItem) { - uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount); - if(lastPos0) dsp.fillRect(_oldtimeleft, clockTop, _oldtimewidth, clockTimeHeight*CHARHEIGHT, config.theme.background); - _timeleft = (width()/2 - _timewidth/2)+clockRightSpace; - setTextColor(config.theme.clock, config.theme.background); - setTextSize(clockTimeHeight); - - setCursor(_timeleft, clockTop); - print(_timeBuf); - strlcpy(_oldTimeBuf, _timeBuf, sizeof(_timeBuf)); - _oldtimewidth = _timewidth; - _oldtimeleft = _timeleft; -} - -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(); - } - _clockSeconds(); -} - -void DspCore::clearClock(){ - dsp.fillRect(_timeleft, clockTop, _timewidth+14, clockTimeHeight*CHARHEIGHT, config.theme.background); -} - -void DspCore::startWrite(void) { } - -void DspCore::endWrite(void) { } - -void DspCore::loop(bool force) { - display(); - delay(5); -} - -void DspCore::charSize(uint8_t textsize, uint8_t& width, uint16_t& height){ - width = textsize * CHARWIDTH; - height = textsize * CHARHEIGHT; -} - -void DspCore::setTextSize(uint8_t s){ - Adafruit_GFX::setTextSize(s); } +void DspCore::clearDsp(bool black){ fillScreen(TFT_BG); } void DspCore::flip(){ #if DSP_MODEL==DSP_SH1107 setRotation(config.store.flipscreen?3:1); @@ -175,47 +45,8 @@ void DspCore::flip(){ setRotation(config.store.flipscreen?2:0); #endif } - -void DspCore::invert(){ - invertDisplay(config.store.invertdisplay); -} - -void DspCore::sleep(void) { oled_command(SH110X_DISPLAYOFF); } -void DspCore::wake(void) { oled_command(SH110X_DISPLAYON); } - -void DspCore::writePixel(int16_t x, int16_t y, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x > _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } -#if DSP_MODEL==DSP_SH1107 - Adafruit_SH1107::writePixel(x, y, color); -#else - Adafruit_SH1106G::writePixel(x, y, color); -#endif -} - -void DspCore::writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x >= _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } -#if DSP_MODEL==DSP_SH1107 - Adafruit_SH1107::writeFillRect(x, y, w, h, color); -#else - Adafruit_SH1106G::writeFillRect(x, y, w, h, color); -#endif -} - -void DspCore::setClipping(clipArea ca){ - _cliparea = ca; - _clipping = true; -} - -void DspCore::clearClipping(){ - _clipping = false; -} - -void DspCore::setNumFont(){ - setTextSize(2); -} +void DspCore::invert(){ invertDisplay(config.store.invertdisplay); } +void DspCore::sleep(void){ oled_command(SH110X_DISPLAYOFF); } +void DspCore::wake(void){ oled_command(SH110X_DISPLAYON); } #endif diff --git a/yoRadio/src/displays/displaySH1106.h b/yoRadio/src/displays/displaySH1106.h index 9f3e06c..3777598 100644 --- a/yoRadio/src/displays/displaySH1106.h +++ b/yoRadio/src/displays/displaySH1106.h @@ -1,21 +1,20 @@ #ifndef displaySH1106_h #define displaySH1106_h -#include "../core/options.h" #include "Arduino.h" #include #include -#include "tools/l10n.h" - -#define CHARWIDTH 6 -#define CHARHEIGHT 8 - -#define DSP_OLED -#define GXCLOCKFONT +#include "fonts/bootlogo21x32.h" typedef GFXcanvas1 Canvas; -#include "widgets/widgets.h" -#include "widgets/pages.h" + +#if DSP_MODEL==DSP_SH1106 +typedef Adafruit_SH1106G yoDisplay; +#else +typedef Adafruit_SH1107 yoDisplay; +#endif + +#include "tools/commongfx.h" #if __has_include("conf/displaySH1106conf_custom.h") #include "conf/displaySH1106conf_custom.h" @@ -23,16 +22,6 @@ typedef GFXcanvas1 Canvas; #include "conf/displaySH1106conf.h" #endif -#if DSP_MODEL==DSP_SH1106 -class DspCore: public Adafruit_SH1106G { -#else -class DspCore: public Adafruit_SH1107 { -#endif -#include "tools/commongfx.h" -}; - -extern DspCore dsp; - /* * OLED COLORS */ diff --git a/yoRadio/src/displays/displaySSD1305.cpp b/yoRadio/src/displays/displaySSD1305.cpp index 7208dd2..12c4ef6 100644 --- a/yoRadio/src/displays/displaySSD1305.cpp +++ b/yoRadio/src/displays/displaySSD1305.cpp @@ -1,33 +1,16 @@ #include "../core/options.h" #if DSP_MODEL==DSP_SSD1305 || DSP_MODEL==DSP_SSD1305I2C - -#include "displaySSD1305.h" +#include "dspcore.h" #include "../core/config.h" -#include "../core/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 - #ifndef DEF_SPI_FREQ #define DEF_SPI_FREQ 8000000UL /* set it to 0 for system default */ #endif -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 -}; - #if DSP_MODEL==DSP_SSD1305 #if DSP_HSPI DspCore::DspCore(): Adafruit_SSD1305(128, 64, &SPI2, TFT_DC, TFT_RST, TFT_CS, DEF_SPI_FREQ) {} @@ -42,8 +25,6 @@ DspCore::DspCore(): Adafruit_SSD1305(128, 64, &I2CSSD1305, -1){ } #endif -#include "tools/utf8RusGFX.h" - void DspCore::initDisplay() { #if DSP_MODEL==DSP_SSD1305I2C I2CSSD1305.begin(I2C_SDA, I2C_SCL); @@ -58,163 +39,12 @@ void DspCore::initDisplay() { flip(); invert(); setTextWrap(false); - - plItemHeight = playlistConf.widget.textsize*(CHARHEIGHT-1)+playlistConf.widget.textsize*4; - plTtemsCount = round((float)height()/plItemHeight); - if(plTtemsCount%2==0) plTtemsCount++; - plCurrentPos = plTtemsCount/2; - plYStart = (height() / 2 - plItemHeight / 2) - plItemHeight * (plTtemsCount - 1) / 2 + playlistConf.widget.textsize*2; } -void DspCore::drawLogo(uint16_t top) { - drawBitmap( (width() - LOGO_WIDTH ) / 2, 8, logo, LOGO_WIDTH, LOGO_HEIGHT, 1); - display(); -} - -void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){ - setTextSize(playlistConf.widget.textsize); - if (pos == plCurrentPos) { - current.setText(item); - } else { - uint8_t plColor = (abs(pos - plCurrentPos)-1)>4?4:abs(pos - plCurrentPos)-1; - setTextColor(config.theme.playlist[plColor], config.theme.background); - setCursor(TFT_FRAMEWDT, plYStart + pos * plItemHeight); - fillRect(0, plYStart + pos * plItemHeight - 1, width(), plItemHeight - 2, config.theme.background); - print(utf8Rus(item, true)); - } -} - -void DspCore::drawPlaylist(uint16_t currentItem) { - uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount); - if(lastPos0) dsp.fillRect(_oldtimeleft, clockTop, _oldtimewidth, clockTimeHeight*CHARHEIGHT, config.theme.background); - _timeleft = (width()/2 - _timewidth/2)+clockRightSpace; - setTextColor(config.theme.clock, config.theme.background); - setTextSize(clockTimeHeight); - - setCursor(_timeleft, clockTop); - print(_timeBuf); - //setFont(); - strlcpy(_oldTimeBuf, _timeBuf, sizeof(_timeBuf)); - _oldtimewidth = _timewidth; - _oldtimeleft = _timeleft; -} - -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(); - } - _clockSeconds(); -} - -void DspCore::clearClock(){ - dsp.fillRect(_timeleft, clockTop, _timewidth+14, clockTimeHeight*CHARHEIGHT, config.theme.background); -} - -void DspCore::startWrite(void) { } - -void DspCore::endWrite(void) { } - -void DspCore::loop(bool force) { - display(); - delay(5); -} - -void DspCore::charSize(uint8_t textsize, uint8_t& width, uint16_t& height){ - width = textsize * CHARWIDTH; - height = textsize * CHARHEIGHT; -} - -void DspCore::setTextSize(uint8_t s){ - Adafruit_GFX::setTextSize(s); -} - -void DspCore::flip(){ - setRotation(config.store.flipscreen?2:0); -} - -void DspCore::invert(){ - invertDisplay(config.store.invertdisplay); -} - -void DspCore::sleep(void) { - oled_command(SSD1305_DISPLAYOFF); -} -void DspCore::wake(void) { - oled_command(SSD1305_DISPLAYON); -} - -void DspCore::writePixel(int16_t x, int16_t y, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x > _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - Adafruit_SSD1305::writePixel(x, y, color); -} - -void DspCore::writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x >= _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - Adafruit_SSD1305::writeFillRect(x, y, w, h, color); -} - -void DspCore::setClipping(clipArea ca){ - _cliparea = ca; - _clipping = true; -} - -void DspCore::clearClipping(){ - _clipping = false; -} - -void DspCore::setNumFont(){ - setTextSize(2); -} +void DspCore::clearDsp(bool black){ fillScreen(TFT_BG); } +void DspCore::flip(){ setRotation(config.store.flipscreen?2:0); } +void DspCore::invert(){ invertDisplay(config.store.invertdisplay); } +void DspCore::sleep(void){ oled_command(SSD1305_DISPLAYOFF); } +void DspCore::wake(void){ oled_command(SSD1305_DISPLAYON); } #endif diff --git a/yoRadio/src/displays/displaySSD1305.h b/yoRadio/src/displays/displaySSD1305.h index 3809309..19f4cf4 100644 --- a/yoRadio/src/displays/displaySSD1305.h +++ b/yoRadio/src/displays/displaySSD1305.h @@ -1,21 +1,15 @@ #ifndef displaySSD1305_h #define displaySSD1305_h -#include "../core/options.h" #include "Arduino.h" #include #include -#include "tools/l10n.h" - -#define CHARWIDTH 6 -#define CHARHEIGHT 8 - -#define DSP_OLED -#define GXCLOCKFONT +#include "fonts/bootlogo21x32.h" typedef GFXcanvas1 Canvas; -#include "widgets/widgets.h" -#include "widgets/pages.h" +typedef Adafruit_SSD1305 yoDisplay; + +#include "tools/commongfx.h" #if __has_include("conf/displaySSD1305conf_custom.h") #include "conf/displaySSD1305conf_custom.h" @@ -23,12 +17,6 @@ typedef GFXcanvas1 Canvas; #include "conf/displaySSD1305conf.h" #endif -class DspCore: public Adafruit_SSD1305 { -#include "tools/commongfx.h" -}; - -extern DspCore dsp; - /* * OLED COLORS */ diff --git a/yoRadio/src/displays/displaySSD1306.cpp b/yoRadio/src/displays/displaySSD1306.cpp index a5d3e34..f6b0448 100644 --- a/yoRadio/src/displays/displaySSD1306.cpp +++ b/yoRadio/src/displays/displaySSD1306.cpp @@ -1,34 +1,13 @@ #include "../core/options.h" #if DSP_MODEL==DSP_SSD1306 || DSP_MODEL==DSP_SSD1306x32 - -#include "displaySSD1306.h" +#include "dspcore.h" #include -#include "../core/player.h" #include "../core/config.h" -#include "../core/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 -#if DSP_MODEL==DSP_SSD1306 - -#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, - 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 -}; -#endif - #ifndef I2CFREQ_HZ #define I2CFREQ_HZ 4000000UL #endif @@ -37,8 +16,6 @@ TwoWire I2CSSD1306 = TwoWire(0); DspCore::DspCore(): Adafruit_SSD1306(128, ((DSP_MODEL==DSP_SSD1306)?64:32), &I2CSSD1306, I2C_RST, I2CFREQ_HZ) { } -#include "tools/utf8RusGFX.h" - void DspCore::initDisplay() { I2CSSD1306.begin(I2C_SDA, I2C_SCL); if (!begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) { @@ -50,178 +27,12 @@ void DspCore::initDisplay() { flip(); invert(); setTextWrap(false); - - plItemHeight = playlistConf.widget.textsize*(CHARHEIGHT-1)+playlistConf.widget.textsize*4; - plTtemsCount = round((float)height()/plItemHeight); - if(plTtemsCount%2==0) plTtemsCount++; - plCurrentPos = plTtemsCount/2; - plYStart = (height() / 2 - plItemHeight / 2) - plItemHeight * (plTtemsCount - 1) / 2 + playlistConf.widget.textsize*2; } -void DspCore::drawLogo(uint16_t top) { -#if DSP_MODEL==DSP_SSD1306 - drawBitmap((width() - LOGO_WIDTH ) / 2, 8, logo, LOGO_WIDTH, LOGO_HEIGHT, 1); -#else - setTextSize(1); - setCursor((width() - 6*CHARWIDTH) / 2, 0); - setTextColor(TFT_FG, TFT_BG); - print(utf8Rus("ёRadio", false)); - setTextSize(1); -#endif - display(); -} - -void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){ - setTextSize(playlistConf.widget.textsize); - if (pos == plCurrentPos) { - current.setText(item); - } else { - uint8_t plColor = (abs(pos - plCurrentPos)-1)>4?4:abs(pos - plCurrentPos)-1; - setTextColor(config.theme.playlist[plColor], config.theme.background); - setCursor(TFT_FRAMEWDT, plYStart + pos * plItemHeight); - fillRect(0, plYStart + pos * plItemHeight - 1, width(), plItemHeight - 2, config.theme.background); - print(utf8Rus(item, true)); - } -} - -void DspCore::drawPlaylist(uint16_t currentItem) { - uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount); - if(lastPos0) dsp.fillRect(_oldtimeleft, clockTop, _oldtimewidth, clockTimeHeight*CHARHEIGHT, config.theme.background); - #if DSP_MODEL!=DSP_SSD1306x32 - _timeleft = (width()/2 - _timewidth/2)+clockRightSpace; - setTextColor(config.theme.clock, config.theme.background); - #else - _timeleft = (width() - _timewidth)-clockRightSpace; - setTextColor(0, 1); - #endif - setTextSize(clockTimeHeight); - - setCursor(_timeleft, clockTop); - print(_timeBuf); - //setFont(); - strlcpy(_oldTimeBuf, _timeBuf, sizeof(_timeBuf)); - _oldtimewidth = _timewidth; - _oldtimeleft = _timeleft; -} - -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(); - } - _clockSeconds(); -} - -void DspCore::clearClock(){ - dsp.fillRect(_timeleft, clockTop, _timewidth+14, clockTimeHeight*CHARHEIGHT, config.theme.background); -} - -void DspCore::startWrite(void) { } - -void DspCore::endWrite(void) { } - -void DspCore::loop(bool force) { - display(); - delay(5); -} - -void DspCore::charSize(uint8_t textsize, uint8_t& width, uint16_t& height){ - width = textsize * CHARWIDTH; - height = textsize * CHARHEIGHT; -} - -void DspCore::setTextSize(uint8_t s){ - Adafruit_GFX::setTextSize(s); -} - -void DspCore::flip(){ - setRotation(config.store.flipscreen?2:0); -} - -void DspCore::invert(){ - invertDisplay(config.store.invertdisplay); -} - -void DspCore::sleep(void) { ssd1306_command(SSD1306_DISPLAYOFF); } -void DspCore::wake(void) { ssd1306_command(SSD1306_DISPLAYON); } - -void DspCore::writePixel(int16_t x, int16_t y, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x > _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - Adafruit_SSD1306::writePixel(x, y, color); -} - -void DspCore::writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x >= _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - Adafruit_SSD1306::writeFillRect(x, y, w, h, color); -} - -void DspCore::setClipping(clipArea ca){ - _cliparea = ca; - _clipping = true; -} - -void DspCore::clearClipping(){ - _clipping = false; -} - -void DspCore::setNumFont(){ - setTextSize(2); -} +void DspCore::clearDsp(bool black){ fillScreen(TFT_BG); } +void DspCore::flip(){ setRotation(config.store.flipscreen?2:0); } +void DspCore::invert(){ invertDisplay(config.store.invertdisplay); } +void DspCore::sleep(void){ ssd1306_command(SSD1306_DISPLAYOFF); } +void DspCore::wake(void){ ssd1306_command(SSD1306_DISPLAYON); } #endif diff --git a/yoRadio/src/displays/displaySSD1306.h b/yoRadio/src/displays/displaySSD1306.h index f979a9b..688410e 100644 --- a/yoRadio/src/displays/displaySSD1306.h +++ b/yoRadio/src/displays/displaySSD1306.h @@ -1,21 +1,18 @@ #ifndef displaySSD1306_h #define displaySSD1306_h -#include "../core/options.h" #include "Arduino.h" #include #include -#include "tools/l10n.h" -#define CHARWIDTH 6 -#define CHARHEIGHT 8 - -#define DSP_OLED -#define GXCLOCKFONT +#if DSP_MODEL==DSP_SSD1306 + #include "fonts/bootlogo21x32.h" +#endif typedef GFXcanvas1 Canvas; -#include "widgets/widgets.h" -#include "widgets/pages.h" +typedef Adafruit_SSD1306 yoDisplay; + +#include "tools/commongfx.h" #if __has_include("conf/displaySSD1306conf_custom.h") #include "conf/displaySSD1306conf_custom.h" @@ -27,13 +24,6 @@ typedef GFXcanvas1 Canvas; #endif #endif - -class DspCore: public Adafruit_SSD1306 { -#include "tools/commongfx.h" -}; - -extern DspCore dsp; - /* * OLED COLORS */ diff --git a/yoRadio/src/displays/displaySSD1322.cpp b/yoRadio/src/displays/displaySSD1322.cpp index 69bf400..f96362a 100644 --- a/yoRadio/src/displays/displaySSD1322.cpp +++ b/yoRadio/src/displays/displaySSD1322.cpp @@ -1,13 +1,7 @@ #include "../core/options.h" #if DSP_MODEL==DSP_SSD1322 - -#include "displaySSD1322.h" +#include "dspcore.h" #include "../core/config.h" -#include "../core/network.h" - -#define LOGO_WIDTH 21 -#define LOGO_HEIGHT 32 - #ifndef DEF_SPI_FREQ #define DEF_SPI_FREQ 16000000UL /* set it to 0 for system default */ @@ -15,18 +9,6 @@ #ifndef SSD1322_GRAYSCALE #define SSD1322_GRAYSCALE false #endif -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 -}; - #if DSP_HSPI DspCore::DspCore(): Jamis_SSD1322(256, 64, &SPI2, TFT_DC, TFT_RST, TFT_CS, DEF_SPI_FREQ) {} @@ -34,8 +16,6 @@ const unsigned char logo [] PROGMEM= DspCore::DspCore(): Jamis_SSD1322(256, 64, &SPI, TFT_DC, TFT_RST, TFT_CS, DEF_SPI_FREQ) {} #endif -#include "tools/utf8RusGFX.h" - void DspCore::initDisplay() { #if !SSD1322_GRAYSCALE #include "tools/oledcolorfix.h" @@ -74,174 +54,12 @@ void DspCore::initDisplay() { flip(); invert(); setTextWrap(false); - - plItemHeight = playlistConf.widget.textsize*(CHARHEIGHT-1)+playlistConf.widget.textsize*4; - plTtemsCount = round((float)height()/plItemHeight); - if(plTtemsCount%2==0) plTtemsCount++; - plCurrentPos = plTtemsCount/2; - plYStart = (height() / 2 - plItemHeight / 2) - plItemHeight * (plTtemsCount - 1) / 2 + playlistConf.widget.textsize*2; } -void DspCore::drawLogo(uint16_t top) { - drawBitmap( (width() - LOGO_WIDTH ) / 2, 8, logo, LOGO_WIDTH, LOGO_HEIGHT, 1); - display(); -} - -void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){ - setTextSize(playlistConf.widget.textsize); - if (pos == plCurrentPos) { - current.setText(item); - } else { - uint8_t plColor = (abs(pos - plCurrentPos)-1)>4?4:abs(pos - plCurrentPos)-1; - setTextColor(config.theme.playlist[plColor], config.theme.background); - setCursor(TFT_FRAMEWDT, plYStart + pos * plItemHeight); - fillRect(0, plYStart + pos * plItemHeight - 1, width(), plItemHeight - 2, config.theme.background); - print(utf8Rus(item, true)); - } -} - -void DspCore::drawPlaylist(uint16_t currentItem) { - uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount); - if(lastPosglyph + c; -} - -uint8_t DspCore::_charWidth(unsigned char c){ - GFXglyph *glyph = pgm_read_glyph_ptr(&DS_DIGI28pt7b, c - 0x20); - return pgm_read_byte(&glyph->xAdvance); -} - -uint16_t DspCore::textWidth(const char *txt){ - uint16_t w = 0, l=strlen(txt); - for(uint16_t c=0;c0 && !CLOCKFONT_MONO) dsp.fillRect(_oldtimeleft, clockTop-clockTimeHeight+1, _oldtimewidth+CHARWIDTH*2+2, clockTimeHeight, config.theme.background); - _timeleft = (width()/*/2*/ - _timewidth/*/2*/)-clockRightSpace; - setTextSize(1); - setFont(&DS_DIGI28pt7b); - - if(CLOCKFONT_MONO) { - setCursor(_timeleft, clockTop); - setTextColor(config.theme.clockbg, config.theme.background); - print("88:88"); - } - setTextColor(config.theme.clock, config.theme.background); - setCursor(_timeleft, clockTop); - print(_timeBuf); - setFont(); - strlcpy(_oldTimeBuf, _timeBuf, sizeof(_timeBuf)); - _oldtimewidth = _timewidth; - _oldtimeleft = _timeleft; -} - -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(); - } - _clockSeconds(); -} - -void DspCore::clearClock(){ - dsp.fillRect(_timeleft, clockTop-clockTimeHeight, _timewidth+2, clockTimeHeight+1, config.theme.background); -} - -void DspCore::startWrite(void) { - //TAKE_MUTEX(); - Jamis_SSD1322::startWrite(); -} - -void DspCore::endWrite(void) { - Jamis_SSD1322::endWrite(); - //GIVE_MUTEX(); -} - -void DspCore::loop(bool force) { - display(); - delay(5); -} - -void DspCore::charSize(uint8_t textsize, uint8_t& width, uint16_t& height){ - width = textsize * CHARWIDTH; - height = textsize * CHARHEIGHT; -} - -void DspCore::setTextSize(uint8_t s){ - Adafruit_GFX::setTextSize(s); -} - -void DspCore::flip(){ - setRotation(config.store.flipscreen?2:0); -} - -void DspCore::invert(){ - invertDisplay(config.store.invertdisplay); -} - -void DspCore::sleep(void) { oled_command(SSD1322_DISPLAYOFF); } -void DspCore::wake(void) { oled_command(SSD1322_DISPLAYON); } - -void DspCore::writePixel(int16_t x, int16_t y, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x > _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - Jamis_SSD1322::writePixel(x, y, color); -} - -void DspCore::writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x >= _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - Jamis_SSD1322::writeFillRect(x, y, w, h, color); -} - -void DspCore::setClipping(clipArea ca){ - _cliparea = ca; - _clipping = true; -} - -void DspCore::clearClipping(){ - _clipping = false; -} - -void DspCore::setNumFont(){ - setFont(&DS_DIGI28pt7b); - setTextSize(1); -} +void DspCore::clearDsp(bool black){ clearDisplay(); } +void DspCore::flip(){ setRotation(config.store.flipscreen?2:0); } +void DspCore::invert(){ invertDisplay(config.store.invertdisplay); } +void DspCore::sleep(void){ oled_command(SSD1322_DISPLAYOFF); } +void DspCore::wake(void){ oled_command(SSD1322_DISPLAYON); } #endif diff --git a/yoRadio/src/displays/displaySSD1322.h b/yoRadio/src/displays/displaySSD1322.h index 4b7a4ab..362a07c 100644 --- a/yoRadio/src/displays/displaySSD1322.h +++ b/yoRadio/src/displays/displaySSD1322.h @@ -1,26 +1,16 @@ #ifndef displaySSD1322_h #define displaySSD1322_h -#include "../core/options.h" #include "Arduino.h" #include #include "../SSD1322/SSD1322.h" - -#if CLOCKFONT_MONO - #include "fonts/DS_DIGI28pt7b_mono.h" // https://tchapi.github.io/Adafruit-GFX-Font-Customiser/ -#else - #include "fonts/DS_DIGI28pt7b.h" -#endif -#include "tools/l10n.h" - -#define CHARWIDTH 6 -#define CHARHEIGHT 8 - -#define DSP_OLED +#include "fonts/bootlogo21x32.h" +#include "fonts/dsfont35.h" typedef GFXcanvas1 Canvas; -#include "widgets/widgets.h" -#include "widgets/pages.h" +typedef Jamis_SSD1322 yoDisplay; + +#include "tools/commongfx.h" #if __has_include("conf/displaySSD1322conf_custom.h") #include "conf/displaySSD1322conf_custom.h" @@ -28,18 +18,10 @@ typedef GFXcanvas1 Canvas; #include "conf/displaySSD1322conf.h" #endif -class DspCore: public Jamis_SSD1322 { -#include "tools/commongfx.h" -}; - -extern DspCore dsp; - /* * OLED COLORS */ -#define BOOT_PRG_COLOR WHITE -#define BOOT_TXT_COLOR WHITE -#define PINK WHITE + #define SILVER WHITE #define TFT_BG BLACK #define TFT_FG WHITE diff --git a/yoRadio/src/displays/displaySSD1327.cpp b/yoRadio/src/displays/displaySSD1327.cpp index 95f4183..edd6bfa 100644 --- a/yoRadio/src/displays/displaySSD1327.cpp +++ b/yoRadio/src/displays/displaySSD1327.cpp @@ -1,12 +1,8 @@ #include "../core/options.h" #if DSP_MODEL==DSP_SSD1327 - -#include "displaySSD1327.h" +#include "dspcore.h" #include -#include "fonts/bootlogo40.h" -#include "../core/player.h" #include "../core/config.h" -#include "../core/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 @@ -20,8 +16,6 @@ TwoWire tw = TwoWire(0); DspCore::DspCore(): Adafruit_SSD1327(128, 128, &tw, I2C_RST/*, I2CFREQ_HZ*/) {} -#include "tools/utf8RusGFX.h" - #define CLR_ITEM1 0xA #define CLR_ITEM2 0x8 #define CLR_ITEM3 0x5 @@ -57,170 +51,12 @@ void DspCore::initDisplay() { flip(); invert(); setTextWrap(false); - - plItemHeight = playlistConf.widget.textsize*(CHARHEIGHT-1)+playlistConf.widget.textsize*4; - plTtemsCount = round((float)height()/plItemHeight); - if(plTtemsCount%2==0) plTtemsCount++; - plCurrentPos = plTtemsCount/2; - plYStart = (height() / 2 - plItemHeight / 2) - plItemHeight * (plTtemsCount - 1) / 2 + playlistConf.widget.textsize*2; } -void DspCore::drawLogo(uint16_t top) { - drawRGBBitmap((DSP_WIDTH - 62) / 2, top, bootlogo40, 62, 40); -} - -void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){ - setTextSize(playlistConf.widget.textsize); - if (pos == plCurrentPos) { - current.setText(item); - } else { - uint8_t plColor = (abs(pos - plCurrentPos)-1)>4?4:abs(pos - plCurrentPos)-1; - setTextColor(config.theme.playlist[plColor], config.theme.background); - setCursor(TFT_FRAMEWDT, plYStart + pos * plItemHeight); - fillRect(0, plYStart + pos * plItemHeight - 1, width(), plItemHeight - 2, config.theme.background); - print(utf8Rus(item, true)); - } -} - -void DspCore::drawPlaylist(uint16_t currentItem) { - uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount); - if(lastPosglyph + c; -} - -uint8_t DspCore::_charWidth(unsigned char c){ - GFXglyph *glyph = pgm_read_glyph_ptr(&DS_DIGI28pt7b, c - 0x20); - return pgm_read_byte(&glyph->xAdvance); -} - -uint16_t DspCore::textWidth(const char *txt){ - uint16_t w = 0, l=strlen(txt); - for(uint16_t c=0;c0 && !CLOCKFONT_MONO) dsp.fillRect(_oldtimeleft, clockTop-clockTimeHeight+1, _oldtimewidth, clockTimeHeight, config.theme.background); - _timeleft = (width()/2 - _timewidth/2)+clockRightSpace; - setTextSize(1); - setFont(&DS_DIGI28pt7b); - - if(CLOCKFONT_MONO) { - setCursor(_timeleft, clockTop); - setTextColor(config.theme.clockbg, config.theme.background); - print("88:88"); - } - setTextColor(config.theme.clock, config.theme.background); - setCursor(_timeleft, clockTop); - print(_timeBuf); - setFont(); - strlcpy(_oldTimeBuf, _timeBuf, sizeof(_timeBuf)); - _oldtimewidth = _timewidth; - _oldtimeleft = _timeleft; -} - -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(); - } - //_clockSeconds(); -} - -void DspCore::clearClock(){ - dsp.fillRect(_timeleft, clockTop-clockTimeHeight, _timewidth, clockTimeHeight+1, config.theme.background); -} - -void DspCore::startWrite(void) { } - -void DspCore::endWrite(void) { } - -void DspCore::loop(bool force) { - display(); - delay(5); -} - -void DspCore::charSize(uint8_t textsize, uint8_t& width, uint16_t& height){ - width = textsize * CHARWIDTH; - height = textsize * CHARHEIGHT; -} - -void DspCore::setTextSize(uint8_t s){ - Adafruit_GFX::setTextSize(s); -} - -void DspCore::flip(){ - if(ROTATE_90){ - setRotation(config.store.flipscreen?3:1); - }else{ - setRotation(config.store.flipscreen?2:0); - } -} - -void DspCore::invert(){ - invertDisplay(config.store.invertdisplay); -} - -void DspCore::sleep(void) { oled_command(SSD1327_DISPLAYOFF); } -void DspCore::wake(void) { oled_command(SSD1327_DISPLAYON); } - -void DspCore::writePixel(int16_t x, int16_t y, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x > _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - Adafruit_SSD1327::writePixel(x, y, color); -} - -void DspCore::writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x >= _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - Adafruit_SSD1327::writeFillRect(x, y, w, h, color); -} - -void DspCore::setClipping(clipArea ca){ - _cliparea = ca; - _clipping = true; -} - -void DspCore::clearClipping(){ - _clipping = false; -} - -void DspCore::setNumFont(){ - setFont(&DS_DIGI28pt7b); - setTextSize(1); -} +void DspCore::clearDsp(bool black){ fillScreen(black?0:config.theme.background); } +void DspCore::flip(){ if(ROTATE_90) setRotation(config.store.flipscreen?3:1); else setRotation(config.store.flipscreen?2:0); } +void DspCore::invert(){ invertDisplay(config.store.invertdisplay); } +void DspCore::sleep(void){ oled_command(SSD1327_DISPLAYOFF); } +void DspCore::wake(void){ oled_command(SSD1327_DISPLAYON); } #endif diff --git a/yoRadio/src/displays/displaySSD1327.h b/yoRadio/src/displays/displaySSD1327.h index 9c71e8e..4e50251 100644 --- a/yoRadio/src/displays/displaySSD1327.h +++ b/yoRadio/src/displays/displaySSD1327.h @@ -1,26 +1,16 @@ #ifndef displaySSD1327_h #define displaySSD1327_h -#include "../core/options.h" #include "Arduino.h" #include #include - -#if CLOCKFONT_MONO - #include "fonts/DS_DIGI28pt7b_mono.h" // https://tchapi.github.io/Adafruit-GFX-Font-Customiser/ -#else - #include "fonts/DS_DIGI28pt7b.h" -#endif -#include "tools/l10n.h" - -#define CHARWIDTH 6 -#define CHARHEIGHT 8 - -#define DSP_OLED +#include "fonts/bootlogo62x40.h" +#include "fonts/dsfont35.h" typedef GFXcanvas1 Canvas; -#include "widgets/widgets.h" -#include "widgets/pages.h" +typedef Adafruit_SSD1327 yoDisplay; + +#include "tools/commongfx.h" #if __has_include("conf/displaySSD1327conf_custom.h") #include "conf/displaySSD1327conf_custom.h" @@ -28,12 +18,6 @@ typedef GFXcanvas1 Canvas; #include "conf/displaySSD1327conf.h" #endif -class DspCore: public Adafruit_SSD1327 { -#include "tools/commongfx.h" -}; - -extern DspCore dsp; - /* SSD1327_GRAYTABLE, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, @@ -43,14 +27,12 @@ extern DspCore dsp; /* * TFT COLORS */ -#define BOOT_PRG_COLOR 0x07 -#define BOOT_TXT_COLOR 0x3f + #define DARK_GRAY 0x01 #define SILVER 0x07 #define TFT_BG 0x00 #define TFT_FG 0x08 #define TFT_LOGO 0x3f #define ORANGE 0x05 -#define PINK 0x02 #endif diff --git a/yoRadio/src/displays/displayST7735.cpp b/yoRadio/src/displays/displayST7735.cpp index 712aeb3..364a72b 100644 --- a/yoRadio/src/displays/displayST7735.cpp +++ b/yoRadio/src/displays/displayST7735.cpp @@ -1,13 +1,10 @@ #include "../core/options.h" #if DSP_MODEL==DSP_ST7735 - -#include "displayST7735.h" -#include "fonts/bootlogo40.h" +#include "dspcore.h" #include "../core/config.h" -#include "../core/network.h" #ifndef DEF_SPI_FREQ -#define DEF_SPI_FREQ 26000000UL /* set it to 0 for system default */ +#define DEF_SPI_FREQ 0 //26000000UL /* set it to 0 for system default */ #endif #if DSP_HSPI @@ -16,8 +13,6 @@ DspCore::DspCore(): Adafruit_ST7735(&SPI2, TFT_CS, TFT_DC, TFT_RST) {} DspCore::DspCore(): Adafruit_ST7735(&SPI, TFT_CS, TFT_DC, TFT_RST) {} #endif -#include "tools/utf8RusGFX.h" - void DspCore::initDisplay() { initR(DTYPE); if(DEF_SPI_FREQ > 0) setSPISpeed(DEF_SPI_FREQ); @@ -25,180 +20,12 @@ void DspCore::initDisplay() { invert(); flip(); setTextWrap(false); - - plItemHeight = playlistConf.widget.textsize*(CHARHEIGHT-1)+playlistConf.widget.textsize*4; - plTtemsCount = round((float)height()/plItemHeight); - if(plTtemsCount%2==0) plTtemsCount++; - plCurrentPos = plTtemsCount/2; - plYStart = (height() / 2 - plItemHeight / 2) - plItemHeight * (plTtemsCount - 1) / 2 + playlistConf.widget.textsize*2; } -void DspCore::drawLogo(uint16_t top) { -#ifdef DSP_MINI - drawRGBBitmap((DSP_WIDTH - 62) / 2, 5, bootlogo40, 62, 40); -#else - //drawRGBBitmap((DSP_WIDTH - 99) / 2, 18, bootlogo2, 99, 64); - drawRGBBitmap((DSP_WIDTH - 62) / 2, 34, bootlogo40, 62, 40); -#endif -} - -void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){ - setTextSize(playlistConf.widget.textsize); - if (pos == plCurrentPos) { - current.setText(item); - } else { - uint8_t plColor = (abs(pos - plCurrentPos)-1)>4?4:abs(pos - plCurrentPos)-1; - setTextColor(config.theme.playlist[plColor], config.theme.background); - setCursor(TFT_FRAMEWDT, plYStart + pos * plItemHeight); - fillRect(0, plYStart + pos * plItemHeight - 1, width(), plItemHeight - 2, config.theme.background); - print(utf8Rus(item, true)); - } -} - -void DspCore::drawPlaylist(uint16_t currentItem) { - uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount); - if(lastPosglyph + c; -} - -uint8_t DspCore::_charWidth(unsigned char c){ - GFXglyph *glyph = pgm_read_glyph_ptr(&DS_DIGI28pt7b, c - 0x20); - return pgm_read_byte(&glyph->xAdvance); -} - -uint16_t DspCore::textWidth(const char *txt){ - uint16_t w = 0, l=strlen(txt); - for(uint16_t c=0;c0 && !CLOCKFONT_MONO) dsp.fillRect(_oldtimeleft, clockTop-clockTimeHeight+1, _oldtimewidth, clockTimeHeight, config.theme.background); - _timeleft = (width()/2 - _timewidth/2)+clockRightSpace; - setTextSize(1); - setFont(&DS_DIGI28pt7b); - - if(CLOCKFONT_MONO) { - setCursor(_timeleft, clockTop); - setTextColor(config.theme.clockbg, config.theme.background); - print("88:88"); - } - setTextColor(config.theme.clock, config.theme.background); - setCursor(_timeleft, clockTop); - print(_timeBuf); - setFont(); - strlcpy(_oldTimeBuf, _timeBuf, sizeof(_timeBuf)); - _oldtimewidth = _timewidth; - _oldtimeleft = _timeleft; -} - -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(); - } - _clockSeconds(); -} - -void DspCore::clearClock(){ - dsp.fillRect(_timeleft, clockTop-clockTimeHeight, _timewidth, clockTimeHeight+1, config.theme.background); -} - -void DspCore::startWrite(void) { - Adafruit_ST7735::startWrite(); -} - -void DspCore::endWrite(void) { - Adafruit_ST7735::endWrite(); -} - -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::setTextSize(uint8_t s){ - Adafruit_GFX::setTextSize(s); -} - -void DspCore::flip(){ - if(ROTATE_90){ - setRotation(config.store.flipscreen?2:0); - }else{ - setRotation(config.store.flipscreen?3:1); - } -} - -void DspCore::invert(){ - invertDisplay((DTYPE==INITR_MINI160x80)?!config.store.invertdisplay:config.store.invertdisplay); -} - -void DspCore::sleep(void) { - enableSleep(true); delay(150); enableDisplay(false); delay(150); -} -void DspCore::wake(void) { - enableDisplay(true); delay(150); enableSleep(false); delay(150); -} - -void DspCore::writePixel(int16_t x, int16_t y, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x > _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - Adafruit_ST7735::writePixel(x, y, color); -} - -void DspCore::writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x >= _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - Adafruit_ST7735::writeFillRect(x, y, w, h, color); -} - -void DspCore::setClipping(clipArea ca){ - _cliparea = ca; - _clipping = true; -} - -void DspCore::clearClipping(){ - _clipping = false; -} - -void DspCore::setNumFont(){ - setFont(&DS_DIGI28pt7b); - setTextSize(1); -} +void DspCore::clearDsp(bool black){ fillScreen(black?0:config.theme.background); } +void DspCore::flip(){ if(ROTATE_90) setRotation(config.store.flipscreen?2:0); else setRotation(config.store.flipscreen?3:1); } +void DspCore::invert(){ invertDisplay((DTYPE==INITR_MINI160x80)?!config.store.invertdisplay:config.store.invertdisplay); } +void DspCore::sleep(void){ enableSleep(true); delay(150); enableDisplay(false); delay(150); } +void DspCore::wake(void){ enableDisplay(true); delay(150); enableSleep(false); delay(150); } #endif diff --git a/yoRadio/src/displays/displayST7735.h b/yoRadio/src/displays/displayST7735.h index 4e387c4..43bc930 100644 --- a/yoRadio/src/displays/displayST7735.h +++ b/yoRadio/src/displays/displayST7735.h @@ -1,25 +1,16 @@ #ifndef displayST7735_h #define displayST7735_h -#include "../core/options.h" #include "Arduino.h" #include #include - -#if CLOCKFONT_MONO - #include "fonts/DS_DIGI28pt7b_mono.h" // https://tchapi.github.io/Adafruit-GFX-Font-Customiser/ -#else - #include "fonts/DS_DIGI28pt7b.h" -#endif -#include "tools/l10n.h" - -#define CHARWIDTH 6 -#define CHARHEIGHT 8 +#include "fonts/bootlogo62x40.h" +#include "fonts/dsfont35.h" typedef GFXcanvas16 Canvas; -#include "widgets/widgets.h" -#include "widgets/pages.h" +typedef Adafruit_ST7735 yoDisplay; +#include "tools/commongfx.h" #if __has_include("conf/displayST7735conf_custom.h") #include "conf/displayST7735conf_custom.h" @@ -33,14 +24,6 @@ typedef GFXcanvas16 Canvas; #endif #endif -#define BOOT_PRG_COLOR 0xE68B -#define BOOT_TXT_COLOR 0xFFFF -#define PINK 0xF97F -class DspCore: public Adafruit_ST7735 { -#include "tools/commongfx.h" -}; - -extern DspCore dsp; #endif diff --git a/yoRadio/src/displays/displayST7789.cpp b/yoRadio/src/displays/displayST7789.cpp index 37f94fd..e2987c0 100644 --- a/yoRadio/src/displays/displayST7789.cpp +++ b/yoRadio/src/displays/displayST7789.cpp @@ -1,16 +1,7 @@ #include "../core/options.h" #if DSP_MODEL==DSP_ST7789 || DSP_MODEL==DSP_ST7789_240 || DSP_MODEL==DSP_ST7789_76 - -#include "displayST7789.h" -//#include -#if DSP_MODEL==DSP_ST7789_76 -#include "fonts/bootlogo40.h" -#else -#include "fonts/bootlogo.h" -#endif - +#include "dspcore.h" #include "../core/config.h" -#include "../core/network.h" #ifndef DEF_SPI_FREQ #define DEF_SPI_FREQ 40000000UL /* set it to 0 for system default */ @@ -22,8 +13,6 @@ DspCore::DspCore(): Adafruit_ST7789(&SPI2, TFT_CS, TFT_DC, TFT_RST) {} DspCore::DspCore(): Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST) {} #endif -#include "tools/utf8RusGFX.h" - void DspCore::initDisplay() { if(DSP_MODEL==DSP_ST7789_76){ init(76,284); @@ -37,211 +26,9 @@ void DspCore::initDisplay() { setTextWrap(false); setTextSize(1); fillScreen(0x0000); - - plItemHeight = playlistConf.widget.textsize*(CHARHEIGHT-1)+playlistConf.widget.textsize*4; - plTtemsCount = round((float)height()/plItemHeight); - if(plTtemsCount%2==0) plTtemsCount++; - plCurrentPos = plTtemsCount/2; - plYStart = (height() / 2 - plItemHeight / 2) - plItemHeight * (plTtemsCount - 1) / 2 + playlistConf.widget.textsize*2; - -} -#if DSP_MODEL==DSP_ST7789_76 -void DspCore::drawLogo(uint16_t top) { - //drawBitmap( (width() - LOGO_WIDTH ) / 2, 8, logo, LOGO_WIDTH, LOGO_HEIGHT, 1); - drawRGBBitmap((width() - 62) / 2, 8, bootlogo40, 62, 40); -} -#else -void DspCore::drawLogo(uint16_t top) { drawRGBBitmap((width() - 99) / 2, top, bootlogo2, 99, 64); } -#endif - -void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){ - setTextSize(playlistConf.widget.textsize); - if (pos == plCurrentPos) { - current.setText(item); - } else { - uint8_t plColor = (abs(pos - plCurrentPos)-1)>4?4:abs(pos - plCurrentPos)-1; - setTextColor(config.theme.playlist[plColor], config.theme.background); - setCursor(TFT_FRAMEWDT, plYStart + pos * plItemHeight); - fillRect(0, plYStart + pos * plItemHeight - 1, width(), plItemHeight - 2, config.theme.background); - print(utf8Rus(item, true)); - } -} - -void DspCore::drawPlaylist(uint16_t currentItem) { - uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount); - if(lastPosglyph + c; -} - -uint8_t DspCore::_charWidth(unsigned char c){ -#if DSP_MODEL==DSP_ST7789_76 - GFXglyph *glyph = pgm_read_glyph_ptr(&DS_DIGI28pt7b, c - 0x20); -#else - GFXglyph *glyph = pgm_read_glyph_ptr(&DS_DIGI42pt7b, c - 0x20); -#endif - return pgm_read_byte(&glyph->xAdvance); -} - -uint16_t DspCore::textWidth(const char *txt){ - uint16_t w = 0, l=strlen(txt); - for(uint16_t c=0;c0 && !CLOCKFONT_MONO) dsp.fillRect(_oldtimeleft, clockTop-clockTimeHeight+1, _oldtimewidth+CHARWIDTH*2+2, clockTimeHeight, config.theme.background); - _timeleft = (width()/*/2*/ - _timewidth/*/2*/)-clockRightSpace; - setTextSize(1); - setFont(&DS_DIGI28pt7b); - - if(CLOCKFONT_MONO) { - setCursor(_timeleft, clockTop); - setTextColor(config.theme.clockbg, config.theme.background); - print("88:88"); - } - setTextColor(config.theme.clock, config.theme.background); - setCursor(_timeleft, clockTop); - print(_timeBuf); - setFont(); - strlcpy(_oldTimeBuf, _timeBuf, sizeof(_timeBuf)); - _oldtimewidth = _timewidth; - _oldtimeleft = _timeleft; -} - -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(); - } - _clockSeconds(); -} - -void DspCore::clearClock(){ - dsp.fillRect(_timeleft, clockTop-clockTimeHeight, _timewidth+2, clockTimeHeight+1, config.theme.background); -} -#else -void DspCore::_clockSeconds(){ - setTextSize(3); - setTextColor(config.theme.seconds, config.theme.background); - setCursor(width() - 8 - clockRightSpace - CHARWIDTH*3*2, clockTop-clockTimeHeight+1); - sprintf(_bufforseconds, "%02d", network.timeinfo.tm_sec); - if(!config.isScreensaver) print(_bufforseconds); /* print seconds */ - setNumFont(); - setTextColor((network.timeinfo.tm_sec % 2 == 0) ? config.theme.clock : (CLOCKFONT_MONO?config.theme.clockbg:config.theme.background), config.theme.background); - setCursor(_timeleft+_dotsLeft, clockTop); - print(":"); /* print dots */ - setFont(); -} - -void DspCore::_clockDate(){ - if(_olddateleft>0) - dsp.fillRect(_olddateleft, clockTop+10, _olddatewidth, CHARHEIGHT, config.theme.background); - setTextColor(config.theme.date, config.theme.background); - setCursor(_dateleft, clockTop+10); - if(!config.isScreensaver) print(_dateBuf); /* print date */ - strlcpy(_oldDateBuf, _dateBuf, sizeof(_dateBuf)); - _olddatewidth = _datewidth; - _olddateleft = _dateleft; - setTextSize(3); - setTextColor(config.theme.dow, config.theme.background); - setCursor(width() - 8 - clockRightSpace - CHARWIDTH*3*2, clockTop-CHARHEIGHT*3+4); - print(utf8Rus(dow[network.timeinfo.tm_wday], false)); /* print dow */ -} - -void DspCore::_clockTime(){ - if(_oldtimeleft>0 && !CLOCKFONT_MONO) dsp.fillRect(_oldtimeleft, clockTop-clockTimeHeight+1, _oldtimewidth, clockTimeHeight, config.theme.background); - _timeleft = width()-clockRightSpace-CHARWIDTH*3*2-24-_timewidth; - setNumFont(); - - if(CLOCKFONT_MONO) { - setCursor(_timeleft, clockTop); - setTextColor(config.theme.clockbg, config.theme.background); - print("88:88"); - } - setCursor(_timeleft, clockTop); - setTextColor(config.theme.clock, config.theme.background); - print(_timeBuf); - setFont(); - strlcpy(_oldTimeBuf, _timeBuf, sizeof(_timeBuf)); - _oldtimewidth = _timewidth; - _oldtimeleft = _timeleft; - if(!config.isScreensaver) drawFastVLine(width()-clockRightSpace-CHARWIDTH*3*2-18, clockTop-clockTimeHeight, clockTimeHeight+3, config.theme.div); /*divider vert*/ - if(!config.isScreensaver) drawFastHLine(width()-clockRightSpace-CHARWIDTH*3*2-18, clockTop-clockTimeHeight+29, 44, 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::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(!config.isScreensaver) - if(strcmp(_oldDateBuf, _dateBuf)!=0 || redraw) _clockDate(); - } - _clockSeconds(); -} - -void DspCore::clearClock(){ - dsp.fillRect(_timeleft, clockTop-clockTimeHeight, _timewidth+CHARWIDTH*3*2+24, clockTimeHeight+10+CHARHEIGHT, config.theme.background); -} -#endif - -void DspCore::startWrite(void) { - Adafruit_ST7789::startWrite(); -} - -void DspCore::endWrite(void) { - Adafruit_ST7789::endWrite(); -} - -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::setTextSize(uint8_t s){ - Adafruit_GFX::setTextSize(s); } +void DspCore::clearDsp(bool black){ fillScreen(black?0:config.theme.background); } void DspCore::flip(){ #if DSP_MODEL==DSP_ST7789 || DSP_MODEL==DSP_ST7789_76 setRotation(config.store.flipscreen?3:1); @@ -254,48 +41,8 @@ void DspCore::flip(){ } #endif } +void DspCore::invert(){ invertDisplay(config.store.invertdisplay); } +void DspCore::sleep(void){ enableSleep(true); delay(150); enableDisplay(false); delay(150); } +void DspCore::wake(void){ enableDisplay(true); delay(150); enableSleep(false); delay(150); } -void DspCore::invert(){ - invertDisplay(config.store.invertdisplay); -} - -void DspCore::sleep(void) { - enableSleep(true); delay(150); enableDisplay(false); delay(150); -} -void DspCore::wake(void) { - enableDisplay(true); delay(150); enableSleep(false); delay(150); -} - - -void DspCore::writePixel(int16_t x, int16_t y, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x > _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - Adafruit_ST7789::writePixel(x, y, color); -} - -void DspCore::writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x >= _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - Adafruit_ST7789::writeFillRect(x, y, w, h, color); -} - -void DspCore::setClipping(clipArea ca){ - _cliparea = ca; - _clipping = true; -} - -void DspCore::clearClipping(){ - _clipping = false; -} - -void DspCore::setNumFont(){ -#if DSP_MODEL==DSP_ST7789_76 - setFont(&DS_DIGI28pt7b); -#else - setFont(&DS_DIGI42pt7b); -#endif - setTextSize(1); -} #endif diff --git a/yoRadio/src/displays/displayST7789.h b/yoRadio/src/displays/displayST7789.h index 891ebe3..99348bb 100644 --- a/yoRadio/src/displays/displayST7789.h +++ b/yoRadio/src/displays/displayST7789.h @@ -1,32 +1,22 @@ #ifndef displayST7789_h #define displayST7789_h -#include "../core/options.h" #include "Arduino.h" #include #include #if DSP_MODEL==DSP_ST7789_76 - #if CLOCKFONT_MONO - #include "fonts/DS_DIGI28pt7b_mono.h" // https://tchapi.github.io/Adafruit-GFX-Font-Customiser/ - #else - #include "fonts/DS_DIGI28pt7b.h" - #endif + #include "fonts/bootlogo62x40.h" + #include "fonts/dsfont35.h" #else - #if CLOCKFONT_MONO - #include "fonts/DS_DIGI42pt7b_mono.h" // https://tchapi.github.io/Adafruit-GFX-Font-Customiser/ - #else - #include "fonts/DS_DIGI42pt7b.h" - #endif + #include "fonts/bootlogo99x64.h" + #include "fonts/dsfont52.h" #endif -#include "tools/l10n.h" - -#define CHARWIDTH 6 -#define CHARHEIGHT 8 typedef GFXcanvas16 Canvas; -#include "widgets/widgets.h" -#include "widgets/pages.h" +typedef Adafruit_ST7789 yoDisplay; + +#include "tools/commongfx.h" #if __has_include("conf/displayST7789conf_custom.h") #include "conf/displayST7789conf_custom.h" @@ -40,14 +30,4 @@ typedef GFXcanvas16 Canvas; #endif #endif -#define BOOT_PRG_COLOR 0xE68B -#define BOOT_TXT_COLOR 0xFFFF -#define PINK 0xF97F - -class DspCore: public Adafruit_ST7789 { -#include "tools/commongfx.h" -}; - -extern DspCore dsp; - #endif diff --git a/yoRadio/src/displays/displayST7796.cpp b/yoRadio/src/displays/displayST7796.cpp index 352806b..1903e20 100644 --- a/yoRadio/src/displays/displayST7796.cpp +++ b/yoRadio/src/displays/displayST7796.cpp @@ -1,11 +1,7 @@ #include "../core/options.h" #if DSP_MODEL==DSP_ST7796 - -#include "displayST7796.h" -//#include -#include "fonts/bootlogo.h" +#include "dspcore.h" #include "../core/config.h" -#include "../core/network.h" #ifndef DEF_SPI_FREQ #define DEF_SPI_FREQ 40000000UL /* set it to 0 for system default */ @@ -17,8 +13,6 @@ DspCore::DspCore(): Adafruit_ST7796S_kbv(&SPI2, TFT_DC, TFT_CS, TFT_RST) {} DspCore::DspCore(): Adafruit_ST7796S_kbv(TFT_CS, TFT_DC, TFT_RST) {} #endif -#include "tools/utf8RusGFX.h" - void DspCore::initDisplay() { begin(); if(DEF_SPI_FREQ > 0) setSPISpeed(DEF_SPI_FREQ); @@ -28,196 +22,12 @@ void DspCore::initDisplay() { setTextWrap(false); setTextSize(1); fillScreen(0x0000); - - plItemHeight = playlistConf.widget.textsize*(CHARHEIGHT-1)+playlistConf.widget.textsize*4; - plTtemsCount = round((float)height()/plItemHeight); - if(plTtemsCount%2==0) plTtemsCount++; - plCurrentPos = plTtemsCount/2; - plYStart = (height() / 2 - plItemHeight / 2) - plItemHeight * (plTtemsCount - 1) / 2 + playlistConf.widget.textsize*2; } -void DspCore::drawLogo(uint16_t top) { drawRGBBitmap((width() - 99) / 2, top, bootlogo2, 99, 64); } +void DspCore::clearDsp(bool black){ fillScreen(black?0:config.theme.background); } +void DspCore::flip(){ setRotation(config.store.flipscreen?3:1); } +void DspCore::invert(){ invertDisplay(config.store.invertdisplay); } +void DspCore::sleep(void){ sendCommand(ST7796S_SLPIN); delay(150); sendCommand(ST7796S_DISPOFF); delay(150); } +void DspCore::wake(void){ sendCommand(ST7796S_DISPON); delay(150); sendCommand(ST7796S_SLPOUT); delay(150); } -void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){ - setTextSize(playlistConf.widget.textsize); - if (pos == plCurrentPos) { - current.setText(item); - } else { - uint8_t plColor = (abs(pos - plCurrentPos)-1)>4?4:abs(pos - plCurrentPos)-1; - setTextColor(config.theme.playlist[plColor], config.theme.background); - setCursor(TFT_FRAMEWDT, plYStart + pos * plItemHeight); - fillRect(0, plYStart + pos * plItemHeight - 1, width(), plItemHeight - 2, config.theme.background); - print(utf8Rus(item, true)); - } -} - -void DspCore::drawPlaylist(uint16_t currentItem) { - uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount); - if(lastPosglyph + c; -} - -uint8_t DspCore::_charWidth(unsigned char c){ - GFXglyph *glyph = pgm_read_glyph_ptr(&DS_DIGI56pt7b, c - 0x20); - return pgm_read_byte(&glyph->xAdvance); -} - -uint16_t DspCore::textWidth(const char *txt){ - uint16_t w = 0, l=strlen(txt); - for(uint16_t c=0;c0) - dsp.fillRect(_olddateleft, clockTop+14, _olddatewidth, CHARHEIGHT*2, config.theme.background); - setTextColor(config.theme.date, config.theme.background); - setCursor(_dateleft, clockTop+15); - setTextSize(2); - if(!config.isScreensaver) print(_dateBuf); /* print date */ - strlcpy(_oldDateBuf, _dateBuf, sizeof(_dateBuf)); - _olddatewidth = _datewidth; - _olddateleft = _dateleft; - setTextSize(4); - setTextColor(config.theme.dow, config.theme.background); - setCursor(width() - 8 - clockRightSpace - CHARWIDTH*4*2, clockTop-CHARHEIGHT*4+4); - print(utf8Rus(dow[network.timeinfo.tm_wday], false)); /* print dow */ -} - -void DspCore::_clockTime(){ - if(_oldtimeleft>0 && !CLOCKFONT_MONO) dsp.fillRect(_oldtimeleft, clockTop-clockTimeHeight+1, _oldtimewidth, clockTimeHeight, config.theme.background); - _timeleft = width()-clockRightSpace-CHARWIDTH*4*2-24-_timewidth; - setTextSize(1); - setFont(&DS_DIGI56pt7b); - - if(CLOCKFONT_MONO) { - setCursor(_timeleft, clockTop); - setTextColor(config.theme.clockbg, config.theme.background); - print("88:88"); - } - setTextColor(config.theme.clock, config.theme.background); - setCursor(_timeleft, clockTop); - print(_timeBuf); - setFont(); - strlcpy(_oldTimeBuf, _timeBuf, sizeof(_timeBuf)); - _oldtimewidth = _timewidth; - _oldtimeleft = _timeleft; - if(!config.isScreensaver) drawFastVLine(width()-clockRightSpace-CHARWIDTH*4*2-18, clockTop-clockTimeHeight, clockTimeHeight+4, config.theme.div); /*divider vert*/ - if(!config.isScreensaver) drawFastHLine(width()-clockRightSpace-CHARWIDTH*4*2-18, clockTop-clockTimeHeight+37, 59, 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*2; - _dateleft = width() - 10 - clockRightSpace - _datewidth; -} - -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(!config.isScreensaver) - if(strcmp(_oldDateBuf, _dateBuf)!=0 || redraw) _clockDate(); - } - _clockSeconds(); -} - -void DspCore::clearClock(){ - dsp.fillRect(_timeleft, clockTop-clockTimeHeight, _timewidth+CHARWIDTH*3*2+24, clockTimeHeight+12+CHARHEIGHT, config.theme.background); -} - -void DspCore::startWrite(void) { - Adafruit_ST7796S_kbv::startWrite(); -} - -void DspCore::endWrite(void) { - Adafruit_ST7796S_kbv::endWrite(); -} - -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::setTextSize(uint8_t s){ - Adafruit_GFX::setTextSize(s); -} - -void DspCore::flip(){ - setRotation(config.store.flipscreen?3:1); -} - -void DspCore::invert(){ - invertDisplay(config.store.invertdisplay); -} - -void DspCore::sleep(void) { - sendCommand(ST7796S_SLPIN); delay(150); sendCommand(ST7796S_DISPOFF); delay(150); -} - -void DspCore::wake(void) { - sendCommand(ST7796S_DISPON); delay(150); sendCommand(ST7796S_SLPOUT); delay(150); -} - -void DspCore::writePixel(int16_t x, int16_t y, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x > _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - Adafruit_ST7796S_kbv::writePixel(x, y, color); -} - -void DspCore::writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x >= _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - Adafruit_ST7796S_kbv::writeFillRect(x, y, w, h, color); -} - -void DspCore::setClipping(clipArea ca){ - _cliparea = ca; - _clipping = true; -} - -void DspCore::clearClipping(){ - _clipping = false; -} - -void DspCore::setNumFont(){ - setFont(&DS_DIGI56pt7b); - setTextSize(1); -} #endif diff --git a/yoRadio/src/displays/displayST7796.h b/yoRadio/src/displays/displayST7796.h index b82d2d8..f2b594f 100644 --- a/yoRadio/src/displays/displayST7796.h +++ b/yoRadio/src/displays/displayST7796.h @@ -1,24 +1,16 @@ #ifndef displayST7796_h #define displayST7796_h -#include "../core/options.h" #include "Arduino.h" #include #include "../Adafruit_ST7796S/Adafruit_ST7796S_kbv.h" - -#if CLOCKFONT_MONO - #include "fonts/DS_DIGI56pt7b_mono.h" // https://tchapi.github.io/Adafruit-GFX-Font-Customiser/ -#else - #include "fonts/DS_DIGI56pt7b.h" -#endif -#include "tools/l10n.h" - -#define CHARWIDTH 6 -#define CHARHEIGHT 8 +#include "fonts/bootlogo99x64.h" +#include "fonts/dsfont70.h" typedef GFXcanvas16 Canvas; -#include "widgets/widgets.h" -#include "widgets/pages.h" +typedef Adafruit_ST7796S_kbv yoDisplay; + +#include "tools/commongfx.h" #if __has_include("conf/displayST7796conf_custom.h") #include "conf/displayST7796conf_custom.h" @@ -26,14 +18,4 @@ typedef GFXcanvas16 Canvas; #include "conf/displayST7796conf.h" #endif -#define BOOT_PRG_COLOR 0xE68B -#define BOOT_TXT_COLOR 0xFFFF -#define PINK 0xF97F - -class DspCore: public Adafruit_ST7796S_kbv { -#include "tools/commongfx.h" -}; - -extern DspCore dsp; - #endif diff --git a/yoRadio/src/displays/displayST7920.cpp b/yoRadio/src/displays/displayST7920.cpp index a52cbbc..68a2965 100644 --- a/yoRadio/src/displays/displayST7920.cpp +++ b/yoRadio/src/displays/displayST7920.cpp @@ -1,39 +1,18 @@ #include "../core/options.h" #if DSP_MODEL==DSP_ST7920 - -#include "displayST7920.h" -#include "../core/player.h" +#include "dspcore.h" #include "../core/config.h" -#include "../core/network.h" - -#define LOGO_WIDTH 21 -#define LOGO_HEIGHT 32 #ifndef DEF_SPI_FREQ #define DEF_SPI_FREQ 8000000UL #endif -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 -}; - #if DSP_HSPI DspCore::DspCore(): ST7920(&SPI2, TFT_CS, DEF_SPI_FREQ) {} #else DspCore::DspCore(): ST7920(&SPI, TFT_CS, DEF_SPI_FREQ) {} #endif - -#include "tools/utf8RusGFX.h" - void DspCore::initDisplay() { #include "tools/oledcolorfix.h" begin(); @@ -41,159 +20,12 @@ void DspCore::initDisplay() { flip(); invert(); setTextWrap(false); - - plItemHeight = playlistConf.widget.textsize*(CHARHEIGHT-1)+playlistConf.widget.textsize*4; - plTtemsCount = round((float)height()/plItemHeight); - if(plTtemsCount%2==0) plTtemsCount++; - plCurrentPos = plTtemsCount/2; - plYStart = (height() / 2 - plItemHeight / 2) - plItemHeight * (plTtemsCount - 1) / 2 + playlistConf.widget.textsize*2; } -void DspCore::drawLogo(uint16_t top) { - drawBitmap( (width() - LOGO_WIDTH ) / 2, 8, logo, LOGO_WIDTH, LOGO_HEIGHT, 1); - display(); -} - -void DspCore::printPLitem(uint8_t pos, const char* item, ScrollWidget& current){ - setTextSize(playlistConf.widget.textsize); - if (pos == plCurrentPos) { - current.setText(item); - } else { - uint8_t plColor = (abs(pos - plCurrentPos)-1)>4?4:abs(pos - plCurrentPos)-1; - setTextColor(config.theme.playlist[plColor], config.theme.background); - setCursor(TFT_FRAMEWDT, plYStart + pos * plItemHeight); - fillRect(0, plYStart + pos * plItemHeight - 1, width(), plItemHeight - 2, config.theme.background); - print(utf8Rus(item, true)); - } -} - -void DspCore::drawPlaylist(uint16_t currentItem) { - uint8_t lastPos = config.fillPlMenu(currentItem - plCurrentPos, plTtemsCount); - if(lastPos0) dsp.fillRect(_oldtimeleft, clockTop, _oldtimewidth, clockTimeHeight*CHARHEIGHT, config.theme.background); - _timeleft = (width()/2 - _timewidth/2)+clockRightSpace; - setTextColor(config.theme.clock, config.theme.background); - setTextSize(clockTimeHeight); - - setCursor(_timeleft, clockTop); - print(_timeBuf); - //setFont(); - strlcpy(_oldTimeBuf, _timeBuf, sizeof(_timeBuf)); - _oldtimewidth = _timewidth; - _oldtimeleft = _timeleft; -} - -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(); - } - _clockSeconds(); -} - -void DspCore::clearClock(){ - dsp.fillRect(_timeleft, clockTop, _timewidth+14, clockTimeHeight*CHARHEIGHT, config.theme.background); -} - -void DspCore::startWrite(void) { } - -void DspCore::endWrite(void) { } - -void DspCore::loop(bool force) { - display(); - delay(20); -} - -void DspCore::charSize(uint8_t textsize, uint8_t& width, uint16_t& height){ - width = textsize * CHARWIDTH; - height = textsize * CHARHEIGHT; -} - -void DspCore::setTextSize(uint8_t s){ - Adafruit_GFX::setTextSize(s); -} - -void DspCore::flip(){ - setRotation(config.store.flipscreen?2:0); -} - -void DspCore::invert(){ - invertDisplay(config.store.invertdisplay); -} - -void DspCore::sleep(void) { doSleep(true); } -void DspCore::wake(void) { doSleep(false); } - -void DspCore::writePixel(int16_t x, int16_t y, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x > _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - ST7920::writePixel(x, y, color); -} - -void DspCore::writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) { - if(_clipping){ - if ((x < _cliparea.left) || (x >= _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; - } - ST7920::writeFillRect(x, y, w, h, color); -} - -void DspCore::setClipping(clipArea ca){ - _cliparea = ca; - _clipping = true; -} - -void DspCore::clearClipping(){ - _clipping = false; -} - -void DspCore::setNumFont(){ - setTextSize(2); -} +void DspCore::clearDsp(bool black){ fillScreen(TFT_BG); } +void DspCore::flip(){ setRotation(config.store.flipscreen?2:0); } +void DspCore::invert(){ invertDisplay(config.store.invertdisplay); } +void DspCore::sleep(void){ doSleep(true); } +void DspCore::wake(void){ doSleep(false); } #endif diff --git a/yoRadio/src/displays/displayST7920.h b/yoRadio/src/displays/displayST7920.h index 2aa4163..e364905 100644 --- a/yoRadio/src/displays/displayST7920.h +++ b/yoRadio/src/displays/displayST7920.h @@ -1,21 +1,15 @@ #ifndef displayST7920_h #define displayST7920_h -#include "../core/options.h" #include "Arduino.h" #include #include "../ST7920/ST7920.h" -#include "tools/l10n.h" - -#define CHARWIDTH 6 -#define CHARHEIGHT 8 - -#define DSP_OLED -#define GXCLOCKFONT +#include "fonts/bootlogo21x32.h" typedef GFXcanvas1 Canvas; -#include "widgets/widgets.h" -#include "widgets/pages.h" +typedef ST7920 yoDisplay; + +#include "tools/commongfx.h" #if __has_include("conf/displayST7920conf_custom.h") #include "conf/displayST7920conf_custom.h" @@ -23,12 +17,6 @@ typedef GFXcanvas1 Canvas; #include "conf/displayST7920conf.h" #endif -class DspCore: public ST7920 { -#include "tools/commongfx.h" -}; - -extern DspCore dsp; - /* * OLED COLORS */ diff --git a/yoRadio/src/displays/dspcore.h b/yoRadio/src/displays/dspcore.h index bff288f..7504dff 100644 --- a/yoRadio/src/displays/dspcore.h +++ b/yoRadio/src/displays/dspcore.h @@ -1,49 +1,106 @@ #ifndef dspcore_h #define dspcore_h -#include "../core/options.h" +#pragma once #if DSP_MODEL==DSP_DUMMY #define DUMMYDISPLAY #define DSP_NOT_FLIPPED - #include "tools/l10n.h" -#elif DSP_MODEL==DSP_ST7735 + +#elif DSP_MODEL==DSP_ST7735 // https://k210.org/images/content/uploads/yoradio/ST7735.jpg + #define TIME_SIZE 35 + #define PSFBUFFER #include "displayST7735.h" -#elif DSP_MODEL==DSP_SSD1306 || DSP_MODEL==DSP_SSD1306x32 + +#elif DSP_MODEL==DSP_SSD1306 // https://k210.org/images/content/uploads/yoradio/SSD1306.jpg + #define TIME_SIZE 2 + #define DSP_OLED #include "displaySSD1306.h" -#elif DSP_MODEL==DSP_NOKIA5110 + +#elif DSP_MODEL==DSP_SSD1306x32 // https://k210.org/images/content/uploads/yoradio/SSD1306x32.jpg + #define TIME_SIZE 1 + #define DSP_OLED + #include "displaySSD1306.h" + +#elif DSP_MODEL==DSP_NOKIA5110 // https://k210.org/images/content/uploads/yoradio/NOKIA5110.jpg + #define TIME_SIZE 19 + #define DSP_OLED #include "displayN5110.h" -#elif DSP_MODEL==DSP_ST7789 || DSP_MODEL==DSP_ST7789_240 || DSP_MODEL==DSP_ST7789_76 + +#elif DSP_MODEL==DSP_ST7789 || DSP_MODEL==DSP_ST7789_240 // https://k210.org/images/content/uploads/yoradio/ST7789.jpg + #define TIME_SIZE 52 + #define PSFBUFFER #include "displayST7789.h" -#elif DSP_MODEL==DSP_SH1106 + +#elif DSP_MODEL==DSP_ST7789_76 // https://k210.org/images/content/uploads/yoradio/ST7789_76.mp4 + #define TIME_SIZE 35 + #define PSFBUFFER + #include "displayST7789.h" + +#elif DSP_MODEL==DSP_SH1106 || DSP_MODEL==DSP_SH1107 // https://k210.org/images/content/uploads/yoradio/SH1106.jpg + #define TIME_SIZE 2 + #define DSP_OLED #include "displaySH1106.h" -#elif DSP_MODEL==DSP_1602I2C || DSP_MODEL==DSP_2004I2C + +#elif DSP_MODEL==DSP_1602I2C || DSP_MODEL==DSP_2004I2C || DSP_MODEL==DSP_1602 || DSP_MODEL==DSP_2004 +// https://k210.org/images/content/uploads/yoradio/DSP_1602.jpg +// https://k210.org/images/content/uploads/yoradio/DSP_2004.jpg + #define TIME_SIZE 1 + #define DSP_LCD #include "displayLC1602.h" -#elif DSP_MODEL==DSP_SSD1327 + +#elif DSP_MODEL==DSP_SSD1327 // https://k210.org/images/content/uploads/yoradio/SSD1327.jpg + #define TIME_SIZE 35 + #define DSP_OLED #include "displaySSD1327.h" -#elif DSP_MODEL==DSP_ILI9341 + +#elif DSP_MODEL==DSP_ILI9341 // https://k210.org/images/content/uploads/yoradio/ILI9341.jpg + #define TIME_SIZE 52 + #define PSFBUFFER #include "displayILI9341.h" -#elif DSP_MODEL==DSP_SSD1305 || DSP_MODEL==DSP_SSD1305I2C + +#elif DSP_MODEL==DSP_SSD1305 || DSP_MODEL==DSP_SSD1305I2C // https://k210.org/images/content/uploads/yoradio/SSD1305.jpg + #define TIME_SIZE 2 + #define DSP_OLED #include "displaySSD1305.h" -#elif DSP_MODEL==DSP_SH1107 - #include "displaySH1106.h" -#elif DSP_MODEL==DSP_1602 || DSP_MODEL==DSP_2004 - #include "displayLC1602.h" -#elif DSP_MODEL==DSP_GC9106 + +#elif DSP_MODEL==DSP_GC9106 // https://k210.org/images/content/uploads/yoradio/GC9106.jpg + #define TIME_SIZE 35 + #define PSFBUFFER #include "displayGC9106.h" + #elif DSP_MODEL==DSP_CUSTOM + #define TIME_SIZE 0 #include "displayCustom.h" -#elif DSP_MODEL==DSP_ILI9225 + +#elif DSP_MODEL==DSP_ILI9225 // https://k210.org/images/content/uploads/yoradio/ILI9225.jpg + #define TIME_SIZE 35 #include "displayILI9225.h" -#elif DSP_MODEL==DSP_ST7796 + +#elif DSP_MODEL==DSP_ST7796 // https://k210.org/images/content/uploads/yoradio/ST7796.jpg + #define TIME_SIZE 70 + #define PSFBUFFER #include "displayST7796.h" -#elif DSP_MODEL==DSP_GC9A01A + +#elif DSP_MODEL==DSP_GC9A01A // https://k210.org/images/content/uploads/yoradio/GC9A01A.jpg + #define TIME_SIZE 52 + #define PSFBUFFER #include "displayGC9A01A.h" -#elif DSP_MODEL==DSP_ILI9488 || DSP_MODEL==DSP_ILI9486 + +#elif DSP_MODEL==DSP_ILI9488 || DSP_MODEL==DSP_ILI9486 // https://k210.org/images/content/uploads/yoradio/ILI9488.jpg + #define TIME_SIZE 70 + #define PSFBUFFER #include "displayILI9488.h" -#elif DSP_MODEL==DSP_SSD1322 + +#elif DSP_MODEL==DSP_SSD1322 // https://k210.org/images/content/uploads/yoradio/ssd1322.mp4 + #define TIME_SIZE 35 + #define DSP_OLED #include "displaySSD1322.h" -#elif DSP_MODEL==DSP_ST7920 + +#elif DSP_MODEL==DSP_ST7920 // https://k210.org/images/content/uploads/yoradio/ST7920.jpg + #define TIME_SIZE 2 + #define DSP_OLED #include "displayST7920.h" + #endif //extern DspCore dsp; diff --git a/yoRadio/src/displays/fonts/DS_DIGI15pt7b.h b/yoRadio/src/displays/fonts/DS_DIGI15pt7b.h index bc3f4b2..90d150e 100644 --- a/yoRadio/src/displays/fonts/DS_DIGI15pt7b.h +++ b/yoRadio/src/displays/fonts/DS_DIGI15pt7b.h @@ -53,7 +53,7 @@ const GFXglyph DS_DIGI15pt7bGlyphs[] PROGMEM = { { 257, 3, 15, 6, 2, -14 } // 0x3A ':' }; -const GFXfont DS_DIGI15pt7b PROGMEM = { +const GFXfont Clock_GFXfont PROGMEM = { (uint8_t *)DS_DIGI15pt7bBitmaps, (GFXglyph *)DS_DIGI15pt7bGlyphs, 0x20, 0x3A, 29 }; diff --git a/yoRadio/src/displays/fonts/DS_DIGI15pt7b_mono.h b/yoRadio/src/displays/fonts/DS_DIGI15pt7b_mono.h index 8770177..596aa4f 100644 --- a/yoRadio/src/displays/fonts/DS_DIGI15pt7b_mono.h +++ b/yoRadio/src/displays/fonts/DS_DIGI15pt7b_mono.h @@ -53,7 +53,7 @@ const GFXglyph DS_DIGI15pt7bGlyphs[] PROGMEM = { { 257, 3, 15, 6, 2, -14 } // 0x3A ':' }; -const GFXfont DS_DIGI15pt7b PROGMEM = { +const GFXfont Clock_GFXfont PROGMEM = { (uint8_t *)DS_DIGI15pt7bBitmaps, (GFXglyph *)DS_DIGI15pt7bGlyphs, 0x20, 0x3A, 29 }; diff --git a/yoRadio/src/displays/fonts/DS_DIGI28pt7b.h b/yoRadio/src/displays/fonts/DS_DIGI28pt7b.h index d7e0cd6..2d123a0 100644 --- a/yoRadio/src/displays/fonts/DS_DIGI28pt7b.h +++ b/yoRadio/src/displays/fonts/DS_DIGI28pt7b.h @@ -75,7 +75,7 @@ const uint8_t DS_DIGI28pt7bBitmaps[] PROGMEM = { }; const GFXglyph DS_DIGI28pt7bGlyphs[] PROGMEM = { - { 0, 0, 0, 12, 0, 1 }, // 0x20 ' ' + { 0, 0, 0, 11, 0, 1 }, // 0x20 ' ' { 0, 0, 0, 0, 0, 0 }, // 0x21 '!' { 0, 0, 0, 0, 0, 0 }, // 0x22 '"' { 0, 0, 0, 0, 0, 0 }, // 0x23 '#' @@ -104,6 +104,6 @@ const GFXglyph DS_DIGI28pt7bGlyphs[] PROGMEM = { { 859, 4, 29, 11, 4, -28 } // 0x3A ':' }; -const GFXfont DS_DIGI28pt7b PROGMEM = { +const GFXfont Clock_GFXfont PROGMEM = { (uint8_t *)DS_DIGI28pt7bBitmaps, (GFXglyph *)DS_DIGI28pt7bGlyphs, 0x20, 0x3A, 55 }; diff --git a/yoRadio/src/displays/fonts/DS_DIGI28pt7b_mono.h b/yoRadio/src/displays/fonts/DS_DIGI28pt7b_mono.h index 5521f8e..c5edc77 100644 --- a/yoRadio/src/displays/fonts/DS_DIGI28pt7b_mono.h +++ b/yoRadio/src/displays/fonts/DS_DIGI28pt7b_mono.h @@ -75,7 +75,7 @@ const uint8_t DS_DIGI28pt7bBitmaps[] PROGMEM = { }; const GFXglyph DS_DIGI28pt7bGlyphs[] PROGMEM = { - { 0, 0, 0, 12, 0, 1 }, // 0x20 ' ' + { 0, 0, 0, 11, 0, 1 }, // 0x20 ' ' { 0, 0, 0, 0, 0, 0 }, // 0x21 '!' { 0, 0, 0, 0, 0, 0 }, // 0x22 '"' { 0, 0, 0, 0, 0, 0 }, // 0x23 '#' @@ -104,6 +104,6 @@ const GFXglyph DS_DIGI28pt7bGlyphs[] PROGMEM = { { 859, 4, 29, 11, 4, -28 } // 0x3A ':' }; -const GFXfont DS_DIGI28pt7b PROGMEM = { +const GFXfont Clock_GFXfont PROGMEM = { (uint8_t *)DS_DIGI28pt7bBitmaps, (GFXglyph *)DS_DIGI28pt7bGlyphs, 0x20, 0x3A, 55 }; diff --git a/yoRadio/src/displays/fonts/DS_DIGI42pt7b_mono.h b/yoRadio/src/displays/fonts/DS_DIGI42pt7b_mono.h index f6e6bbd..bb2c3dc 100644 --- a/yoRadio/src/displays/fonts/DS_DIGI42pt7b_mono.h +++ b/yoRadio/src/displays/fonts/DS_DIGI42pt7b_mono.h @@ -192,7 +192,7 @@ const GFXglyph DS_DIGI42pt7bGlyphs[] PROGMEM = { { 1888, 6, 43, 15, 4, -42 } // 0x3A ':' }; -const GFXfont DS_DIGI42pt7b PROGMEM = { +const GFXfont Clock_GFXfont PROGMEM = { (uint8_t *)DS_DIGI42pt7bBitmaps, (GFXglyph *)DS_DIGI42pt7bGlyphs, 0x20, 0x3A, 82 }; diff --git a/yoRadio/src/displays/fonts/DS_DIGI56pt7b_mono.h b/yoRadio/src/displays/fonts/DS_DIGI56pt7b_mono.h index ba42515..8c05d23 100644 --- a/yoRadio/src/displays/fonts/DS_DIGI56pt7b_mono.h +++ b/yoRadio/src/displays/fonts/DS_DIGI56pt7b_mono.h @@ -343,7 +343,7 @@ const GFXglyph DS_DIGI56pt7bGlyphs[] PROGMEM = { { 3688, 7, 59, 24, 8, -58 } // 0x3A ':' }; -const GFXfont DS_DIGI56pt7b PROGMEM = { +const GFXfont Clock_GFXfont PROGMEM = { (uint8_t *)DS_DIGI56pt7bBitmaps, (GFXglyph *)DS_DIGI56pt7bGlyphs, 0x20, 0x3A, 110 }; diff --git a/yoRadio/src/displays/fonts/bootlogo21x28.h b/yoRadio/src/displays/fonts/bootlogo21x28.h new file mode 100644 index 0000000..21264e0 --- /dev/null +++ b/yoRadio/src/displays/fonts/bootlogo21x28.h @@ -0,0 +1,38 @@ +#ifndef bootlogo_h +#define bootlogo_h + + +/******************************************************************************* +* generated by lcd-image-converter rev.030b30d from 2019-03-17 01:38:34 +0500 +* image +* filename: unsaved +* name: bootlogo +* +* preset name: Color R5G6B5 +* data block size: 16 bit(s), uint16_t +* RLE compression enabled: no +* conversion type: Color, not_used not_used +* split to rows: yes +* bits per pixel: 16 +* +* preprocess: +* main scan direction: top_to_bottom +* line scan direction: forward +* inverse: no +*******************************************************************************/ + +#include +#define LOGO_WIDTH 21 +#define LOGO_HEIGHT 28 + +const unsigned char logo [] PROGMEM= +{ + 0x07, 0x03, 0x80, 0x0f, 0x87, 0xc0, 0x0f, 0x87, 0xc0, 0x0f, 0x87, 0xc0, 0x0f, 0x87, 0xc0, 0x07, + 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xfe, 0x00, 0x07, 0xff, 0x80, 0x1f, 0xff, + 0xc0, 0x1f, 0xff, 0xe0, 0x3f, 0xff, 0xf0, 0x7f, 0x07, 0xf0, 0x7e, 0x03, 0xf0, 0x7e, 0x01, 0xf8, + 0x7f, 0xff, 0xf8, 0xff, 0xff, 0xf8, 0xff, 0xff, 0xf8, 0x7f, 0xff, 0xf8, 0x7e, 0x00, 0x00, 0x7f, + 0x00, 0x00, 0x7f, 0x80, 0x20, 0x3f, 0xff, 0xe0, 0x3f, 0xff, 0xe0, 0x1f, 0xff, 0xe0, 0x0f, 0xff, + 0xe0, 0x01, 0xff, 0xc0 +}; + +#endif diff --git a/yoRadio/src/displays/fonts/bootlogo21x32.h b/yoRadio/src/displays/fonts/bootlogo21x32.h new file mode 100644 index 0000000..174e428 --- /dev/null +++ b/yoRadio/src/displays/fonts/bootlogo21x32.h @@ -0,0 +1,40 @@ +#ifndef bootlogo_h +#define bootlogo_h + + +/******************************************************************************* +* generated by lcd-image-converter rev.030b30d from 2019-03-17 01:38:34 +0500 +* image +* filename: unsaved +* name: bootlogo +* +* preset name: Color R5G6B5 +* data block size: 16 bit(s), uint16_t +* RLE compression enabled: no +* conversion type: Color, not_used not_used +* split to rows: yes +* bits per pixel: 16 +* +* preprocess: +* main scan direction: top_to_bottom +* line scan direction: forward +* inverse: no +*******************************************************************************/ + +#include +#define LOGO_WIDTH 21 +#define LOGO_HEIGHT 32 + +static 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 +}; + +#endif diff --git a/yoRadio/src/displays/fonts/bootlogo40.h b/yoRadio/src/displays/fonts/bootlogo62x40.h similarity index 99% rename from yoRadio/src/displays/fonts/bootlogo40.h rename to yoRadio/src/displays/fonts/bootlogo62x40.h index 8776659..ffa8211 100644 --- a/yoRadio/src/displays/fonts/bootlogo40.h +++ b/yoRadio/src/displays/fonts/bootlogo62x40.h @@ -22,8 +22,10 @@ *******************************************************************************/ #include +#define LOGO_WIDTH 62 +#define LOGO_HEIGHT 40 -static const uint16_t bootlogo40[2480] PROGMEM = { +static const uint16_t logo[2480] PROGMEM = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0020, 0x5aa4, 0xcdc9, 0xde6a, 0xde4a, 0x9c67, 0x20e1, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1081, 0x83a5, 0xc527, 0xc526, 0xb4c5, 0x5a83, 0x0820, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7345, 0xd60a, 0xd62a, 0xde2a, 0xde4a, 0xde4a, 0xc5a9, 0x18e1, 0x0000, 0x0000, 0x0000, 0x1081, 0xbd48, 0xcd88, 0xc547, 0xc527, 0xbd06, 0xbce6, 0x7b44, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2102, 0xd5c9, 0xd5c9, 0xd5e9, 0xd60a, 0xd62a, 0xde4a, 0xde4a, 0x83c6, 0x0000, 0x0000, 0x0000, 0x83e6, 0xd5e9, 0xcda8, 0xcd88, 0xcd68, 0xc547, 0xc527, 0xc527, 0x20e1, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, diff --git a/yoRadio/src/displays/fonts/bootlogo.h b/yoRadio/src/displays/fonts/bootlogo99x64.h similarity index 99% rename from yoRadio/src/displays/fonts/bootlogo.h rename to yoRadio/src/displays/fonts/bootlogo99x64.h index ddd1cef..e0a607e 100644 --- a/yoRadio/src/displays/fonts/bootlogo.h +++ b/yoRadio/src/displays/fonts/bootlogo99x64.h @@ -22,8 +22,10 @@ *******************************************************************************/ #include +#define LOGO_WIDTH 99 +#define LOGO_HEIGHT 64 -static const uint16_t bootlogo2[6336] PROGMEM = { +static const uint16_t logo[6336] PROGMEM = { // ∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙▒▓▓▓▓▒∙∙∙∙∙∙∙∙∙∙∙∙░▒▓▓▓▒░∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙ // ∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙▒▓▓▓▓▓▓▓▓░∙∙∙∙∙∙∙∙∙▓▓▓▓▓▒▒▒▒∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙ // ∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙░▓▓▓▓▓▓▓▓▓▓░∙∙∙∙∙∙∙▓▓▓▓▓▓▓▓▒▒▒∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙∙ diff --git a/yoRadio/src/displays/fonts/dsfont19.h b/yoRadio/src/displays/fonts/dsfont19.h new file mode 100644 index 0000000..1bb8a98 --- /dev/null +++ b/yoRadio/src/displays/fonts/dsfont19.h @@ -0,0 +1,10 @@ +#ifndef dsfont_h +#define dsfont_h + +#if CLOCKFONT_MONO + #include "DS_DIGI15pt7b_mono.h" +#else + #include "DS_DIGI15pt7b.h" +#endif + +#endif diff --git a/yoRadio/src/displays/fonts/dsfont35.h b/yoRadio/src/displays/fonts/dsfont35.h new file mode 100644 index 0000000..76a246a --- /dev/null +++ b/yoRadio/src/displays/fonts/dsfont35.h @@ -0,0 +1,10 @@ +#ifndef dsfont_h +#define dsfont_h + +#if CLOCKFONT_MONO + #include "DS_DIGI28pt7b_mono.h" // https://tchapi.github.io/Adafruit-GFX-Font-Customiser/ +#else + #include "DS_DIGI28pt7b.h" +#endif + +#endif diff --git a/yoRadio/src/displays/fonts/dsfont52.h b/yoRadio/src/displays/fonts/dsfont52.h new file mode 100644 index 0000000..5df7a30 --- /dev/null +++ b/yoRadio/src/displays/fonts/dsfont52.h @@ -0,0 +1,10 @@ +#ifndef dsfont_h +#define dsfont_h + +#if CLOCKFONT_MONO + #include "DS_DIGI42pt7b_mono.h" // https://tchapi.github.io/Adafruit-GFX-Font-Customiser/ +#else + #include "DS_DIGI42pt7b.h" +#endif + +#endif diff --git a/yoRadio/src/displays/fonts/dsfont70.h b/yoRadio/src/displays/fonts/dsfont70.h new file mode 100644 index 0000000..c29385d --- /dev/null +++ b/yoRadio/src/displays/fonts/dsfont70.h @@ -0,0 +1,10 @@ +#ifndef dsfont_h +#define dsfont_h + +#if CLOCKFONT_MONO + #include "DS_DIGI56pt7b_mono.h" // https://tchapi.github.io/Adafruit-GFX-Font-Customiser/ +#else + #include "DS_DIGI56pt7b.h" +#endif + +#endif diff --git a/yoRadio/src/displays/nextion.cpp b/yoRadio/src/displays/nextion.cpp index e7d9dd4..cffdf09 100644 --- a/yoRadio/src/displays/nextion.cpp +++ b/yoRadio/src/displays/nextion.cpp @@ -1,5 +1,7 @@ #include "../core/options.h" - +#if DSP_MODEL==DSP_DUMMY +#define DUMMYDISPLAY +#endif #if NEXTION_RX!=255 && NEXTION_TX!=255 #include "nextion.h" #include "../core/config.h" @@ -8,6 +10,8 @@ #include "../core/controls.h" #include "../core/netserver.h" #include "../core/network.h" +#include "../core/timekeeper.h" +#include "tools/l10n.h" #ifndef CORE_STACK_SIZE #define CORE_STACK_SIZE 1024*3 @@ -63,7 +67,7 @@ void Nextion::start(){ } #ifdef DUMMYDISPLAY display.mode(PLAYER); - config.setTitle(const_PlReady); + config.setTitle(LANG::const_PlReady); #endif putRequest({NEWMODE, PLAYER}); putRequest({NEWSTATION, 0}); @@ -97,7 +101,7 @@ void Nextion::processQueue(){ case NEWTITLE: newTitle(config.station.title); break; case BOOTSTRING: { char buf[50]; - snprintf(buf, 50, bootstrFmt, config.ssids[request.payload].ssid); + snprintf(buf, 50, LANG::bootstrFmt, config.ssids[request.payload].ssid); bootString(buf); break; } @@ -251,7 +255,7 @@ void Nextion::loop() { }else if(strlen(config.store.sntp1)>0){ configTime(config.store.tzHour * 3600 + config.store.tzMin * 60, config.getTimezoneOffset(), config.store.sntp1); } - network.forceTimeSync = true; + timekeeper.forceTimeSync = true; } if (sscanf(rxbuf, "tzmin=%d", &scanDigit) == 1){ config.setTimezone(config.store.tzHour, (int8_t)scanDigit); @@ -260,7 +264,7 @@ void Nextion::loop() { }else if(strlen(config.store.sntp1)>0){ configTime(config.store.tzHour * 3600 + config.store.tzMin * 60, config.getTimezoneOffset(), config.store.sntp1); } - network.forceTimeSync = true; + timekeeper.forceTimeSync = true; } if (sscanf(rxbuf, "audioinfo=%d", &scanDigit) == 1){ config.saveValue(&config.store.audioinfo, static_cast(scanDigit)); @@ -416,7 +420,7 @@ void Nextion::printClock(struct tm timeinfo){ strftime(timeStringBuff, sizeof(timeStringBuff), "player.clock.txt=\"%H:%M\"", &timeinfo); putcmd(timeStringBuff); putcmdf("player.secText.txt=\"%02d\"", timeinfo.tm_sec); - snprintf(timeStringBuff, sizeof(timeStringBuff), "player.dateText.txt=\"%s, %d %s %d\"", dowf[timeinfo.tm_wday], timeinfo.tm_mday, mnths[timeinfo.tm_mon], timeinfo.tm_year+1900); + snprintf(timeStringBuff, sizeof(timeStringBuff), "player.dateText.txt=\"%s, %d %s %d\"", LANG::dowf[timeinfo.tm_wday], timeinfo.tm_mday, LANG::mnths[timeinfo.tm_mon], timeinfo.tm_year+1900); putcmd(utf8Rus(timeStringBuff, false)); if(mode==TIMEZONE) localTime(network.timeinfo); if(mode==INFO) rssi(); @@ -434,12 +438,52 @@ void Nextion::printPLitem(uint8_t pos, const char* item){ putcmd(cmd); } +uint8_t Nextion::_fillPlMenu(int from, uint8_t count) { + int ls = from; + uint8_t c = 0; + bool finded = false; + if (config.playlistLength() == 0) { + return 0; + } + File playlist = config.SDPLFS()->open(REAL_PLAYL, "r"); + File index = config.SDPLFS()->open(REAL_INDEX, "r"); + while (true) { + if (ls < 1) { + ls++; + printPLitem(c, ""); + c++; + continue; + } + if (!finded) { + index.seek((ls - 1) * 4, SeekSet); + uint32_t pos; + index.readBytes((char *) &pos, 4); + finded = true; + index.close(); + playlist.seek(pos, SeekSet); + } + bool pla = true; + while (pla) { + pla = playlist.available(); + String stationName = playlist.readStringUntil('\n'); + stationName = stationName.substring(0, stationName.indexOf('\t')); + if(config.store.numplaylist && stationName.length()>0) stationName = String(from+c)+" "+stationName; + printPLitem(c, stationName.c_str()); + c++; + if (c >= count) break; + } + break; + } + playlist.close(); + return c; +} + void Nextion::drawPlaylist(uint16_t currentPlItem){ mode=STATIONS; - uint8_t lastPos = config.fillPlMenu(currentPlItem - 3, 7, true); + uint8_t lastPos = _fillPlMenu(currentPlItem - 3, 7); if(lastPos<7){ for(int i=0;i<7-lastPos;i++){ - nextion.printPLitem(lastPos+i, ""); + printPLitem(lastPos+i, ""); } } _volDelay = millis(); diff --git a/yoRadio/src/displays/nextion.h b/yoRadio/src/displays/nextion.h index cd3ed97..73f4afe 100644 --- a/yoRadio/src/displays/nextion.h +++ b/yoRadio/src/displays/nextion.h @@ -30,6 +30,7 @@ class Nextion { unsigned long _volDelay; void processQueue(); void drawVU(); + uint8_t _fillPlMenu(int from, uint8_t count); public: displayMode_e mode; bool dt; diff --git a/yoRadio/src/displays/tools/commongfx.h b/yoRadio/src/displays/tools/commongfx.h index 148c659..bc24bf4 100644 --- a/yoRadio/src/displays/tools/commongfx.h +++ b/yoRadio/src/displays/tools/commongfx.h @@ -1,31 +1,50 @@ #ifndef common_gfx_h #define common_gfx_h - public: - uint16_t plItemHeight, plTtemsCount, plCurrentPos; - int plYStart; +#include "../widgets/widgetsconfig.h" // displayXXXDDDDconf.h +#include "utf8Rus.h" +#define ADAFRUIT_CLIPPING !defined(DSP_LCD) && DSP_MODEL!=DSP_ILI9225 + +typedef struct clipArea { + uint16_t left; + uint16_t top; + uint16_t width; + uint16_t height; +} clipArea; + +class psFrameBuffer; + +class DspCore: public yoDisplay { public: DspCore(); - //char plMenu[PLMITEMS][PLMITEMLENGHT]; void initDisplay(); - void drawLogo(uint16_t top); void clearDsp(bool black=false); void printClock(){} - void printClock(uint16_t top, uint16_t rightspace, uint16_t timeheight, bool redraw); - void clearClock(); - char* utf8Rus(const char* str, bool uppercase); - void drawPlaylist(uint16_t currentItem); - void loop(bool force=false); - void charSize(uint8_t textsize, uint8_t& width, uint16_t& height); - #ifndef DSP_LCD + #ifdef DSP_OLED + inline void loop(bool force=false){ #if DSP_MODEL==DSP_NOKIA5110 - virtual void command(uint8_t c); - virtual void data(uint8_t c); + if(digitalRead(TFT_CS)==LOW) return; + display(); #else - virtual void startWrite(void); - virtual void endWrite(void); + display(); + //delay(DSP_MODEL==DSP_ST7920?20:5); + vTaskDelay(DSP_MODEL==DSP_ST7920?10:0); #endif - void setTextSize(uint8_t s); + } + inline void drawLogo(uint16_t top) { + #if DSP_MODEL!=DSP_SSD1306x32 + drawBitmap((width() - LOGO_WIDTH ) / 2, top, logo, LOGO_WIDTH, LOGO_HEIGHT, 1); + #else + setTextSize(1); setCursor((width() - 6*CHARWIDTH) / 2, 0); setTextColor(TFT_FG, TFT_BG); print(utf8Rus("ёRadio", false)); + #endif + display(); + } #else + #ifndef DSP_LCD + inline void loop(bool force=false){} + inline void drawLogo(uint16_t top){ drawRGBBitmap((width() - LOGO_WIDTH) / 2, top, logo, LOGO_WIDTH, LOGO_HEIGHT); } + #endif + #endif + #ifdef DSP_LCD uint16_t width(); uint16_t height(); void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); @@ -35,24 +54,20 @@ void setTextColor(uint16_t c, uint16_t bg){} void setFont(){} void apScreen(); + void drawLogo(uint16_t top){} + void loop(bool force=false){} #endif - void flip(); void invert(); void sleep(); void wake(); - void writePixel(int16_t x, int16_t y, uint16_t color); - void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); - void setClipping(clipArea ca); - void clearClipping(); void setScrollId(void * scrollid) { _scrollid = scrollid; } void * getScrollId() { return _scrollid; } - void setNumFont(); uint16_t textWidth(const char *txt); #if DSP_MODEL==DSP_ILI9225 uint16_t width(void) { return (int16_t)maxX(); } uint16_t height(void) { return (int16_t)maxY(); } - void drawRGBBitmap(int16_t x, int16_t y, const uint16_t *bitmap, int16_t w, int16_t h); + inline void drawRGBBitmap(int16_t x, int16_t y, const uint16_t *bitmap, int16_t w, int16_t h){ drawBitmap(x, y, bitmap, w, h); } uint16_t print(const char* s); void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); void drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); @@ -62,24 +77,57 @@ void setCursor(int16_t x, int16_t y); void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color); void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color); - uint16_t drawChar(uint16_t x, uint16_t y, uint16_t ch, uint16_t color = COLOR_WHITE); + inline uint16_t drawChar(uint16_t x, uint16_t y, uint16_t ch, uint16_t color = COLOR_WHITE){ + if(_clipping){ + if ((x < _cliparea.left) || (x >= _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) { + return cfont.width; + } + } + uint16_t ret=TFT_22_ILI9225::drawChar(x, y, ch, color); + return ret; + } + void setTextSize(uint8_t s); #endif - void printPLitem(uint8_t pos, const char* item, ScrollWidget& current); + #if ADAFRUIT_CLIPPING + inline void writePixel(int16_t x, int16_t y, uint16_t color) { + if(_clipping){ + if ((x < _cliparea.left) || (x > _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; + } + yoDisplay::writePixel(x, y, color); + } + inline void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) { + if(_clipping){ + if ((x < _cliparea.left) || (x >= _cliparea.left+_cliparea.width) || (y < _cliparea.top) || (y > _cliparea.top + _cliparea.height)) return; + } + yoDisplay::writeFillRect(x, y, w, h, color); + } + #else + inline void writePixel(int16_t x, int16_t y, uint16_t color) { } + inline void writeFillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color) { } + #endif + inline void setClipping(clipArea ca){ + _cliparea = ca; + _clipping = true; + } + inline void clearClipping(){ + _clipping = false; + #ifdef DSP_LCD + setClipping({0, 0, width(), height()}); + #endif + } private: - char _timeBuf[20], _dateBuf[20], _oldTimeBuf[20], _oldDateBuf[20], _bufforseconds[4], _buffordate[40]; - uint16_t _timewidth, _timeleft, _datewidth, _dateleft, _oldtimeleft, _oldtimewidth, _olddateleft, _olddatewidth, clockTop, clockRightSpace, clockTimeHeight, _dotsLeft; - bool _clipping, _printdots; + bool _clipping; clipArea _cliparea; void * _scrollid; - void _getTimeBounds(); - void _clockSeconds(); - void _clockDate(); - void _clockTime(); - uint8_t _charWidth(unsigned char c); + #ifdef PSFBUFFER + psFrameBuffer* _fb=nullptr; + #endif #if DSP_MODEL==DSP_ILI9225 uint16_t _bgcolor, _fgcolor; int16_t _cursorx, _cursory; bool _gFont/*, _started*/; #endif +}; +extern DspCore dsp; #endif diff --git a/yoRadio/src/displays/tools/l10n.h b/yoRadio/src/displays/tools/l10n.h index 1a5b245..0362e71 100644 --- a/yoRadio/src/displays/tools/l10n.h +++ b/yoRadio/src/displays/tools/l10n.h @@ -1,6 +1,6 @@ #ifndef _display_l10n_h #define _display_l10n_h - +namespace LANG{ //================================================== #if L10N_LANGUAGE==RU #define L10N_PATH "../../../locale/displayL10n_ru.h" @@ -14,5 +14,5 @@ #include L10N_PATH #endif //================================================== - +} #endif diff --git a/yoRadio/src/displays/tools/oledcolorfix.h b/yoRadio/src/displays/tools/oledcolorfix.h index ecd0141..f2b58ca 100644 --- a/yoRadio/src/displays/tools/oledcolorfix.h +++ b/yoRadio/src/displays/tools/oledcolorfix.h @@ -1,5 +1,6 @@ #ifndef _OLEDCOLORFIX_H_ #define _OLEDCOLORFIX_H_ +#pragma once config.theme.background = TFT_BG; #if DSP_INVERT_TITLE @@ -12,6 +13,7 @@ config.theme.metafill = TFT_BG; #endif config.theme.clock = TFT_FG; + config.theme.seconds = TFT_FG; config.theme.clockbg = TFT_BG; config.theme.weather = TFT_FG; config.theme.title1 = TFT_FG; diff --git a/yoRadio/src/displays/tools/psframebuffer.h b/yoRadio/src/displays/tools/psframebuffer.h new file mode 100644 index 0000000..0840c22 --- /dev/null +++ b/yoRadio/src/displays/tools/psframebuffer.h @@ -0,0 +1,79 @@ +#ifndef psframebuffer_h +#define psframebuffer_h + +#ifdef PSFBUFFER +#include + +class psFrameBuffer : public Adafruit_GFX { + public: + psFrameBuffer(int16_t w, int16_t h):Adafruit_GFX(w, h){ setTextWrap(false); cp437(true); } + ~psFrameBuffer(){ freeBuffer(); } + bool ready() { return _ready; } + + void freeBuffer(){ + _ready = false; + if(buffer) { + _dspl->fillRect(_ll, _tt, _ww, _hh, _bgcolor); + free(buffer); + } + buffer = nullptr; + } + bool begin(yoDisplay *dspl, int16_t l, int16_t t, int16_t w, int16_t h, uint16_t bgcolor = 0){ + _dspl = dspl; _ll = l; _tt = t; _ww = w; _hh = h; _bgcolor = bgcolor; + _createBuffer(); + return _ready; + } + void move(int16_t l, int16_t t, int16_t w, int16_t h){ + _ll = l; _tt = t; _ww = w; _hh = h; + freeBuffer(); + _createBuffer(); + } + void drawPixel( int16_t x, int16_t y, uint16_t color){ + if (x < 0 || x >= _ww || y < 0 || y >= _hh) return; + if(!buffer) return; + buffer[x + y * _ww] = color; + } + void display(){ + if(!buffer) return; + _dspl->startWrite(); + _dspl->setAddrWindow(_ll, _tt, _ww, _hh); + _dspl->writePixels((uint16_t*)buffer, _ww * _hh); + _dspl->endWrite(); + } + void clear(){ + if(!buffer) return; + fillRect(0, 0, _ww, _hh, _bgcolor); + } + int16_t width(){ return _ww; } + int16_t height(){ return _hh; } + private: + int16_t _ll, _tt, _ww, _hh; + yoDisplay *_dspl; + uint16_t *buffer=nullptr; + bool _ready = false; + uint16_t _bgcolor; + void _createBuffer(){ + if(USE_FBUFFER){ + if(psramInit()) + buffer = (uint16_t*) ps_calloc(_hh * _ww, sizeof(uint16_t)); + #ifdef SFBUFFER + else + buffer = (uint16_t*) calloc(_hh * _ww, sizeof(uint16_t)); + #endif + } + if(buffer){ + for (int i = 0; i < _hh * _ww; i++) + buffer[i] = 0; + _ready = true; + } + } +}; +#else +struct psFrameBuffer { + bool ready() { return false; } + void display() {} +}; +#endif //#ifdef PSFBUFFER + + +#endif diff --git a/yoRadio/src/displays/tools/utf8RusLCD.h b/yoRadio/src/displays/tools/utf8Rus.cpp similarity index 61% rename from yoRadio/src/displays/tools/utf8RusLCD.h rename to yoRadio/src/displays/tools/utf8Rus.cpp index 5ad4a96..e431b49 100644 --- a/yoRadio/src/displays/tools/utf8RusLCD.h +++ b/yoRadio/src/displays/tools/utf8Rus.cpp @@ -1,7 +1,85 @@ -#ifndef utf8RusLCD_h -#define utf8RusLCD_h +#include "Arduino.h" +#include "../../core/options.h" +#include "../dspcore.h" +#include "utf8Rus.h" -char* DspCore::utf8Rus(const char* str, bool uppercase) { +#ifndef DSP_LCD +char* 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; + } + uint8_t rus = (uint8_t) * iter; + if (rus == 208 && (uint8_t) * (iter + 1) == 129) { // ёКостыли + *iter = (char)209; + *(iter + 1) = (char)145; + E = true; + continue; + } + if (rus == 209 && (uint8_t) * (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); + } + } + if(L10N_LANGUAGE==EN) return strn; + 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; +} +#else //#ifndef DSP_LCD +char* utf8Rus(const char* str, bool uppercase) { int index = 0; static char strn[BUFLEN]; static char newStr[BUFLEN]; @@ -109,5 +187,6 @@ char* DspCore::utf8Rus(const char* str, bool uppercase) { } return newStr; } +#endif //#ifndef DSP_LCD + -#endif diff --git a/yoRadio/src/displays/tools/utf8Rus.h b/yoRadio/src/displays/tools/utf8Rus.h new file mode 100644 index 0000000..36ea1d7 --- /dev/null +++ b/yoRadio/src/displays/tools/utf8Rus.h @@ -0,0 +1,6 @@ +#ifndef utf8Rus_h +#define utf8Rus_h + +char* utf8Rus(const char* str, bool uppercase); + +#endif diff --git a/yoRadio/src/displays/tools/utf8RusGFX.h b/yoRadio/src/displays/tools/utf8RusGFX.h deleted file mode 100644 index a7daf3e..0000000 --- a/yoRadio/src/displays/tools/utf8RusGFX.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef utf8RusGFX_h -#define utf8RusGFX_h - -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; - } - uint8_t rus = (uint8_t) * iter; - if (rus == 208 && (uint8_t) * (iter + 1) == 129) { // ёКостыли - *iter = (char)209; - *(iter + 1) = (char)145; - E = true; - continue; - } - if (rus == 209 && (uint8_t) * (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); - } - } - if(L10N_LANGUAGE==EN) return strn; - 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; -} - -#endif diff --git a/yoRadio/src/displays/widgets/pages.cpp b/yoRadio/src/displays/widgets/pages.cpp index d056cb7..ad4ca1f 100644 --- a/yoRadio/src/displays/widgets/pages.cpp +++ b/yoRadio/src/displays/widgets/pages.cpp @@ -1,7 +1,8 @@ -#include "../dspcore.h" +#include "../../core/options.h" #if DSP_MODEL!=DSP_DUMMY - +#include "../dspcore.h" #include "pages.h" +#include "widgets.h" void Pager::begin(){ diff --git a/yoRadio/src/displays/widgets/pages.h b/yoRadio/src/displays/widgets/pages.h index f675462..6752653 100644 --- a/yoRadio/src/displays/widgets/pages.h +++ b/yoRadio/src/displays/widgets/pages.h @@ -3,6 +3,7 @@ #include +class Widget; class Page { protected: diff --git a/yoRadio/src/displays/widgets/widgets.cpp b/yoRadio/src/displays/widgets/widgets.cpp index 601e93b..a25393e 100644 --- a/yoRadio/src/displays/widgets/widgets.cpp +++ b/yoRadio/src/displays/widgets/widgets.cpp @@ -1,8 +1,13 @@ -#include "../dspcore.h" +#include "../../core/options.h" #if DSP_MODEL!=DSP_DUMMY - +#include "../dspcore.h" +#include "Arduino.h" #include "widgets.h" #include "../../core/player.h" // for VU widget +#include "../../core/network.h" // for Clock widget +#include "../../core/config.h" +#include "../tools/l10n.h" +#include "../tools/psframebuffer.h" /************************ FILL WIDGET @@ -31,6 +36,16 @@ TextWidget::~TextWidget() { free(_oldtext); } +void TextWidget::_charSize(uint8_t textsize, uint8_t& width, uint16_t& height){ +#ifndef DSP_LCD + width = textsize * CHARWIDTH; + height = textsize * CHARHEIGHT; +#else + width = 1; + height = 1; +#endif +} + void TextWidget::init(WidgetConfig wconf, uint16_t buffsize, bool uppercase, uint16_t fgcolor, uint16_t bgcolor) { Widget::init(wconf, fgcolor, bgcolor); _buffsize = buffsize; @@ -38,15 +53,13 @@ void TextWidget::init(WidgetConfig wconf, uint16_t buffsize, bool uppercase, uin memset(_text, 0, _buffsize); _oldtext = (char *) malloc(sizeof(char) * _buffsize); memset(_oldtext, 0, _buffsize); - //_charWidth = wconf.textsize * CHARWIDTH; // default GFX font - //_textheight = wconf.textsize * CHARHEIGHT; // default GFX font - dsp.charSize(_config.textsize, _charWidth, _textheight); + _charSize(_config.textsize, _charWidth, _textheight); _textwidth = _oldtextwidth = _oldleft = 0; _uppercase = uppercase; } void TextWidget::setText(const char* txt) { - strlcpy(_text, dsp.utf8Rus(txt, _uppercase), _buffsize); + strlcpy(_text, utf8Rus(txt, _uppercase), _buffsize); _textwidth = strlen(_text) * _charWidth; if (strcmp(_oldtext, _text) == 0) return; if (_active) dsp.fillRect(_oldleft == 0 ? _realLeft() : min(_oldleft, _realLeft()), _config.top, max(_oldtextwidth, _textwidth), _textheight, _bgcolor); @@ -67,11 +80,12 @@ void TextWidget::setText(const char* txt, const char *format){ setText(buf); } -uint16_t TextWidget::_realLeft() { +uint16_t TextWidget::_realLeft(bool w_fb) { + uint16_t realwidth = (_width>0 && w_fb)?_width:dsp.width(); switch (_config.align) { - case WA_CENTER: return (dsp.width() - _textwidth) / 2; break; - case WA_RIGHT: return (dsp.width() - _textwidth - _config.left); break; - default: return _config.left; break; + case WA_CENTER: return (realwidth - _textwidth) / 2; break; + case WA_RIGHT: return (realwidth - _textwidth - (!w_fb?_config.left:0)); break; + default: return !w_fb?_config.left:0; break; } } @@ -93,6 +107,7 @@ ScrollWidget::ScrollWidget(const char* separator, ScrollConfig conf, uint16_t fg } ScrollWidget::~ScrollWidget() { + free(_fb); free(_sep); free(_window); } @@ -106,21 +121,31 @@ void ScrollWidget::init(const char* separator, ScrollConfig conf, uint16_t fgcol _startscrolldelay = conf.startscrolldelay; _scrolldelta = conf.scrolldelta; _scrolltime = conf.scrolltime; - //_charWidth = CHARWIDTH * _config.textsize; // default GFX font - //_textheight = CHARHEIGHT * _config.textsize; // default GFX font - dsp.charSize(_config.textsize, _charWidth, _textheight); + _charSize(_config.textsize, _charWidth, _textheight); _sepwidth = strlen(_sep) * _charWidth; _width = conf.width; _backMove.width = _width; _window = (char *) malloc(sizeof(char) * (MAX_WIDTH / _charWidth + 1)); memset(_window, 0, (MAX_WIDTH / _charWidth + 1)); // +1? _doscroll = false; + #ifdef PSFBUFFER + _fb = new psFrameBuffer(dsp.width(), dsp.height()); + uint16_t _rl = (_config.align==WA_CENTER)?(dsp.width()-_width)/2:_config.left; + _fb->begin(&dsp, _rl, _config.top, _width, _textheight, _bgcolor); + #endif } void ScrollWidget::_setTextParams() { if (_config.textsize == 0) return; - dsp.setTextSize(_config.textsize); - dsp.setTextColor(_fgcolor, _bgcolor); + if(_fb->ready()){ + #ifdef PSFBUFFER + _fb->setTextSize(_config.textsize); + _fb->setTextColor(_fgcolor, _bgcolor); + #endif + }else{ + dsp.setTextSize(_config.textsize); + dsp.setTextColor(_fgcolor, _bgcolor); + } } bool ScrollWidget::_checkIsScrollNeeded() { @@ -128,28 +153,47 @@ bool ScrollWidget::_checkIsScrollNeeded() { } void ScrollWidget::setText(const char* txt) { - strlcpy(_text, dsp.utf8Rus(txt, _uppercase), _buffsize - 1); + strlcpy(_text, utf8Rus(txt, _uppercase), _buffsize - 1); if (strcmp(_oldtext, _text) == 0) return; _textwidth = strlen(_text) * _charWidth; - _x = _config.left; + _x = _fb->ready()?0:_config.left; _doscroll = _checkIsScrollNeeded(); if (dsp.getScrollId() == this) dsp.setScrollId(NULL); _scrolldelay = millis(); if (_active) { _setTextParams(); if (_doscroll) { + if(_fb->ready()){ + #ifdef PSFBUFFER + _fb->fillRect(0, 0, _width, _textheight, _bgcolor); + _fb->setCursor(0, 0); + snprintf(_window, _width / _charWidth + 1, "%s", _text); //TODO + _fb->print(_window); + _fb->display(); + #endif + } else { dsp.fillRect(_config.left, _config.top, _width, _textheight, _bgcolor); dsp.setCursor(_config.left, _config.top); snprintf(_window, _width / _charWidth + 1, "%s", _text); //TODO dsp.setClipping({_config.left, _config.top, _width, _textheight}); dsp.print(_window); dsp.clearClipping(); + } } else { - dsp.fillRect(_config.left, _config.top, _width, _textheight, _bgcolor); - dsp.setCursor(_realLeft(), _config.top); - //dsp.setClipping({_config.left, _config.top, _width, _textheight}); - dsp.print(_text); - //dsp.clearClipping(); + if(_fb->ready()){ + #ifdef PSFBUFFER + _fb->fillRect(0, 0, _width, _textheight, _bgcolor); + _fb->setCursor(_realLeft(true), 0); + _fb->print(_text); + _fb->display(); + #endif + } else { + dsp.fillRect(_config.left, _config.top, _width, _textheight, _bgcolor); + dsp.setCursor(_realLeft(), _config.top); + //dsp.setClipping({_config.left, _config.top, _width, _textheight}); + dsp.print(_text); + //dsp.clearClipping(); + } } strlcpy(_oldtext, _text, _buffsize); } @@ -164,21 +208,30 @@ void ScrollWidget::setText(const char* txt, const char *format){ void ScrollWidget::loop() { if(_locked) return; if (!_doscroll || _config.textsize == 0 || (dsp.getScrollId() != NULL && dsp.getScrollId() != this)) return; - if (_checkDelay(_x == _config.left ? _startscrolldelay : _scrolltime, _scrolldelay)) { + uint16_t fbl = _fb->ready()?0:_config.left; + if (_checkDelay(_x == fbl ? _startscrolldelay : _scrolltime, _scrolldelay)) { _calcX(); if (_active) _draw(); } } void ScrollWidget::_clear(){ - dsp.fillRect(_config.left, _config.top, _width, _textheight, _bgcolor); + if(_fb->ready()){ + #ifdef PSFBUFFER + _fb->fillRect(0, 0, _width, _textheight, _bgcolor); + _fb->display(); + #endif + } else { + dsp.fillRect(_config.left, _config.top, _width, _textheight, _bgcolor); + } } void ScrollWidget::_draw() { if(!_active || _locked) return; _setTextParams(); if (_doscroll) { - uint16_t _newx = _config.left - _x; + uint16_t fbl = _fb->ready()?0:_config.left; + uint16_t _newx = fbl - _x; const char* _cursor = _text + _newx / _charWidth; uint16_t hiddenChars = _cursor - _text; if (hiddenChars < strlen(_text)) { @@ -187,27 +240,45 @@ void ScrollWidget::_draw() { const char* _scursor = _sep + (_cursor - (_text + strlen(_text))); snprintf(_window, _width / _charWidth + 1, "%s%s", _scursor, _text); } - dsp.setCursor(_x + hiddenChars * _charWidth, _config.top); - dsp.setClipping({_config.left, _config.top, _width, _textheight}); - dsp.print(_window); - #ifndef DSP_LCD - dsp.print(" "); + if(_fb->ready()){ + #ifdef PSFBUFFER + _fb->setCursor(_x + hiddenChars * _charWidth, 0); + _fb->print(_window); + _fb->display(); #endif - dsp.clearClipping(); + } else { + dsp.setCursor(_x + hiddenChars * _charWidth, _config.top); + dsp.setClipping({_config.left, _config.top, _width, _textheight}); + dsp.print(_window); + #ifndef DSP_LCD + dsp.print(" "); + #endif + dsp.clearClipping(); + } } else { - dsp.fillRect(_config.left, _config.top, _width, _textheight, _bgcolor); - dsp.setCursor(_realLeft(), _config.top); - dsp.setClipping({_realLeft(), _config.top, _width, _textheight}); - dsp.print(_text); - dsp.clearClipping(); + if(_fb->ready()){ + #ifdef PSFBUFFER + _fb->fillRect(0, 0, _width, _textheight, _bgcolor); + _fb->setCursor(_realLeft(true), 0); + _fb->print(_text); + _fb->display(); + #endif + } else { + dsp.fillRect(_config.left, _config.top, _width, _textheight, _bgcolor); + dsp.setCursor(_realLeft(), _config.top); + dsp.setClipping({_realLeft(), _config.top, _width, _textheight}); + dsp.print(_text); + dsp.clearClipping(); + } } } void ScrollWidget::_calcX() { if (!_doscroll || _config.textsize == 0) return; _x -= _scrolldelta; - if (-_x > _textwidth + _sepwidth - _config.left) { - _x = _config.left; + uint16_t fbl = _fb->ready()?0:_config.left; + if (-_x > _textwidth + _sepwidth - fbl) { + _x = fbl; dsp.setScrollId(NULL); } else { dsp.setScrollId(this); @@ -225,9 +296,14 @@ bool ScrollWidget::_checkDelay(int m, uint32_t &tstamp) { void ScrollWidget::_reset(){ dsp.setScrollId(NULL); - _x = _config.left; + _x = _fb->ready()?0:_config.left; _scrolldelay = millis(); _doscroll = _checkIsScrollNeeded(); + #ifdef PSFBUFFER + _fb->freeBuffer(); + uint16_t _rl = (_config.align==WA_CENTER)?(dsp.width()-_width)/2:_config.left; + _fb->begin(&dsp, _rl, _config.top, _width, _textheight, _bgcolor); + #endif } /************************ @@ -343,12 +419,26 @@ void VuWidget::_draw(){ #else _canvas->fillRect(0, 0, _bands.width-(_bands.width-measL), _bands.width, _bgcolor); _canvas->fillRect(_bands.width * 2 + _bands.space - measR, 0, measR, _bands.width, _bgcolor); + #if DSP_MODEL!=DSP_ILI9225 + dsp.startWrite(); + dsp.setAddrWindow(_config.left, _config.top, _bands.width * 2 + _bands.space, _bands.height); + dsp.writePixels((uint16_t*)_canvas->getBuffer(), (_bands.width * 2 + _bands.space)*_bands.height); + dsp.endWrite(); + #else dsp.drawRGBBitmap(_config.left, _config.top, _canvas->getBuffer(), _bands.width * 2 + _bands.space, _bands.height); + #endif #endif }else{ _canvas->fillRect(0, 0, _bands.width, measL, _bgcolor); _canvas->fillRect(_bands.width + _bands.space, 0, _bands.width, measR, _bgcolor); + #if DSP_MODEL!=DSP_ILI9225 + dsp.startWrite(); + dsp.setAddrWindow(_config.left, _config.top, _bands.width * 2 + _bands.space, _bands.height); + dsp.writePixels((uint16_t*)_canvas->getBuffer(), (_bands.width * 2 + _bands.space)*_bands.height); + dsp.endWrite(); + #else dsp.drawRGBBitmap(_config.left, _config.top, _canvas->getBuffer(), _bands.width * 2 + _bands.space, _bands.height); + #endif } } @@ -368,6 +458,53 @@ void VuWidget::_draw(){ } void VuWidget::loop(){ } void VuWidget::_clear(){ } #endif + +/************************ + NUM & CLOCK + ************************/ +#if !defined(DSP_LCD) + #if TIME_SIZE<19 //19->NOKIA + const GFXfont* Clock_GFXfontPtr = nullptr; + #define CLOCKFONT5x7 + #else + const GFXfont* Clock_GFXfontPtr = &Clock_GFXfont; + #endif +#endif //!defined(DSP_LCD) + +#if !defined(CLOCKFONT5x7) && !defined(DSP_LCD) + inline GFXglyph *pgm_read_glyph_ptr(const GFXfont *gfxFont, uint8_t c) { + return gfxFont->glyph + c; + } + uint8_t _charWidth(unsigned char c){ + GFXglyph *glyph = pgm_read_glyph_ptr(&Clock_GFXfont, c - 0x20); + return pgm_read_byte(&glyph->xAdvance); + } + uint16_t _textHeight(){ + GFXglyph *glyph = pgm_read_glyph_ptr(&Clock_GFXfont, '8' - 0x20); + return pgm_read_byte(&glyph->height); + } +#else //!defined(CLOCKFONT5x7) && !defined(DSP_LCD) + uint8_t _charWidth(unsigned char c){ + #ifndef DSP_LCD + return CHARWIDTH * TIME_SIZE; + #else + return 1; + #endif + } + uint16_t _textHeight(){ + return CHARHEIGHT * TIME_SIZE; + } +#endif +uint16_t _textWidth(const char *txt){ + uint16_t w = 0, l=strlen(txt); + for(uint16_t c=0;c35 || DSP_MODEL==DSP_ILI9225; + if(_fullclock) _superfont = TIME_SIZE / 17; //magick + else if(TIME_SIZE==19 || TIME_SIZE==2) _superfont=1; + else _superfont=0; + _space = (5*_superfont)/2; //magick + if(_fullclock){ + _dateheight = _superfont<4?1:2; + _clockheight = _timeheight + _space + CHARHEIGHT * _dateheight; + } else { + _clockheight = _timeheight; + } + _getTimeBounds(); +#ifdef PSFBUFFER + _fb = new psFrameBuffer(dsp.width(), dsp.height()); + _begin(); +#endif +} + +void ClockWidget::_begin(){ +#ifdef PSFBUFFER + _fb->begin(&dsp, _clockleft, _config.top-_timeheight, _clockwidth, _clockheight+1, config.theme.background); +#endif +} + +bool ClockWidget::_getTime(){ + strftime(_timebuffer, sizeof(_timebuffer), "%H:%M", &network.timeinfo); + bool ret = network.timeinfo.tm_sec==0 || _forceflag!=network.timeinfo.tm_year; + _forceflag = network.timeinfo.tm_year; + return ret; +} + +uint16_t ClockWidget::_left(){ + if(_fb->ready()) return 0; else return _clockleft; +} +uint16_t ClockWidget::_top(){ + if(_fb->ready()) return _timeheight; else return _config.top; +} + +void ClockWidget::_getTimeBounds() { + _timewidth = _textWidth(_timebuffer); + uint8_t fs = _superfont>0?_superfont:TIME_SIZE; + uint16_t rightside = CHARWIDTH * fs * 2; // seconds + if(_fullclock){ + rightside += _space*2+1; //2space+vline + _clockwidth = _timewidth+rightside; + } else { + if(_superfont==0) + _clockwidth = _timewidth; + else + _clockwidth = _timewidth + rightside; + } + switch(_config.align){ + case WA_LEFT: _clockleft = _config.left; break; + case WA_RIGHT: _clockleft = dsp.width()-_clockwidth-_config.left; break; + default: + _clockleft = (dsp.width()/2 - _clockwidth/2)+_config.left; + break; + } + char buf[4]; + strftime(buf, 4, "%H", &network.timeinfo); + _dotsleft=_textWidth(buf); +} + +#ifndef DSP_LCD +#if DSP_MODEL==DSP_ILI9225 + auto& ClockWidget::getRealDsp(){ + return dsp; + } +#else + Adafruit_GFX& ClockWidget::getRealDsp(){ + #ifdef PSFBUFFER + if (_fb && _fb->ready()) return *_fb; + #endif + return dsp; + } +#endif +void ClockWidget::_printClock(bool force){ + auto& gfx = getRealDsp(); + gfx.setTextSize(Clock_GFXfontPtr==nullptr?TIME_SIZE:1); + gfx.setFont(Clock_GFXfontPtr); + bool clockInTitle=!config.isScreensaver && _config.top<_timeheight; //DSP_SSD1306x32 + if(force){ + _clearClock(); + _getTimeBounds(); + #ifndef DSP_OLED + if(CLOCKFONT_MONO) { + gfx.setTextColor(config.theme.clockbg, config.theme.background); + gfx.setCursor(_left(), _top()); + gfx.print("88:88"); + } + #endif + if(clockInTitle) + gfx.setTextColor(config.theme.meta, config.theme.metabg); + else + gfx.setTextColor(config.theme.clock, config.theme.background); + gfx.setCursor(_left(), _top()); + gfx.print(_timebuffer); + if(_fullclock){ + // lines, date & dow + bool fullClockOnScreensaver = (!config.isScreensaver || (_fb->ready() && FULL_SCR_CLOCK)); + _linesleft = _left()+_timewidth+_space; + if(fullClockOnScreensaver){ + gfx.drawFastVLine(_linesleft, _top()-_timeheight, _timeheight, config.theme.div); + gfx.drawFastHLine(_linesleft, _top()-(_timeheight)/2, CHARWIDTH * _superfont * 2 + _space, config.theme.div); + gfx.setFont(); + gfx.setTextSize(_superfont); + gfx.setCursor(_linesleft+_space+1, _top()-CHARHEIGHT * _superfont); + gfx.setTextColor(config.theme.dow, config.theme.background); + gfx.print(utf8Rus(LANG::dow[network.timeinfo.tm_wday], false)); + sprintf(_tmp, "%2d %s %d", network.timeinfo.tm_mday,LANG::mnths[network.timeinfo.tm_mon], network.timeinfo.tm_year+1900); + strlcpy(_datebuf, utf8Rus(_tmp, true), sizeof(_datebuf)); + uint16_t _datewidth = strlen(_datebuf) * CHARWIDTH*_dateheight; + gfx.setTextSize(_dateheight); + #if DSP_MODEL==DSP_GC9A01A + gfx.setCursor((dsp.width()-_datewidth)/2, _top() + _space); + #else + gfx.setCursor(_left()+_clockwidth-_datewidth, _top() + _space); + #endif + gfx.setTextColor(config.theme.date, config.theme.background); + gfx.print(_datebuf); + } + } + } + if(_fullclock || _superfont>0){ + gfx.setFont(); + gfx.setTextSize(_superfont); + if(!_fullclock){ + #ifndef CLOCKFONT5x7 + gfx.setCursor(_left()+_timewidth+_space, _top()-_timeheight+_space); + #else + gfx.setCursor(_left()+_timewidth+_space, _top()); + #endif + }else{ + gfx.setCursor(_linesleft+_space+1, _top()-_timeheight); + } + gfx.setTextColor(config.theme.seconds, config.theme.background); + sprintf(_tmp, "%02d", network.timeinfo.tm_sec); + gfx.print(_tmp); + } + gfx.setTextSize(Clock_GFXfontPtr==nullptr?TIME_SIZE:1); + gfx.setFont(Clock_GFXfontPtr); + #ifndef DSP_OLED + gfx.setTextColor(dots ? config.theme.clock : (CLOCKFONT_MONO?config.theme.clockbg:config.theme.background), config.theme.background); + #else + if(clockInTitle) + gfx.setTextColor(dots ? config.theme.meta:config.theme.metabg, config.theme.metabg); + else + gfx.setTextColor(dots ? config.theme.clock:config.theme.background, config.theme.background); + #endif + dots=!dots; + gfx.setCursor(_left()+_dotsleft, _top()); + gfx.print(":"); + gfx.setFont(); + if(_fb->ready()) _fb->display(); +} + +void ClockWidget::_clearClock(){ +#ifdef PSFBUFFER + if(_fb->ready()) _fb->clear(); + else +#endif +#ifndef CLOCKFONT5x7 + dsp.fillRect(_left(), _top()-_timeheight, _clockwidth, _clockheight+1, config.theme.background); +#else + dsp.fillRect(_left(), _top(), _clockwidth+1, _clockheight+1, config.theme.background); +#endif +} + void ClockWidget::draw(){ if(!_active) return; - dsp.printClock(_config.top, _config.left, _config.textsize, false); + _printClock(_getTime()); } void ClockWidget::_draw(){ if(!_active) return; - dsp.printClock(_config.top, _config.left, _config.textsize, true); + _printClock(true); +} + +void ClockWidget::_reset(){ +#ifdef PSFBUFFER + if(_fb->ready()) { + _fb->freeBuffer(); + _getTimeBounds(); + _begin(); + } +#endif } void ClockWidget::_clear(){ - dsp.clearClock(); + _clearClock(); +} +#else //#ifndef DSP_LCD + +void ClockWidget::_printClock(bool force){ + strftime(_timebuffer, sizeof(_timebuffer), "%H:%M", &network.timeinfo); + if(force){ + dsp.setCursor(dsp.width()-5, 0); + dsp.print(_timebuffer); + } + dsp.setCursor(dsp.width()-5+2, 0); + dsp.print((network.timeinfo.tm_sec % 2 == 0)?":":" "); } +void ClockWidget::_clearClock(){} + +void ClockWidget::draw(){ + if(!_active) return; + _printClock(true); +} +void ClockWidget::_draw(){ + if(!_active) return; + _printClock(true); +} +void ClockWidget::_reset(){} +void ClockWidget::_clear(){} +#endif //#ifndef DSP_LCD + +/************************** + BITRATE WIDGET + **************************/ void BitrateWidget::init(BitrateConfig bconf, uint16_t fgcolor, uint16_t bgcolor){ Widget::init(bconf.widget, fgcolor, bgcolor); _dimension = bconf.dimension; _bitrate = 0; - _format = BF_UNCNOWN; - dsp.charSize(bconf.widget.textsize, _charWidth, _textheight); + _format = BF_UNKNOWN; + _charSize(bconf.widget.textsize, _charWidth, _textheight); memset(_buf, 0, 6); } @@ -480,9 +835,20 @@ void BitrateWidget::setFormat(BitrateFormat format){ _draw(); } +//TODO move to parent +void BitrateWidget::_charSize(uint8_t textsize, uint8_t& width, uint16_t& height){ +#ifndef DSP_LCD + width = textsize * CHARWIDTH; + height = textsize * CHARHEIGHT; +#else + width = 1; + height = 1; +#endif +} + void BitrateWidget::_draw(){ _clear(); - if(!_active || _format == BF_UNCNOWN || _bitrate==0) return; + if(!_active || _format == BF_UNKNOWN || _bitrate==0) return; dsp.drawRect(_config.left, _config.top, _dimension, _dimension, _fgcolor); dsp.fillRect(_config.left, _config.top + _dimension/2, _dimension, _dimension/2, _fgcolor); dsp.setFont(); @@ -507,4 +873,104 @@ void BitrateWidget::_clear() { dsp.fillRect(_config.left, _config.top, _dimension, _dimension, _bgcolor); } + +/************************** + PLAYLIST WIDGET + **************************/ +void PlayListWidget::init(ScrollWidget* current){ + Widget::init({0, 0, 0, WA_LEFT}, 0, 0); + _current = current; + #ifndef DSP_LCD + _plItemHeight = playlistConf.widget.textsize*(CHARHEIGHT-1)+playlistConf.widget.textsize*4; + _plTtemsCount = round((float)dsp.height()/_plItemHeight); + if(_plTtemsCount%2==0) _plTtemsCount++; + _plCurrentPos = _plTtemsCount/2; + _plYStart = (dsp.height() / 2 - _plItemHeight / 2) - _plItemHeight * (_plTtemsCount - 1) / 2 + playlistConf.widget.textsize*2; + #else + _plTtemsCount = PLMITEMS; + _plCurrentPos = 1; + #endif +} + +uint8_t PlayListWidget::_fillPlMenu(int from, uint8_t count) { + int ls = from; + uint8_t c = 0; + bool finded = false; + if (config.playlistLength() == 0) { + return 0; + } + File playlist = config.SDPLFS()->open(REAL_PLAYL, "r"); + File index = config.SDPLFS()->open(REAL_INDEX, "r"); + while (true) { + if (ls < 1) { + ls++; + _printPLitem(c, ""); + c++; + continue; + } + if (!finded) { + index.seek((ls - 1) * 4, SeekSet); + uint32_t pos; + index.readBytes((char *) &pos, 4); + finded = true; + index.close(); + playlist.seek(pos, SeekSet); + } + bool pla = true; + while (pla) { + pla = playlist.available(); + String stationName = playlist.readStringUntil('\n'); + stationName = stationName.substring(0, stationName.indexOf('\t')); + if(config.store.numplaylist && stationName.length()>0) stationName = String(from+c)+" "+stationName; + _printPLitem(c, stationName.c_str()); + c++; + if (c >= count) break; + } + break; + } + playlist.close(); + return c; +} +#ifndef DSP_LCD +void PlayListWidget::drawPlaylist(uint16_t currentItem) { + uint8_t lastPos = _fillPlMenu(currentItem - _plCurrentPos, _plTtemsCount); + if(lastPos<_plTtemsCount){ + dsp.fillRect(0, lastPos*_plItemHeight+_plYStart, dsp.width(), dsp.height()/2, config.theme.background); + } +} + +void PlayListWidget::_printPLitem(uint8_t pos, const char* item){ + dsp.setTextSize(playlistConf.widget.textsize); + if (pos == _plCurrentPos) { + _current->setText(item); + } else { + uint8_t plColor = (abs(pos - _plCurrentPos)-1)>4?4:abs(pos - _plCurrentPos)-1; + dsp.setTextColor(config.theme.playlist[plColor], config.theme.background); + dsp.setCursor(TFT_FRAMEWDT, _plYStart + pos * _plItemHeight); + dsp.fillRect(0, _plYStart + pos * _plItemHeight - 1, dsp.width(), _plItemHeight - 2, config.theme.background); + Serial.println(item); + dsp.print(utf8Rus(item, true)); + } +} +#else +void PlayListWidget::_printPLitem(uint8_t pos, const char* item){ + if (pos == _plCurrentPos) { + _current->setText(item); + } else { + dsp.setCursor(1, pos); + char tmp[dsp.width()] = {0}; + strlcpy(tmp, utf8Rus(item, true), dsp.width()); + dsp.print(tmp); + } +} + +void PlayListWidget::drawPlaylist(uint16_t currentItem) { + dsp.clear(); + _fillPlMenu(currentItem - _plCurrentPos, _plTtemsCount); + dsp.setCursor(0,1); + dsp.write(uint8_t(126)); +} +#endif + + #endif // #if DSP_MODEL!=DSP_DUMMY diff --git a/yoRadio/src/displays/widgets/widgets.h b/yoRadio/src/displays/widgets/widgets.h index 9d05e5e..eef58fb 100644 --- a/yoRadio/src/displays/widgets/widgets.h +++ b/yoRadio/src/displays/widgets/widgets.h @@ -1,67 +1,17 @@ #ifndef widgets_h #define widgets_h +#if DSP_MODEL!=DSP_DUMMY +#include "widgetsconfig.h" -#include "Arduino.h" -#include "../../core/config.h" -enum WidgetAlign { WA_LEFT, WA_CENTER, WA_RIGHT }; +#ifndef DSP_LCD + #define CHARWIDTH 6 + #define CHARHEIGHT 8 +#else + #define CHARWIDTH 1 + #define CHARHEIGHT 1 +#endif - -typedef struct clipArea { - uint16_t left; - uint16_t top; - uint16_t width; - uint16_t height; -} clipArea; - -struct WidgetConfig { - uint16_t left; - uint16_t top; - uint16_t textsize; - WidgetAlign align; -}; - -struct ScrollConfig { - WidgetConfig widget; - uint16_t buffsize; - bool uppercase; - uint16_t width; - uint16_t startscrolldelay; - uint8_t scrolldelta; - uint16_t scrolltime; -}; - -struct FillConfig { - WidgetConfig widget; - uint16_t width; - uint16_t height; - bool outlined; -}; - -struct ProgressConfig { - uint16_t speed; - uint16_t width; - uint16_t barwidth; -}; - -struct VUBandsConfig { - uint16_t width; - uint16_t height; - uint8_t space; - uint8_t vspace; - uint8_t perheight; - uint8_t fadespeed; -}; - -struct MoveConfig { - uint16_t x; - uint16_t y; - int16_t width; -}; - -struct BitrateConfig { - WidgetConfig widget; - uint16_t dimension; -}; +class psFrameBuffer; class Widget{ public: @@ -133,7 +83,8 @@ class TextWidget: public Widget { uint8_t _charWidth; protected: void _draw(); - uint16_t _realLeft(); + uint16_t _realLeft(bool w_fb=false); + void _charSize(uint8_t textsize, uint8_t& width, uint16_t& height); }; class FillWidget: public Widget { @@ -168,6 +119,7 @@ class ScrollWidget: public TextWidget { uint32_t _scrolldelay; uint16_t _sepwidth, _startscrolldelay; uint8_t _charWidth; + psFrameBuffer* _fb=nullptr; private: void _setTextParams(); void _calcX(); @@ -201,7 +153,8 @@ class SliderWidget: public Widget { class VuWidget: public Widget { public: VuWidget() {} - VuWidget(WidgetConfig wconf, VUBandsConfig bands, uint16_t vumaxcolor, uint16_t vumincolor, uint16_t bgcolor) { init(wconf, bands, vumaxcolor, vumincolor, bgcolor); } + VuWidget(WidgetConfig wconf, VUBandsConfig bands, uint16_t vumaxcolor, uint16_t vumincolor, uint16_t bgcolor) + { init(wconf, bands, vumaxcolor, vumincolor, bgcolor); } ~VuWidget(); using Widget::init; void init(WidgetConfig wconf, VUBandsConfig bands, uint16_t vumaxcolor, uint16_t vumincolor, uint16_t bgcolor); @@ -250,10 +203,41 @@ class ProgressWidget: public TextWidget { class ClockWidget: public Widget { public: + using Widget::init; + void init(WidgetConfig wconf, uint16_t fgcolor, uint16_t bgcolor); void draw(); + uint8_t textsize(){ return _config.textsize; } + void clear(){ _clearClock(); } + inline uint16_t dateSize(){ return _space+ _dateheight; } + inline uint16_t clockWidth(){ return _clockwidth; } + private: + #ifndef DSP_LCD + #if DSP_MODEL==DSP_ILI9225 + auto &getRealDsp(); + #else + Adafruit_GFX &getRealDsp(); + #endif + #endif protected: + char _timebuffer[20]="00:00"; + char _tmp[30], _datebuf[30]; + uint8_t _superfont; + uint16_t _clockleft, _clockwidth, _timewidth, _dotsleft, _linesleft; + uint8_t _clockheight, _timeheight, _dateheight, _space; + uint16_t _forceflag = 0; + bool dots = true; + bool _fullclock; + psFrameBuffer* _fb=nullptr; void _draw(); void _clear(); + void _reset(); + void _getTimeBounds(); + void _printClock(bool force=false); + void _clearClock(); + bool _getTime(); + uint16_t _left(); + uint16_t _top(); + void _begin(); }; class BitrateWidget: public Widget { @@ -272,6 +256,29 @@ class BitrateWidget: public Widget { uint16_t _dimension, _bitrate, _textheight; void _draw(); void _clear(); + void _charSize(uint8_t textsize, uint8_t& width, uint16_t& height); }; +class PlayListWidget: public Widget { + public: + using Widget::init; + void init(ScrollWidget* current); + void drawPlaylist(uint16_t currentItem); + inline uint16_t itemHeight(){ return _plItemHeight; } + inline uint16_t currentTop(){ return _plYStart+_plCurrentPos*_plItemHeight; } + private: + ScrollWidget* _current; + uint16_t _plItemHeight, _plTtemsCount, _plCurrentPos; + int _plYStart; + uint8_t _fillPlMenu(int from, uint8_t count); + void _printPLitem(uint8_t pos, const char* item); + +}; + + #endif +#endif + + + + diff --git a/yoRadio/src/displays/widgets/widgetsconfig.h b/yoRadio/src/displays/widgets/widgetsconfig.h new file mode 100644 index 0000000..355c674 --- /dev/null +++ b/yoRadio/src/displays/widgets/widgetsconfig.h @@ -0,0 +1,57 @@ +#ifndef widgetsconfig_h +#define widgetsconfig_h + +enum WidgetAlign { WA_LEFT, WA_CENTER, WA_RIGHT }; +enum BitrateFormat { BF_UNKNOWN, BF_MP3, BF_AAC, BF_FLAC, BF_OGG, BF_WAV }; + +struct WidgetConfig { + uint16_t left; + uint16_t top; + uint16_t textsize; + WidgetAlign align; +}; + +struct ScrollConfig { + WidgetConfig widget; + uint16_t buffsize; + bool uppercase; + uint16_t width; + uint16_t startscrolldelay; + uint8_t scrolldelta; + uint16_t scrolltime; +}; + +struct FillConfig { + WidgetConfig widget; + uint16_t width; + uint16_t height; + bool outlined; +}; + +struct ProgressConfig { + uint16_t speed; + uint16_t width; + uint16_t barwidth; +}; + +struct VUBandsConfig { + uint16_t width; + uint16_t height; + uint8_t space; + uint8_t vspace; + uint8_t perheight; + uint8_t fadespeed; +}; + +struct MoveConfig { + uint16_t x; + uint16_t y; + int16_t width; +}; + +struct BitrateConfig { + WidgetConfig widget; + uint16_t dimension; +}; + +#endif diff --git a/yoRadio/src/main.cpp b/yoRadio/src/main.cpp index 2000e30..87dfbd8 100644 --- a/yoRadio/src/main.cpp +++ b/yoRadio/src/main.cpp @@ -1,6 +1,7 @@ #include "Arduino.h" #include "core/options.h" #include "core/config.h" +#include "pluginsManager/pluginsManager.h" #include "core/telnet.h" #include "core/player.h" #include "core/display.h" @@ -10,6 +11,9 @@ #include "core/mqtt.h" #include "core/optionschecker.h" #include "core/timekeeper.h" +#ifdef USE_NEXTION +#include "displays/nextion.h" +#endif #if USE_OTA #if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0) diff --git a/yoRadio/src/pluginsManager/pluginsManager.h b/yoRadio/src/pluginsManager/pluginsManager.h index 758e443..958cf4d 100644 --- a/yoRadio/src/pluginsManager/pluginsManager.h +++ b/yoRadio/src/pluginsManager/pluginsManager.h @@ -121,24 +121,24 @@ public: Plugin* get(size_t index); requestParams_t *request; template - void call_event(Func&& func, Args&&... args){ + inline void call_event(Func&& func, Args&&... args){ for (auto* plugin : plugins) { if (plugin) { (plugin->*func)(std::forward(args)...); } } } - void on_setup(){ call_event(&Plugin::on_setup); } - void on_end_setup(){ call_event(&Plugin::on_end_setup); } - void on_connect(){ call_event(&Plugin::on_connect); } - void on_start_play(){ call_event(&Plugin::on_start_play); } - void on_stop_play(){ call_event(&Plugin::on_stop_play); } - void on_track_change(){ call_event(&Plugin::on_track_change); } - void on_station_change(){ call_event(&Plugin::on_station_change); } - void on_display_queue(requestParams_t &request, bool& result){ call_event(&Plugin::on_display_queue, request, result); } - void on_display_player(){ call_event(&Plugin::on_display_player); } - void on_ticker(){ call_event(&Plugin::on_ticker); } - void on_btn_click(controlEvt_e &btnid){ call_event(&Plugin::on_btn_click, btnid); } + inline void on_setup(){ call_event(&Plugin::on_setup); } + inline void on_end_setup(){ call_event(&Plugin::on_end_setup); } + inline void on_connect(){ call_event(&Plugin::on_connect); } + inline void on_start_play(){ call_event(&Plugin::on_start_play); } + inline void on_stop_play(){ call_event(&Plugin::on_stop_play); } + inline void on_track_change(){ call_event(&Plugin::on_track_change); } + inline void on_station_change(){ call_event(&Plugin::on_station_change); } + inline void on_display_queue(requestParams_t &request, bool& result){ call_event(&Plugin::on_display_queue, request, result); } + inline void on_display_player(){ call_event(&Plugin::on_display_player); } + inline void on_ticker(){ call_event(&Plugin::on_ticker); } + inline void on_btn_click(controlEvt_e &btnid){ call_event(&Plugin::on_btn_click, btnid); } private: std::vector plugins; };