mirror of
https://github.com/lumapu/ahoy.git
synced 2025-06-02 02:31:38 +02:00
Improved ESP8266 support for HMS version (same code base: only ESP32 supports HMS!)
This commit is contained in:
parent
8c67f59eed
commit
27f16c4e91
5 changed files with 39 additions and 19 deletions
20
src/app.cpp
20
src/app.cpp
|
@ -61,22 +61,20 @@ void app::setup() {
|
||||||
mMiPayload.enableSerialDebug(mConfig->serial.debug);
|
mMiPayload.enableSerialDebug(mConfig->serial.debug);
|
||||||
mMiPayload.addPayloadListener(std::bind(&app::payloadEventListener, this, std::placeholders::_1));
|
mMiPayload.addPayloadListener(std::bind(&app::payloadEventListener, this, std::placeholders::_1));
|
||||||
|
|
||||||
if(!mNrfRadio.isChipConnected())
|
#if defined(ESP32)
|
||||||
DPRINTLN(DBG_WARN, F("WARNING! your NRF24 module can't be reached, check the wiring"));
|
|
||||||
}
|
|
||||||
//if(mConfig->cmt.enabled) {
|
|
||||||
mHmsPayload.setup(this, &mSys, &mCmtRadio, &mStat, 5, &mTimestamp);
|
mHmsPayload.setup(this, &mSys, &mCmtRadio, &mStat, 5, &mTimestamp);
|
||||||
mHmsPayload.enableSerialDebug(mConfig->serial.debug);
|
mHmsPayload.enableSerialDebug(mConfig->serial.debug);
|
||||||
mHmsPayload.addPayloadListener(std::bind(&app::payloadEventListener, this, std::placeholders::_1));
|
mHmsPayload.addPayloadListener(std::bind(&app::payloadEventListener, this, std::placeholders::_1));
|
||||||
//}
|
#endif
|
||||||
|
|
||||||
/*DBGPRINTLN("--- after payload");
|
/*DBGPRINTLN("--- after payload");
|
||||||
DBGPRINTLN(String(ESP.getFreeHeap()));
|
DBGPRINTLN(String(ESP.getFreeHeap()));
|
||||||
DBGPRINTLN(String(ESP.getHeapFragmentation()));
|
DBGPRINTLN(String(ESP.getHeapFragmentation()));
|
||||||
DBGPRINTLN(String(ESP.getMaxFreeBlockSize()));*/
|
DBGPRINTLN(String(ESP.getMaxFreeBlockSize()));*/
|
||||||
|
|
||||||
//if (!mSys.Radio.isChipConnected())
|
if(mConfig->nrf.enabled) {
|
||||||
// DPRINTLN(DBG_WARN, F("WARNING! your NRF24 module can't be reached, check the wiring"));
|
if (!mSys.Radio.isChipConnected())
|
||||||
|
DPRINTLN(DBG_WARN, F("WARNING! your NRF24 module can't be reached, check the wiring"));
|
||||||
|
}
|
||||||
|
|
||||||
// when WiFi is in client mode, then enable mqtt broker
|
// when WiFi is in client mode, then enable mqtt broker
|
||||||
#if !defined(AP_ONLY)
|
#if !defined(AP_ONLY)
|
||||||
|
@ -371,10 +369,12 @@ void app::tickMidnight(void) {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void app::tickSend(void) {
|
void app::tickSend(void) {
|
||||||
/*if(!mNrfRadio.isChipConnected()) {
|
if(mConfig->nrf.enabled) {
|
||||||
|
if(!mNrfRadio.isChipConnected()) {
|
||||||
DPRINTLN(DBG_WARN, F("NRF24 not connected!"));
|
DPRINTLN(DBG_WARN, F("NRF24 not connected!"));
|
||||||
return;
|
return;
|
||||||
}*/
|
}
|
||||||
|
}
|
||||||
if (mIVCommunicationOn) {
|
if (mIVCommunicationOn) {
|
||||||
if (!mNrfRadio.mBufCtrl.empty()) {
|
if (!mNrfRadio.mBufCtrl.empty()) {
|
||||||
if (mConfig->serial.debug) {
|
if (mConfig->serial.debug) {
|
||||||
|
|
12
src/app.h
12
src/app.h
|
@ -36,11 +36,13 @@
|
||||||
#define ASIN(x) (degrees(asin(x)))
|
#define ASIN(x) (degrees(asin(x)))
|
||||||
#define ACOS(x) (degrees(acos(x)))
|
#define ACOS(x) (degrees(acos(x)))
|
||||||
|
|
||||||
typedef CmtRadio<esp32_3wSpi<>> CmtRadioType;
|
|
||||||
typedef HmSystem<MAX_NUM_INVERTERS> HmSystemType;
|
typedef HmSystem<MAX_NUM_INVERTERS> HmSystemType;
|
||||||
typedef HmPayload<HmSystemType, HmRadio<>> PayloadType;
|
typedef HmPayload<HmSystemType, HmRadio<>> PayloadType;
|
||||||
typedef MiPayload<HmSystemType, HmRadio<>> MiPayloadType;
|
typedef MiPayload<HmSystemType, HmRadio<>> MiPayloadType;
|
||||||
|
#ifdef ESP32
|
||||||
|
typedef CmtRadio<esp32_3wSpi<>> CmtRadioType;
|
||||||
typedef HmsPayload<HmSystemType, CmtRadioType> HmsPayloadType;
|
typedef HmsPayload<HmSystemType, CmtRadioType> HmsPayloadType;
|
||||||
|
#endif
|
||||||
typedef Web<HmSystemType> WebType;
|
typedef Web<HmSystemType> WebType;
|
||||||
typedef RestApi<HmSystemType, HmRadio<>> RestApiType;
|
typedef RestApi<HmSystemType, HmRadio<>> RestApiType;
|
||||||
typedef PubMqtt<HmSystemType> PubMqttType;
|
typedef PubMqtt<HmSystemType> PubMqttType;
|
||||||
|
@ -66,9 +68,11 @@ class app : public IApp, public ah::Scheduler {
|
||||||
mNrfRadio.handleIntr();
|
mNrfRadio.handleIntr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ESP32
|
||||||
void handleHmsIntr(void) {
|
void handleHmsIntr(void) {
|
||||||
mCmtRadio.handleIntr();
|
mCmtRadio.handleIntr();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
uint32_t getUptime() {
|
uint32_t getUptime() {
|
||||||
return Scheduler::getUptime();
|
return Scheduler::getUptime();
|
||||||
|
@ -299,7 +303,6 @@ class app : public IApp, public ah::Scheduler {
|
||||||
|
|
||||||
HmSystemType mSys;
|
HmSystemType mSys;
|
||||||
HmRadio<> mNrfRadio;
|
HmRadio<> mNrfRadio;
|
||||||
CmtRadioType mCmtRadio;
|
|
||||||
|
|
||||||
bool mShowRebootRequest;
|
bool mShowRebootRequest;
|
||||||
bool mIVCommunicationOn;
|
bool mIVCommunicationOn;
|
||||||
|
@ -309,8 +312,11 @@ class app : public IApp, public ah::Scheduler {
|
||||||
RestApiType mApi;
|
RestApiType mApi;
|
||||||
PayloadType mPayload;
|
PayloadType mPayload;
|
||||||
MiPayloadType mMiPayload;
|
MiPayloadType mMiPayload;
|
||||||
HmsPayloadType mHmsPayload;
|
|
||||||
PubSerialType mPubSerial;
|
PubSerialType mPubSerial;
|
||||||
|
#ifdef ESP32
|
||||||
|
CmtRadioType mCmtRadio;
|
||||||
|
HmsPayloadType mHmsPayload;
|
||||||
|
#endif
|
||||||
|
|
||||||
char mVersion[12];
|
char mVersion[12];
|
||||||
settings mSettings;
|
settings mSettings;
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 6
|
#define VERSION_MINOR 6
|
||||||
#define VERSION_PATCH 9
|
#define VERSION_PATCH 10
|
||||||
|
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -14,9 +14,11 @@ IRAM_ATTR void handleIntr(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
#ifdef ESP32
|
||||||
IRAM_ATTR void handleHmsIntr(void) {
|
IRAM_ATTR void handleHmsIntr(void) {
|
||||||
myApp.handleHmsIntr();
|
myApp.handleHmsIntr();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void setup() {
|
void setup() {
|
||||||
|
@ -26,10 +28,12 @@ void setup() {
|
||||||
if(DEF_PIN_OFF != myApp.getNrfIrqPin())
|
if(DEF_PIN_OFF != myApp.getNrfIrqPin())
|
||||||
attachInterrupt(digitalPinToInterrupt(myApp.getNrfIrqPin()), handleIntr, FALLING);
|
attachInterrupt(digitalPinToInterrupt(myApp.getNrfIrqPin()), handleIntr, FALLING);
|
||||||
}
|
}
|
||||||
|
#ifdef ESP32
|
||||||
if(myApp.getCmtEnabled()) {
|
if(myApp.getCmtEnabled()) {
|
||||||
if(DEF_PIN_OFF != myApp.getCmtIrqPin())
|
if(DEF_PIN_OFF != myApp.getCmtIrqPin())
|
||||||
attachInterrupt(digitalPinToInterrupt(myApp.getCmtIrqPin()), handleHmsIntr, RISING);
|
attachInterrupt(digitalPinToInterrupt(myApp.getCmtIrqPin()), handleHmsIntr, RISING);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-8 col-sm-3">Dark Mode</div>
|
<div class="col-8 col-sm-3">Dark Mode</div>
|
||||||
<div class="col-4 col-sm-9"><input type="checkbox" name="darkMode"/></div>
|
<div class="col-4 col-sm-9"><input type="checkbox" name="darkMode"/></div>
|
||||||
<div class="col-8 col-sm-3">(empty browser cache or use CTRL + F5 after reboot to apply this setting)</div>
|
<div class="col-12">(empty browser cache or use CTRL + F5 after reboot to apply this setting)</div>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset class="mb-4">
|
<fieldset class="mb-4">
|
||||||
|
@ -33,7 +33,7 @@
|
||||||
<div id="rf24"></div>
|
<div id="rf24"></div>
|
||||||
|
|
||||||
<p class="des">Radio (CMT2300A)</p>
|
<p class="des">Radio (CMT2300A)</p>
|
||||||
<div id="cmt"></div>
|
<div id="cmt"><div class="col-12">(ESP32 only)</div></div>
|
||||||
|
|
||||||
<p class="des">Serial Console</p>
|
<p class="des">Serial Console</p>
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
|
@ -695,6 +695,16 @@
|
||||||
|
|
||||||
function parseNrfRadio(obj, type, system) {
|
function parseNrfRadio(obj, type, system) {
|
||||||
var e = document.getElementById("rf24");
|
var e = document.getElementById("rf24");
|
||||||
|
var en = inp("nrfEnable", null, null, ["cb"], "nrfEnable", "checkbox");
|
||||||
|
en.checked = obj["en"];
|
||||||
|
|
||||||
|
e.replaceChildren (
|
||||||
|
ml("div", {class: "row mb-3"}, [
|
||||||
|
ml("div", {class: "col-8 col-sm-3 my-2"}, "NRF24 Enable"),
|
||||||
|
ml("div", {class: "col-4 col-sm-9"}, en)
|
||||||
|
])
|
||||||
|
);
|
||||||
|
|
||||||
if ("ESP8266" == type) {
|
if ("ESP8266" == type) {
|
||||||
pins = [['cs', 'pinCs'], ['ce', 'pinCe'], ['irq', 'pinIrq']];
|
pins = [['cs', 'pinCs'], ['ce', 'pinCe'], ['irq', 'pinIrq']];
|
||||||
} else {
|
} else {
|
||||||
|
@ -730,7 +740,7 @@
|
||||||
var en = inp("cmtEnable", null, null, ["cb"], "cmtEnable", "checkbox");
|
var en = inp("cmtEnable", null, null, ["cb"], "cmtEnable", "checkbox");
|
||||||
en.checked = obj["en"];
|
en.checked = obj["en"];
|
||||||
|
|
||||||
e.append(
|
e.replaceChildren (
|
||||||
ml("div", {class: "row mb-3"}, [
|
ml("div", {class: "row mb-3"}, [
|
||||||
ml("div", {class: "col-8 col-sm-3 my-2"}, "CMT2300A Enable"),
|
ml("div", {class: "col-8 col-sm-3 my-2"}, "CMT2300A Enable"),
|
||||||
ml("div", {class: "col-4 col-sm-9"}, en)
|
ml("div", {class: "col-4 col-sm-9"}, en)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue