Skip to content

Commit

Permalink
merged PR Monodisplay, many thanks to @dAjaY85 #566, Note: (setting…
Browse files Browse the repository at this point in the history
…s are introduced but not able to be modified, will be included in next version)
  • Loading branch information
lumapu committed Jan 16, 2023
1 parent 7c3a78e commit 3ff348b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* fixed YieldTotal correction calculation #589
* fixed serial output of power limit acknowledge #569
* reviewed `sendDiscoveryConfig` #565
* merged PR `Monodisplay`, many thanks to @dAjaY85 #566, Note: (settings are introduced but not able to be modified, will be included in next version)

## 0.5.70
* corrected MQTT `comm_disabled` #529
Expand Down
2 changes: 1 addition & 1 deletion src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void app::setup() {

// Plugins
#if defined(ENA_NOKIA) || defined(ENA_SSD1306) || defined(ENA_SH1106)
mMonoDisplay.setup(mSys, &mTimestamp);
mMonoDisplay.setup(&mConfig->plugin.display, mSys, &mTimestamp);
#endif

mPubSerial.setup(mConfig, mSys, &mTimestamp);
Expand Down
15 changes: 15 additions & 0 deletions src/config/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,17 @@ typedef struct {
cfgIv_t iv[MAX_NUM_INVERTERS];
} cfgInst_t;

typedef struct {
bool pwrSaveAtIvOffline;
uint32_t wakeUp;
uint32_t sleepAt;
uint8_t contrast;
} display_t;

typedef struct {
display_t display;
} plugins_t;

typedef struct {
cfgSys_t sys;
cfgNrf24_t nrf;
Expand All @@ -125,6 +136,7 @@ typedef struct {
cfgMqtt_t mqtt;
cfgLed_t led;
cfgInst_t inst;
plugins_t plugin;
bool valid;
} settings_t;

Expand Down Expand Up @@ -314,6 +326,9 @@ class settings {
mCfg.led.led1 = DEF_LED1_PIN;

memset(&mCfg.inst, 0, sizeof(cfgInst_t));

mCfg.plugin.display.pwrSaveAtIvOffline = false;
mCfg.plugin.display.contrast = 60;
}

void jsonWifi(JsonObject obj, bool set = false) {
Expand Down
11 changes: 7 additions & 4 deletions src/plugins/MonochromeDisplay/MonochromeDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class MonochromeDisplay {
}
#endif

void setup(HMSYSTEM *sys, uint32_t *utcTs) {
void setup(display_t *cfg, HMSYSTEM *sys, uint32_t *utcTs) {
mCfg = cfg;
mSys = sys;
mUtcTs = utcTs;
memset( mToday, 0, sizeof(float)*MAX_NUM_INVERTERS );
Expand Down Expand Up @@ -222,7 +223,7 @@ class MonochromeDisplay {
mDisplay.print(timeStr);
}
#else // ENA_SSD1306
mDisplay.setContrast(60);
mDisplay.setContrast(mCfg->contrast);
// pxZittern in +x (0 - 8 px)
int ex = 2*( mExtra % 5 );
mDisplay.drawXBM(100+ex,2,16,16,bmp_logo);
Expand Down Expand Up @@ -253,8 +254,9 @@ class MonochromeDisplay {
mDisplay.setFont(u8g2_font_logisoso18_tr);
mDisplay.setCursor(10+ex,20);
mDisplay.print(String(F("offline")));
if ((millis() - displaySleepTimer) > displaySleepDelay) {
mDisplay.setPowerSave(true);
if(mCfg->pwrSaveAtIvOffline) {
if ((millis() - displaySleepTimer) > displaySleepDelay)
mDisplay.setPowerSave(true);
}
//<=======================
}
Expand Down Expand Up @@ -309,6 +311,7 @@ class MonochromeDisplay {
float mToday[ MAX_NUM_INVERTERS ];
uint32_t *mUtcTs;
int mLastHour;
display_t *mCfg;
HMSYSTEM *mSys;
Timezone mCE;
bool displaySleep;
Expand Down

0 comments on commit 3ff348b

Please sign in to comment.