Browse Source

0.7.49

* add option to strip webUI for ESP8266 (reduce code size, add ESP32 special features; `IF_ESP32` directives)
* started to get CMT info into `system` - not finished
pull/1163/head
lumapu 1 year ago
parent
commit
9dd689b395
  1. 2
      src/CHANGES.md
  2. 8
      src/app.h
  3. 9
      src/appInterface.h
  4. 25
      src/web/RestApi.h
  5. 31
      src/web/html/convert.py
  6. 28
      src/web/html/setup.html
  7. 2
      src/web/html/style.css
  8. 77
      src/web/html/system.html

2
src/CHANGES.md

@ -4,6 +4,8 @@
* merge PR: symbolic icons for mono displays, PR #1136
* merge MI code restructuring PR #1145
* merge Prometheus PR #1148
* add option to strip webUI for ESP8266 (reduce code size, add ESP32 special features; `IF_ESP32` directives)
* started to get CMT info into `system` - not finished
## 0.7.48 - 2023-09-10
* fix SSD1309 2.42" display pinout

8
src/app.h

@ -9,9 +9,9 @@
#include <Arduino.h>
#include <ArduinoJson.h>
#include "appInterface.h"
#include "config/settings.h"
#include "defines.h"
#include "appInterface.h"
#include "hm/hmPayload.h"
#include "hm/hmSystem.h"
#include "hm/hmRadio.h"
@ -75,11 +75,17 @@ class app : public IApp, public ah::Scheduler {
void handleIntr(void) {
mNrfRadio.handleIntr();
}
const HmRadio<>& getNrfRadioObj(void) const {
return mNrfRadio;
}
#ifdef ESP32
void handleHmsIntr(void) {
mCmtRadio.handleIntr();
}
const CmtRadioType& getCmtRadioObj(void) const {
return mCmtRadio;
}
#endif
uint32_t getUptime() {

9
src/appInterface.h

@ -14,6 +14,11 @@
#include "ESPAsyncWebServer.h"
#endif
//#include "hms/hmsRadio.h"
#if defined(ESP32)
//typedef CmtRadio<esp32_3wSpi<>> CmtRadioType;
#endif
// abstract interface to App. Make members of App accessible from child class
// like web or API without forward declaration
class IApp {
@ -62,6 +67,10 @@ class IApp {
virtual void getNrfRadioCounters(uint32_t *sendCnt, uint32_t *retransmits) = 0;
//virtual void getCmtRadioCounters(uint32_t *sendCnt, uint32_t *retransmits) = 0;
#if defined(ESP32)
//virtual const CmtRadioType& getCmtRadioObj(void) const = 0;
#endif
};
#endif /*__IAPP_H__*/

25
src/web/RestApi.h

@ -239,6 +239,9 @@ class RestApi {
getGeneric(request, obj);
getRadioNrf(obj.createNestedObject(F("radio")));
#if defined(ESP32)
getRadioCmtInfo(obj.createNestedObject(F("radioCmt")));
#endif
getStatistics(obj.createNestedObject(F("statistics")));
#if defined(ESP32)
@ -490,19 +493,25 @@ class RestApi {
obj[F("led_high_active")] = mConfig->led.led_high_active;
}
#if defined(ESP32)
void getRadioCmt(JsonObject obj) {
obj[F("csb")] = mConfig->cmt.pinCsb;
obj[F("fcsb")] = mConfig->cmt.pinFcsb;
obj[F("gpio3")] = mConfig->cmt.pinIrq;
obj[F("en")] = (bool) mConfig->cmt.enabled;
obj[F("csb")] = mConfig->cmt.pinCsb;
obj[F("fcsb")] = mConfig->cmt.pinFcsb;
obj[F("gpio3")] = mConfig->cmt.pinIrq;
obj[F("en")] = (bool) mConfig->cmt.enabled;
}
void getRadioCmtInfo(JsonObject obj) {
obj[F("en")] = (bool) mConfig->cmt.enabled;
}
#endif
void getRadioNrf(JsonObject obj) {
obj[F("power_level")] = mConfig->nrf.amplifierPower;
obj[F("isconnected")] = mRadio->isChipConnected();
obj[F("DataRate")] = mRadio->getDataRate();
obj[F("isPVariant")] = mRadio->isPVariant();
obj[F("en")] = (bool) mConfig->nrf.enabled;
//obj[F("DataRate")] = mRadio->getDataRate();
//obj[F("isPVariant")] = mRadio->isPVariant();
obj[F("en")] = (bool) mConfig->nrf.enabled;
}
void getSerial(JsonObject obj) {
@ -593,7 +602,9 @@ class RestApi {
getNtp(obj.createNestedObject(F("ntp")));
getSun(obj.createNestedObject(F("sun")));
getPinout(obj.createNestedObject(F("pinout")));
#if defined(ESP32)
getRadioCmt(obj.createNestedObject(F("radioCmt")));
#endif
getRadioNrf(obj.createNestedObject(F("radioNrf")));
getSerial(obj.createNestedObject(F("serial")));
getStaticIp(obj.createNestedObject(F("static_ip")));

31
src/web/html/convert.py

@ -6,6 +6,7 @@ import shutil
from datetime import date
from pathlib import Path
import subprocess
Import("env")
def get_git_sha():
@ -60,13 +61,41 @@ def htmlParts(file, header, nav, footer, version):
link = '<a target="_blank" href="https://github.com/lumapu/ahoy/commits/' + get_git_sha() + '">GIT SHA: ' + get_git_sha() + ' :: ' + version + '</a>'
p = p.replace("{#VERSION}", version)
p = p.replace("{#VERSION_GIT}", link)
# remove if - endif ESP32
p = checkIf(p)
f = open("tmp/" + file, "w")
f.write(p);
f.close();
return p
def checkIf(data):
if (env['PIOENV'][0:5] == "esp32") or env['PIOENV'][0:4] == "open":
data = data.replace("<!--IF_ESP32-->", "")
data = data.replace("<!--ENDIF_ESP32-->", "")
data = data.replace("/*IF_ESP32*/", "")
data = data.replace("/*ENDIF_ESP32*/", "")
else:
while 1:
start = data.find("<!--IF_ESP32-->")
end = data.find("<!--ENDIF_ESP32-->")+18
if -1 == start:
break
else:
data = data[0:start] + data[end:]
while 1:
start = data.find("/*IF_ESP32*/")
end = data.find("/*ENDIF_ESP32*/")+15
if -1 == start:
break
else:
data = data[0:start] + data[end:]
return data
def convert2Header(inFile, version):
fileType = inFile.split(".")[1]
fileType = inFile.split(".")[1]
define = inFile.split(".")[0].upper()
define2 = inFile.split(".")[1].upper()
inFileVarName = inFile.replace(".", "_")

28
src/web/html/setup.html

@ -35,10 +35,10 @@
<p class="des">Radio (NRF24L01+)</p>
<div id="rf24"></div>
<!--IF_ESP32-->
<p class="des">Radio (CMT2300A)</p>
<div id="cmt"><div class="col-12">(ESP32 only)</div></div>
<!--ENDIF_ESP32-->
<p class="des">Serial Console</p>
<div class="row mb-3">
<div class="col-8 col-sm-3">print inverter data</div>
@ -366,6 +366,8 @@
[15, "D8 (GPIO15)"],
[16, "D0 (GPIO16 - no IRQ!)"]
];
/*IF_ESP32*/
var esp32pins = [
[255, "off / default"],
[0, "GPIO0"],
@ -443,6 +445,7 @@
[47, "GPIO47"],
[48, "GPIO48"],
];
/*ENDIF_ESP32*/
var led_high_active = [
[0, "low active"],
[1, "high active"],
@ -796,6 +799,7 @@
);
}
/*IF_ESP32*/
function parseCmtRadio(obj, type, system) {
var e = document.getElementById("cmt");
var en = inp("cmtEnable", null, null, ["cb"], "cmtEnable", "checkbox");
@ -819,6 +823,7 @@
);
}
}
/*ENDIF_ESP32*/
function parseSerial(obj) {
for(var i of [["serEn", "show_live_data"], ["serDbg", "debug"]])
@ -833,8 +838,9 @@
var e = document.getElementById("dispPins");
//KEEP this order !!!
var pins = [['clock', 'disp_clk'], ['data', 'disp_data'], ['cs', 'disp_cs'], ['dc', 'disp_dc'], ['reset', 'disp_rst']];
if("ESP32" == type)
pins.push(['busy', 'disp_bsy']);
/*IF_ESP32*/
pins.push(['busy', 'disp_bsy']);
/*ENDIF_ESP32*/
for(p of pins) {
e.append(
ml("div", {class: "row mb-3", id: "row_" + p[1]}, [
@ -848,8 +854,9 @@
// keep display types grouped
var opts = [[0, "None"], [2, "SH1106 1.3\" 128X64"], [5, "SSD1306 0.66\" 64X48 (Wemos OLED Shield)"], [4, "SSD1306 0.91\" 128X32"], [1, "SSD1306 0.96\" 128X64"], [6, "SSD1309 2.42\" 128X64"], [3, "Nokia5110"]];
if("ESP32" == type)
opts.push([10, "ePaper"]);
/*IF_ESP32*/
opts.push([10, "ePaper"]);
/*ENDIF_ESP32*/
var dispType = sel("disp_typ", opts, obj["disp_typ"]);
document.getElementById("dispType").append(
ml("div", {class: "row mb-3"}, [
@ -862,10 +869,10 @@
});
opts = [[0, "0&deg;"], [2, "180&deg;"]];
if("ESP32" == type) {
/*IF_ESP32*/
opts.push([1, "90&deg;"]);
opts.push([3, "270&deg;"]);
}
/*ENDIF_ESP32*/
document.getElementById("dispRot").append(
ml("div", {class: "row mb-3"}, [
ml("div", {class: "col-12 col-sm-3 my-2"}, "Rotation"),
@ -916,8 +923,9 @@
parseSun(root["sun"]);
parsePinout(root["pinout"], root["system"]["esp_type"], root["system"]);
parseNrfRadio(root["radioNrf"], root["pinout"], root["system"]["esp_type"], root["system"]);
if(root["generic"]["esp_type"] == "ESP32")
parseCmtRadio(root["radioCmt"], root["system"]["esp_type"], root["system"]);
/*IF_ESP32*/
parseCmtRadio(root["radioCmt"], root["system"]["esp_type"], root["system"]);
/*ENDIF_ESP32*/
parseSerial(root["serial"]);
parseDisplay(root["display"], root["system"]["esp_type"], root["system"]);
getAjax("/api/inverter/list", parseIv);

2
src/web/html/style.css

@ -756,7 +756,7 @@ h5 {
.badge {
display: inline-block;
padding: .25em .4em;
font-size: 75%;
font-size: 85%;
font-weight: 700;
line-height: 1;
text-align: center;

77
src/web/html/system.html

@ -8,10 +8,7 @@
{#HTML_NAV}
<div id="wrapper">
<div id="content">
<pre id="stat"></pre>
<div id="info" class="col-sm-12 col-md-6 mt-3"></div>
<div id="radio" class="col-sm-12 col-md-6 mt-3"></div>
<div id="sun" class="col-sm-12 col-md-6 mt-3"></div>
<div id="html" class="mt-3 mb-3"></div>
</div>
</div>
@ -49,8 +46,8 @@
}
}
function badge(success, text) {
return ml("span", {class: "badge badge-" + ((success) ? "success" : "error")}, text);
function badge(success, text, second="error") {
return ml("span", {class: "badge badge-" + ((success) ? "success" : second)}, text);
}
function headline(text) {
@ -68,19 +65,23 @@
function parseRadio(obj, stat) {
const pa = ["MIN (recommended)", "LOW", "HIGH", "MAX"];
const datarate = ["1 MBps", "2 MBps", "250 kbps"];
document.getElementById("radio").append(
if(obj.en)
lines = [
tr("NRF24L01", badge(obj.isconnected, ((obj.isconnected) ? "" : "not ") + "connected")),
tr("Power Level", pa[obj.power_level])
];
else
lines = tr("NRF24L01", badge(false, "not enabled"));
document.getElementById("info").append(
headline("NRF Radio"),
ml("table", {class: "table"}, [
ml("tbody", {}, [
tr("NRF24L01", badge(obj.isconnected, ((obj.isconnected) ? "" : "not ") + "connected")),
tr("Power Level", pa[obj.power_level])
])
]),
ml("table", {class: "table"},
ml("tbody", {}, lines)
),
headline("Statistics"),
ml("table", {class: "table"}, [
ml("table", {class: "table"},
ml("tbody", {}, [
tr("TX count", stat.tx_cnt),
tr("RX success", stat.rx_success),
@ -89,24 +90,41 @@
tr("RX fragments", stat.frame_cnt),
tr("TX retransmits", stat.retransmits)
])
])
)
);
}
/*IF_ESP32*/
function parseCmt(obj) {
if(obj.en)
lines = [
tr("CMT2300A", badge(obj.isconnected, ((obj.isconnected) ? "" : "not ") + "connected"))
];
else
lines = tr("CMT2300A", badge(false, "not enabled"));
document.getElementById("info").append(
headline("CMT Radio"),
ml("table", {class: "table"},
ml("tbody", {}, lines)
)
);
}
/*ENDIF_ESP32*/
function parseIndex(obj) {
if(obj["ts_sunrise"] > 0) {
var h = div(["head", "p-2"]);
var r = div(["row"]);
r.appendChild(div(["col", "a-c"], "Sun"));
h.appendChild(r);
document.getElementById("sun").append (
h,
genTabRow("Sunrise", new Date(obj["ts_sunrise"] * 1000).toLocaleString('de-DE')),
genTabRow("Sunset", new Date(obj["ts_sunset"] * 1000).toLocaleString('de-DE')),
genTabRow("Communication start", new Date((obj["ts_sunrise"] - obj["ts_offset"]) * 1000).toLocaleString('de-DE')),
genTabRow("Communication stop", new Date((obj["ts_sunset"] + obj["ts_offset"]) * 1000).toLocaleString('de-DE')),
genTabRow("Night Communication", ((obj["disNightComm"]) ? "disabled" : "enabled"))
if(obj.ts_sunrise > 0) {
document.getElementById("info").append(
headline("Sun"),
ml("table", {class: "table"},
ml("tbody", {}, [
tr("Sunrise", new Date(obj.ts_sunrise * 1000).toLocaleString('de-DE')),
tr("Sunset", new Date(obj.ts_sunset * 1000).toLocaleString('de-DE')),
tr("Communication start", new Date((obj.ts_sunrise - obj.ts_offset) * 1000).toLocaleString('de-DE')),
tr("Communication stop", new Date((obj.ts_sunset + obj.ts_offset) * 1000).toLocaleString('de-DE')),
tr("Night behaviour", badge(obj.disNightComm, ((obj.disNightComm) ? "not" : "") + " communicating", "warning"))
])
)
);
}
}
@ -124,6 +142,9 @@
else {
parseSysInfo(obj["system"]);
parseRadio(obj["system"]["radio"], obj["system"]["statistics"]);
/*IF_ESP32*/
parseCmt(obj["system"]["radioCmt"]);
/*ENDIF_ESP32*/
getAjax('/api/index', parseIndex);
}
document.getElementById("html").innerHTML = obj["html"];

Loading…
Cancel
Save