Browse Source

Korrektur für ESP8266

pull/735/head
dAjaY85 2 years ago
parent
commit
a746e5c583
  1. 10
      src/plugins/Display/Display.h
  2. 6
      src/plugins/Display/Display_Mono.cpp
  3. 20
      src/plugins/Display/Display_ePaper.cpp

10
src/plugins/Display/Display.h

@ -25,7 +25,7 @@ class Display {
if (mCfg->type == 0) { if (mCfg->type == 0) {
return; return;
} else if (1 < mCfg->type < 11) { } else if ((1 < mCfg->type) && (mCfg->type < 11)) {
switch (mCfg->rot) { switch (mCfg->rot) {
case 0: case 0:
DisplayMono.disp_rotation = U8G2_R0; DisplayMono.disp_rotation = U8G2_R0;
@ -47,10 +47,12 @@ class Display {
DisplayMono.init(mCfg->type, mCfg->disp_cs, mCfg->disp_dc, mCfg->disp_reset, mCfg->disp_busy, mCfg->disp_clk, mCfg->disp_data, mVersion); DisplayMono.init(mCfg->type, mCfg->disp_cs, mCfg->disp_dc, mCfg->disp_reset, mCfg->disp_busy, mCfg->disp_clk, mCfg->disp_data, mVersion);
} else if (mCfg->type > 10) { } else if (mCfg->type > 10) {
#if defined(ESP32)
DisplayEPaper.displayRotation = mCfg->rot; DisplayEPaper.displayRotation = mCfg->rot;
counterEPaper = 0; counterEPaper = 0;
DisplayEPaper.init(mCfg->type, mCfg->disp_cs, mCfg->disp_dc, mCfg->disp_reset, mCfg->disp_busy, mCfg->disp_clk, mCfg->disp_data, mVersion); DisplayEPaper.init(mCfg->type, mCfg->disp_cs, mCfg->disp_dc, mCfg->disp_reset, mCfg->disp_busy, mCfg->disp_clk, mCfg->disp_data, mVersion);
#endif
} }
} }
@ -89,18 +91,20 @@ class Display {
continue; continue;
if (iv->isProducing(*mUtcTs)) if (iv->isProducing(*mUtcTs))
uint8_t isprod = 0; isprod += 0;
totalPower += iv->getChannelFieldValue(CH0, FLD_PAC, rec); totalPower += iv->getChannelFieldValue(CH0, FLD_PAC, rec);
totalYieldDay += iv->getChannelFieldValue(CH0, FLD_YD, rec); totalYieldDay += iv->getChannelFieldValue(CH0, FLD_YD, rec);
totalYieldTotal += iv->getChannelFieldValue(CH0, FLD_YT, rec); totalYieldTotal += iv->getChannelFieldValue(CH0, FLD_YT, rec);
} }
if (1 < mCfg->type < 11) { if ((1 < mCfg->type) && (mCfg->type < 11)) {
DisplayMono.loop(totalPower, totalYieldDay, totalYieldTotal, isprod); DisplayMono.loop(totalPower, totalYieldDay, totalYieldTotal, isprod);
} else if (mCfg->type > 10) { } else if (mCfg->type > 10) {
#if defined(ESP32)
DisplayEPaper.loop(totalPower, totalYieldDay, totalYieldTotal, isprod); DisplayEPaper.loop(totalPower, totalYieldDay, totalYieldTotal, isprod);
counterEPaper++; counterEPaper++;
#endif
} }
_lastDisplayUpdate = millis(); _lastDisplayUpdate = millis();
} }

6
src/plugins/Display/Display_Mono.cpp

@ -5,7 +5,11 @@
#include <map> #include <map>
#include "WiFi.h" #ifdef ESP8266
#include <ESP8266WiFi.h>
#elif defined(ESP32)
#include <WiFi.h>
#endif
#include "imagedata.h" #include "imagedata.h"
#ifdef U8X8_HAVE_HW_SPI #ifdef U8X8_HAVE_HW_SPI

20
src/plugins/Display/Display_ePaper.cpp

