Browse Source

added Nokia display again for ESP8266 #764

changed `var` / `VAr` to SI unit `var` #732
fix MQTT retained flags for totals (P_AC, P_DC) #726, #721
pull/753/head
lumapu 2 years ago
parent
commit
6ef7720324
  1. 5
      src/CHANGES.md
  2. 2
      src/defines.h
  3. 6
      src/hm/miPayload.h
  4. 3
      src/plugins/Display/Display.h
  5. 10
      src/plugins/Display/Display_Mono.cpp
  6. 3
      src/plugins/Display/Display_Mono.h
  7. 18
      src/publisher/pubMqtt.h
  8. 8
      src/web/html/setup.html
  9. 5
      src/web/html/visualization.html

5
src/CHANGES.md

@ -2,6 +2,11 @@
(starting from release version `0.5.66`)
## 0.5.96
* added Nokia display again for ESP8266 #764
* changed `var` / `VAr` to SI unit `var` #732
* fix MQTT retained flags for totals (P_AC, P_DC) #726, #721
## 0.5.95
* merged #742 MI Improvments
* merged #736 remove obsolete JSON Endpoint

2
src/defines.h

@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 5
#define VERSION_PATCH 95
#define VERSION_PATCH 96
//-------------------------------------
typedef struct {

6
src/hm/miPayload.h

@ -561,9 +561,9 @@ class MiPayload {
iv->setValue(iv->getPosByChFld(0, FLD_PAC, rec), rec, (float) (ac_pow/10));
if ( mPayload[iv->id].complete || //4ch device
iv->type != INV_TYPE_4CH //other devices
((iv->type != INV_TYPE_4CH) //other devices
&& mPayload[iv->id].dataAB[CH0]
&& mPayload[iv->id].stsAB[CH0] ) {
&& mPayload[iv->id].stsAB[CH0])) {
mPayload[iv->id].complete = true; // For 2 CH devices, this might be too short...
DPRINTLN(DBG_INFO, F("rec. complete set of msgs"));
iv->setValue(iv->getPosByChFld(0, FLD_YD, rec), rec, calcYieldDayCh0(iv,0));
@ -620,7 +620,7 @@ class MiPayload {
//uint8_t cmd = getQueuedCmd();
if(!*complete) {
DPRINTLN(DBG_VERBOSE, F("incomlete, txCmd is 0x") + String(txCmd, HEX)); // + F("cmd is 0x") + String(cmd, HEX));
if (txCmd == 0x09 || txCmd == 0x11 || txCmd >= 0x36 && txCmd <= 0x39 )
if (txCmd == 0x09 || txCmd == 0x11 || (txCmd >= 0x36 && txCmd <= 0x39))
return false;
}

3
src/plugins/Display/Display.h

@ -42,6 +42,7 @@ class Display {
}
void tickerSecond() {
loop();
if (mNewPayload || ((++mLoopCnt % 10) == 0)) {
mNewPayload = false;
mLoopCnt = 0;
@ -79,7 +80,7 @@ class Display {
}
if ((1 < mCfg->type) && (mCfg->type < 10)) {
mMono.loop(totalPower, totalYieldDay, totalYieldTotal, isprod);
mMono.disp(totalPower, totalYieldDay, totalYieldTotal, isprod);
} else if (mCfg->type >= 10) {
#if defined(ESP32)
mEpaper.loop(totalPower, totalYieldDay, totalYieldTotal, isprod);

10
src/plugins/Display/Display_Mono.cpp

@ -31,7 +31,7 @@ void DisplayMono::init(uint8_t type, uint8_t rot, uint8_t cs, uint8_t dc, uint8_
u8g2_cb_t *rot = (u8g2_cb_t *)((rot != 0x00) ? U8G2_R2 : U8G2_R0);
switch(type) {
case 1:
mDisplay = new U8G2_PCD8544_84X48_F_4W_HW_SPI(rot, cs, dc, reset);
mDisplay = new U8G2_PCD8544_84X48_F_4W_SW_SPI(rot, clock, data, cs, dc, reset);
break;
case 2:
mDisplay = new U8G2_SSD1306_128X64_NONAME_F_HW_I2C(rot, reset, clock, data);
@ -64,10 +64,14 @@ void DisplayMono::config(bool enPowerSafe, bool enScreenSaver, uint8_t lum) {
mLuminance = lum;
}
void DisplayMono::loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod) {
void DisplayMono::loop(void) {
if (mEnPowerSafe)
if(mTimeout != 0)
mTimeout--;
}
void DisplayMono::disp(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod) {
mDisplay->clearBuffer();
@ -144,6 +148,6 @@ void DisplayMono::printText(const char* text, uint8_t line, uint8_t dispX) {
}
setFont(line);
dispX += (mEnPowerSafe) ? (_mExtra % 7) : 0;
dispX += (mEnScreenSaver) ? (_mExtra % 7) : 0;
mDisplay->drawStr(dispX, mLineOffsets[line], text);
}

3
src/plugins/Display/Display_Mono.h

@ -11,7 +11,8 @@ class DisplayMono {
void init(uint8_t type, uint8_t rot, uint8_t cs, uint8_t dc, uint8_t reset, uint8_t clock, uint8_t data, uint32_t *utcTs, const char* version);
void config(bool enPowerSafe, bool enScreenSaver, uint8_t lum);
void loop(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod);
void loop(void);
void disp(float totalPower, float totalYieldDay, float totalYieldTotal, uint8_t isprod);
private:
void calcLineHeights();

18
src/publisher/pubMqtt.h

@ -59,7 +59,16 @@ class PubMqtt {
if((strlen(mCfgMqtt->user) > 0) && (strlen(mCfgMqtt->pwd) > 0))
mClient.setCredentials(mCfgMqtt->user, mCfgMqtt->pwd);
snprintf(mClientId, 24, "%s-%s%s%s", mDevName, WiFi.macAddress().substring(9,11).c_str(), WiFi.macAddress().substring(12,14).c_str(), WiFi.macAddress().substring(15,17).c_str());
snprintf(mClientId, 26, "%s-", mDevName);
uint8_t pos = strlen(mClientId);
mClientId[pos++] = WiFi.macAddress().substring( 9, 10).c_str()[0];
mClientId[pos++] = WiFi.macAddress().substring(10, 11).c_str()[0];
mClientId[pos++] = WiFi.macAddress().substring(12, 13).c_str()[0];
mClientId[pos++] = WiFi.macAddress().substring(13, 14).c_str()[0];
mClientId[pos++] = WiFi.macAddress().substring(15, 16).c_str()[0];
mClientId[pos++] = WiFi.macAddress().substring(16, 17).c_str()[0];
mClientId[pos++] = '\0';
mClient.setClientId(mClientId);
mClient.setServer(mCfgMqtt->broker, mCfgMqtt->port);
mClient.setWill(mLwtTopic, QOS_0, true, mqttStr[MQTT_STR_LWT_NOT_CONN]);
@ -560,11 +569,13 @@ class PubMqtt {
if (sendTotals) {
uint8_t fieldId;
bool retained = true;
for (uint8_t i = 0; i < 4; i++) {
switch (i) {
default:
case 0:
fieldId = FLD_PAC;
retained = false;
break;
case 1:
fieldId = FLD_YT;
@ -574,11 +585,12 @@ class PubMqtt {
break;
case 3:
fieldId = FLD_PDC;
retained = false;
break;
}
snprintf(topic, 32 + MAX_NAME_LENGTH, "total/%s", fields[fieldId]);
snprintf(val, 40, "%g", ah::round3(total[i]));
publish(topic, val, true);
publish(topic, val, retained);
}
RTRDataHasBeenSent = true;
yield();
@ -610,7 +622,7 @@ class PubMqtt {
// last will topic and payload must be available trough lifetime of 'espMqttClient'
char mLwtTopic[MQTT_TOPIC_LEN+5];
const char *mDevName, *mVersion;
char mClientId[24]; // number of chars is limited to 23 up to v3.1 of MQTT
char mClientId[26]; // number of chars is limited to 23 up to v3.1 of MQTT
};
#endif /*__PUB_MQTT_H__*/

8
src/web/html/setup.html

@ -636,7 +636,7 @@
var e = document.getElementById("dispPins");
pins = [['clock', 'disp_clk'], ['data', 'disp_data'], ['cs', 'disp_cs'], ['dc', 'disp_dc'], ['reset', 'disp_rst'], ['busy', 'disp_bsy']];
for(p of pins) {
if(("ESP8266" == type) && p[0] == "cs")
if(("ESP8266" == type) && p[0] == "busy")
break;
e.append(
ml("div", {class: "row mb-3"}, [
@ -648,11 +648,9 @@
);
}
var opts = [[0, "None"], [2, "SSD1306 0.96\""], [3, "SH1106 1.3\""]];
if("ESP32" == type) {
opts.push([1, "Nokia5110"]);
var opts = [[0, "None"], [1, "Nokia5110"], [2, "SSD1306 0.96\""], [3, "SH1106 1.3\""]];
if("ESP32" == type)
opts.push([10, "ePaper"]);
}
document.getElementById("dispType").append(
ml("div", {class: "row mb-3"}, [
ml("div", {class: "col-12 col-sm-3 my-2"}, "Type"),

5
src/web/html/visualization.html

@ -116,7 +116,7 @@
numMid(obj.ch[0][1], "A", "Current"),
numMid(obj.ch[0][3], "Hz", "Frequency"),
numMid(obj.ch[0][9], "%", "Efficiency"),
numMid(obj.ch[0][10], "VAr", "Reactive Power"),
numMid(obj.ch[0][10], "var", "Reactive Power"),
numMid(obj.ch[0][4], "", "Power Factor")
])
])
@ -216,9 +216,10 @@
mNum = 0;
total.fill(0);
for(var i = 0; i < obj.iv.length; i++) {
if(obj.iv[i])
if(obj.iv[i]) {
getAjax("/api/inverter/id/" + i, parseIv);
break;
}
}
document.getElementById("refresh").innerHTML = obj["refresh"];
if(true == exeOnce) {

Loading…
Cancel
Save