ssd1322_v2

This commit is contained in:
e2002
2023-03-10 16:37:47 +03:00
parent 391c68b1ba
commit 30ded099ae
3 changed files with 13 additions and 10 deletions

View File

@@ -19,6 +19,7 @@
* *
*/ */
#include "../core/options.h" #include "../core/options.h"
#include "../core/player.h"
#if DSP_MODEL==DSP_SSD1322 #if DSP_MODEL==DSP_SSD1322
@@ -38,8 +39,10 @@
#define SSD1322_MODE_DATA digitalWrite(dcPin, HIGH); ///< Data mode #define SSD1322_MODE_DATA digitalWrite(dcPin, HIGH); ///< Data mode
#if defined(SPI_HAS_TRANSACTION) #if defined(SPI_HAS_TRANSACTION)
#define SPI_TRANSACTION_START spi->beginTransaction(spiSettings) ///< Pre-SPI #define TAKE_MUTEX() if(player.mutex_pl) xSemaphoreTake(player.mutex_pl, portMAX_DELAY)
#define SPI_TRANSACTION_END spi->endTransaction() ///< Post-SPI #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 #else // SPI transactions likewise not present in older Arduino SPI lib
#define SPI_TRANSACTION_START ///< Dummy stand-in define #define SPI_TRANSACTION_START ///< Dummy stand-in define
#define SPI_TRANSACTION_END ///< keeps compiler happy #define SPI_TRANSACTION_END ///< keeps compiler happy
@@ -551,4 +554,8 @@ void Jamis_SSD1322::display(void) {
TRANSACTION_END TRANSACTION_END
} }
void Jamis_SSD1322::invertDisplay(boolean flag) {
ssd1322_command(flag ? SSD1322_INVERSEDISPLAY : SSD1322_NORMALDISPLAY);
}
#endif //if DSP_MODEL==DSP_SSD1322 #endif //if DSP_MODEL==DSP_SSD1322

View File

@@ -40,7 +40,8 @@
#define SSD1322_DISPLAYOFF 0xAE #define SSD1322_DISPLAYOFF 0xAE
#define SSD1322_DISPLAYON 0xAF #define SSD1322_DISPLAYON 0xAF
#define SSD1322_NORMALDISPLAY 0xA6
#define SSD1322_INVERSEDISPLAY 0xA7
/*! /*!
@brief Class that stores state and functions for interacting with @brief Class that stores state and functions for interacting with
SSD1322 OLED displays. SSD1322 OLED displays.
@@ -61,7 +62,8 @@ class Jamis_SSD1322 : public Adafruit_GFX {
void ssd1322_command(uint8_t c); void ssd1322_command(uint8_t c);
boolean getPixel(int16_t x, int16_t y); boolean getPixel(int16_t x, int16_t y);
uint8_t *getBuffer(void); 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: private:
inline void SPIwrite(uint8_t d) __attribute__((always_inline)); inline void SPIwrite(uint8_t d) __attribute__((always_inline));
void drawFastHLineInternal(int16_t x, int16_t y, int16_t w, void drawFastHLineInternal(int16_t x, int16_t y, int16_t w,

View File

@@ -2,15 +2,12 @@
#if DSP_MODEL==DSP_SSD1322 #if DSP_MODEL==DSP_SSD1322
#include "displaySSD1322.h" #include "displaySSD1322.h"
#include "../core/player.h"
#include "../core/config.h" #include "../core/config.h"
#include "../core/network.h" #include "../core/network.h"
#define LOGO_WIDTH 21 #define LOGO_WIDTH 21
#define LOGO_HEIGHT 32 #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 #ifndef DEF_SPI_FREQ
#define DEF_SPI_FREQ 16000000UL /* set it to 0 for system default */ #define DEF_SPI_FREQ 16000000UL /* set it to 0 for system default */
@@ -123,7 +120,6 @@ void DspCore::_clockDate(){ }
void DspCore::_clockTime(){ 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+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; _timeleft = (width()/*/2*/ - _timewidth/*/2*/)-clockRightSpace;
setTextSize(1); setTextSize(1);
setFont(&DS_DIGI28pt7b); setFont(&DS_DIGI28pt7b);
@@ -150,7 +146,6 @@ void DspCore::printClock(uint16_t top, uint16_t rightspace, uint16_t timeheight,
void DspCore::clearClock(){ void DspCore::clearClock(){
dsp.fillRect(_timeleft, clockTop-clockTimeHeight, _timewidth+2, clockTimeHeight, config.theme.background); 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) { void DspCore::startWrite(void) {
@@ -164,7 +159,6 @@ void DspCore::endWrite(void) {
} }
void DspCore::loop(bool force) { void DspCore::loop(bool force) {
//clearDisplay();
display(); display();
delay(5); delay(5);
} }