From 30ded099ae178849118ab83744e7b331285bf1a2 Mon Sep 17 00:00:00 2001 From: e2002 Date: Fri, 10 Mar 2023 16:37:47 +0300 Subject: [PATCH] ssd1322_v2 --- yoRadio/src/SSD1322/SSD1322.cpp | 11 +++++++++-- yoRadio/src/SSD1322/SSD1322.h | 6 ++++-- yoRadio/src/displays/displaySSD1322.cpp | 6 ------ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/yoRadio/src/SSD1322/SSD1322.cpp b/yoRadio/src/SSD1322/SSD1322.cpp index 5d75d58..b16f8ac 100644 --- a/yoRadio/src/SSD1322/SSD1322.cpp +++ b/yoRadio/src/SSD1322/SSD1322.cpp @@ -19,6 +19,7 @@ * */ #include "../core/options.h" +#include "../core/player.h" #if DSP_MODEL==DSP_SSD1322 @@ -38,8 +39,10 @@ #define SSD1322_MODE_DATA digitalWrite(dcPin, HIGH); ///< Data mode #if defined(SPI_HAS_TRANSACTION) - #define SPI_TRANSACTION_START spi->beginTransaction(spiSettings) ///< Pre-SPI - #define SPI_TRANSACTION_END spi->endTransaction() ///< Post-SPI + #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 SPI_TRANSACTION_START TAKE_MUTEX(); spi->beginTransaction(spiSettings) ///< Pre-SPI + #define SPI_TRANSACTION_END spi->endTransaction(); GIVE_MUTEX() ///< Post-SPI #else // SPI transactions likewise not present in older Arduino SPI lib #define SPI_TRANSACTION_START ///< Dummy stand-in define #define SPI_TRANSACTION_END ///< keeps compiler happy @@ -551,4 +554,8 @@ void Jamis_SSD1322::display(void) { TRANSACTION_END } +void Jamis_SSD1322::invertDisplay(boolean flag) { + ssd1322_command(flag ? SSD1322_INVERSEDISPLAY : SSD1322_NORMALDISPLAY); +} + #endif //if DSP_MODEL==DSP_SSD1322 diff --git a/yoRadio/src/SSD1322/SSD1322.h b/yoRadio/src/SSD1322/SSD1322.h index 69d23e3..a99a0d2 100644 --- a/yoRadio/src/SSD1322/SSD1322.h +++ b/yoRadio/src/SSD1322/SSD1322.h @@ -40,7 +40,8 @@ #define SSD1322_DISPLAYOFF 0xAE #define SSD1322_DISPLAYON 0xAF - +#define SSD1322_NORMALDISPLAY 0xA6 +#define SSD1322_INVERSEDISPLAY 0xA7 /*! @brief Class that stores state and functions for interacting with SSD1322 OLED displays. @@ -61,7 +62,8 @@ class Jamis_SSD1322 : public Adafruit_GFX { void ssd1322_command(uint8_t c); boolean getPixel(int16_t x, int16_t y); uint8_t *getBuffer(void); - void oled_command(uint8_t c) { ssd1322_command1(c); } + void oled_command(uint8_t c) { ssd1322_command(c); } + void invertDisplay(boolean flag); private: inline void SPIwrite(uint8_t d) __attribute__((always_inline)); void drawFastHLineInternal(int16_t x, int16_t y, int16_t w, diff --git a/yoRadio/src/displays/displaySSD1322.cpp b/yoRadio/src/displays/displaySSD1322.cpp index 2f9b00b..b0940bc 100644 --- a/yoRadio/src/displays/displaySSD1322.cpp +++ b/yoRadio/src/displays/displaySSD1322.cpp @@ -2,15 +2,12 @@ #if DSP_MODEL==DSP_SSD1322 #include "displaySSD1322.h" -#include "../core/player.h" #include "../core/config.h" #include "../core/network.h" #define LOGO_WIDTH 21 #define LOGO_HEIGHT 32 -#define TAKE_MUTEX() if(player.mutex_pl) xSemaphoreTake(player.mutex_pl, portMAX_DELAY) -#define GIVE_MUTEX() if(player.mutex_pl) xSemaphoreGive(player.mutex_pl) #ifndef DEF_SPI_FREQ #define DEF_SPI_FREQ 16000000UL /* set it to 0 for system default */ @@ -123,7 +120,6 @@ void DspCore::_clockDate(){ } void DspCore::_clockTime(){ if(_oldtimeleft>0) 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_DIGI28pt7b); @@ -150,7 +146,6 @@ void DspCore::printClock(uint16_t top, uint16_t rightspace, uint16_t timeheight, void DspCore::clearClock(){ dsp.fillRect(_timeleft, clockTop-clockTimeHeight, _timewidth+2, clockTimeHeight, config.theme.background); - //dsp.fillRect(_timeleft, clockTop-clockTimeHeight, _timewidth+CHARWIDTH*3*2+24, clockTimeHeight+10+CHARHEIGHT, config.theme.background); } void DspCore::startWrite(void) { @@ -164,7 +159,6 @@ void DspCore::endWrite(void) { } void DspCore::loop(bool force) { - //clearDisplay(); display(); delay(5); }