v0.8.100
This commit is contained in:
66
yoRadio/src/displays/conf/displayGC9A01Aconf.h
Normal file
66
yoRadio/src/displays/conf/displayGC9A01Aconf.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/*************************************************************************************
|
||||
ST7789 240x240 displays configuration file.
|
||||
Copy this file to yoRadio/src/displays/conf/displayST7789conf_custom.h
|
||||
and modify it
|
||||
More info on https://github.com/e2002/yoradio/wiki/Widgets#widgets-description
|
||||
*************************************************************************************/
|
||||
|
||||
#ifndef displayST7789conf_h
|
||||
#define displayST7789conf_h
|
||||
|
||||
#define DSP_WIDTH 240
|
||||
#define TFT_FRAMEWDT 8
|
||||
#define MAX_WIDTH DSP_WIDTH-TFT_FRAMEWDT*2
|
||||
#define PLMITEMS 11
|
||||
#define PLMITEMLENGHT 40
|
||||
#define PLMITEMHEIGHT 22
|
||||
|
||||
#define bootLogoTop 68
|
||||
#define HIDE_TITLE2
|
||||
/* SROLLS */ /* {{ left, top, fontsize, align }, buffsize, uppercase, width, scrolldelay, scrolldelta, scrolltime } */
|
||||
const ScrollConfig metaConf PROGMEM = {{ TFT_FRAMEWDT+12, TFT_FRAMEWDT+28+20, 3, WA_CENTER }, 140, true, MAX_WIDTH-24, 5000, 5, 30 };
|
||||
const ScrollConfig title1Conf PROGMEM = {{ TFT_FRAMEWDT, /*70*/90, 2, WA_CENTER }, 140, true, MAX_WIDTH, 5000, 4, 30 };
|
||||
const ScrollConfig title2Conf PROGMEM = {{ TFT_FRAMEWDT, 90, 2, WA_CENTER }, 140, true, MAX_WIDTH, 5000, 4, 30 };
|
||||
const ScrollConfig playlistConf PROGMEM = {{ TFT_FRAMEWDT, 112, 2, WA_LEFT }, 140, true, MAX_WIDTH, 0, 2, 30 };
|
||||
const ScrollConfig apTitleConf PROGMEM = {{ TFT_FRAMEWDT+12, TFT_FRAMEWDT+28+20, 3, WA_CENTER }, 140, false, MAX_WIDTH, 0, 4, 20 };
|
||||
const ScrollConfig apSettConf PROGMEM = {{ TFT_FRAMEWDT, 240-TFT_FRAMEWDT-16, 2, WA_LEFT }, 140, false, MAX_WIDTH, 0, 4, 30 };
|
||||
const ScrollConfig weatherConf PROGMEM = {{ TFT_FRAMEWDT+30, 36, 1, WA_LEFT }, 140, true, MAX_WIDTH-60, 0, 3, 30 };
|
||||
/* BACKGROUNDS */ /* {{ left, top, fontsize, align }, width, height, outlined } */
|
||||
const FillConfig metaBGConf PROGMEM = {{ 0, 32+20, 0, WA_LEFT }, DSP_WIDTH, 30, false };
|
||||
const FillConfig volbarConf PROGMEM = {{ TFT_FRAMEWDT+56, 240-TFT_FRAMEWDT-6, 0, WA_LEFT }, MAX_WIDTH-112, 6+TFT_FRAMEWDT+1, true };
|
||||
const FillConfig playlBGConf PROGMEM = {{ 0, 107, 0, WA_LEFT }, DSP_WIDTH, 24, false };
|
||||
const FillConfig heapbarConf PROGMEM = {{ 0, 83, 0, WA_LEFT }, DSP_WIDTH, 1, false };
|
||||
|
||||
/* WIDGETS */ /* { left, top, fontsize, align } */
|
||||
const WidgetConfig bootstrConf PROGMEM = { 0, 182, 1, WA_CENTER };
|
||||
const WidgetConfig bitrateConf PROGMEM = { 134, 20, 1, WA_RIGHT };
|
||||
const WidgetConfig voltxtConf PROGMEM = { 80, 6, 1, WA_CENTER };
|
||||
const WidgetConfig iptxtConf PROGMEM = { TFT_FRAMEWDT, 214, 1, WA_CENTER };
|
||||
const WidgetConfig rssiConf PROGMEM = { 134, 20, 1, WA_LEFT };
|
||||
const WidgetConfig numConf PROGMEM = { 0, 120+30+20, 52, WA_CENTER };
|
||||
const WidgetConfig apNameConf PROGMEM = { TFT_FRAMEWDT, 86, 2, WA_CENTER };
|
||||
const WidgetConfig apName2Conf PROGMEM = { TFT_FRAMEWDT, 110, 2, WA_CENTER };
|
||||
const WidgetConfig apPassConf PROGMEM = { TFT_FRAMEWDT, 150, 2, WA_CENTER };
|
||||
const WidgetConfig apPass2Conf PROGMEM = { TFT_FRAMEWDT, 174, 2, WA_CENTER };
|
||||
const WidgetConfig clockConf PROGMEM = { 0, 176, 52, WA_CENTER }; /* 52 is a fixed font size. do not change */
|
||||
const WidgetConfig vuConf PROGMEM = { TFT_FRAMEWDT+10, 188, 1, WA_CENTER };
|
||||
|
||||
const WidgetConfig bootWdtConf PROGMEM = { 0, 162, 1, WA_CENTER };
|
||||
const ProgressConfig bootPrgConf PROGMEM = { 90, 14, 4 };
|
||||
|
||||
/* BANDS */ /* { onebandwidth, onebandheight, bandsHspace, bandsVspace, numofbands, fadespeed } */
|
||||
const VUBandsConfig bandsConf PROGMEM = { 90, 20, 10, 2, 10, 5 };
|
||||
|
||||
/* STRINGS */
|
||||
const char numtxtFmt[] PROGMEM = "%d";
|
||||
const char rssiFmt[] PROGMEM = "WIFI %d";
|
||||
const char iptxtFmt[] PROGMEM = "%s";
|
||||
const char voltxtFmt[] PROGMEM = "VOL %d";
|
||||
const char bitrateFmt[] PROGMEM = "%d KBS";
|
||||
|
||||
/* MOVES */ /* { left, top, width } */
|
||||
const MoveConfig clockMove PROGMEM = { 0, 164, 0 };
|
||||
const MoveConfig weatherMove PROGMEM = { TFT_FRAMEWDT, 202, -1 };
|
||||
const MoveConfig weatherMoveVU PROGMEM = { TFT_FRAMEWDT, 202, -1/*MAX_WIDTH*/ };
|
||||
|
||||
#endif
|
||||
226
yoRadio/src/displays/displayGC9A01A.cpp
Normal file
226
yoRadio/src/displays/displayGC9A01A.cpp
Normal file
@@ -0,0 +1,226 @@
|
||||
#include "../core/options.h"
|
||||
#if DSP_MODEL==DSP_GC9A01A
|
||||
|
||||
#include "displayGC9A01A.h"
|
||||
//#include <SPI.h>
|
||||
#include "fonts/bootlogo.h"
|
||||
#include "../core/player.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 */
|
||||
#endif
|
||||
|
||||
#define TAKE_MUTEX() if(player.mutex_pl) xSemaphoreTake(player.mutex_pl, portMAX_DELAY)
|
||||
#define GIVE_MUTEX() if(player.mutex_pl) xSemaphoreGive(player.mutex_pl)
|
||||
|
||||
#if DSP_HSPI
|
||||
DspCore::DspCore(): Adafruit_GC9A01A(&SPI2, TFT_CS, TFT_DC, TFT_RST) {}
|
||||
#else
|
||||
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);
|
||||
invert();
|
||||
cp437(true);
|
||||
flip();
|
||||
setTextWrap(false);
|
||||
setTextSize(1);
|
||||
fillScreen(0x0000);
|
||||
}
|
||||
|
||||
void DspCore::drawLogo(uint16_t top) { drawRGBBitmap((width() - 99) / 2, top, bootlogo2, 99, 64); }
|
||||
|
||||
void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
|
||||
for (byte i = 0; i < PLMITEMS; i++) {
|
||||
plMenu[i][0] = '\0';
|
||||
}
|
||||
config.fillPlMenu(plMenu, currentItem - 5, PLMITEMS);
|
||||
setTextSize(2);
|
||||
int yStart = (height() / 2 - PLMITEMHEIGHT / 2) - PLMITEMHEIGHT * (PLMITEMS - 1) / 2 + 3;
|
||||
|
||||
for (byte i = 0; i < PLMITEMS; i++) {
|
||||
if (i == 5) {
|
||||
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
|
||||
} else {
|
||||
setTextColor(config.theme.playlist[abs(i - 5)-1], config.theme.background);
|
||||
setCursor(TFT_FRAMEWDT, yStart + i * PLMITEMHEIGHT);
|
||||
fillRect(0, yStart + i * PLMITEMHEIGHT - 1, width(), PLMITEMHEIGHT - 2, config.theme.background);
|
||||
print(utf8Rus(plMenu[i], true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DspCore::clearDsp(bool black) { fillScreen(black?0:config.theme.background); }
|
||||
|
||||
GFXglyph *pgm_read_glyph_ptr(const GFXfont *gfxFont, uint8_t c) {
|
||||
return gfxFont->glyph + 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;c<l;c++) w+=_charWidth(txt[c]);
|
||||
return w;
|
||||
}
|
||||
|
||||
void DspCore::_getTimeBounds() {
|
||||
_timewidth = textWidth(_timeBuf);
|
||||
char buf[4];
|
||||
strftime(buf, 4, "%H", &network.timeinfo);
|
||||
_dotsLeft=textWidth(buf);
|
||||
}
|
||||
|
||||
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);
|
||||
print(_bufforseconds); /* print seconds */
|
||||
setTextSize(1);
|
||||
setFont(&DS_DIGI42pt7b);
|
||||
setTextColor((network.timeinfo.tm_sec % 2 == 0) ? config.theme.clock : 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);
|
||||
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) 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);
|
||||
setTextColor(config.theme.clock, config.theme.background);
|
||||
setCursor(_timeleft, clockTop);
|
||||
print(_timeBuf);
|
||||
setFont();
|
||||
strlcpy(_oldTimeBuf, _timeBuf, sizeof(_timeBuf));
|
||||
_oldtimewidth = _timewidth;
|
||||
_oldtimeleft = _timeleft;
|
||||
drawFastVLine(width()-clockRightSpace-CHARWIDTH*3*2-18, clockTop-clockTimeHeight, clockTimeHeight+3, config.theme.div); /*divider vert*/
|
||||
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(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) {
|
||||
TAKE_MUTEX();
|
||||
Adafruit_GC9A01A::startWrite();
|
||||
}
|
||||
|
||||
void DspCore::endWrite(void) {
|
||||
Adafruit_GC9A01A::endWrite();
|
||||
GIVE_MUTEX();
|
||||
}
|
||||
|
||||
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
|
||||
34
yoRadio/src/displays/displayGC9A01A.h
Normal file
34
yoRadio/src/displays/displayGC9A01A.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef displayGC9A01A_h
|
||||
#define displayGC9A01A_h
|
||||
#include "../core/options.h"
|
||||
|
||||
#include "Arduino.h"
|
||||
#include <Adafruit_GFX.h>
|
||||
#include "../Adafruit_GC9A01A/Adafruit_GC9A01A.h"
|
||||
#include "fonts/DS_DIGI42pt7b.h" // https://tchapi.github.io/Adafruit-GFX-Font-Customiser/
|
||||
#include "tools/l10n.h"
|
||||
|
||||
#define CHARWIDTH 6
|
||||
#define CHARHEIGHT 8
|
||||
|
||||
typedef GFXcanvas16 Canvas;
|
||||
#include "widgets/widgets.h"
|
||||
#include "widgets/pages.h"
|
||||
|
||||
#if __has_include("conf/displayGC9A01Aconf_custom.h")
|
||||
#include "conf/displayGC9A01Aconf_custom.h"
|
||||
#else
|
||||
#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
|
||||
@@ -36,6 +36,8 @@
|
||||
#include "displayILI9225.h"
|
||||
#elif DSP_MODEL==DSP_ST7796
|
||||
#include "displayST7796.h"
|
||||
#elif DSP_MODEL==DSP_GC9A01A
|
||||
#include "displayGC9A01A.h"
|
||||
#endif
|
||||
|
||||
//extern DspCore dsp;
|
||||
|
||||
Reference in New Issue
Block a user