mirror of
https://github.com/lumapu/ahoy.git
synced 2025-04-29 02:06:21 +02:00
fix setup for multiple inverters
This commit is contained in:
parent
35d8fdcab2
commit
f2a794d518
4 changed files with 31 additions and 3 deletions
|
@ -79,3 +79,7 @@ function span(val, cl=null, id=null) {
|
|||
if(null != id) e.id = id;
|
||||
return e;
|
||||
}
|
||||
|
||||
function br() {
|
||||
return document.createElement('br');
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
<fieldset>
|
||||
<legend class="des">Inverter</legend>
|
||||
<div id="inverter"></div><br/>
|
||||
<input type="button" name="btnAdd" value="Add Inverter"/>
|
||||
<input type="button" id="btnAdd" value="Add Inverter"/>
|
||||
<p class="subdes">General</p>
|
||||
<label for="invInterval">Interval [s]</label>
|
||||
<input type="text" class="text" name="invInterval"/>
|
||||
|
@ -132,8 +132,8 @@
|
|||
|
||||
const re = /11[2,4,6]1.*/;
|
||||
|
||||
document.getElementsByName("btnAdd")[0].addEventListener("click", function() {
|
||||
if(highestId < (maxInv-1))
|
||||
document.getElementById("btnAdd").addEventListener("click", function() {
|
||||
if(highestId <= (maxInv-1))
|
||||
ivHtml(JSON.parse('{"name":"","serial":"","channels":4,"ch_max_power":[0,0,0,0],"ch_name":["","","",""]}'), highestId + 1);
|
||||
});
|
||||
|
||||
|
@ -174,6 +174,14 @@
|
|||
getAjax("/api/setup", apiCbMqtt, "POST", JSON.stringify(obj));
|
||||
}
|
||||
|
||||
function delIv() {
|
||||
var id = this.id.substring(0,4);
|
||||
var e = document.getElementsByName(id + "Addr")[0];
|
||||
e.value = "";
|
||||
e.dispatchEvent(new Event("keyup"));
|
||||
document.getElementsByName(id + "Name")[0].value = "";
|
||||
}
|
||||
|
||||
function ivHtml(obj, id) {
|
||||
highestId = id;
|
||||
if(highestId == (maxInv - 1))
|
||||
|
@ -182,6 +190,7 @@
|
|||
iv.appendChild(des("Inverter " + id));
|
||||
id = "inv" + id;
|
||||
|
||||
|
||||
iv.appendChild(lbl(id + "Addr", "Address*"));
|
||||
var addr = inp(id + "Addr", obj["serial"], 12)
|
||||
iv.appendChild(addr);
|
||||
|
@ -226,6 +235,11 @@
|
|||
}
|
||||
iv.appendChild(d);
|
||||
}
|
||||
iv.appendChild(br());
|
||||
iv.appendChild(lbl(id + "lbldel", "Delete"));
|
||||
var del = inp(id+"del", "X", 0, ["btn", "btnDel"], id+"del", "button");
|
||||
iv.appendChild(del);
|
||||
del.addEventListener("click", delIv);
|
||||
}
|
||||
|
||||
function ivGlob(obj) {
|
||||
|
|
|
@ -129,6 +129,10 @@ input.sh {
|
|||
margin-right: 10px;
|
||||
}
|
||||
|
||||
input.btnDel {
|
||||
background-color: #c00 !important;
|
||||
}
|
||||
|
||||
input.btn {
|
||||
background-color: #006ec0;
|
||||
color: #fff;
|
||||
|
|
|
@ -236,6 +236,12 @@ void web::showSave(AsyncWebServerRequest *request) {
|
|||
if(strlen(buf) == 0)
|
||||
memset(buf, 0, 20);
|
||||
iv->serial.u64 = mMain->Serial2u64(buf);
|
||||
switch(iv->serial.b[4]) {
|
||||
case 0x21: iv->type = INV_TYPE_1CH; iv->channels = 1; break;
|
||||
case 0x41: iv->type = INV_TYPE_2CH; iv->channels = 2; break;
|
||||
case 0x61: iv->type = INV_TYPE_4CH; iv->channels = 4; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
// name
|
||||
request->arg("inv" + String(i) + "Name").toCharArray(iv->name, MAX_NAME_LENGTH);
|
||||
|
|
Loading…
Add table
Reference in a new issue