mirror of https://github.com/lumapu/ahoy.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1166 lines
56 KiB
1166 lines
56 KiB
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<title>Setup</title>
|
|
{#HTML_HEADER}
|
|
</head>
|
|
<body>
|
|
{#HTML_NAV}
|
|
<div id="wrapper">
|
|
<div id="content">
|
|
<form method="post" action="/save" id="settings">
|
|
<fieldset>
|
|
<button type="button" class="s_collapsible mt-4">System Config</button>
|
|
<div class="s_content">
|
|
<fieldset class="mb-2">
|
|
<legend class="des">Device Host Name</legend>
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3">Device Name</div>
|
|
<div class="col-12 col-sm-9"><input type="text" name="device"/></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-8 col-sm-3">Reboot Ahoy at midnight</div>
|
|
<div class="col-4 col-sm-9"><input type="checkbox" name="schedReboot"/></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<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-12">(empty browser cache or use CTRL + F5 after reboot to apply this setting)</div>
|
|
</div>
|
|
</fieldset>
|
|
<fieldset class="mb-4">
|
|
<legend class="des">System Config</legend>
|
|
<p class="des">Status LEDs</p>
|
|
<div id="pinout"></div>
|
|
|
|
<p class="des">Radio (NRF24L01+)</p>
|
|
<div id="rf24"></div>
|
|
<!--IF_ESP32-->
|
|
<p class="des">Radio (CMT2300A)</p>
|
|
<div id="cmt"><div class="col-12">(ESP32 only)</div></div>
|
|
<!--ENDIF_ESP32-->
|
|
<p class="des">Serial Console</p>
|
|
<div class="row mb-3">
|
|
<div class="col-8 col-sm-3">print inverter data</div>
|
|
<div class="col-4 col-sm-9"><input type="checkbox" name="serEn"/></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-8 col-sm-3">Serial Debug</div>
|
|
<div class="col-4 col-sm-9"><input type="checkbox" name="serDbg"/></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-8 col-sm-3">Privacy Mode</div>
|
|
<div class="col-4 col-sm-9"><input type="checkbox" name="priv"/></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-8 col-sm-3">Print whole traces in Log</div>
|
|
<div class="col-4 col-sm-9"><input type="checkbox" name="wholeTrace"/></div>
|
|
</div>
|
|
</fieldset>
|
|
</div>
|
|
|
|
<button type="button" class="s_collapsible">Network</button>
|
|
<div class="s_content">
|
|
<fieldset class="mb-2">
|
|
<legend class="des">WiFi</legend>
|
|
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 my-2">AP Password (min. length: 8)</div>
|
|
<div class="col-12 col-sm-9"><input type="text" name="ap_pwd" minlength="8" /></div>
|
|
</div>
|
|
|
|
<p>Enter the credentials to your preferred WiFi station. After rebooting the device tries to connect with this information.</p>
|
|
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 my-2">Search Networks</div>
|
|
<div class="col-12 col-sm-9"><input type="button" name="scanbtn" id="scanbtn" class="btn" value="scan" onclick="scan()"/></div>
|
|
</div>
|
|
|
|
<div class="row mb-2 mb-sm-3">
|
|
<div class="col-12 col-sm-3 my-2">Avail Networks</div>
|
|
<div class="col-12 col-sm-9">
|
|
<select name="networks" id="networks" onChange="selNet()">
|
|
<option value="-1" selected disabled hidden>not scanned</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="row mb-2 mb-sm-3">
|
|
<div class="col-12 col-sm-3 my-2">SSID</div>
|
|
<div class="col-12 col-sm-9"><input type="text" name="ssid"/></div>
|
|
</div>
|
|
<div class="row mb-2 mb-sm-3">
|
|
<div class="col-12 col-sm-3">SSID is hidden</div>
|
|
<div class="col-12 col-sm-9"><input type="checkbox" name="hidd"/></div>
|
|
</div>
|
|
<div class="row mb-2 mb-sm-3">
|
|
<div class="col-12 col-sm-3 my-2">Password</div>
|
|
<div class="col-12 col-sm-9"><input type="password" name="pwd" value="{PWD}"/></div>
|
|
</div>
|
|
</fieldset>
|
|
<fieldset class="mb-4">
|
|
<legend class="des">Static IP (optional)</legend>
|
|
<p>
|
|
Leave fields blank for DHCP<br/>
|
|
The following fields are parsed in this format: 192.168.4.1
|
|
</p>
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 my-2">IP Address</div>
|
|
<div class="col-12 col-sm-9"><input type="text" name="ipAddr" maxlength="15" /></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 my-2">Submask</div>
|
|
<div class="col-12 col-sm-9"><input type="text" name="ipMask" maxlength="15" /></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 my-2">DNS 1</div>
|
|
<div class="col-12 col-sm-9"><input type="text" name="ipDns1" maxlength="15" /></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 my-2">DNS 2</div>
|
|
<div class="col-12 col-sm-9"><input type="text" name="ipDns2" maxlength="15" /></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 my-2">Gateway</div>
|
|
<div class="col-12 col-sm-9"><input type="text" name="ipGateway" maxlength="15" /></div>
|
|
</div>
|
|
</fieldset>
|
|
</div>
|
|
|
|
<button type="button" class="s_collapsible">Protection</button>
|
|
<div class="s_content">
|
|
<fieldset class="mb-4">
|
|
<legend class="des mx-2">Protection</legend>
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 mb-2 mt-2">Admin Password</div>
|
|
<div class="col-12 col-sm-9"><input type="password" name="adminpwd" value="{PWD}"/></div>
|
|
</div>
|
|
<p>Select pages which should be protected by password</p>
|
|
<div id="prot_mask"></div>
|
|
</fieldset>
|
|
</div>
|
|
|
|
<button type="button" class="s_collapsible">Inverter</button>
|
|
<div class="s_content">
|
|
<fieldset class="mb-4">
|
|
<legend class="des">Inverter</legend>
|
|
<div id="inverter"></div>
|
|
<div class="row mb-3">
|
|
<div class="col-8 my-2">Interval [s]</div>
|
|
<div class="col-4"><input type="number" name="invInterval" title="Invalid input"/></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-8 my-2">Inverter Gap [ms]</div>
|
|
<div class="col-4"><input type="number" name="invGap" title="Invalid input"/></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-8 mb-2">Reset values and YieldDay at midnight</div>
|
|
<div class="col-4"><input type="checkbox" name="invRstMid"/></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-8 mb-2">Reset values when inverter polling pauses at sunset</div>
|
|
<div class="col-4"><input type="checkbox" name="invRstComStop"/></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-8">Reset values when inverter status is 'not available'</div>
|
|
<div class="col-4"><input type="checkbox" name="invRstNotAvail"/></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-8">Reset 'max' values at midnight</div>
|
|
<div class="col-4"><input type="checkbox" name="invRstMaxMid"/></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-8">Start without time sync (useful in AP-Only-Mode)</div>
|
|
<div class="col-4"><input type="checkbox" name="strtWthtTm"/></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-8">Read Grid Profile</div>
|
|
<div class="col-4"><input type="checkbox" name="rdGrid"/></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-8">Yield Efficiency (Standard 1.0)</div>
|
|
<div class="col-4"><input type="number" name="yldEff" step="any"/></div>
|
|
</div>
|
|
</fieldset>
|
|
</div>
|
|
|
|
<button type="button" class="s_collapsible">NTP Server</button>
|
|
<div class="s_content">
|
|
<fieldset class="mb-4">
|
|
<legend class="des">NTP Server</legend>
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 my-2">NTP Server / IP</div>
|
|
<div class="col-12 col-sm-9"><input type="text" name="ntpAddr"/></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 my-2">NTP Port</div>
|
|
<div class="col-12 col-sm-9"><input type="number" name="ntpPort"/></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 my-2">NTP Interval (in Minutes, min. 5 Minutes)</div>
|
|
<div class="col-12 col-sm-9"><input type="number" name="ntpIntvl"/></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 my-2">set System time</div>
|
|
<div class="col-12 col-sm-9">
|
|
<input type="button" name="ntpBtn" id="ntpBtn" class="btn" value="from browser" onclick="setTime()"/>
|
|
<input type="button" name="ntpSync" id="ntpSync" class="btn" value="sync NTP" onclick="syncTime()"/><br/>
|
|
<span id="apiResultNtp"></span>
|
|
</div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 my-2">System Time</div>
|
|
<div class="col-12 col-sm-9 my-2"><span id="date"></span></div>
|
|
</div>
|
|
</fieldset>
|
|
</div>
|
|
|
|
<button type="button" class="s_collapsible">Sunrise & Sunset</button>
|
|
<div class="s_content">
|
|
<fieldset class="mb-4">
|
|
<legend class="des">Sunrise & Sunset</legend>
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 my-2">Latitude (decimal)</div>
|
|
<div class="col-12 col-sm-9"><input type="number" name="sunLat" step="any"/></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 my-2">Longitude (decimal)</div>
|
|
<div class="col-12 col-sm-9"><input type="number" name="sunLon" step="any"/></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 my-2">Offset (pre sunrise, post sunset)</div>
|
|
<div class="col-12 col-sm-9"><select name="sunOffs"></select></div>
|
|
</div>
|
|
</fieldset>
|
|
</div>
|
|
|
|
<button type="button" class="s_collapsible">MQTT</button>
|
|
<div class="s_content">
|
|
<fieldset class="mb-4">
|
|
<legend class="des">MQTT</legend>
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 my-2">Broker / Server IP</div>
|
|
<div class="col-12 col-sm-9"><input type="text" name="mqttAddr"/></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 my-2">Port</div>
|
|
<div class="col-12 col-sm-9"><input type="number" name="mqttPort"/></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 my-2">Client Id (optional)</div>
|
|
<div class="col-12 col-sm-9"><input type="text" name="mqttClientId"/></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 my-2">Username (optional)</div>
|
|
<div class="col-12 col-sm-9"><input type="text" name="mqttUser"/></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 my-2">Password (optional)</div>
|
|
<div class="col-12 col-sm-9"><input type="password" name="mqttPwd"/></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 my-2">Topic</div>
|
|
<div class="col-12 col-sm-9"><input type="text" name="mqttTopic" pattern="[\-\+A-Za-z0-9\.\/#\$%&=_]+" title="Invalid input" /></div>
|
|
</div>
|
|
<p class="des">Send Inverter data in a fixed interval, even if there is no change. A value of '0' disables the fixed interval. The data is published once it was successfully received from inverter. (default: 0)</p>
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 my-2">Interval [s]</div>
|
|
<div class="col-12 col-sm-9"><input type="number" name="mqttInterval" title="Invalid input" /></div>
|
|
</div>
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 my-2">Discovery Config (homeassistant)</div>
|
|
<div class="col-12 col-sm-9">
|
|
<input type="button" name="mqttDiscovery" id="mqttDiscovery" class="btn" value="send" onclick="sendDiscoveryConfig()"/>
|
|
<span id="apiResultMqtt"></span>
|
|
</div>
|
|
</div>
|
|
</fieldset>
|
|
</div>
|
|
|
|
<button type="button" class="s_collapsible">Display Config</button>
|
|
<div class="s_content">
|
|
<fieldset class="mb-4">
|
|
<legend class="des">Display Config</legend>
|
|
<div id="dispType"></div>
|
|
<div id="dispRot"></div>
|
|
<div class="row mb-3">
|
|
<div class="col-8 col-sm-3">Turn off while inverters are offline</div>
|
|
<div class="col-4 col-sm-9"><input type="checkbox" name="disp_pwr"/></div>
|
|
</div>
|
|
<div id="screenSaver"></div>
|
|
<div class="row mb-3">
|
|
<div class="col-12 col-sm-3 my-2">Luminance</div>
|
|
<div class="col-12 col-sm-9"><input type="number" name="disp_cont" min="0" max="255"></select></div>
|
|
</div>
|
|
<p class="des">Pinout</p>
|
|
<div id="dispPins"></div>
|
|
<div id="pirPin"></div>
|
|
</fieldset>
|
|
</div>
|
|
|
|
<div class="row mb-4 mt-4">
|
|
<div class="col-8 col-sm-3">Reboot device after successful save</div>
|
|
<div class="col-4 col-sm-9">
|
|
<input type="checkbox" name="reboot" checked />
|
|
<input type="submit" value="save" class="btn right"/>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
<div class="hr mb-3 mt-3"></div>
|
|
<div class="mb-4 mt-4">
|
|
<a class="btn" href="/erase">ERASE SETTINGS (not WiFi)</a>
|
|
<fieldset class="mb-4">
|
|
<legend class="des">Import / Export JSON Settings</legend>
|
|
<div class="row mb-4 mt-4">
|
|
<div class="col-12 col-sm-3">Import</div>
|
|
<div class="col-12 col-sm-9">
|
|
<form id="form" method="POST" action="/upload" enctype="multipart/form-data" accept-charset="utf-8">
|
|
<div class="row">
|
|
<div class="col-12 col-sm-8 my-2"><input type="file" name="upload"></div>
|
|
<div class="col-12 col-sm-4 my-2"><input type="button" class="btn" value="Import" onclick="hide()"></div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<div class="row mb-4 mt-4">
|
|
<div class="col-12 col-sm-3 my-2">Export</div>
|
|
<div class="col-12 col-sm-9">
|
|
<a class="btn" href="/get_setup" target="_blank">Export settings (JSON file)</a><span> (only values, passwords will be removed!)</span>
|
|
</div>
|
|
</div>
|
|
</fieldset>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{#HTML_FOOTER}
|
|
<script type="text/javascript">
|
|
var maxInv = 0;
|
|
var ts = 0;
|
|
|
|
var esp8266pins = [
|
|
[255, "off / default"],
|
|
[0, "D3 (GPIO0)"],
|
|
[1, "TX (GPIO1)"],
|
|
[2, "D4 (GPIO2)"],
|
|
[3, "RX (GPIO3)"],
|
|
[4, "D2 (GPIO4, SDA)"],
|
|
[5, "D1 (GPIO5, SCL)"],
|
|
[6, "GPIO6"],
|
|
[7, "GPIO7"],
|
|
[8, "GPIO8"],
|
|
[9, "GPIO9"],
|
|
[10, "GPIO10"],
|
|
[11, "GPIO11"],
|
|
[12, "D6 (GPIO12)"],
|
|
[13, "D7 (GPIO13)"],
|
|
[14, "D5 (GPIO14)"],
|
|
[15, "D8 (GPIO15)"],
|
|
[16, "D0 (GPIO16 - no IRQ!)"]
|
|
];
|
|
|
|
/*IF_ESP32*/
|
|
var esp32pins = [
|
|
[255, "off / default"],
|
|
[0, "GPIO0"],
|
|
[1, "TX (GPIO1)"],
|
|
[2, "GPIO2 (LED)"],
|
|
[3, "RX (GPIO3)"],
|
|
[4, "GPIO4"],
|
|
[5, "GPIO5"],
|
|
[12, "GPIO12 (HSPI MISO)"],
|
|
[13, "GPIO13 (HSPI MOSI)"],
|
|
[14, "GPIO14 (HSPI SCLK)"],
|
|
[15, "GPIO15"],
|
|
[16, "GPIO16"],
|
|
[17, "GPIO17"],
|
|
[18, "GPIO18 (VSPI SCLK)"],
|
|
[19, "GPIO19 (VSPI MISO)"],
|
|
[21, "GPIO21 (SDA)"],
|
|
[22, "GPIO22 (SCL)"],
|
|
[23, "GPIO23 (VSPI MOSI)"],
|
|
[25, "GPIO25"],
|
|
[26, "GPIO26"],
|
|
[27, "GPIO27"],
|
|
[32, "GPIO32"],
|
|
[33, "GPIO33"],
|
|
[34, "GPIO34 (in only)"],
|
|
[35, "GPIO35 (in only)"],
|
|
[36, "VP (GPIO36, in only)"],
|
|
[39, "VN (GPIO39, in only)"]
|
|
];
|
|
var esp32s3pins = [
|
|
[255, "off / default"],
|
|
[0, "GPIO0 (DONT USE - BOOT)"],
|
|
[1, "GPIO1"],
|
|
[2, "GPIO2"],
|
|
[3, "GPIO3"],
|
|
[4, "GPIO4"],
|
|
[5, "GPIO5"],
|
|
[6, "GPIO6"],
|
|
[7, "GPIO7"],
|
|
[8, "GPIO8"],
|
|
[9, "GPIO9"],
|
|
[10, "GPIO10"],
|
|
[11, "GPIO11"],
|
|
[12, "GPIO12"],
|
|
[13, "GPIO13"],
|
|
[14, "GPIO14"],
|
|
[15, "GPIO15"],
|
|
[16, "GPIO16"],
|
|
[17, "GPIO17"],
|
|
[18, "GPIO18"],
|
|
[19, "GPIO19 (DONT USE - USB-)"],
|
|
[20, "GPIO20 (DONT USE - USB+)"],
|
|
[21, "GPIO21"],
|
|
[26, "GPIO26 (PSRAM - not available)"],
|
|
[27, "GPIO27 (FLASH - not available)"],
|
|
[28, "GPIO28 (FLASH - not available)"],
|
|
[29, "GPIO29 (FLASH - not available)"],
|
|
[30, "GPIO30 (FLASH - not available)"],
|
|
[31, "GPIO31 (FLASH - not available)"],
|
|
[32, "GPIO32 (FLASH - not available)"],
|
|
[33, "GPIO33 (not exposed on WROOM modules)"],
|
|
[34, "GPIO34 (not exposed on WROOM modules)"],
|
|
[35, "GPIO35"],
|
|
[36, "GPIO36"],
|
|
[37, "GPIO37"],
|
|
[38, "GPIO38"],
|
|
[39, "GPIO39"],
|
|
[40, "GPIO40"],
|
|
[41, "GPIO41"],
|
|
[42, "GPIO42"],
|
|
[43, "GPIO43"],
|
|
[44, "GPIO44"],
|
|
[45, "GPIO45 (DONT USE - STRAPPING PIN)"],
|
|
[46, "GPIO46 (DONT USE - STRAPPING PIN)"],
|
|
[47, "GPIO47"],
|
|
[48, "GPIO48"],
|
|
];
|
|
var esp32c3pins = [
|
|
[255, "off / default"],
|
|
[0, "GPIO0"],
|
|
[1, "GPIO1"],
|
|
[2, "GPIO2"],
|
|
[3, "GPIO3"],
|
|
[4, "GPIO4"],
|
|
[5, "GPIO5"],
|
|
[6, "GPIO6"],
|
|
[7, "GPIO7"],
|
|
[8, "GPIO8"],
|
|
[9, "GPIO9"],
|
|
[10, "GPIO10"],
|
|
[11, "GPIO11"],
|
|
[12, "GPIO12 (PSRAM/FLASH)"],
|
|
[13, "GPIO13 (PSRAM/FLASH)"],
|
|
[14, "GPIO14 (PSRAM/FLASH)"],
|
|
[15, "GPIO15 (PSRAM/FLASH)"],
|
|
[16, "GPIO16 (PSRAM/FLASH)"],
|
|
[17, "GPIO17 (PSRAM/FLASH)"],
|
|
[18, "GPIO18 (DONT USE - USB-)"],
|
|
[19, "GPIO19 (DONT USE - USB+)"],
|
|
[20, "GPIO20 (RX)"],
|
|
[21, "GPIO21 (TX)"],
|
|
];
|
|
/*ENDIF_ESP32*/
|
|
var nrfPa = [
|
|
[0, "MIN (recommended)"],
|
|
[1, "LOW"],
|
|
[2, "HIGH"],
|
|
[3, "MAX (experimental)"]
|
|
];
|
|
var esp32cmtPa = [];
|
|
var esp32cmtFreq = [];
|
|
|
|
/*IF_ESP32*/
|
|
var freqFmt = new Intl.NumberFormat('en-US', {
|
|
minimumIntegerDigits: 3,
|
|
minimumFractionDigits: 2
|
|
});
|
|
for(var i = 0; i < 31; i++) {
|
|
esp32cmtPa.push([i, String(i-10) + " dBm"]);
|
|
}
|
|
for(var i = 12; i < 41; i++) {
|
|
esp32cmtFreq.push([i, freqFmt.format(860 + i*0.25) + " MHz"]);
|
|
}
|
|
/*ENDIF_ESP32*/
|
|
var led_high_active = [
|
|
[0, "low active"],
|
|
[1, "high active"],
|
|
];
|
|
|
|
window.onload = function() {
|
|
for(it of document.getElementsByClassName("s_collapsible")) {
|
|
it.addEventListener("click", function() {
|
|
this.classList.toggle("active");
|
|
var content = this.nextElementSibling;
|
|
content.style.display = (content.style.display === "block") ? "none" : "block";
|
|
});
|
|
}
|
|
|
|
document.getElementById("settings").addEventListener("submit", function() {
|
|
var inputs = document.querySelectorAll("input[type='number']");
|
|
for (var i = 0; i < inputs.length; i++) {
|
|
if (inputs[i].value.indexOf(",") != -1)
|
|
inputs[i].value = inputs[i].value.replace(",", ".");
|
|
}
|
|
});
|
|
}
|
|
|
|
function apiCbWifi(obj) {
|
|
var e = document.getElementById("networks");
|
|
selDelAllOpt(e);
|
|
if(obj["success"])
|
|
e.appendChild(opt("-1", "scanning ..."))
|
|
else
|
|
e.appendChild(opt("-1", "Error: " + obj["error"]));
|
|
}
|
|
|
|
function apiCbNtp(obj) {
|
|
var e = document.getElementById("apiResultNtp");
|
|
if(obj["success"])
|
|
e.innerHTML = "command executed, set new time ...";
|
|
else
|
|
e.innerHTML = "Error: " + obj["error"];
|
|
}
|
|
|
|
function apiCbNtp2(obj) {
|
|
var e = document.getElementById("apiResultNtp");
|
|
var date = new Date(obj["ts_now"] * 1000);
|
|
e.innerHTML = "synced at: " + toIsoDateStr(date) + ", difference: " + (ts - obj["ts_now"]) + "ms";
|
|
}
|
|
|
|
function apiCbMqtt(obj) {
|
|
var e = document.getElementById("apiResultMqtt");
|
|
if(obj["success"])
|
|
e.innerHTML = "command executed";
|
|
else
|
|
e.innerHTML = "Error: " + obj["error"];
|
|
}
|
|
|
|
function setTime() {
|
|
var date = new Date();
|
|
var obj = new Object();
|
|
obj.cmd = "set_time";
|
|
obj.val = parseInt(date.getTime() / 1000);
|
|
getAjax("/api/setup", apiCbNtp, "POST", JSON.stringify(obj));
|
|
setTimeout(function() {getAjax('/api/index', apiCbNtp2)}, 2000);
|
|
}
|
|
|
|
function scan() {
|
|
var obj = new Object();
|
|
obj.cmd = "scan_wifi";
|
|
getAjax("/api/setup", apiCbWifi, "POST", JSON.stringify(obj));
|
|
setTimeout(function() {getAjax('/api/setup/networks', listNetworks)}, 5000);
|
|
}
|
|
|
|
function syncTime() {
|
|
var obj = new Object();
|
|
obj.cmd = "sync_ntp";
|
|
getAjax("/api/setup", apiCbNtp, "POST", JSON.stringify(obj));
|
|
setTimeout(function() {getAjax('/api/index', apiCbNtp2)}, 2000);
|
|
}
|
|
|
|
function sendDiscoveryConfig() {
|
|
var obj = new Object();
|
|
obj.cmd = "discovery_cfg";
|
|
getAjax("/api/setup", apiCbMqtt, "POST", JSON.stringify(obj));
|
|
}
|
|
|
|
function hide() {
|
|
document.getElementById("form").submit();
|
|
var e = document.getElementById("content");
|
|
e.replaceChildren(span("upload started"));
|
|
}
|
|
|
|
function delIv() {
|
|
var id = this.id.substring(0, this.id.length-3);
|
|
document.getElementById(id).remove();
|
|
}
|
|
|
|
function mlCb(id, des, chk=false) {
|
|
var cb = ml("input", {type: "checkbox", id: id, name: id}, "");
|
|
if(chk)
|
|
cb.checked = true;
|
|
return ml("div", {class: "row mb-3"}, [
|
|
ml("div", {class: "col-8 col-sm-3"}, des),
|
|
ml("div", {class: "col-4 col-sm-9"}, cb)
|
|
]);
|
|
}
|
|
|
|
function mlE(des, e) {
|
|
return ml("div", {class: "row mb-3"}, [
|
|
ml("div", {class: "col-12 col-sm-3 my-2"}, des),
|
|
ml("div", {class: "col-12 col-sm-9"}, e)
|
|
]);
|
|
}
|
|
|
|
function getFreeId() {
|
|
var id = 0;
|
|
while(id < maxInv) {
|
|
if(null == document.getElementById("inv" + id))
|
|
return id;
|
|
id++;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function ivGlob(obj) {
|
|
for(var i of [["invInterval", "interval"], ["yldEff", "yldEff"], ["invGap", "gap"]])
|
|
document.getElementsByName(i[0])[0].value = obj[i[1]];
|
|
for(var i of ["Mid", "ComStop", "NotAvail", "MaxMid"])
|
|
document.getElementsByName("invRst"+i)[0].checked = obj["rst" + i];
|
|
document.getElementsByName("strtWthtTm")[0].checked = obj["strtWthtTm"];
|
|
document.getElementsByName("rdGrid")[0].checked = obj["rdGrid"];
|
|
}
|
|
|
|
function parseSys(obj) {
|
|
for(var i of [["device", "device_name"], ["ssid", "ssid"], ["ap_pwd", "ap_pwd"]])
|
|
document.getElementsByName(i[0])[0].value = obj[i[1]];
|
|
document.getElementsByName("hidd")[0].checked = obj["hidd"];
|
|
document.getElementsByName("darkMode")[0].checked = obj["dark_mode"];
|
|
document.getElementsByName("schedReboot")[0].checked = obj["sched_reboot"];
|
|
e = document.getElementsByName("adminpwd")[0];
|
|
if(!obj["pwd_set"])
|
|
e.value = "";
|
|
var d = document.getElementById("prot_mask");
|
|
var a = ["Index", "Live", "Webserial", "Settings", "Update", "System"];
|
|
var el = [];
|
|
for(var i = 0; i < 6; i++) {
|
|
var chk = ((obj["prot_mask"] & (1 << i)) == (1 << i));
|
|
el.push(mlCb("protMask" + i, a[i], chk))
|
|
}
|
|
d.append(...el);
|
|
}
|
|
|
|
function parseGeneric(obj) {
|
|
parseNav(obj);
|
|
parseESP(obj);
|
|
parseRssi(obj);
|
|
|
|
ts = obj["ts_now"];
|
|
window.setInterval("tick()", 1000);
|
|
}
|
|
|
|
function parseStaticIp(obj) {
|
|
for(var i of [["ipAddr", "ip"], ["ipMask", "mask"], ["ipDns1", "dns1"], ["ipDns2", "dns2"], ["ipGateway", "gateway"]])
|
|
if(null != obj[i[1]])
|
|
document.getElementsByName(i[0])[0].value = obj[i[1]];
|
|
}
|
|
|
|
function parseIv(obj) {
|
|
maxInv = obj["max_num_inverters"];
|
|
var lines = [];
|
|
lines.push(ml("tr", {}, [
|
|
ml("th", {style: "width: 10%; text-align: center;"}, ""),
|
|
ml("th", {}, "Name"),
|
|
ml("th", {}, "Serial"),
|
|
ml("th", {style: "width: 10%; text-align: center;"}, "Edit"),
|
|
ml("th", {style: "width: 10%; text-align: center;"}, "Delete")
|
|
]));
|
|
|
|
for(let i = 0; i < obj.inverter.length; i++) {
|
|
lines.push(ml("tr", {}, [
|
|
ml("td", {}, badge(obj.inverter[i].enabled, (obj.inverter[i].enabled) ? "enabled" : "disabled")),
|
|
ml("td", {}, obj.inverter[i].name),
|
|
ml("td", {}, String(obj.inverter[i].serial)),
|
|
ml("td", {style: "text-align: center;", onclick: function() {ivModal(obj.inverter[i]);}}, svg(iconGear, 25, 25, "icon icon-fg pointer")),
|
|
ml("td", {style: "text-align: center; ", onclick: function() {ivDel(obj.inverter[i]);}}, svg(iconDel, 25, 25, "icon icon-fg pointer"))
|
|
]));
|
|
}
|
|
|
|
var add = new Object();
|
|
add.id = obj.inverter.length;
|
|
add.name = "";
|
|
add.enabled = true;
|
|
add.ch_max_pwr = [400,400,400,400,400,400];
|
|
add.ch_name = [];
|
|
add.ch_yield_cor = [];
|
|
add.freq = 12;
|
|
add.pa = 30;
|
|
add.add2total = true;
|
|
|
|
var e = document.getElementById("inverter");
|
|
e.innerHTML = ""; // remove all childs
|
|
e.append(ml("table", {class: "table"}, ml("tbody", {}, lines)));
|
|
if(obj.max_num_inverters > obj.inverter.length)
|
|
e.append(ml("div", {class: "row my-3"}, ml("div", {class: "col a-r"}, ml("input", {type: "button", value: "add Inverter", class: "btn", onclick: function() { ivModal(add); }}, null))));
|
|
|
|
ivGlob(obj);
|
|
}
|
|
|
|
function ivModal(obj) {
|
|
var lines = [];
|
|
lines.push(ml("tr", {}, [
|
|
ml("th", {style: "width: 10%;"}, "Input"),
|
|
ml("th", {}, "Max Module Power [Wp]"),
|
|
ml("th", {}, "Name (optional)"),
|
|
ml("th", {}, "Yield Correction [kWh] (optional)")
|
|
]));
|
|
|
|
for(let i = 0; i < 6; i++) {
|
|
lines.push(ml("tr", {id: "ch"+i}, [
|
|
ml("td", {}, String(i+1)),
|
|
ml("td", {}, ml("input", {name: "ch_p"+i, class: "text", type: "number", max: 999, value: obj.ch_max_pwr[i]}, null)),
|
|
ml("td", {}, ml("input", {name: "ch_n"+i, class: "text", type: "text", maxlength: 15, value: (undefined === obj.ch_name[i]) ? "" : obj.ch_name[i]}, null)),
|
|
ml("td", {}, ml("input", {name: "yld_c"+i, class: "text", type: "number", max: 999999, value: obj.ch_yield_cor[i], step: "0.001"}, null))
|
|
]));
|
|
}
|
|
|
|
var cbEn = ml("input", {name: "enable", type: "checkbox"}, null);
|
|
var cbDisNightCom = ml("input", {name: "disnightcom", type: "checkbox"}, null);
|
|
var cbAddTotal = ml("input", {name: "add2total", type: "checkbox"}, null);
|
|
cbEn.checked = (obj.enabled);
|
|
cbDisNightCom.checked = (obj.disnightcom);
|
|
cbAddTotal.checked = (obj.add2total);
|
|
|
|
var ser = ml("input", {name: "ser", class: "text", type: "number", max: 138999999999, value: obj.serial}, null);
|
|
var html = ml("div", {}, [
|
|
tabs(["General", "Inputs", "Radio", "Advanced"]),
|
|
ml("div", {id: "divGeneral", class: "tab-content"}, [
|
|
ml("div", {class: "row mb-3"}, [
|
|
ml("div", {class: "col-2"}, "Enable"),
|
|
ml("div", {class: "col-10"}, cbEn)
|
|
]),
|
|
ml("div", {class: "row mb-3"}, [
|
|
ml("div", {class: "col-2 mt-2"}, "Serial"),
|
|
ml("div", {class: "col-10"}, ser)
|
|
]),
|
|
ml("div", {class: "row mb-3"}, [
|
|
ml("div", {class: "col-2 mt-2"}, "Name"),
|
|
ml("div", {class: "col-10"}, ml("input", {name: "name", class: "text", type: "text", value: obj.name}, null))
|
|
])
|
|
]),
|
|
ml("div", {id: "divInputs", class: "tab-content hide"}, [
|
|
ml("div", {class: "row mb-3"},
|
|
ml("table", {class: "table"},
|
|
ml("tbody", {}, lines)
|
|
)
|
|
)
|
|
]),
|
|
ml("div", {id: "divRadio", class: "tab-content hide"}, [
|
|
ml("input", {type: "hidden", name: "isnrf"}, null),
|
|
ml("div", {id: "setcmt"}, [
|
|
ml("div", {class: "row mb-3"}, [
|
|
ml("div", {class: "col-3 mt-2"}, "Frequency"),
|
|
ml("div", {class: "col-9"}, sel("freq", esp32cmtFreq, obj.freq))
|
|
]),
|
|
ml("div", {class: "row mb-3"}, [
|
|
ml("div", {class: "col-3 mt-2"}, "Power Level"),
|
|
ml("div", {class: "col-9"}, sel("cmtpa", esp32cmtPa, obj.pa))
|
|
]),
|
|
]),
|
|
ml("div", {id: "setnrf"},
|
|
ml("div", {class: "row mb-3"}, [
|
|
ml("div", {class: "col-3 mt-2"}, "Power Level"),
|
|
ml("div", {class: "col-9"}, sel("nrfpa", nrfPa, obj.pa))
|
|
]),
|
|
),
|
|
]),
|
|
ml("div", {id: "divAdvanced", class: "tab-content hide"}, [
|
|
ml("div", {class: "row mb-3"}, [
|
|
ml("div", {class: "col-10"}, "Pause communication during night (lat. and lon. need to be set)"),
|
|
ml("div", {class: "col-2"}, cbDisNightCom)
|
|
]),
|
|
ml("div", {class: "row mb-3"}, [
|
|
ml("div", {class: "col-10"}, "Include inverter to sum of total (should be checked by default)"),
|
|
ml("div", {class: "col-2"}, cbAddTotal)
|
|
])
|
|
]),
|
|
ml("div", {class: "row mt-5"}, [
|
|
ml("div", {class: "col-8", id: "res"}, ""),
|
|
ml("div", {class: "col-4 a-r"}, ml("input", {type: "button", value: "save", class: "btn", onclick: function() { ivSave(); }}, null))
|
|
])
|
|
]);
|
|
|
|
['keyup', 'change'].forEach(function(evt) {
|
|
ser.addEventListener(evt, (e) => {
|
|
var sn = parseInt(ser.value, 16);
|
|
sn = Math.floor(sn / Math.pow(2, 32));
|
|
|
|
var max = 1;
|
|
switch(sn & 0x00f0) {
|
|
case 0x0010: max = 1; break;
|
|
case 0x0040: max = 2; break;
|
|
case 0x0060: max = 4; break;
|
|
case 0x0080: max = 6; break;
|
|
}
|
|
for(var i = 0; i < 6; i++) {
|
|
setHide("ch"+i, (i >= max));
|
|
}
|
|
|
|
var nrf = true;
|
|
switch(sn & 0xff00) {
|
|
case 0x1000: nrf = true; break;
|
|
case 0x1100:
|
|
switch(sn & 0x000f) {
|
|
case 0x0004: nrf = false; break;
|
|
default: nrf = true; break;
|
|
}
|
|
break;
|
|
case 0x1300: nrf = false; break;
|
|
}
|
|
setHide("setcmt", nrf);
|
|
setHide("setnrf", !nrf);
|
|
document.getElementsByName("isnrf")[0].value = nrf;
|
|
})
|
|
});
|
|
|
|
modal("Edit inverter " + obj.name, html);
|
|
ser.dispatchEvent(new Event('change'));
|
|
|
|
function ivSave() {
|
|
var o = new Object();
|
|
o.cmd = "save_iv";
|
|
o.id = obj.id;
|
|
o.ser = parseInt(document.getElementsByName("ser")[0].value, 16);
|
|
o.name = document.getElementsByName("name")[0].value;
|
|
o.en = document.getElementsByName("enable")[0].checked;
|
|
o.ch = [];
|
|
for(let i = 0; i < 6; i++) {
|
|
var q = new Object();
|
|
q.pwr = document.getElementsByName("ch_p"+i)[0].value;
|
|
q.name = document.getElementsByName("ch_n"+i)[0].value;
|
|
q.yld = document.getElementsByName("yld_c"+i)[0].value;
|
|
o.ch.push(q);
|
|
}
|
|
if("true" == document.getElementsByName("isnrf")[0].value)
|
|
o.pa = document.getElementsByName("nrfpa")[0].value;
|
|
else
|
|
o.pa = document.getElementsByName("cmtpa")[0].value;
|
|
o.freq = document.getElementsByName("freq")[0].value;
|
|
o.disnightcom = document.getElementsByName("disnightcom")[0].checked;
|
|
o.add2total = document.getElementsByName("add2total")[0].checked;
|
|
getAjax("/api/setup", cb, "POST", JSON.stringify(o));
|
|
}
|
|
|
|
function cb(obj2) {
|
|
var e = document.getElementById("res");
|
|
if(!obj2.success)
|
|
e.innerHTML = "error: " + obj2.error;
|
|
else {
|
|
modalClose();
|
|
getAjax("/api/inverter/list", parseIv);
|
|
}
|
|
}
|
|
}
|
|
|
|
function ivDel(obj) {
|
|
var html = ml("div", {class: "row"}, [
|
|
ml("div", {class: "col-9"}, "do you realy want to delete inverter " + obj.name + "?"),
|
|
ml("div", {class: "col-3 a-r"}, ml("div", {class: "col-4 a-r"}, ml("input", {type: "button", value: "yes", class: "btn", onclick: function() { del(); }}, null)))
|
|
]);
|
|
modal("Delete inverter " + obj.name, html);
|
|
|
|
function del() {
|
|
var o = new Object();
|
|
o.cmd = "save_iv";
|
|
o.id = obj.id;
|
|
o.ser = 0;
|
|
o.name = "";
|
|
o.en = false;
|
|
o.ch = [];
|
|
for(let i = 0; i < 6; i++) {
|
|
var q = new Object();
|
|
q.pwr = 0;
|
|
q.name = "";
|
|
q.yld = 0;
|
|
o.ch.push(q);
|
|
}
|
|
getAjax("/api/setup", cb, "POST", JSON.stringify(o));
|
|
}
|
|
|
|
function cb(obj) {
|
|
if(obj.success) {
|
|
modalClose();
|
|
getAjax("/api/inverter/list", parseIv);
|
|
}
|
|
}
|
|
}
|
|
|
|
function parseMqtt(obj) {
|
|
for(var i of [["Addr", "broker"], ["Port", "port"], ["ClientId", "clientId"], ["User", "user"], ["Pwd", "pwd"], ["Topic", "topic"], ["Interval", "interval"]])
|
|
document.getElementsByName("mqtt"+i[0])[0].value = obj[i[1]];
|
|
}
|
|
|
|
function parseNtp(obj) {
|
|
for(var i of [["ntpAddr", "addr"], ["ntpPort", "port"], ["ntpIntvl", "interval"]])
|
|
document.getElementsByName(i[0])[0].value = obj[i[1]];
|
|
}
|
|
|
|
function parseSun(obj) {
|
|
document.getElementsByName("sunLat")[0].value = obj["lat"];
|
|
document.getElementsByName("sunLon")[0].value = obj["lon"];
|
|
const sel = document.getElementsByName("sunOffs")[0];
|
|
for(var i = 0; i <= 60; i++) {
|
|
sel.appendChild(opt(i, i + " minutes", (i == (obj["offs"] / 60))));
|
|
}
|
|
}
|
|
|
|
function parsePinout(obj, type, system) {
|
|
var e = document.getElementById("pinout");
|
|
var pinList = esp8266pins;
|
|
/*IF_ESP32*/
|
|
var pinList = esp32pins;
|
|
if ("ESP32-S3" == system["chip_model"]) pinList = esp32s3pins;
|
|
else if("ESP32-C3" == system["chip_model"]) pinList = esp32c3pins;
|
|
/*ENDIF_ESP32*/
|
|
pins = [['led0', 'pinLed0', 'At least one inverter is producing'], ['led1', 'pinLed1', 'MqTT connected']];
|
|
for(p of pins) {
|
|
e.append(
|
|
ml("div", {class: "row mb-3"}, [
|
|
ml("div", {class: "col-12 col-sm-3 my-2"}, p[2]),
|
|
ml("div", {class: "col-12 col-sm-9"},
|
|
sel(p[1], pinList, obj[p[0]])
|
|
)
|
|
])
|
|
);
|
|
}
|
|
e.append(
|
|
ml("div", { class: "row mb-3" }, [
|
|
ml("div", { class: "col-12 col-sm-3 my-2" }, "LED polarity"),
|
|
ml("div", { class: "col-12 col-sm-9" },
|
|
sel('pinLedHighActive', led_high_active, obj['led_high_active'])
|
|
)
|
|
])
|
|
)
|
|
}
|
|
|
|
function parseNrfRadio(obj, objPin, type, system) {
|
|
var e = document.getElementById("rf24");
|
|
var en = inp("nrfEnable", null, null, ["cb"], "nrfEnable", "checkbox");
|
|
en.checked = obj["en"];
|
|
|
|
var pinList = esp8266pins;
|
|
/*IF_ESP32*/
|
|
var pinList = esp32pins;
|
|
if ("ESP32-S3" == system["chip_model"]) pinList = esp32s3pins;
|
|
else if("ESP32-C3" == system["chip_model"]) pinList = esp32c3pins;
|
|
/*ENDIF_ESP32*/
|
|
|
|
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) {
|
|
pins = [['cs', 'pinCs'], ['ce', 'pinCe'], ['irq', 'pinIrq']];
|
|
} else {
|
|
pins = [['cs', 'pinCs'], ['ce', 'pinCe'], ['irq', 'pinIrq'], ['sclk', 'pinSclk'], ['mosi', 'pinMosi'], ['miso', 'pinMiso']];
|
|
}
|
|
for(p of pins) {
|
|
e.append(
|
|
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], pinList, objPin[p[0]])
|
|
)
|
|
])
|
|
);
|
|
}
|
|
}
|
|
|
|
/*IF_ESP32*/
|
|
function parseCmtRadio(obj, type, system) {
|
|
var e = document.getElementById("cmt");
|
|
var en = inp("cmtEnable", null, null, ["cb"], "cmtEnable", "checkbox");
|
|
var pinList = esp32pins;
|
|
if ("ESP32-S3" == system["chip_model"]) pinList = esp32s3pins;
|
|
else if("ESP32-C3" == system["chip_model"]) pinList = esp32c3pins;
|
|
|
|
en.checked = obj["en"];
|
|
|
|
e.replaceChildren (
|
|
ml("div", {class: "row mb-3"}, [
|
|
ml("div", {class: "col-8 col-sm-3 my-2"}, "CMT2300A Enable"),
|
|
ml("div", {class: "col-4 col-sm-9"}, en)
|
|
])
|
|
);
|
|
pins = [['sclk', 'pinCmtSclk'], ['sdio', 'pinSdio'], ['csb', 'pinCsb'], ['fcsb', 'pinFcsb'], ['gpio3', 'pinGpio3']];
|
|
for(p of pins) {
|
|
e.append(
|
|
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], pinList, obj[p[0]])
|
|
)
|
|
])
|
|
);
|
|
}
|
|
}
|
|
/*ENDIF_ESP32*/
|
|
|
|
function parseSerial(obj) {
|
|
for(var i of [["serEn", "show_live_data"], ["serDbg", "debug"], ["priv", "priv"], ["wholeTrace", "wholeTrace"]])
|
|
document.getElementsByName(i[0])[0].checked = obj[i[1]];
|
|
}
|
|
|
|
function parseDisplay(obj, type, system) {
|
|
var pinList = esp8266pins;
|
|
/*IF_ESP32*/
|
|
var pinList = esp32pins;
|
|
if ("ESP32-S3" == system["chip_model"]) pinList = esp32s3pins;
|
|
else if("ESP32-C3" == system["chip_model"]) pinList = esp32c3pins;
|
|
/*ENDIF_ESP32*/
|
|
|
|
for(var i of ["disp_pwr"])
|
|
document.getElementsByName(i)[0].checked = obj[i];
|
|
|
|
var dpins_elem = document.getElementById("dispPins");
|
|
//KEEP this order !!!
|
|
var pins = [['clock', 'disp_clk'], ['data', 'disp_data'], ['cs', 'disp_cs'], ['dc', 'disp_dc'], ['reset', 'disp_rst']];
|
|
/*IF_ESP32*/
|
|
pins.push(['busy', 'disp_bsy']);
|
|
/*ENDIF_ESP32*/
|
|
for(p of pins) {
|
|
dpins_elem.append(
|
|
ml("div", {class: "row mb-3", id: "row_" + p[1]}, [
|
|
ml("div", {class: "col-12 col-sm-3 my-2"}, p[0].toUpperCase()),
|
|
ml("div", {class: "col-12 col-sm-9"},
|
|
sel(p[1], pinList, obj[p[1]])
|
|
)
|
|
])
|
|
);
|
|
}
|
|
// keep display types grouped
|
|
var opts = [[0, "None"],
|
|
[2, "SH1106 128x64 (1.3\")"],
|
|
[5, "SSD1306 64x48 (0.66\" Wemos OLED Shield)"],
|
|
[4, "SSD1306 128x32 (0.91\")"],
|
|
[1, "SSD1306 128x64 (0.96\", 1.54\")"],
|
|
[6, "SSD1309 128X64 (2.42\")"],
|
|
[3, "PCD8544 84X48 (1.6\" Nokia 5110)"]];
|
|
/*IF_ESP32*/
|
|
opts.push([10, "ePaper"]);
|
|
/*ENDIF_ESP32*/
|
|
var dtype_sel = sel("disp_typ", opts, obj["disp_typ"]);
|
|
document.getElementById("dispType").append(
|
|
ml("div", {class: "row mb-3"}, [
|
|
ml("div", {class: "col-12 col-sm-3 my-2"}, "Type"),
|
|
ml("div", {class: "col-12 col-sm-9"}, dtype_sel)
|
|
])
|
|
);
|
|
opts = [[0, "0°"], [2, "180°"]];
|
|
/*IF_ESP32*/
|
|
opts.push([1, "90°"]);
|
|
opts.push([3, "270°"]);
|
|
/*ENDIF_ESP32*/
|
|
document.getElementById("dispRot").append(
|
|
ml("div", {class: "row mb-3"}, [
|
|
ml("div", {class: "col-12 col-sm-3 my-2"}, "Rotation"),
|
|
ml("div", {class: "col-12 col-sm-9"}, sel("disp_rot", opts, obj["disp_rot"]))
|
|
])
|
|
);
|
|
|
|
var opts1 = [[0, "off"], [1, "pixel shift"], [2, "motion sensor"]];
|
|
var screensaver_sel = sel("disp_screensaver", opts1, obj["disp_screensaver"]);
|
|
screensaver_sel.id = 'disp_screensaver';
|
|
document.getElementById("screenSaver").append(
|
|
ml("div", {class: "row mb-3"}, [
|
|
ml("div", {class: "col-12 col-sm-3 my-2"}, "Screensaver (OLED only)"),
|
|
ml("div", {class: "col-12 col-sm-9"}, screensaver_sel)
|
|
])
|
|
);
|
|
|
|
var esp8266pirpins = [[255, "off / default"],
|
|
[17, "A0"]];
|
|
document.getElementById("pirPin").append(
|
|
ml("div", {class: "row mb-3"}, [
|
|
ml("div", {class: "col-12 col-sm-3 my-2"}, "PIR sensor"),
|
|
ml("div", {class: "col-12 col-sm-9"}, sel("pir_pin", ("ESP8266" == type) ? esp8266pirpins : pinList, obj["pir_pin"]))
|
|
])
|
|
);
|
|
|
|
document.getElementsByName("disp_cont")[0].value = obj["disp_cont"];
|
|
|
|
dtype_sel.addEventListener('change', function(e) {
|
|
hideDispPins(pins, parseInt(e.target.value))
|
|
});
|
|
|
|
document.getElementById("disp_screensaver").addEventListener('change', function(e) {
|
|
hideDispPins(pins, parseInt(dtype_sel.value))
|
|
});
|
|
|
|
hideDispPins(pins, obj.disp_typ);
|
|
}
|
|
|
|
function hideDispPins(pins, dispType) {
|
|
// create pin map for each display type.
|
|
// It depends on fix pin array (see var pins)
|
|
// var pins = [['clock', 'disp_clk'], ['data', 'disp_data'], ['cs', 'disp_cs'], ['dc', 'disp_dc'], ['reset', 'disp_rst']];
|
|
const pinMap = new Map([
|
|
[0, [0,0,0,0,0,0]], //none
|
|
[1, [1,1,0,0,0,0]], //SSD1306_128X64
|
|
[2, [1,1,0,0,0,0]], //SH1106_128X64
|
|
[3, [1,1,1,1,0,0]], //PCD8544_84X48 /nokia5110
|
|
[4, [1,1,0,0,0,0]], //SSD1306_128X32
|
|
[5, [1,1,0,0,0,0]], //SSD1306_128x64
|
|
[6, [1,1,0,0,0,0]], //SSD1309_128x64
|
|
[10, [1,1,1,1,1,1]] //ePaper
|
|
])
|
|
for(var i = 0; i < pins.length; i++) {
|
|
var cl = document.getElementById("row_" + pins[i][1]).classList;
|
|
if(pinMap.get(dispType)[i]) {
|
|
cl.remove("hide");
|
|
}
|
|
else {
|
|
cl.add("hide");
|
|
}
|
|
}
|
|
|
|
var screenSaver = document.getElementById("disp_screensaver").value;
|
|
|
|
if (2==screenSaver) { // show pir pin only for motion screensaver
|
|
setHide("pirPin", false);
|
|
}
|
|
else { // no pir pin for all others
|
|
setHide("pirPin", true);
|
|
}
|
|
}
|
|
|
|
function tick() {
|
|
document.getElementById("date").innerHTML = toIsoDateStr((new Date((++ts) * 1000)));
|
|
}
|
|
|
|
function parse(root) {
|
|
if(null != root) {
|
|
parseGeneric(root["generic"]);
|
|
parseSys(root["system"]);
|
|
parseStaticIp(root["static_ip"]);
|
|
parseMqtt(root["mqtt"]);
|
|
parseNtp(root["ntp"]);
|
|
parseSun(root["sun"]);
|
|
parsePinout(root["pinout"], root["system"]["esp_type"], root["system"]);
|
|
parseNrfRadio(root["radioNrf"], root["pinout"], root["system"]["esp_type"], root["system"]);
|
|
/*IF_ESP32*/
|
|
parseCmtRadio(root["radioCmt"], root["system"]["esp_type"], root["system"]);
|
|
/*ENDIF_ESP32*/
|
|
parseSerial(root["serial"]);
|
|
parseDisplay(root["display"], root["system"]["esp_type"], root["system"]);
|
|
getAjax("/api/inverter/list", parseIv);
|
|
}
|
|
}
|
|
|
|
function listNetworks(root) {
|
|
var s = document.getElementById("networks");
|
|
selDelAllOpt(s);
|
|
if(root["networks"].length > 0) {
|
|
s.appendChild(opt("-1", "please select network"));
|
|
for(i = 0; i < root["networks"].length; i++) {
|
|
s.appendChild(opt(root["networks"][i]["ssid"], root["networks"][i]["ssid"] + " (" + root["networks"][i]["rssi"] + " dBm)"));
|
|
}
|
|
} else
|
|
s.appendChild(opt("-1", "no network found"));
|
|
}
|
|
|
|
function selNet() {
|
|
var s = document.getElementById("networks");
|
|
var e = document.getElementsByName("ssid")[0];
|
|
if(-1 != s.value)
|
|
e.value = s.value;
|
|
}
|
|
|
|
getAjax("/api/setup", parse);
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|