Browse Source

ePaper mittels SW-SPI

pull/961/head
dAjaY85 2 years ago
parent
commit
abb2a43b75
  1. 2
      src/platformio.ini
  2. 8
      src/plugins/Display/Display_ePaper.cpp
  3. 3
      src/plugins/Display/Display_ePaper.h

2
src/platformio.ini

@ -30,7 +30,7 @@ lib_deps =
bblanchon/ArduinoJson @ ^6.21.2 bblanchon/ArduinoJson @ ^6.21.2
https://github.com/JChristensen/Timezone @ ^1.2.4 https://github.com/JChristensen/Timezone @ ^1.2.4
olikraus/U8g2 @ ^2.34.17 olikraus/U8g2 @ ^2.34.17
zinggjm/GxEPD2 @ ^1.5.2 https://github.com/dAjaY85/GxEPD2_SWSPI
[env:esp8266-release] [env:esp8266-release]

8
src/plugins/Display/Display_ePaper.cpp

@ -21,7 +21,6 @@ DisplayEPaper::DisplayEPaper() {
mHeadFootPadding = 16; mHeadFootPadding = 16;
} }
//*************************************************************************** //***************************************************************************
void DisplayEPaper::init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI, uint32_t *utcTs, const char *version) { void DisplayEPaper::init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI, uint32_t *utcTs, const char *version) {
mUtcTs = utcTs; mUtcTs = utcTs;
@ -29,12 +28,14 @@ void DisplayEPaper::init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, u
if (type > 9) { if (type > 9) {
Serial.begin(115200); Serial.begin(115200);
_display = new GxEPD2_BW<GxEPD2_150_BN, GxEPD2_150_BN::HEIGHT>(GxEPD2_150_BN(_CS, _DC, _RST, _BUSY)); _display = new GxEPD2_BW<GxEPD2_150_BN, GxEPD2_150_BN::HEIGHT>(GxEPD2_150_BN(_CS, _DC, _RST, _BUSY));
hspi.begin(_SCK, _BUSY, _MOSI, _CS);
#if defined(ESP32) && defined(USE_HSPI_FOR_EPD) #if defined(ESP32) && defined(USE_HSPI_FOR_EPD)
hspi.begin(_SCK, _BUSY, _MOSI, _CS);
_display->epd2.selectSPI(hspi, SPISettings(spiClk, MSBFIRST, SPI_MODE0)); _display->epd2.selectSPI(hspi, SPISettings(spiClk, MSBFIRST, SPI_MODE0));
#endif #endif
_display->init(115200, true, 2, false);
_display->epd2.init(_SCK, _MOSI, 115200, true, 20, false);
_display->init(115200, true, 20, false);
_display->setRotation(mDisplayRotation); _display->setRotation(mDisplayRotation);
_display->setFullWindow(); _display->setFullWindow();
@ -197,7 +198,6 @@ void DisplayEPaper::actualPowerPaged(float totalPower, float totalYieldDay, floa
_display->setCursor(10, _display->height() - (mHeadFootPadding + 10)); _display->setCursor(10, _display->height() - (mHeadFootPadding + 10));
snprintf(_fmtText, sizeof(_fmtText), "%d Inverter online", isprod); snprintf(_fmtText, sizeof(_fmtText), "%d Inverter online", isprod);
_display->println(_fmtText); _display->println(_fmtText);
} }
} while (_display->nextPage()); } while (_display->nextPage());
} }

3
src/plugins/Display/Display_ePaper.h

@ -4,7 +4,7 @@
#if defined(ESP32) #if defined(ESP32)
// uncomment next line to use HSPI for EPD (and VSPI for SD), e.g. with Waveshare ESP32 Driver Board // uncomment next line to use HSPI for EPD (and VSPI for SD), e.g. with Waveshare ESP32 Driver Board
#define USE_HSPI_FOR_EPD // #define USE_HSPI_FOR_EPD
/// uncomment next line to use class GFX of library GFX_Root instead of Adafruit_GFX, to use less code and ram /// uncomment next line to use class GFX of library GFX_Root instead of Adafruit_GFX, to use less code and ram
// #include <GFX.h> // #include <GFX.h>
@ -34,7 +34,6 @@ class DisplayEPaper {
void config(uint8_t rotation, bool enPowerSafe); void config(uint8_t rotation, bool enPowerSafe);
void loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod); void loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod);
private: private:
void headlineIP(); void headlineIP();
void actualPowerPaged(float _totalPower, float _totalYieldDay, float _totalYieldTotal, uint8_t _isprod); void actualPowerPaged(float _totalPower, float _totalYieldDay, float _totalYieldTotal, uint8_t _isprod);

Loading…
Cancel
Save