diff --git a/src/config/settings.h b/src/config/settings.h index 0a738309..9894dcf9 100644 --- a/src/config/settings.h +++ b/src/config/settings.h @@ -234,6 +234,9 @@ class settings { mCfg.valid = true; jsonWifi(root[F("wifi")]); jsonNrf(root[F("nrf")]); + #if defined(ESP32) + jsonCmt(root[F("cmt")]); + #endif jsonNtp(root[F("ntp")]); jsonSun(root[F("sun")]); jsonSerial(root[F("serial")]); @@ -263,6 +266,9 @@ class settings { JsonObject root = json.to(); jsonWifi(root.createNestedObject(F("wifi")), true); jsonNrf(root.createNestedObject(F("nrf")), true); + #if defined(ESP32) + jsonCmt(root.createNestedObject(F("cmt")), true); + #endif jsonNtp(root.createNestedObject(F("ntp")), true); jsonSun(root.createNestedObject(F("sun")), true); jsonSerial(root.createNestedObject(F("serial")), true); @@ -317,6 +323,12 @@ class settings { mCfg.nrf.pinCe = DEF_CE_PIN; mCfg.nrf.pinIrq = DEF_IRQ_PIN; mCfg.nrf.amplifierPower = DEF_AMPLIFIERPOWER & 0x03; + mCfg.nrf.enabled = true; + + mCfg.cmt.pinCsb = DEF_PIN_OFF; + mCfg.cmt.pinFcsb = DEF_PIN_OFF; + mCfg.cmt.pinIrq = DEF_PIN_OFF; + mCfg.cmt.enabled = false; snprintf(mCfg.ntp.addr, NTP_ADDR_LEN, "%s", DEF_NTP_SERVER_NAME); mCfg.ntp.port = DEF_NTP_PORT; @@ -394,6 +406,7 @@ class settings { obj[F("ce")] = mCfg.nrf.pinCe; obj[F("irq")] = mCfg.nrf.pinIrq; obj[F("pwr")] = mCfg.nrf.amplifierPower; + obj[F("en")] = (bool) mCfg.nrf.enabled; } else { mCfg.nrf.sendInterval = obj[F("intvl")]; mCfg.nrf.maxRetransPerPyld = obj[F("maxRetry")]; @@ -401,6 +414,21 @@ class settings { mCfg.nrf.pinCe = obj[F("ce")]; mCfg.nrf.pinIrq = obj[F("irq")]; mCfg.nrf.amplifierPower = obj[F("pwr")]; + mCfg.nrf.enabled = (bool) obj[F("en")]; + } + } + + void jsonCmt(JsonObject obj, bool set = false) { + if(set) { + obj[F("csb")] = mCfg.cmt.pinCsb; + obj[F("fcsb")] = mCfg.cmt.pinFcsb; + obj[F("irq")] = mCfg.cmt.pinIrq; + obj[F("en")] = (bool) mCfg.cmt.enabled; + } else { + mCfg.cmt.pinCsb = obj[F("csb")]; + mCfg.cmt.pinFcsb = obj[F("fcsb")]; + mCfg.cmt.pinIrq = obj[F("irq")]; + mCfg.cmt.enabled = (bool) obj[F("en")]; } } diff --git a/src/hm/hmDefines.h b/src/hm/hmDefines.h index 61850f04..f8e72205 100644 --- a/src/hm/hmDefines.h +++ b/src/hm/hmDefines.h @@ -10,7 +10,7 @@ #include // inverter generations -enum {IV_HM = 0, IV_MI}; +enum {IV_HM = 0, IV_MI, IV_HMS, IV_HMT}; // units enum {UNIT_V = 0, UNIT_A, UNIT_W, UNIT_WH, UNIT_KWH, UNIT_HZ, UNIT_C, UNIT_PCT, UNIT_VAR, UNIT_NONE}; diff --git a/src/hm/hmSystem.h b/src/hm/hmSystem.h index fbadbdb6..0508a6e0 100644 --- a/src/hm/hmSystem.h +++ b/src/hm/hmSystem.h @@ -24,9 +24,12 @@ class HmSystem { if (0ULL != config->iv[i].serial.u64) { if (NULL != iv) { DPRINT(DBG_INFO, "added inverter "); - if(iv->config->serial.b[5] == 0x11) - DBGPRINT("HM"); - else { + if(iv->config->serial.b[5] == 0x11) { + if((iv->config->serial.b[4] & 0x0f) == 0x04) + DBGPRINT("HMS"); + else + DBGPRINT("HM"); + } else { DBGPRINT(((iv->config->serial.b[4] & 0x03) == 0x01) ? " (2nd Gen) " : " (3rd Gen) "); } @@ -56,6 +59,7 @@ class HmSystem { case 0x21: p->type = INV_TYPE_1CH; break; case 0x42: case 0x41: p->type = INV_TYPE_2CH; break; + case 0x64: // HMS2000 case 0x62: case 0x61: p->type = INV_TYPE_4CH; break; default: @@ -63,8 +67,12 @@ class HmSystem { break; } - if(p->config->serial.b[5] == 0x11) - p->ivGen = IV_HM; + if(p->config->serial.b[5] == 0x11) { + if((p->config->serial.b[4] & 0x0f) == 0x04) + p->ivGen = IV_HMS; + else + p->ivGen = IV_HM; + } else if((p->config->serial.b[4] & 0x03) == 0x02) // MI 3rd Gen -> same as HM p->ivGen = IV_HM; else // MI 2nd Gen diff --git a/src/hms/esp32_3wSpi.h b/src/hms/esp32_3wSpi.h index c70e37a8..aeb01f2d 100644 --- a/src/hms/esp32_3wSpi.h +++ b/src/hms/esp32_3wSpi.h @@ -11,6 +11,10 @@ #include "driver/spi_master.h" #include "esp_rom_gpio.h" // for esp_rom_gpio_connect_out_signal +#define CLK_PIN 18 +#define MOSI_PIN 23 +#define MISO_PIN -1 + #define SPI_CLK 1 * 1000 * 1000 // 1MHz template diff --git a/src/web/RestApi.h b/src/web/RestApi.h index b1304510..11f87c64 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -212,7 +212,7 @@ class RestApi { obj[F("sketch_used")] = ESP.getSketchSize() / 1024; // in kb getGeneric(obj); - getRadio(obj.createNestedObject(F("radio"))); + getRadioNrf(obj.createNestedObject(F("radio"))); getStatistics(obj.createNestedObject(F("statistics"))); #if defined(ESP32) @@ -345,11 +345,19 @@ class RestApi { obj[F("led1")] = mConfig->led.led1; } - void getRadio(JsonObject obj) { + void getRadioCmt(JsonObject obj) { + obj[F("csb")] = mConfig->cmt.pinCsb; + obj[F("fcsb")] = mConfig->cmt.pinFcsb; + obj[F("irq")] = mConfig->cmt.pinIrq; + obj[F("en")] = (bool) mConfig->cmt.enabled; + } + + 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; } void getSerial(JsonObject obj) { @@ -482,7 +490,8 @@ class RestApi { getNtp(obj.createNestedObject(F("ntp"))); getSun(obj.createNestedObject(F("sun"))); getPinout(obj.createNestedObject(F("pinout"))); - getRadio(obj.createNestedObject(F("radio"))); + getRadioCmt(obj.createNestedObject(F("radioCmt"))); + getRadioNrf(obj.createNestedObject(F("radioNrf"))); getSerial(obj.createNestedObject(F("serial"))); getStaticIp(obj.createNestedObject(F("static_ip"))); getDisplay(obj.createNestedObject(F("display"))); diff --git a/src/web/html/setup.html b/src/web/html/setup.html index efcf0adc..03809290 100644 --- a/src/web/html/setup.html +++ b/src/web/html/setup.html @@ -173,6 +173,9 @@

Radio (NRF24L01+)

+

Radio (CMT2300A)

+
+

Serial Console


@@ -408,6 +411,11 @@ case "6": max = 4; break; } } + else if(serial.charAt(2) == 6) { + switch(serial.charAt(3) == 4) { + case "4": max = 4; break; + } + } } } @@ -519,22 +527,56 @@ function parsePinout(obj, type) { var e = document.getElementById("pinout"); - pins = [['cs', 'pinCs'], ['ce', 'pinCe'], ['irq', 'pinIrq'], ['led0', 'pinLed0'], ['led1', 'pinLed1']]; + pins = [['led0', 'pinLed0'], ['led1', 'pinLed1']]; for(p of pins) { - e.appendChild(lbl(p[1], p[0].toUpperCase())); - e.appendChild(sel(p[1], ("ESP8266" == type) ? esp8266pins : esp32pins, obj[p[0]])); + e.append( + lbl(p[1], p[0].toUpperCase()), + sel(p[1], ("ESP8266" == type) ? esp8266pins : esp32pins, obj[p[0]]) + ); } } - function parseRadio(obj) { + function parseNrfRadio(obj) { var e = document.getElementById("rf24"); - e.appendChild(lbl("rf24Power", "Amplifier Power Level")); - e.appendChild(sel("rf24Power", [ - [0, "MIN"], - [1, "LOW"], - [2, "HIGH"], - [3, "MAX"] - ], obj["power_level"])); + var en = inp("rf24Enable", null, null, ["cb"], "rf24Enable", "checkbox"); + en.checked = obj["en"]; + + e.append( + lbl("rf24Enable", "NRF24 Radio Enable"), + en, + lbl("rf24Power", "Amplifier Power Level"), + sel("rf24Power", [ + [0, "MIN"], + [1, "LOW"], + [2, "HIGH"], + [3, "MAX"] + ], obj["power_level"]) + ); + pins = [['cs', 'pinCs'], ['ce', 'pinCe'], ['irq', 'pinIrq']]; + for(p of pins) { + e.append( + lbl(p[1], p[0].toUpperCase()), + sel(p[1], ("ESP8266" == type) ? esp8266pins : esp32pins, obj[p[0]]) + ); + } + } + + function parseCmtRadio(obj) { + var e = document.getElementById("cmt"); + var en = inp("cmtEnable", null, null, ["cb"], "cmtEnable", "checkbox"); + en.checked = obj["en"]; + + e.append( + lbl("cmtEnable", "CMT2300A Radio Enable"), + en + ); + pins = [['csb', 'pinCsb'], ['fcsb', 'pinFcsb'], ['irq', 'pinGpio3']]; + for(p of pins) { + e.append( + lbl(p[1], p[0].toUpperCase()), + sel(p[1], ("ESP8266" == type) ? esp8266pins : esp32pins, obj[p[0]]) + ); + } } function parseSerial(obj) { @@ -577,7 +619,9 @@ parseNtp(root["ntp"]); parseSun(root["sun"]); parsePinout(root["pinout"], root["system"]["esp_type"]); - parseRadio(root["radio"]); + parseNrfRadio(root["radioNrf"]); + if(root["generic"]["esp_type"] == "ESP32") + parseCmtRadio(root["radioCmt"]); parseSerial(root["serial"]); parseDisplay(root["display"], root["system"]["esp_type"]); } diff --git a/src/web/web.h b/src/web/web.h index 92809ca3..c8b8e896 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -33,7 +33,7 @@ #define WEB_SERIAL_BUF_SIZE 2048 -const char* const pinArgNames[] = {"pinCs", "pinCe", "pinIrq", "pinLed0", "pinLed1"}; +const char* const pinArgNames[] = {"pinCs", "pinCe", "pinIrq", "pinLed0", "pinLed1", "pinCsb", "pinFcsb", "pinGpio3"}; template class Web { @@ -512,13 +512,20 @@ class Web { default: mConfig->nrf.pinCs = ((pin != 0xff) ? pin : DEF_CS_PIN); break; case 1: mConfig->nrf.pinCe = ((pin != 0xff) ? pin : DEF_CE_PIN); break; case 2: mConfig->nrf.pinIrq = ((pin != 0xff) ? pin : DEF_IRQ_PIN); break; - case 3: mConfig->led.led0 = pin; break; - case 4: mConfig->led.led1 = pin; break; + case 3: mConfig->led.led0 = pin; break; + case 4: mConfig->led.led1 = pin; break; + case 5: mConfig->cmt.pinCsb = pin; break; + case 6: mConfig->cmt.pinFcsb = pin; break; + case 7: mConfig->cmt.pinIrq = pin; break; } } // nrf24 amplifier power mConfig->nrf.amplifierPower = request->arg("rf24Power").toInt() & 0x03; + mConfig->nrf.enabled = (request->arg("rf24Enable") == "on"); + + // cmt + mConfig->cmt.enabled = (request->arg("cmtEnable") == "on"); // ntp if(request->arg("ntpAddr") != "") {