Browse Source

0.7.51

* fix CMT configureable pins #1150
* fix default CMT pins for opendtufusion
* beautified `system`
* changed main loops, fix resets #1125, #1135
pull/1163/head
lumapu 1 year ago
parent
commit
9521cf756a
  1. 6
      src/CHANGES.md
  2. 49
      src/app.cpp
  3. 9
      src/app.h
  4. 2
      src/defines.h
  5. 4
      src/platformio.ini
  6. 6
      src/web/html/index.html
  7. 2
      src/web/html/setup.html
  8. 26
      src/web/html/system.html
  9. 2
      src/web/web.h

6
src/CHANGES.md

@ -1,5 +1,11 @@
# Development Changes
## 0.7.51 - 2023-09-16
* fix CMT configureable pins #1150
* fix default CMT pins for opendtufusion
* beautified `system`
* changed main loops, fix resets #1125, #1135
## 0.7.50 - 2023-09-12
* moved MqTT info to `system`
* added CMT info for ESP32 devices

49
src/app.cpp

@ -11,10 +11,7 @@
//-----------------------------------------------------------------------------
app::app()
: ah::Scheduler {},
mInnerLoopCb {nullptr} {
}
app::app() : ah::Scheduler {} {}
//-----------------------------------------------------------------------------
@ -55,14 +52,6 @@ void app::setup() {
DSERIAL.flush();
#endif // ETHERNET
#if !defined(ETHERNET)
#if defined(AP_ONLY)
mInnerLoopCb = std::bind(&app::loopStandard, this);
#else
mInnerLoopCb = std::bind(&app::loopWifi, this);
#endif
#endif /* !defined(ETHERNET) */
#if !defined(ETHERNET)
mWifi.setup(mConfig, &mTimestamp, std::bind(&app::onNetwork, this, std::placeholders::_1));
#if !defined(AP_ONLY)
@ -128,14 +117,6 @@ void app::setup() {
//-----------------------------------------------------------------------------
void app::loop(void) {
if (mInnerLoopCb)
mInnerLoopCb();
#if !defined(ETHERNET)
#endif
}
//-----------------------------------------------------------------------------
void app::loopStandard(void) {
ah::Scheduler::loop();
if (mNrfRadio.loop() && mConfig->nrf.enabled) {
@ -198,24 +179,14 @@ void app::loopStandard(void) {
mHmsPayload.loop();
#endif
if (mMqttEnabled)
if (mMqttEnabled && mNetworkConnected)
mMqtt.loop();
}
#if !defined(ETHERNET)
//-----------------------------------------------------------------------------
void app::loopWifi(void) {
ah::Scheduler::loop();
yield();
}
#endif /* !defined(ETHERNET) */
//-----------------------------------------------------------------------------
void app::onNetwork(bool gotIp) {
DPRINTLN(DBG_DEBUG, F("onNetwork"));
ah::Scheduler::resetTicker();
regularTickers(); // reinstall regular tickers
if (gotIp) {
mNetworkConnected = gotIp;
every(std::bind(&app::tickSend, this), mConfig->nrf.sendInterval, "tSend");
#if defined(ESP32)
if(mConfig->cmt.enabled)
@ -223,22 +194,14 @@ void app::onNetwork(bool gotIp) {
#endif
mMqttReconnect = true;
mSunrise = 0; // needs to be set to 0, to reinstall sunrise and ivComm tickers!
once(std::bind(&app::tickNtpUpdate, this), 2, "ntp2");
//once(std::bind(&app::tickNtpUpdate, this), 2, "ntp2");
tickNtpUpdate();
#if !defined(ETHERNET)
if (WIFI_AP == WiFi.getMode()) {
mMqttEnabled = false;
}
everySec(std::bind(&ahoywifi::tickWifiLoop, &mWifi), "wifiL");
#endif /* !defined(ETHERNET) */
mInnerLoopCb = [this]() { this->loopStandard(); };
} else {
#if defined(ETHERNET)
mInnerLoopCb = nullptr;
#else /* defined(ETHERNET) */
mInnerLoopCb = [this]() { this->loopWifi(); };
everySec(std::bind(&ahoywifi::tickWifiLoop, &mWifi), "wifiL");
#endif /* defined(ETHERNET) */
}
}
//-----------------------------------------------------------------------------
@ -560,6 +523,8 @@ void app::resetSystem(void) {
mSavePending = false;
mSaveReboot = false;
mNetworkConnected = false;
memset(&mStat, 0, sizeof(statistics_t));
}

9
src/app.h

@ -66,9 +66,6 @@ class app : public IApp, public ah::Scheduler {
void setup(void);
void loop(void);
void loopStandard(void);
#if !defined(ETHERNET)
void loopWifi(void);
#endif /* !defined(ETHERNET) */
void onNetwork(bool gotIp);
void regularTickers(void);
@ -272,8 +269,6 @@ class app : public IApp, public ah::Scheduler {
#define CHECK_AVAIL true
#define SKIP_YIELD_DAY true
typedef std::function<void()> innerLoopCb;
void resetSystem(void);
void zeroIvValues(bool checkAvail = false, bool skipYieldDay = true);
@ -325,8 +320,6 @@ class app : public IApp, public ah::Scheduler {
void tickZeroValues(void);
void tickMidnight(void);
innerLoopCb mInnerLoopCb;
HmSystemType mSys;
HmRadio<> mNrfRadio;
@ -360,6 +353,8 @@ class app : public IApp, public ah::Scheduler {
uint8_t mSendLastIvId;
bool mSendFirst;
bool mNetworkConnected;
statistics_t mStat;
// mqtt

2
src/defines.h

@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 7
#define VERSION_PATCH 50
#define VERSION_PATCH 51
//-------------------------------------
typedef struct {

4
src/platformio.ini

@ -137,10 +137,12 @@ build_flags = ${env.build_flags}
-DDEF_CMT_CSB=4
-DDEF_CMT_FCSB=21
-DDEF_CMT_IRQ=8
-DDEF_CMT_SDIO=5
-DDEF_CMT_SCLK=6
-DDEF_LED0=18
-DDEF_LED1=17
-DLED_ACTIVE_HIGH
-DARDUINO_USB_MODE=1
;-DARDUINO_USB_CDC_ON_BOOT=1
-DARDUINO_USB_CDC_ON_BOOT=1
monitor_filters =
esp32_exception_decoder, colorize

6
src/web/html/index.html

@ -115,7 +115,7 @@
}
}
function parseIv(obj) {
function parseIv(obj, ts) {
var p = div(["none"]);
for(var i of obj) {
var icon = iconSuccess;
@ -125,7 +125,7 @@
icon = iconWarn;
cl = "icon-warn";
avail = "disabled";
} else if(false == i["is_avail"]) {
} else if((false == i["is_avail"]) || (0 == ts)) {
icon = iconInfo;
cl = "icon-info";
avail = "not yet available";
@ -192,7 +192,7 @@
parseNav(obj["generic"]);
parseGeneric(obj["generic"]);
parseSys(obj);
parseIv(obj["inverter"]);
parseIv(obj["inverter"], obj.ts_now);
parseWarn(obj["warnings"]);
if(exeOnce) {
window.setInterval("tick()", 1000);

2
src/web/html/setup.html

@ -817,7 +817,7 @@
ml("div", {class: "row mb-3"}, [
ml("div", {class: "col-12 col-sm-3 my-2"}, p[0].toUpperCase()),
ml("div", {class: "col-12 col-sm-9"},
sel(p[1], ("ESP32-S3" == system["chip_model"]) ? esp32s3pins : esp32pins, obj[p[0]])
sel(p[1], (("ESP32-S3" == system["chip_model"]) ? esp32s3pins : esp32pins), obj[p[0]])
)
])
);

26
src/web/html/system.html

@ -20,30 +20,24 @@
parseRssi(obj);
}
function genTabRow(key, value) {
var r = div(["row", "p-1"]);
r.appendChild(div(["col"], key));
r.appendChild(div(["col"], value));
return r;
}
function parseSysInfo(obj) {
const data = ["sdk", "cpu_freq", "chip_revision",
"chip_model", "chip_cores", "esp_type", "mac", "wifi_rssi", "ts_uptime",
"flash_size", "sketch_used", "heap_total", "heap_free", "heap_frag",
"max_free_blk", "version", "core_version", "reboot_reason"];
var main = document.getElementById("info");
var h = div(["head", "p-2"]);
var r = div(["row"]);
r.appendChild(div(["col", "a-c"], "System Information"));
h.appendChild(r);
main.appendChild(h);
lines = [];
for (const [key, value] of Object.entries(obj)) {
if(!data.includes(key) || (typeof value == 'undefined')) continue;
main.appendChild(genTabRow(key, value));
lines.push(tr(key.replace('_', ' '), value));
}
document.getElementById("info").append(
headline("System Information"),
ml("table", {class: "table"},
ml("tbody", {}, lines)
)
);
}
function badge(success, text, second="error") {
@ -58,7 +52,7 @@
if(typeof val2 == "number")
val2 = String(val2);
return ml("tr", {}, [
ml("th", {}, val1),
ml("th", {style: "width: 50%"}, val1),
ml("td", {}, val2)
]);
}

2
src/web/web.h

@ -543,7 +543,7 @@ class Web {
// pinout
uint8_t pin;
for (uint8_t i = 0; i < 12; i++) {
for (uint8_t i = 0; i < 14; i++) {
pin = request->arg(String(pinArgNames[i])).toInt();
switch(i) {
case 0: mConfig->nrf.pinCs = ((pin != 0xff) ? pin : DEF_NRF_CS_PIN); break;

Loading…
Cancel
Save