mirror of
https://github.com/lumapu/ahoy.git
synced 2025-08-04 08:58:22 +02:00
- rework "hiding Pins" to easier configure pins for new displays (using a pin map, remove hard-coded if-statements)
- rework display type handling: remove uneeded checks because defined context from which functions are called - default initialize "mMono" pointer (potential illegal memory access) - define EXACTLY one display type for ePaper display (type 10). There is no need to use ranges and distinguish oled from epaper display. Simply one switch/case - correct type handling for display type (javascript). Event handler gives a string instead of number (display type)
This commit is contained in:
parent
47d5531d05
commit
c99851364a
3 changed files with 46 additions and 48 deletions
|
@ -26,37 +26,29 @@ class Display {
|
|||
mLoopCnt = 0;
|
||||
mVersion = version;
|
||||
|
||||
if (mCfg->type == 0)
|
||||
return;
|
||||
switch (mCfg->type) {
|
||||
case 0: mMono = NULL; break;
|
||||
case 1: // fall-through
|
||||
case 2: mMono = new DisplayMono128X64(); break;
|
||||
case 3: mMono = new DisplayMono84X48(); break;
|
||||
case 4: mMono = new DisplayMono128X32(); break;
|
||||
case 5: mMono = new DisplayMono64X48(); break;
|
||||
|
||||
if ((0 < mCfg->type) && (mCfg->type < 10)) {
|
||||
switch (mCfg->type) {
|
||||
case 1: // fall-through
|
||||
case 2:
|
||||
mMono = new DisplayMono128X64();
|
||||
break;
|
||||
case 3:
|
||||
mMono = new DisplayMono84X48();
|
||||
break;
|
||||
case 4:
|
||||
mMono = new DisplayMono128X32();
|
||||
break;
|
||||
case 5:
|
||||
mMono = new DisplayMono64X48();
|
||||
break;
|
||||
#if defined(ESP32)
|
||||
case 10:
|
||||
mMono = NULL; // ePaper does not use this
|
||||
mRefreshCycle = 0;
|
||||
mEpaper.config(mCfg->rot, mCfg->pwrSaveAtIvOffline);
|
||||
mEpaper.init(mCfg->type, mCfg->disp_cs, mCfg->disp_dc, mCfg->disp_reset, mCfg->disp_busy, mCfg->disp_clk, mCfg->disp_data, mUtcTs, mVersion);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
mMono = new DisplayMono128X64();
|
||||
break;
|
||||
}
|
||||
default: mMono = NULL; break;
|
||||
}
|
||||
if(mMono)
|
||||
{
|
||||
mMono->config(mCfg->pwrSaveAtIvOffline, mCfg->pxShift, mCfg->contrast);
|
||||
mMono->init(mCfg->type, mCfg->rot, mCfg->disp_cs, mCfg->disp_dc, 0xff, mCfg->disp_clk, mCfg->disp_data, mUtcTs, mVersion);
|
||||
} else if (mCfg->type >= 10) {
|
||||
#if defined(ESP32)
|
||||
mRefreshCycle = 0;
|
||||
mEpaper.config(mCfg->rot, mCfg->pwrSaveAtIvOffline);
|
||||
mEpaper.init(mCfg->type, mCfg->disp_cs, mCfg->disp_dc, mCfg->disp_reset, mCfg->disp_busy, mCfg->disp_clk, mCfg->disp_data, mUtcTs, mVersion);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -104,14 +96,16 @@ class Display {
|
|||
totalYieldTotal += iv->getChannelFieldValue(CH0, FLD_YT, rec);
|
||||
}
|
||||
|
||||
if ((0 < mCfg->type) && (mCfg->type < 10) && (mMono != NULL)) {
|
||||
if (mMono ) {
|
||||
mMono->disp(totalPower, totalYieldDay, totalYieldTotal, isprod);
|
||||
} else if (mCfg->type >= 10) {
|
||||
}
|
||||
#if defined(ESP32)
|
||||
else if (mCfg->type == 10) {
|
||||
|
||||
mEpaper.loop(totalPower, totalYieldDay, totalYieldTotal, isprod);
|
||||
mRefreshCycle++;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(ESP32)
|
||||
if (mRefreshCycle > 480) {
|
||||
|
@ -133,7 +127,7 @@ class Display {
|
|||
#if defined(ESP32)
|
||||
DisplayEPaper mEpaper;
|
||||
#endif
|
||||
DisplayMono *mMono;
|
||||
DisplayMono *mMono = NULL; //default !!!
|
||||
};
|
||||
|
||||
#endif /*__DISPLAY__*/
|
||||
|
|
|
@ -26,7 +26,7 @@ DisplayEPaper::DisplayEPaper() {
|
|||
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;
|
||||
|
||||
if (type > 9) {
|
||||
if (type == 10) {
|
||||
Serial.begin(115200);
|
||||
_display = new GxEPD2_BW<GxEPD2_150_BN, GxEPD2_150_BN::HEIGHT>(GxEPD2_150_BN(_CS, _DC, _RST, _BUSY));
|
||||
hspi.begin(_SCK, _BUSY, _MOSI, _CS);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue