mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-22 13:26:10 +02:00
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
This commit is contained in:
parent
f5ef19ccab
commit
6ef7720324
9 changed files with 41 additions and 19 deletions
|
@ -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
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
//-------------------------------------
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 5
|
||||
#define VERSION_PATCH 95
|
||||
#define VERSION_PATCH 96
|
||||
|
||||
//-------------------------------------
|
||||
typedef struct {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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__*/
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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,10 +216,11 @@
|
|||
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) {
|
||||
window.setInterval("getAjax('/api/live', parse)", obj["refresh"] * 1000);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue