mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-25 23:06:11 +02:00
added setttings for cmt
added HMS2000 as possible inverter added enable for NRF24 and CMT
This commit is contained in:
parent
c7e01c849d
commit
6cbd256c1f
7 changed files with 124 additions and 24 deletions
|
@ -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<JsonObject>();
|
||||
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")];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <cstdint>
|
||||
|
||||
// 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};
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<uint8_t CSB_PIN=5, uint8_t FCSB_PIN=4, uint8_t GPIO3_PIN=15>
|
||||
|
|
|
@ -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")));
|
||||
|
|
|
@ -173,6 +173,9 @@
|
|||
<p class="des">Radio (NRF24L01+)</p>
|
||||
<div id="rf24"></div>
|
||||
|
||||
<p class="des">Radio (CMT2300A)</p>
|
||||
<div id="cmt"></div>
|
||||
|
||||
<p class="des">Serial Console</p>
|
||||
<label for="serEn">print inverter data</label>
|
||||
<input type="checkbox" class="cb" name="serEn"/><br/>
|
||||
|
@ -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"]);
|
||||
}
|
||||
|
|
|
@ -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 HMSYSTEM>
|
||||
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") != "") {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue