ST7920_057
This commit is contained in:
147
yoRadio/src/ST7920/ST7920.cpp
Normal file
147
yoRadio/src/ST7920/ST7920.cpp
Normal file
@@ -0,0 +1,147 @@
|
||||
#include "../core/options.h"
|
||||
#include "../core/player.h"
|
||||
#if DSP_MODEL==DSP_ST7920
|
||||
|
||||
#include "Adafruit_GFX.h"
|
||||
#include "ST7920.h"
|
||||
|
||||
//uint8_t buff[1024]; //This array serves as primitive "Video RAM" buffer
|
||||
|
||||
//This display is split into two halfs. Pages are 16bit long and pages are arranged in that way that are lied horizontaly instead of verticaly, unlike SSD1306 OLED, Nokia 5110 LCD, etc.
|
||||
//After 8 horizonral page is written, it jumps to half of the screen (Y = 32) and continues until 16 lines of page have been written. After that, we have set cursor in new line.
|
||||
|
||||
#define TAKE_MUTEX() if(player.mutex_pl) xSemaphoreTake(player.mutex_pl, portMAX_DELAY)
|
||||
#define GIVE_MUTEX() if(player.mutex_pl) xSemaphoreGive(player.mutex_pl)
|
||||
#define st7920_swap(a, b) (((a) ^= (b)), ((b) ^= (a)), ((a) ^= (b)))
|
||||
|
||||
void ST7920::drawPixel(int16_t x, int16_t y, uint16_t color) {
|
||||
if(x<0 || x>=ST7920_WIDTH || y<0 || y>=ST7920_HEIGHT || _dosleep) return;
|
||||
switch (getRotation()) {
|
||||
case 1:
|
||||
st7920_swap(x, y);
|
||||
x = WIDTH - x - 1;
|
||||
break;
|
||||
case 2:
|
||||
x = WIDTH - x - 1;
|
||||
y = HEIGHT - y - 1;
|
||||
break;
|
||||
case 3:
|
||||
st7920_swap(x, y);
|
||||
y = HEIGHT - y - 1;
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
uint8_t y0 = 0, x0 = 0; //Define and initilize varilables for skiping rows
|
||||
uint16_t data, n; //Define variable for sending data itno buffer (basicly, that is one line of page)
|
||||
if (y > 31) { //If Y coordinate is bigger than 31, that means we have to skip into that row, but we have to do that by adding
|
||||
y -= 32;
|
||||
y0 = 16;
|
||||
}
|
||||
x0 = x % 16;
|
||||
x /= 16;
|
||||
data = 0x8000 >> x0;
|
||||
n = (x * 2) + (y0) + (32 * y);
|
||||
if(_invert) color = !color;
|
||||
if (!color) {
|
||||
buffer[n] &= (~data >> 8);
|
||||
buffer[n + 1] &= (~data & 0xFF);
|
||||
}else{
|
||||
buffer[n] |= (data >> 8);
|
||||
buffer[n + 1] |= (data & 0xFF);
|
||||
}
|
||||
}
|
||||
|
||||
ST7920::ST7920(SPIClass *spi, int8_t cs_pin, uint32_t bitrate) :
|
||||
Adafruit_GFX(ST7920_WIDTH, ST7920_HEIGHT), spi(spi), buffer(NULL),
|
||||
csPin(cs_pin) {
|
||||
spiSettings = SPISettings(bitrate, MSBFIRST, SPI_MODE3);
|
||||
}
|
||||
|
||||
ST7920::~ST7920(void) {
|
||||
if(buffer) {
|
||||
free(buffer);
|
||||
buffer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void ST7920::begin(void) {
|
||||
buffer = (uint8_t *)malloc( 1024 );
|
||||
_invert = false;
|
||||
_dosleep = false;
|
||||
spi->begin();
|
||||
pinMode(csPin, OUTPUT);
|
||||
ST7920Command(0x30); //LCD_BASIC);
|
||||
ST7920Command(0x30); //LCD_BASIC);
|
||||
ST7920Command(0x01); //LCD_CLS);
|
||||
delay(2);
|
||||
ST7920Command(0x06); //LCD_ADDRINC);
|
||||
|
||||
ST7920Command(0x0C); // ON
|
||||
ST7920Command(0x34); //LCD_EXTEND);
|
||||
ST7920Command(0x36); //LCD_GFXMODE);
|
||||
}
|
||||
|
||||
void ST7920::clearDisplay() {
|
||||
long* p = (long*)&buffer;
|
||||
for (int i = 0; i < 256; i++) {
|
||||
p[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void ST7920::display() {
|
||||
if(_dosleep) return;
|
||||
int x = 0, y = 0, n = 0;
|
||||
// ST7920Command(B00100100); //EXTENDED INSTRUCTION SET
|
||||
// ST7920Command(B00100110); //EXTENDED INSTRUCTION SET
|
||||
for (y = 0; y < 32; y++) {
|
||||
ST7920Command(0x80 | y);
|
||||
ST7920Command(0x80 | x);
|
||||
for (x = 0; x < 16; x++) {
|
||||
ST7920Data(buffer[n]);
|
||||
ST7920Data(buffer[n + 1]);
|
||||
n += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ST7920::doSleep(bool flag) {
|
||||
_dosleep = flag;
|
||||
ST7920Command(flag?ST7920_DISPLAYOFF:ST7920_DISPLAYON);
|
||||
delay(200);
|
||||
if(flag) ST7920Command(0x01);
|
||||
}
|
||||
|
||||
void ST7920::invertDisplay(bool flag) {
|
||||
for(int i = 0; i<1024; i++) {
|
||||
buffer[i] = ~buffer[i];
|
||||
}
|
||||
_invert = flag;
|
||||
}
|
||||
|
||||
void ST7920::ST7920Data(uint8_t data) { //RS = 1 RW = 0
|
||||
TAKE_MUTEX();
|
||||
spi->beginTransaction(spiSettings);
|
||||
digitalWrite(csPin, HIGH);
|
||||
spi->transfer(B11111010);
|
||||
spi->transfer((data & B11110000));
|
||||
spi->transfer((data & B00001111) << 4);
|
||||
digitalWrite(csPin, LOW);
|
||||
spi->endTransaction();
|
||||
GIVE_MUTEX();
|
||||
delayMicroseconds(38);
|
||||
}
|
||||
|
||||
void ST7920::ST7920Command(uint8_t data) { //RS = 0 RW = 0
|
||||
TAKE_MUTEX();
|
||||
spi->beginTransaction(spiSettings);
|
||||
digitalWrite(csPin, HIGH);
|
||||
spi->transfer(B11111000);
|
||||
spi->transfer((data & B11110000));
|
||||
spi->transfer((data & B00001111) << 4);
|
||||
digitalWrite(csPin, LOW);
|
||||
spi->endTransaction();
|
||||
GIVE_MUTEX();
|
||||
delayMicroseconds(38);
|
||||
}
|
||||
|
||||
#endif //#if DSP_MODEL==DSP_ST7920
|
||||
37
yoRadio/src/ST7920/ST7920.h
Normal file
37
yoRadio/src/ST7920/ST7920.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#include <SPI.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
|
||||
#define ST7920_HEIGHT 64 //64 pixels tall display
|
||||
#define ST7920_WIDTH 128 //128 pixels wide display
|
||||
|
||||
|
||||
#define ST7920_DISPLAYOFF 0x08
|
||||
#define ST7920_DISPLAYON 0x0C
|
||||
//#define ST7920_NORMALDISPLAY 0xA6
|
||||
//#define ST7920_INVERSEDISPLAY 0xA7
|
||||
|
||||
#define BLACK 0 //Defines color - Black color -> Bit in buffer is set to one
|
||||
#define WHITE 1 //Defines color - White color -> Bit in buffer is set to zero
|
||||
|
||||
class ST7920 : public Adafruit_GFX {
|
||||
public:
|
||||
//ST7920(int8_t CS);
|
||||
ST7920(SPIClass *spi, int8_t cs_pin, uint32_t bitrate=8000000UL);
|
||||
~ST7920(void);
|
||||
void begin(void);
|
||||
void clearDisplay(void);
|
||||
void invertDisplay(bool flag);
|
||||
void doSleep(bool flag);
|
||||
void display();
|
||||
void drawPixel(int16_t x, int16_t y, uint16_t color);
|
||||
void ST7920Data(uint8_t data);
|
||||
void ST7920Command(uint8_t data);
|
||||
private:
|
||||
SPIClass *spi;
|
||||
uint8_t *buffer;
|
||||
int8_t csPin;
|
||||
SPISettings spiSettings;
|
||||
bool _invert, _dosleep;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef options_h
|
||||
#define options_h
|
||||
|
||||
#define YOVERSION "0.9.045"
|
||||
#define YOVERSION "0.9.057"
|
||||
|
||||
/*******************************************************
|
||||
DO NOT EDIT THIS FILE.
|
||||
@@ -49,6 +49,7 @@ The connection tables are located here https://github.com/e2002/yoradio#connecti
|
||||
#define DSP_ILI9488 21 // 480x320 3.5' https://aliexpress.com/item/1005001999296476.html?sku_id=12000018365356570
|
||||
#define DSP_ILI9486 22 // (Testing mode) 480x320 3.5' https://aliexpress.com/item/1005001999296476.html?sku_id=12000018365356568
|
||||
#define DSP_SSD1322 23 // 256x64 2.8' https://aliexpress.com/item/1005003480981568.html
|
||||
#define DSP_ST7920 24 // 128x64 2.6' https://aliexpress.com/item/32699482638.html
|
||||
#define DSP_CUSTOM 101 // your display
|
||||
|
||||
#ifndef DSP_MODEL
|
||||
|
||||
68
yoRadio/src/displays/conf/displayST7920conf.h
Normal file
68
yoRadio/src/displays/conf/displayST7920conf.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/*************************************************************************************
|
||||
SSD1305 128x64 displays configuration file.
|
||||
Copy this file to yoRadio/src/displays/conf/displaySSD1305conf_custom.h
|
||||
and modify it
|
||||
More info on https://github.com/e2002/yoradio/wiki/Widgets#widgets-description
|
||||
*************************************************************************************/
|
||||
|
||||
#ifndef displaySSD1305conf_h
|
||||
#define displaySSD1305conf_h
|
||||
|
||||
#define DSP_WIDTH 128
|
||||
#define TFT_FRAMEWDT 1
|
||||
#define MAX_WIDTH DSP_WIDTH-TFT_FRAMEWDT*2
|
||||
|
||||
#define HIDE_HEAPBAR
|
||||
#define HIDE_VOL
|
||||
#define HIDE_VU
|
||||
|
||||
#define bootLogoTop 68
|
||||
|
||||
/* 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 };
|
||||
const ScrollConfig title1Conf PROGMEM = {{ 0, 13, 1, WA_LEFT }, 140, true, DSP_WIDTH-6*4, 5000, 6, 250 };
|
||||
const ScrollConfig title2Conf PROGMEM = {{ 0, 22, 1, WA_LEFT }, 140, true, DSP_WIDTH, 5000, 6, 250 };
|
||||
const ScrollConfig playlistConf PROGMEM = {{ TFT_FRAMEWDT, 30, 1, WA_LEFT }, 140, true, MAX_WIDTH, 500, 6, 250 };
|
||||
const ScrollConfig apTitleConf PROGMEM = {{ TFT_FRAMEWDT+1, TFT_FRAMEWDT+1, 1, WA_CENTER }, 140, false, MAX_WIDTH-2, 0, 6, 250 };
|
||||
const ScrollConfig apSettConf PROGMEM = {{ TFT_FRAMEWDT, 64-7, 1, WA_LEFT }, 140, false, MAX_WIDTH, 0, 6, 250 };
|
||||
const ScrollConfig weatherConf PROGMEM = {{ 0, 64-11, 1, WA_LEFT }, 140, true, DSP_WIDTH-6*4, 0, 6, 250 }; // ПОГОДА!!
|
||||
|
||||
/* BACKGROUNGC9106DS */ /* {{ left, top, fontsize, align }, width, height, outlined } */
|
||||
const FillConfig metaBGConf PROGMEM = {{ 0, 0, 0, WA_LEFT }, DSP_WIDTH, 11, false };
|
||||
const FillConfig volbarConf PROGMEM = {{ 0, 64-1-1-1, 0, WA_LEFT }, DSP_WIDTH, 3, true };
|
||||
const FillConfig playlBGConf PROGMEM = {{ 0, 26, 0, WA_LEFT }, DSP_WIDTH, 12, false };
|
||||
const FillConfig heapbarConf PROGMEM = {{ 0, 63, 0, WA_LEFT }, DSP_WIDTH, 1, false };
|
||||
|
||||
/* WIDGETS */ /* { left, top, fontsize, align } */
|
||||
const WidgetConfig bootstrConf PROGMEM = { 0, 64-8, 1, WA_CENTER };
|
||||
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 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 vuConf PROGMEM = { 1, 28, 1, WA_LEFT };
|
||||
|
||||
const WidgetConfig bootWdtConf PROGMEM = { 0, 64-8*2-5, 1, WA_CENTER };
|
||||
const ProgressConfig bootPrgConf PROGMEM = { 90, 10, 4 };
|
||||
|
||||
/* BANDS */ /* { onebandwidth, onebandheight, bandsHspace, bandsVspace, numofbands, fadespeed } */
|
||||
const VUBandsConfig bandsConf PROGMEM = { 12, 48, 2, 1, 8, 3 };
|
||||
|
||||
/* STRINGS */
|
||||
const char numtxtFmt[] PROGMEM = "%d";
|
||||
const char rssiFmt[] PROGMEM = "%d";
|
||||
const char iptxtFmt[] PROGMEM = "%s";
|
||||
//const char voltxtFmt[] PROGMEM = "%d";
|
||||
const char bitrateFmt[] PROGMEM = "%d";
|
||||
|
||||
/* MOVES */ /* { left, top, width } */
|
||||
const MoveConfig clockMove PROGMEM = { 0, 0, -1 };
|
||||
const MoveConfig weatherMove PROGMEM = { 0, 0, -1 };
|
||||
const MoveConfig weatherMoveVU PROGMEM = { 0, 0, -1 };
|
||||
|
||||
#endif
|
||||
199
yoRadio/src/displays/displayST7920.cpp
Normal file
199
yoRadio/src/displays/displayST7920.cpp
Normal file
@@ -0,0 +1,199 @@
|
||||
#include "../core/options.h"
|
||||
#if DSP_MODEL==DSP_ST7920
|
||||
|
||||
#include "displayST7920.h"
|
||||
#include "../core/player.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 /* 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_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();
|
||||
cp437(true);
|
||||
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(lastPos<plTtemsCount){
|
||||
fillRect(0, lastPos*plItemHeight+plYStart, width(), height()/2, config.theme.background);
|
||||
}
|
||||
}
|
||||
|
||||
void DspCore::clearDsp(bool black) {
|
||||
fillScreen(TFT_BG);
|
||||
}
|
||||
|
||||
uint8_t DspCore::_charWidth(unsigned char c){
|
||||
return CHARWIDTH*clockTimeHeight;
|
||||
}
|
||||
|
||||
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(clockTimeHeight);
|
||||
setTextColor((network.timeinfo.tm_sec % 2 == 0) ? config.theme.clock : config.theme.background, config.theme.background);
|
||||
setCursor(_timeleft+_dotsLeft, clockTop);
|
||||
print(":"); /* print dots */
|
||||
setTextSize(1);
|
||||
setCursor(_timeleft+_timewidth+1, clockTop);
|
||||
setTextColor(config.theme.clock, config.theme.background);
|
||||
sprintf(_bufforseconds, "%02d", network.timeinfo.tm_sec);
|
||||
print(_bufforseconds);
|
||||
//setFont();
|
||||
}
|
||||
|
||||
void DspCore::_clockDate(){ }
|
||||
|
||||
void DspCore::_clockTime(){
|
||||
if(_oldtimeleft>0) 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, 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);
|
||||
}
|
||||
|
||||
#endif
|
||||
42
yoRadio/src/displays/displayST7920.h
Normal file
42
yoRadio/src/displays/displayST7920.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef displaySSD1305_h
|
||||
#define displaySSD1305_h
|
||||
#include "../core/options.h"
|
||||
|
||||
#include "Arduino.h"
|
||||
#include <Adafruit_GFX.h>
|
||||
#include "../ST7920/ST7920.h"
|
||||
#include "tools/l10n.h"
|
||||
|
||||
#define CHARWIDTH 6
|
||||
#define CHARHEIGHT 8
|
||||
|
||||
#define DSP_OLED
|
||||
|
||||
typedef GFXcanvas1 Canvas;
|
||||
#include "widgets/widgets.h"
|
||||
#include "widgets/pages.h"
|
||||
|
||||
#if __has_include("conf/displayST7920conf_custom.h")
|
||||
#include "conf/displayST7920conf_custom.h"
|
||||
#else
|
||||
#include "conf/displayST7920conf.h"
|
||||
#endif
|
||||
|
||||
class DspCore: public ST7920 {
|
||||
#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
|
||||
#define TFT_LOGO WHITE
|
||||
|
||||
#endif
|
||||
@@ -42,6 +42,8 @@
|
||||
#include "displayILI9488.h"
|
||||
#elif DSP_MODEL==DSP_SSD1322
|
||||
#include "displaySSD1322.h"
|
||||
#elif DSP_MODEL==DSP_ST7920
|
||||
#include "displayST7920.h"
|
||||
#endif
|
||||
|
||||
//extern DspCore dsp;
|
||||
|
||||
Reference in New Issue
Block a user