@ -1,6 +1,11 @@
#include "Display_ePaper.h" #include "Display_ePaper.h"
#include "WiFi.h" #ifdef ESP8266
#include <ESP8266WiFi.h>
#elif defined(ESP32)
#include <WiFi.h>
#endif
#include "imagedata.h" #include "imagedata.h"
static const uint32_t spiClk = 4000000; // 4 MHz static const uint32_t spiClk = 4000000; // 4 MHz
@ -24,16 +29,16 @@ DisplayEPaperClass::~DisplayEPaperClass() {
delete _display; delete _display;
} }
//*************************************************************************** //***************************************************************************
void DisplayEPaperClass::init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI, const char *version) { void DisplayEPaperClass::init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _RST, uint8_t _BUSY, uint8_t _SCK, uint8_t _MOSI, const char *versio) {
if (type > 3) { if (type > 10) {
#if defined(ESP32) && defined(USE_HSPI_FOR_EPD)
Serial.begin(115200); Serial.begin(115200);
auto constructor = _ePaperTypes[type]; auto constructor = _ePaperTypes[type];
_display = constructor(_CS, _DC, _RST, _BUSY); _display = constructor(_CS, _DC, _RST, _BUSY);
hspi.begin(_SCK, _BUSY, _MOSI, _CS); hspi.begin(_SCK, _BUSY, _MOSI, _CS);
#if defined(ESP32) && defined(USE_HSPI_FOR_EPD)
_display->epd2.selectSPI(hspi, SPISettings(spiClk, MSBFIRST, SPI_MODE0)); _display->epd2.selectSPI(hspi, SPISettings(spiClk, MSBFIRST, SPI_MODE0));
#endif
_display->init(115200, true, 2, false); _display->init(115200, true, 2, false);
_display->setRotation(displayRotation); _display->setRotation(displayRotation);
_display->setFullWindow(); _display->setFullWindow();
@ -55,6 +60,7 @@ void DisplayEPaperClass::init(uint8_t type, uint8_t _CS, uint8_t _DC, uint8_t _R
// call the PowerPage to change the PV Power Values // call the PowerPage to change the PV Power Values
actualPowerPaged(0, 0, 0, 0); actualPowerPaged(0, 0, 0, 0);
#endif
} }
} }
//*************************************************************************** //***************************************************************************
@ -81,7 +87,7 @@ void DisplayEPaperClass::headlineIP() {
_display->fillScreen(GxEPD_BLACK); _display->fillScreen(GxEPD_BLACK);
do { do {
if ((WiFi.isConnected() == true) && (WiFi.localIP() > 0)) { if (WiFi.isConnected() == true) {
snprintf(_fmtText, sizeof(_fmtText), "%s", WiFi.localIP().toString().c_str()); snprintf(_fmtText, sizeof(_fmtText), "%s", WiFi.localIP().toString().c_str());
} else { } else {
snprintf(_fmtText, sizeof(_fmtText), "WiFi not connected"); snprintf(_fmtText, sizeof(_fmtText), "WiFi not connected");
@ -170,6 +176,7 @@ void DisplayEPaperClass::actualPowerPaged(float _totalPower, float _totalYieldDa
} }
//*************************************************************************** //***************************************************************************
void DisplayEPaperClass::loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod) { void DisplayEPaperClass::loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod) {
#if defined(ESP32)
// check if the IP has changed // check if the IP has changed
if (_settedIP != WiFi.localIP().toString().c_str()) { if (_settedIP != WiFi.localIP().toString().c_str()) {
// save the new IP and call the Headline Funktion to adapt the Headline // save the new IP and call the Headline Funktion to adapt the Headline
@ -187,6 +194,7 @@ void DisplayEPaperClass::loop(float totalPower, float totalYieldDay, float total
} }
_display->powerOff(); _display->powerOff();
#endif
} }
//*************************************************************************** //***************************************************************************
DisplayEPaperClass DisplayEPaper; DisplayEPaperClass DisplayEPaper;
Loading…
Cancel
Save