PCB lives now in its own git repo https://git.la10cy.net/DeltaLima/CanGrow-12V-PCB
396 lines
11 KiB
C
396 lines
11 KiB
C
/*
|
|
*
|
|
* include/Webserver/Page_system_HTML.h - system settings page HTML header file
|
|
*
|
|
*
|
|
*
|
|
*/
|
|
|
|
/* submenu SUBNAV */
|
|
const char Page_system_HTML_SUBNAV[] PROGMEM = R"(<ul class='subnav'>
|
|
<li><a class='%ACTIVE_SUBNAV_GENERAL%' href='/system/'>🛠️ General</a></li>
|
|
<li><a class='%ACTIVE_SUBNAV_SENSOR%' href='/system/sensor/'>🌡️ Sensor</a></li>
|
|
<li><a class='%ACTIVE_SUBNAV_OUTPUT%' href='/system/output/'>⚡ Output</a></li>
|
|
<li><a class='%ACTIVE_SUBNAV_UPDATE%' href='/system/update'>🔄 Firmware update</a></li>
|
|
<li><a class='%ACTIVE_SUBNAV_RESTART%' href='/system/restart' >🔁 System restart</a></li>
|
|
<li><a class='%ACTIVE_SUBNAV_WIPE%' href='/system/wipe' >💣 Factory reset</a></li>
|
|
</ul>)";
|
|
|
|
/* /system main page */
|
|
const char Page_system_HTML[] PROGMEM = R"(%HEADER%
|
|
%SUBNAV%
|
|
%SAVE_MSG%
|
|
<p>here you can set which features and sensors you use<br></p><form method='post' action='/system/'>
|
|
|
|
<u>NTP offset</u>:<br>
|
|
<input class='inputShort' type='number' name='ntpOffset' min='-12' max='14' value='%NTPOFFSET%' required> Hours<br>
|
|
|
|
<u>Maintenance duration</u>:<br> <input class='inputShort' type='number' name='maintenanceDuration' min='0' max='900' value='%MAINTDUR%' required> Seconds<br>
|
|
|
|
<u>ESP32-Cam IP (optional)</u>:<br>
|
|
<input type='text' name='esp32cam' maxlength='16' value='%ESP32CAM%' ><br>
|
|
|
|
<u>HTTP log to serial</u>:<br>
|
|
<select name='httpLogSerial' required>
|
|
<option disabled value='' selected hidden>---</option>
|
|
%HTTPLOGSERIAL%
|
|
</select><br>
|
|
|
|
<u>I2C RTC</u>:<br>
|
|
%RTC_STATUS%<select name='rtc' required>
|
|
<option value='0' selected >---</option>
|
|
%RTC_AVAILABLE%
|
|
</select><br>
|
|
|
|
<u>Save time to LittleFS</u>:<br>
|
|
<select name='time2fs' required>
|
|
<option disabled value='' selected hidden>---</option>
|
|
%TIME2FS%
|
|
</select><br>
|
|
|
|
<u>PWM Frequency</u>:<br>
|
|
<input type='number' name='pwmFreq' min='0' max='65535' value='%PWMFREQ%'>
|
|
</select><br>
|
|
|
|
|
|
<br>
|
|
|
|
<input type='submit' value='💾 Save settings'>
|
|
</form>
|
|
%FOOTER% )";
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
* Subpage update
|
|
*/
|
|
const char Page_system_update_HTML[] PROGMEM = R"(%HEADER%
|
|
|
|
%SUBNAV%
|
|
Version: %CGVER% <br>
|
|
Build : %CGBUILD% <br>
|
|
|
|
<p>You find the latest CanGrow firmware version on the <a href='https://git.la10cy.net/DeltaLima/CanGrow/releases' target='_blank'>release page</a> of the git repository.</p>
|
|
<form method='POST' action='/system/update' enctype='multipart/form-data' onsubmit="document.getElementById('divUploading').style.display = '';">
|
|
<b>Select .bin file:</b><br>
|
|
<input type='file' accept='.bin,.bin.gz' name='firmware' required>
|
|
<input type='submit' value='Update Firmware'>
|
|
</form>
|
|
<div id='divUploading' style='display: none;' class='warnmsg'>🛜 Uploading, please wait...</div>
|
|
|
|
%FOOTER% )";
|
|
|
|
const char Page_system_update_HTML_POST[] PROGMEM = R"(<html>
|
|
<head><meta http-equiv='refresh' content='20;url=/' /></head>
|
|
<body><h1>Successfully updated!
|
|
<br>Restarting...</h1><br>
|
|
Redirecting to "/" in 20 seconds
|
|
</body></html>)";
|
|
|
|
const char Page_system_update_HTML_POST_FAILED[] PROGMEM = R"(<html>
|
|
<head></head><body><h1>UPDATE FAILED</h1><br>
|
|
Please see messages on serial monitor for more information and go back to <a href='/system/update'>\"System settings > Firmware update\"</a> and try another file.
|
|
</body></html>)";
|
|
|
|
/*******************************************************************************
|
|
* Subpage restart
|
|
*/
|
|
const char Page_system_restart_HTML[] PROGMEM = R"(%HEADER%
|
|
%SUBNAV%
|
|
<div class='warnmsg'>
|
|
%RESTART_MSG%
|
|
</div>
|
|
%FOOTER% )";
|
|
|
|
const char Page_system_restart_HTML_RESTART_MSG[] PROGMEM = R"(Do you want to restart CanGrow?<br>Please confirm.
|
|
<form action='/system/restart' method='post'><input type='hidden' name='confirmed' value='true' />
|
|
<input type='submit' value='Confirm restart' />
|
|
</form>)";
|
|
|
|
const char Page_system_restart_HTML_RESTART_MSG_POST[] PROGMEM = R"(Restarting...<br><span style='helpbox'>Redirecting to root page in 20 seconds.</span>)";
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
* Subpage wipe
|
|
*/
|
|
const char Page_system_wipe_HTML[] PROGMEM = R"(%HEADER%
|
|
%SUBNAV%
|
|
<div class='warnmsg'>
|
|
%WIPE_MSG%
|
|
</div>
|
|
|
|
%FOOTER% )";
|
|
|
|
const char Page_system_wipe_HTML_WIPE_MSG[] PROGMEM = R"(All settings will be removed!!<br><br>
|
|
Please confirm wiping LittleFS
|
|
<form action='/system/wipe' method='post'><br>
|
|
Please confirm: <input type='checkbox' id='confirmed' name='confirmed' required /><br>
|
|
<input type='submit' value='Confirm wiping' />
|
|
</form>)";
|
|
|
|
|
|
const char Page_system_wipe_HTML_WIPE_MSG_POST[] PROGMEM = R"(Restarting...)";
|
|
|
|
/*******************************************************************************
|
|
* Subpage output
|
|
*/
|
|
const char Page_system_output_HTML[] PROGMEM = R"(%HEADER%
|
|
%SUBNAV%
|
|
%SAVE_MSG%
|
|
<a class='button %ADD_DISABLED%' href='/system/output/add'>➕ Add output</a>
|
|
<table class='centered'>
|
|
<tr>
|
|
<th> </th>
|
|
<th>ID</th>
|
|
<th>Name</th>
|
|
<th>Type</th>
|
|
<th>Device</th>
|
|
<th> </th>
|
|
<th>Action</th>
|
|
</tr>
|
|
%TR_TD%
|
|
</table>
|
|
%FOOTER% )";
|
|
|
|
/*******************************************************************************
|
|
* Subpage output add
|
|
*/
|
|
const char Page_system_output_add_HTML[] PROGMEM = R"(%HEADER%
|
|
%SUBNAV%
|
|
<h3>%ACTION% output ID %OUTPUT_ID%</h3>
|
|
%SAVE_MSG%
|
|
|
|
<p>Add/Edit CanGrow output.</p>
|
|
<form method='post' action='/system/output/add?%EDIT_MODE%'>
|
|
<input type='hidden' name='outputId' value='%OUTPUT_ID%' />
|
|
|
|
<u>Type</u>:<br>
|
|
<select id='type_sel' name='type' onchange="showSelect('type_sel', 'type_', 'hidden'); SystemOutputAddselectRequired('type_sel');" required>
|
|
<option disabled value='' selected hidden>---</option>
|
|
%OUTPUT_TYPE%
|
|
</select><br>
|
|
|
|
<u>Device</u>:<br>
|
|
<select name='device' required>
|
|
<option disabled value='' selected hidden>---</option>
|
|
%OUTPUT_DEVICE%
|
|
</select><br>
|
|
|
|
<u>Name</u>:<br>
|
|
<input type='text' name='name' maxlength='32' value='%OUTPUT_NAME%' required><br>
|
|
|
|
<u>Enable</u>:<br>
|
|
<select name='enabled' required>
|
|
<option disabled value='' selected hidden>---</option>
|
|
%OUTPUT_ENABLED%
|
|
</select><br>
|
|
|
|
<u>Invert</u>:<br>
|
|
<select name='invert' required>
|
|
<option disabled value='' selected hidden>---</option>
|
|
%INVERT%
|
|
</select><br>
|
|
|
|
|
|
<div class='hidden %CLASS_TYPE_1%' id='type_1'>
|
|
<u>GPIO</u>:<br>
|
|
<select id='gpio' name='gpio'>
|
|
<option disabled value='' selected hidden>---</option>
|
|
%GPIO_INDEX%
|
|
</select><br>
|
|
|
|
<u>GPIO PWM</u>:<br>
|
|
<select id='gpio_pwm' name='gpio_pwm' >
|
|
<option disabled value='' selected hidden>---</option>
|
|
%GPIO_PWM%
|
|
</select><br>
|
|
|
|
</div>
|
|
|
|
|
|
<div class='hidden ' id='type_2'>
|
|
<u>I2C type</u>:<br>
|
|
<select id='i2c_type' name='i2c_type' onchange="SystemOutputAdd_replaceI2cAddr('i2c_type', 'i2c_addr');">
|
|
<option disabled value='' selected hidden>---</option>
|
|
%I2C_TYPE%
|
|
</select><br>
|
|
<u>I2C address</u>:<br>
|
|
<select id='i2c_addr' name='i2c_addr' onchange="SystemOutputAdd_replaceI2cPort('i2c_type', 'i2c_addr', 'i2c_port');">
|
|
<option value='' selected >---</option>
|
|
</select><br>
|
|
<u>I2C module port</u>:<br>
|
|
<select id='i2c_port' name='i2c_port'>
|
|
<option value='' selected >---</option>
|
|
</select><br>
|
|
</div>
|
|
|
|
<div class='hidden %CLASS_TYPE_3%' id='type_3'>
|
|
<u>Webcall host</u>:<br>
|
|
<input id='webcall_host' type='text' name='webcall_host' maxlength='32' value='%WEBCALL_HOST%' ><br>
|
|
|
|
<u>Webcall path 'on'</u>:<br>
|
|
<input id='webcall_path_on' type='text' name='webcall_path_on' maxlength='32' value='%WEBCALL_PATH_ON%' ><br>
|
|
|
|
<u>Webcall path 'off'</u>:<br>
|
|
<input id='webcall_path_off' type='text' name='webcall_path_off' maxlength='32' value='%WEBCALL_PATH_OFF%' ><br>
|
|
</div>
|
|
|
|
<br>
|
|
|
|
<input type='submit' value='💾 Save settings'>
|
|
</form>
|
|
|
|
<script>
|
|
var addr = [ [] ,
|
|
%REPLACE_I2CADDR_JS% ];
|
|
|
|
%I2C_SAVED%
|
|
</script>
|
|
|
|
|
|
%FOOTER% )";
|
|
|
|
const char Page_system_output_add_HTML_NO_ID_AVAILABLE[] PROGMEM = R"(%HEADER%
|
|
%SUBNAV%
|
|
<h3>You cannot create more outputs, limit reached.</h3>
|
|
%FOOTER% )";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
* Subpage sensor
|
|
*/
|
|
const char Page_system_sensor_HTML[] PROGMEM = R"(%HEADER%
|
|
%SUBNAV%
|
|
%SAVE_MSG%
|
|
<a class='button %ADD_DISABLED%' href='/system/sensor/add'>➕ Add sensor</a>
|
|
<table class='centered'>
|
|
<tr>
|
|
<th> </th>
|
|
<th>ID</th>
|
|
<th>Name</th>
|
|
<th>Type</th>
|
|
</tr>
|
|
%TR_TD%
|
|
</table>
|
|
%FOOTER% )";
|
|
|
|
/*******************************************************************************
|
|
* Subpage sensor add
|
|
*/
|
|
const char Page_system_sensor_add_HTML[] PROGMEM = R"(%HEADER%
|
|
%SUBNAV%
|
|
<h3>%ACTION% sensor ID %SENSOR_ID%</h3>
|
|
%SAVE_MSG%
|
|
|
|
<p>Add/Edit CanGrow sensor.</p>
|
|
<form method='post' action='/system/sensor/add'>
|
|
<input type='hidden' name='sensorId' value='%SENSOR_ID%' />
|
|
<u>Type</u>:<br>
|
|
<select id='type_sel' name='type' onchange="SystemSensorAddGpioI2cSel('type_sel'); SystemSensor_replaceAddr('type_sel', 'i2c_addr');" required>
|
|
<option disabled value='' selected hidden>---</option>
|
|
%SENSOR_TYPE%
|
|
</select><br>
|
|
|
|
|
|
|
|
<u>Name</u>:<br>
|
|
<input type='text' name='name' maxlength='32' value='%SENSOR_NAME%' required><br>
|
|
|
|
|
|
<div class='hidden %CLASS_TYPE_1%' id='type_1'>
|
|
<u>GPIO</u>:<br>
|
|
<select id='gpio' name='gpio'>
|
|
<option value='' selected >---</option>
|
|
%GPIO_INDEX%
|
|
</select><br>
|
|
</div>
|
|
|
|
|
|
<div class='hidden %CLASS_TYPE_2%' id='type_2'>
|
|
<u>I2C address</u>:<br>
|
|
<select id='i2c_addr' name='i2c_addr' required>
|
|
<option value='' selected >---</option>
|
|
</select><br>
|
|
</div>
|
|
|
|
<div class='hidden %CLASS_TYPE_3% %CLASS_TYPE_1%' id='type_3'>
|
|
<span>Special 3</span>
|
|
</div>
|
|
|
|
<!-- Sensor reading calibration -->
|
|
|
|
|
|
<br>
|
|
|
|
<input type='submit' value='💾 Save settings'>
|
|
</form>
|
|
|
|
<script>
|
|
var ESP = '%ESP_PLATFORM%';
|
|
// https://stackoverflow.com/a/67412019
|
|
function SystemSensor_replaceAddr(selectId, replaceId) {
|
|
var sel = document.querySelector('#' + replaceId);
|
|
let selVal = document.getElementById(selectId).value;
|
|
// Remove existing options
|
|
Array.from(sel).forEach((option) => {
|
|
sel.removeChild(option)
|
|
})
|
|
|
|
var addr = [ [] ,
|
|
%REPLACE_I2CADDR_JS%
|
|
]
|
|
|
|
addr[selVal].map((optionData) => {
|
|
let opt = document.createElement('option')
|
|
opt.appendChild(document.createTextNode(optionData[0]));
|
|
opt.value = optionData[1]
|
|
if(optionData[2] > 0) {
|
|
opt.disabled = true
|
|
}
|
|
sel.appendChild(opt);
|
|
})
|
|
}
|
|
|
|
%I2C_SAVED%
|
|
</script>
|
|
|
|
%FOOTER% )";
|
|
|
|
const char Page_system_sensor_add_HTML_NO_ID_AVAILABLE[] PROGMEM = R"(%HEADER%
|
|
%SUBNAV%
|
|
<h3>You cannot create more sensors, limit reached.</h3>
|
|
%FOOTER% )";
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
* Subpage sensor calibrate
|
|
*/
|
|
const char Page_system_sensor_calibrate_HTML[] PROGMEM = R"(%HEADER%
|
|
%SUBNAV%
|
|
<h3>🎛️ Calibrate sensor ID %SENSOR_ID% (%SENSOR_NAME%)</h3>
|
|
%SAVE_MSG%
|
|
|
|
<p>Calibrate CanGrow sensor.</p>
|
|
|
|
|
|
%SENSOR_READING%
|
|
|
|
|
|
|
|
<script>
|
|
|
|
</script>
|
|
|
|
%FOOTER% )";
|