|
|
@@ -1473,371 +1473,10 @@
|
|
|
</td>
|
|
|
</tr>
|
|
|
|
|
|
- <!------------- GPIO0 begin ------------------>
|
|
|
- <tr class="GPIO_IO0 GPIO_item expert">
|
|
|
- <td class="indent1">
|
|
|
- <input type="checkbox" id="GPIO_IO0_enabled" value="1" onclick = 'InvertEnableItem("GPIO", "IO0")' unchecked>
|
|
|
- <label for=GPIO_IO0_enabled><span id="GPIO_IO0_text">GPIO0 Configuration</span></label>
|
|
|
- </td>
|
|
|
- <td>
|
|
|
- <select id="GPIO_IO0_value1">
|
|
|
- <option value="input">input</option>
|
|
|
- <option value="input-pullup">input pullup</option>
|
|
|
- <option value="input-pulldown">input pulldown</option>
|
|
|
- <option value="output">output</option>
|
|
|
- </select>
|
|
|
- </td>
|
|
|
- <td>$TOOLTIP_GPIO_IO0</td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO0 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span id="GPIO_IO0_text" class="GPIO_IO0 GPIO_item">GPIO0 Use Interrupt</span>
|
|
|
- </td>
|
|
|
- <td>
|
|
|
- <select id="GPIO_IO0_value2">
|
|
|
- <option value="disabled">disabled</option>
|
|
|
- <option value="rising-edge">rising edge</option>
|
|
|
- <option value="falling-edge">falling edge</option>
|
|
|
- <option value="rising-and-falling">rising and falling</option>
|
|
|
- <option value="low-level-trigger">low level trigger</option>
|
|
|
- <option value="high-level-trigger">high level trigger</option>
|
|
|
- </select>
|
|
|
- </td>
|
|
|
- <td></td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO0 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span class="GPIO_IO0 GPIO_item">GPIO0 PWM Duty Cycle Resolution</span>
|
|
|
- </td>
|
|
|
- <td>
|
|
|
- <input required type="number" id="GPIO_IO0_value3" min="1" max="20"
|
|
|
- oninput="(!validity.rangeUnderflow||(value=1)) && (!validity.rangeOverflow||(value=20)) &&
|
|
|
- (!validity.stepMismatch||(value=parseInt(this.value)));"><span class="GPIO_IO0 GPIO_item">Bits</span>
|
|
|
- </td>
|
|
|
- <td></td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO0 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span class="GPIO_IO0 GPIO_item">GPIO0 Enable MQTT</span>
|
|
|
- </td>
|
|
|
- <td><input type="checkbox" id="GPIO_IO0_value4"></td>
|
|
|
- <td></td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO0 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span class="GPIO_IO0 GPIO_item">GPIO0 Enable REST API</span>
|
|
|
- </td>
|
|
|
- <td><input type="checkbox" id="GPIO_IO0_value5"></td>
|
|
|
- <td></td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO0 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span class="GPIO_IO0 GPIO_item">GPIO0 Name</span>
|
|
|
- </td>
|
|
|
- <td><input type="text" id="GPIO_IO0_value6"></td>
|
|
|
- <td></td>
|
|
|
- </tr>
|
|
|
- <!------------- GPIO0 end ------------------>
|
|
|
-
|
|
|
- <!------------- GPIO1 begin ------------------>
|
|
|
- <tr class="GPIO_IO1 GPIO_item expert">
|
|
|
- <td class="indent1">
|
|
|
- <input type="checkbox" id="GPIO_IO1_enabled" value="1" onclick = 'InvertEnableItem("GPIO", "IO1")' unchecked>
|
|
|
- <label for=GPIO_IO1_enabled><span id="GPIO_IO1_text">GPIO1 Configuration</span></label>
|
|
|
- </td>
|
|
|
- <td>
|
|
|
- <select id="GPIO_IO1_value1">
|
|
|
- <option value="input">input</option>
|
|
|
- <option value="input-pullup">input pullup</option>
|
|
|
- <option value="input-pulldown">input pulldown</option>
|
|
|
- <option value="output">output</option>
|
|
|
- </select>
|
|
|
- </td>
|
|
|
- <td>$TOOLTIP_GPIO_IO1</td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO1 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span class="GPIO_IO1 GPIO_item" class="expert">GPIO1 Use Interrupt</span>
|
|
|
- </td>
|
|
|
- <td>
|
|
|
- <select id="GPIO_IO1_value2">
|
|
|
- <option value="disabled">disabled</option>
|
|
|
- <option value="rising-edge" disabled>rising edge</option>
|
|
|
- <option value="falling-edge" disabled>falling edge</option>
|
|
|
- <option value="rising-and-falling">rising and falling</option>
|
|
|
- <option value="low-level-trigger">low level trigger</option>
|
|
|
- <option value="high-level-trigger">high level trigger</option>
|
|
|
- </select>
|
|
|
- </td>
|
|
|
- <td></td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO1 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span class="GPIO_IO1 GPIO_item">GPIO1 PWM Duty Cycle Resolution</span>
|
|
|
- </td>
|
|
|
- <td>
|
|
|
- <input required type="number" id="GPIO_IO1_value3" min="1" max="20"
|
|
|
- oninput="(!validity.rangeUnderflow||(value=1)) && (!validity.rangeOverflow||(value=20)) &&
|
|
|
- (!validity.stepMismatch||(value=parseInt(this.value)));"><span class="GPIO_IO1 GPIO_item">Bits</span>
|
|
|
- </td>
|
|
|
- <td></td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO1 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span class="GPIO_IO1 GPIO_item">GPIO1 Enable MQTT</span>
|
|
|
- </td>
|
|
|
- <td><input type="checkbox" id="GPIO_IO1_value4"></td>
|
|
|
- <td></td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO1 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span class="GPIO_IO1 GPIO_item">GPIO1 Enable REST API</span>
|
|
|
- </td>
|
|
|
- <td><input type="checkbox" id="GPIO_IO1_value5"></td>
|
|
|
- <td></td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO1 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span class="GPIO_IO1 GPIO_item" class="expert">GPIO1 Name</span>
|
|
|
- </td>
|
|
|
- <td><input type="text" id="GPIO_IO1_value6"></td>
|
|
|
- <td></td>
|
|
|
- </tr>
|
|
|
- <!------------- GPIO1 end ------------------>
|
|
|
-
|
|
|
- <!------------- GPIO3 begin ------------------>
|
|
|
- <tr class="GPIO_IO3 GPIO_item expert">
|
|
|
- <td class="indent1">
|
|
|
- <input type="checkbox" id="GPIO_IO3_enabled" value="1" onclick = 'InvertEnableItem("GPIO", "IO3")' unchecked>
|
|
|
- <label for=GPIO_IO3_enabled><span id="GPIO_IO3_text">GPIO3 Configuration</span></label>
|
|
|
- </td>
|
|
|
- <td>
|
|
|
- <select id="GPIO_IO3_value1">
|
|
|
- <option value="input">input</option>
|
|
|
- <option value="input-pullup">input pullup</option>
|
|
|
- <option value="input-pulldown">input pulldown</option>
|
|
|
- <option value="output">output</option>
|
|
|
- </select>
|
|
|
- </td>
|
|
|
- <td>$TOOLTIP_GPIO_IO3</td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO3 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span class="GPIO_IO3 GPIO_item">GPIO3 Use Interrupt</span>
|
|
|
- </td>
|
|
|
- <td>
|
|
|
- <select id="GPIO_IO3_value2">
|
|
|
- <option value="disabled">disabled</option>
|
|
|
- <option value="rising-edge" disabled>rising edge</option>
|
|
|
- <option value="falling-edge" disabled>falling edge</option>
|
|
|
- <option value="rising-and-falling">rising and falling</option>
|
|
|
- <option value="low-level-trigger">low level trigger</option>
|
|
|
- <option value="high-level-trigger">high level trigger</option>
|
|
|
- </select>
|
|
|
- </td>
|
|
|
- <td></td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO3 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span class="GPIO_IO3 GPIO_item">GPIO3 PWM Duty Cycle Resolution</span>
|
|
|
- </td>
|
|
|
- <td>
|
|
|
- <input required type="number" id="GPIO_IO3_value3" min="1" max="20"
|
|
|
- oninput="(!validity.rangeUnderflow||(value=1)) && (!validity.rangeOverflow||(value=20)) &&
|
|
|
- (!validity.stepMismatch||(value=parseInt(this.value)));"><span class="GPIO_IO3 GPIO_item">Bits</span>
|
|
|
- </td>
|
|
|
- <td></td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO3 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span class="GPIO_IO3 GPIO_item">GPIO3 Enable MQTT</span>
|
|
|
+ <tr id="GPIO_dynamic_container" class="GPIO_item">
|
|
|
+ <td colspan="3" style="padding:0;">
|
|
|
+ <table id="GPIO_dynamic_channels" class="table"></table>
|
|
|
</td>
|
|
|
- <td><input type="checkbox" id="GPIO_IO3_value4"></td>
|
|
|
- <td></td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO3 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span class="GPIO_IO3 GPIO_item">GPIO3 Enable REST API</span>
|
|
|
- </td>
|
|
|
- <td><input type="checkbox" id="GPIO_IO3_value5"></td>
|
|
|
- <td></td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO3 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span class="GPIO_IO3 GPIO_item">GPIO3 Name</span>
|
|
|
- </td>
|
|
|
- <td><input type="text" id="GPIO_IO3_value6"></td>
|
|
|
- <td></td>
|
|
|
- </tr>
|
|
|
- <!------------- GPIO3 end ------------------>
|
|
|
-
|
|
|
- <!------------- GPIO4 begin ------------------>
|
|
|
- <tr class="GPIO_item" style="border-bottom: 0px;">
|
|
|
- <td class="indent1">
|
|
|
- <input type="checkbox" id="GPIO_IO4_enabled" value="1" onclick = 'InvertEnableItem("GPIO", "IO4")' checked>
|
|
|
- <label for=GPIO_IO4_enabled><span id="GPIO_IO4_text">GPIO4 Configuration</span></label>
|
|
|
- </td>
|
|
|
- <td>
|
|
|
- <select id="GPIO_IO4_value1">
|
|
|
- <option value="input">input</option>
|
|
|
- <option value="input-pullup">input pullup</option>
|
|
|
- <option value="input-pulldown">input pulldown</option>
|
|
|
- <option value="output">output</option>
|
|
|
- <option value="built-in-led" select>built-in led flash light</option>
|
|
|
- </select>
|
|
|
- </td>
|
|
|
- <td>$TOOLTIP_GPIO_IO4</td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_item" style="border-top: 0px;">
|
|
|
- <td colspan="2" style="padding-left:28px">
|
|
|
- <b>IMPORTANT NOTE:</b><br>
|
|
|
- If you'd like to use the built-in flash LED in parallel with other GPIO functionality,
|
|
|
- you have to explicitely activate the "built-in LED flash light" option on GPIO4. The light
|
|
|
- intensity control (PWM) of the LED flash light is not functional anymore (only 100%).
|
|
|
- </td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO4 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span class="GPIO_IO4 GPIO_item">GPIO4 Use Interrupt</span>
|
|
|
- </td>
|
|
|
- <td>
|
|
|
- <select id="GPIO_IO4_value2">
|
|
|
- <option value="disabled">disabled</option>
|
|
|
- <option value="rising-edge">rising edge</option>
|
|
|
- <option value="falling-edge">falling edge</option>
|
|
|
- <option value="rising-and-falling">rising and falling</option>
|
|
|
- <option value="low-level-trigger">low level trigger</option>
|
|
|
- <option value="high-level-trigger">high level trigger</option>
|
|
|
- </select>
|
|
|
- </td>
|
|
|
- <td></td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO4 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span class="GPIO_IO4 GPIO_item">GPIO4 PWM Duty Cycle Resolution</span>
|
|
|
- </td>
|
|
|
- <td>
|
|
|
- <input required type="number" id="GPIO_IO4_value3" min="1" max="20"
|
|
|
- oninput="(!validity.rangeUnderflow||(value=1)) && (!validity.rangeOverflow||(value=20)) &&
|
|
|
- (!validity.stepMismatch||(value=parseInt(this.value)));"><span class="GPIO_IO4 GPIO_item">Bits</span>
|
|
|
- </td>
|
|
|
- <td></td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO4 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span class="GPIO_IO4 GPIO_item">GPIO4 Enable MQTT</span>
|
|
|
- </td>
|
|
|
- <td><input type="checkbox" id="GPIO_IO4_value4"></td>
|
|
|
- <td></td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO4 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span class="GPIO_IO4 GPIO_item">GPIO4 Enable REST API</span>
|
|
|
- </td>
|
|
|
- <td><input type="checkbox" id="GPIO_IO4_value5"></td>
|
|
|
- <td></td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO4 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span class="GPIO_IO4 GPIO_item">GPIO4 Name</span>
|
|
|
- </td>
|
|
|
- <td><input type="text" id="GPIO_IO4_value6"></td>
|
|
|
- <td></td>
|
|
|
- </tr>
|
|
|
- <!------------- GPIO4 end ------------------>
|
|
|
-
|
|
|
- <!------------- GPIO12 begin ------------------>
|
|
|
- <tr class="GPIO_item">
|
|
|
- <td class="indent1">
|
|
|
- <input type="checkbox" id="GPIO_IO12_enabled" value="1" onclick = 'InvertEnableItem("GPIO", "IO12")' unchecked>
|
|
|
- <label for=GPIO_IO12_enabled><span id="GPIO_IO12_text">GPIO12 Configuration</span></label>
|
|
|
- </td>
|
|
|
- <td>
|
|
|
- <select id="GPIO_IO12_value1">
|
|
|
- <option value="input">input</option>
|
|
|
- <option value="input-pullup">input pullup</option>
|
|
|
- <option value="input-pulldown">input pulldown</option>
|
|
|
- <option value="output">output</option>
|
|
|
- <!-- <option value="output-pwm">output-pwm</option> -->
|
|
|
- <!-- <option value="external-flash-pwm">external-flash-pwm</option> -->
|
|
|
- <option value="external-flash-ws281x">external flash light ws281x controlled</option>
|
|
|
- </select>
|
|
|
- </td>
|
|
|
- <td>$TOOLTIP_GPIO_IO12</td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO12 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span class="GPIO_IO12 GPIO_item">GPIO12 Use Interrupt</span>
|
|
|
- </td>
|
|
|
- <td>
|
|
|
- <select class="GPIO_IO12 GPIO_item" id="GPIO_IO12_value2">
|
|
|
- <option value="disabled">disabled</option>
|
|
|
- <option value="rising-edge">rising edge</option>
|
|
|
- <option value="falling-edge">falling edge</option>
|
|
|
- <option value="rising-and-falling">rising and falling</option>
|
|
|
- <option value="low-level-trigger">low level trigger</option>
|
|
|
- <option value="high-level-trigger">high level trigger</option>
|
|
|
- </select>
|
|
|
- </td>
|
|
|
- <td></td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO12 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span class="GPIO_IO12 GPIO_item">GPIO12 PWM Duty Cycle Resolution</span>
|
|
|
- </td>
|
|
|
- <td>
|
|
|
- <input required type="number" id="GPIO_IO12_value3" min="1" max="20"
|
|
|
- oninput="(!validity.rangeUnderflow||(value=1)) && (!validity.rangeOverflow||(value=20)) &&
|
|
|
- (!validity.stepMismatch||(value=parseInt(this.value)));"><span class="GPIO_IO12 GPIO_item">Bits</span>
|
|
|
- </td>
|
|
|
- <td></td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO12 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span class="GPIO_IO12 GPIO_item">GPIO12 Enable MQTT</span>
|
|
|
- </td>
|
|
|
- <td><input type="checkbox" id="GPIO_IO12_value4"></td>
|
|
|
- <td></td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO12 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span class="GPIO_IO12 GPIO_item">GPIO12 Enable REST API</span>
|
|
|
- </td>
|
|
|
- <td><input type="checkbox" id="GPIO_IO12_value5"></td>
|
|
|
- <td></td>
|
|
|
- </tr>
|
|
|
-
|
|
|
- <tr class="GPIO_IO12 GPIO_item expert">
|
|
|
- <td class="indent2">
|
|
|
- <span class="GPIO_IO12 GPIO_item">GPIO12 Name</span>
|
|
|
- </td>
|
|
|
- <td><input type="text" id="GPIO_IO12_value6"></td>
|
|
|
- <td></td>
|
|
|
</tr>
|
|
|
|
|
|
<tr class="GPIO_item" unused_id="wstypeex3">
|
|
|
@@ -2415,12 +2054,9 @@ function UpdateInput() {
|
|
|
WriteParameter(param, category, "Webhook", "ApiKey", true);
|
|
|
WriteParameter(param, category, "Webhook", "UploadImg", false);
|
|
|
|
|
|
- WriteParameter(param, category, "GPIO", "IO0", true);
|
|
|
- WriteParameter(param, category, "GPIO", "IO1", true);
|
|
|
- WriteParameter(param, category, "GPIO", "IO3", true);
|
|
|
- WriteParameter(param, category, "GPIO", "IO4", true);
|
|
|
- WriteParameter(param, category, "GPIO", "IO12", true);
|
|
|
- WriteParameter(param, category, "GPIO", "IO13", true);
|
|
|
+ (window.GPIO_AVAILABLE_PINS || []).forEach(function (gpio) {
|
|
|
+ WriteParameter(param, category, "GPIO", "IO" + gpio, true);
|
|
|
+ });
|
|
|
WriteParameter(param, category, "GPIO", "LEDType", false);
|
|
|
WriteParameter(param, category, "GPIO", "LEDNumbers", false);
|
|
|
WriteParameter(param, category, "GPIO", "LEDColor", false);
|
|
|
@@ -2583,12 +2219,9 @@ function ReadParameterAll() {
|
|
|
ReadParameter(param, "Webhook", "ApiKey", true);
|
|
|
ReadParameter(param, "Webhook", "UploadImg", false);
|
|
|
|
|
|
- ReadParameter(param, "GPIO", "IO0", true);
|
|
|
- ReadParameter(param, "GPIO", "IO1", true);
|
|
|
- ReadParameter(param, "GPIO", "IO3", true);
|
|
|
- ReadParameter(param, "GPIO", "IO4", true);
|
|
|
- ReadParameter(param, "GPIO", "IO12", true);
|
|
|
- ReadParameter(param, "GPIO", "IO13", true);
|
|
|
+ (window.GPIO_AVAILABLE_PINS || []).forEach(function (gpio) {
|
|
|
+ ReadParameter(param, "GPIO", "IO" + gpio, true);
|
|
|
+ });
|
|
|
ReadParameter(param, "GPIO", "LEDType", false);
|
|
|
ReadParameter(param, "GPIO", "LEDNumbers", false);
|
|
|
ReadParameter(param, "GPIO", "LEDColor", false);
|
|
|
@@ -2659,18 +2292,8 @@ function UpdateExpertModus() {
|
|
|
// document.getElementById(expert[i].id).style = _style;
|
|
|
}
|
|
|
|
|
|
- // Enable / Disable die Optionen in den Menues für die Auswahl. Falls kein Expertenmodus soll nur ein Wert (built-in-led oder externan-flash-ws281x) möglich sein
|
|
|
- Array.from(document.querySelector("#GPIO_IO4_value1").options).forEach(function(option_element) {
|
|
|
- if (option_element.value != "built-in-led") {
|
|
|
- option_element.hidden = _hidden;
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- Array.from(document.querySelector("#GPIO_IO12_value1").options).forEach(function(option_element) {
|
|
|
- if (option_element.value != "external-flash-ws281x") {
|
|
|
- option_element.hidden = _hidden;
|
|
|
- }
|
|
|
- });
|
|
|
+ // Generic user GPIO channels have no board-owned LED modes.
|
|
|
+ // Built-in flash/status LEDs remain controlled by their board-specific drivers.
|
|
|
}
|
|
|
|
|
|
function UpdateTooltipModus() {
|
|
|
@@ -3378,42 +3001,148 @@ openDescription();
|
|
|
LoadConfigNeu();
|
|
|
|
|
|
/*
|
|
|
- * The board profile is the single source of truth for GPIO choices.
|
|
|
- * Hide legacy hard-coded rows first; only rows present in the firmware
|
|
|
- * whitelist may become visible and editable.
|
|
|
+ * Generate the GPIO editor from the active, audited board whitelist.
|
|
|
+ * Pin numbers and capability flags come only from the firmware.
|
|
|
*/
|
|
|
+window.GPIO_AVAILABLE_PINS = [];
|
|
|
+
|
|
|
(function loadBoardGpioCapabilities() {
|
|
|
var categoryCheckbox = document.getElementById("Category_GPIO_enabled");
|
|
|
var notice = document.getElementById("GPIO_profile_notice");
|
|
|
- var knownPins = [0, 1, 3, 4, 12, 13];
|
|
|
- var capability = {
|
|
|
- input: 1, output: 2, pullUp: 4, pullDown: 8, interrupt: 16, pwm: 32
|
|
|
- };
|
|
|
+ var table = document.getElementById("GPIO_dynamic_channels");
|
|
|
+ var CAP_INPUT = 1, CAP_OUTPUT = 2, CAP_PULL_UP = 4, CAP_PULL_DOWN = 8, CAP_INTERRUPT = 16, CAP_PWM = 32;
|
|
|
|
|
|
- function showUnavailable(message) {
|
|
|
+ function unavailable(message) {
|
|
|
+ window.GPIO_AVAILABLE_PINS = [];
|
|
|
+ if (table) table.innerHTML = "";
|
|
|
if (notice) {
|
|
|
notice.style.display = "";
|
|
|
- notice.cells[0].innerHTML = "<b>GPIO configuration unavailable.</b><br>" + message;
|
|
|
+ notice.cells[0].textContent = "";
|
|
|
+ var strong = document.createElement("b");
|
|
|
+ strong.textContent = "GPIO configuration unavailable.";
|
|
|
+ notice.cells[0].appendChild(strong);
|
|
|
+ notice.cells[0].appendChild(document.createElement("br"));
|
|
|
+ notice.cells[0].appendChild(document.createTextNode(message));
|
|
|
}
|
|
|
if (categoryCheckbox) {
|
|
|
categoryCheckbox.checked = false;
|
|
|
categoryCheckbox.disabled = true;
|
|
|
}
|
|
|
- if (typeof category !== "undefined" && category.GPIO) {
|
|
|
- category.GPIO.enabled = false;
|
|
|
- }
|
|
|
- knownPins.forEach(function (pin) {
|
|
|
- document.querySelectorAll(".GPIO_IO" + pin).forEach(function (row) {
|
|
|
- row.style.display = "none";
|
|
|
- row.querySelectorAll("input, select, textarea").forEach(function (element) {
|
|
|
- element.disabled = true;
|
|
|
- });
|
|
|
- });
|
|
|
- });
|
|
|
+ if (category && category.GPIO) category.GPIO.enabled = false;
|
|
|
}
|
|
|
|
|
|
- showUnavailable("Loading the active board profile…");
|
|
|
+ function addOption(select, value, label, enabled) {
|
|
|
+ var option = document.createElement("option");
|
|
|
+ option.value = value;
|
|
|
+ option.textContent = label;
|
|
|
+ option.disabled = !enabled;
|
|
|
+ select.appendChild(option);
|
|
|
+ }
|
|
|
+
|
|
|
+ function addRow(pin, className, label, control) {
|
|
|
+ var row = document.createElement("tr");
|
|
|
+ row.className = "GPIO_IO" + pin + " GPIO_item expert " + (className || "");
|
|
|
+ var left = document.createElement("td");
|
|
|
+ left.className = "indent2";
|
|
|
+ var text = document.createElement("span");
|
|
|
+ text.id = "GPIO_IO" + pin + "_text";
|
|
|
+ text.className = "GPIO_IO" + pin + " GPIO_item";
|
|
|
+ text.textContent = label;
|
|
|
+ left.appendChild(text);
|
|
|
+ var middle = document.createElement("td");
|
|
|
+ middle.appendChild(control);
|
|
|
+ var right = document.createElement("td");
|
|
|
+ row.appendChild(left);
|
|
|
+ row.appendChild(middle);
|
|
|
+ row.appendChild(right);
|
|
|
+ table.appendChild(row);
|
|
|
+ }
|
|
|
+
|
|
|
+ function makeChannel(pin, caps) {
|
|
|
+ var prefix = "GPIO_IO" + pin;
|
|
|
+ var first = document.createElement("tr");
|
|
|
+ first.className = prefix + " GPIO_item expert";
|
|
|
+ var labelCell = document.createElement("td");
|
|
|
+ labelCell.className = "indent1";
|
|
|
+ var enabled = document.createElement("input");
|
|
|
+ enabled.type = "checkbox";
|
|
|
+ enabled.id = prefix + "_enabled";
|
|
|
+ enabled.onclick = function () {
|
|
|
+ InvertEnableItem("GPIO", "IO" + pin);
|
|
|
+ enforceChannelLimit(enabled);
|
|
|
+ };
|
|
|
+ var label = document.createElement("label");
|
|
|
+ label.htmlFor = enabled.id;
|
|
|
+ var title = document.createElement("span");
|
|
|
+ title.id = prefix + "_text";
|
|
|
+ title.textContent = "GPIO" + pin + " configuration";
|
|
|
+ label.appendChild(title);
|
|
|
+ labelCell.appendChild(enabled);
|
|
|
+ labelCell.appendChild(label);
|
|
|
+
|
|
|
+ var modeCell = document.createElement("td");
|
|
|
+ var mode = document.createElement("select");
|
|
|
+ mode.id = prefix + "_value1";
|
|
|
+ addOption(mode, "input", "Input", !!(caps & CAP_INPUT));
|
|
|
+ addOption(mode, "input-pullup", "Input pull-up", !!((caps & CAP_INPUT) && (caps & CAP_PULL_UP)));
|
|
|
+ addOption(mode, "input-pulldown", "Input pull-down", !!((caps & CAP_INPUT) && (caps & CAP_PULL_DOWN)));
|
|
|
+ addOption(mode, "output", "Output", !!(caps & CAP_OUTPUT));
|
|
|
+ addOption(mode, "output-pwm", "PWM output", !!((caps & CAP_OUTPUT) && (caps & CAP_PWM)));
|
|
|
+ modeCell.appendChild(mode);
|
|
|
+ first.appendChild(labelCell);
|
|
|
+ first.appendChild(modeCell);
|
|
|
+ first.appendChild(document.createElement("td"));
|
|
|
+ table.appendChild(first);
|
|
|
+
|
|
|
+ var interrupt = document.createElement("select");
|
|
|
+ interrupt.id = prefix + "_value2";
|
|
|
+ ["disabled", "rising-edge", "falling-edge", "rising-and-falling", "low-level-trigger", "high-level-trigger"]
|
|
|
+ .forEach(function (v) { addOption(interrupt, v, v, v === "disabled" || !!(caps & CAP_INTERRUPT)); });
|
|
|
+ addRow(pin, "", "Interrupt", interrupt);
|
|
|
+
|
|
|
+ var resolution = document.createElement("input");
|
|
|
+ resolution.type = "number";
|
|
|
+ resolution.min = "1";
|
|
|
+ resolution.max = "20";
|
|
|
+ resolution.step = "1";
|
|
|
+ resolution.id = prefix + "_value3";
|
|
|
+ resolution.value = "10";
|
|
|
+ addRow(pin, "", "PWM duty resolution (bits)", resolution);
|
|
|
+
|
|
|
+ var mqtt = document.createElement("input");
|
|
|
+ mqtt.type = "checkbox";
|
|
|
+ mqtt.id = prefix + "_value4";
|
|
|
+ addRow(pin, "", "Enable MQTT", mqtt);
|
|
|
+
|
|
|
+ var http = document.createElement("input");
|
|
|
+ http.type = "checkbox";
|
|
|
+ http.id = prefix + "_value5";
|
|
|
+ addRow(pin, "", "Enable REST API", http);
|
|
|
+
|
|
|
+ var name = document.createElement("input");
|
|
|
+ name.type = "text";
|
|
|
+ name.maxLength = 99;
|
|
|
+ name.id = prefix + "_value6";
|
|
|
+ name.value = "GPIO" + pin;
|
|
|
+ addRow(pin, "", "Name", name);
|
|
|
+ }
|
|
|
+
|
|
|
+ function enforceChannelLimit(changed) {
|
|
|
+ var active = window.GPIO_AVAILABLE_PINS.filter(function (pin) {
|
|
|
+ var checkbox = document.getElementById("GPIO_IO" + pin + "_enabled");
|
|
|
+ return checkbox && checkbox.checked;
|
|
|
+ });
|
|
|
+ var max = window.GPIO_MAX_CHANNELS || 4;
|
|
|
+ if (active.length > max) {
|
|
|
+ changed.checked = false;
|
|
|
+ InvertEnableItem("GPIO", changed.id.replace("GPIO_IO", "").replace("_enabled", ""));
|
|
|
+ if (typeof firework !== "undefined") {
|
|
|
+ firework.launch("A maximum of " + max + " GPIO channels can be enabled.", "warning", 5000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ unavailable("Loading the active board profile…");
|
|
|
fetch("/GPIO?capabilities=1", { method: "GET", cache: "no-store" })
|
|
|
.then(function (response) {
|
|
|
if (!response.ok) throw new Error("HTTP " + response.status);
|
|
|
@@ -3421,63 +3150,45 @@ LoadConfigNeu();
|
|
|
})
|
|
|
.then(function (profile) {
|
|
|
if (!profile || !Array.isArray(profile.pins) ||
|
|
|
- !Number.isInteger(profile.maxChannels) || profile.maxChannels < 1) {
|
|
|
+ !Number.isInteger(profile.maxChannels) || profile.maxChannels < 1 ||
|
|
|
+ profile.maxChannels > 4) {
|
|
|
throw new Error("Invalid board GPIO profile response");
|
|
|
}
|
|
|
|
|
|
- var available = profile.pins.filter(function (pin) {
|
|
|
- return Number.isInteger(pin.gpio) && knownPins.indexOf(pin.gpio) !== -1 &&
|
|
|
- Number.isInteger(pin.capabilities);
|
|
|
- }).slice(0, Math.min(4, profile.maxChannels));
|
|
|
+ var seen = {};
|
|
|
+ var pins = profile.pins.filter(function (pin) {
|
|
|
+ if (!pin || !Number.isInteger(pin.gpio) || pin.gpio < 0 ||
|
|
|
+ !Number.isInteger(pin.capabilities) || pin.capabilities <= 0 ||
|
|
|
+ seen[pin.gpio]) return false;
|
|
|
+ seen[pin.gpio] = true;
|
|
|
+ return true;
|
|
|
+ });
|
|
|
+
|
|
|
+ window.GPIO_MAX_CHANNELS = profile.maxChannels;
|
|
|
+ window.GPIO_AVAILABLE_PINS = pins.map(function (pin) { return pin.gpio; });
|
|
|
+ pins.forEach(function (pin) { makeChannel(pin.gpio, pin.capabilities); });
|
|
|
|
|
|
- if (notice) notice.style.display = available.length ? "none" : "";
|
|
|
- if (!available.length) {
|
|
|
- showUnavailable("The active profile (" + profile.profile +
|
|
|
- ") does not currently whitelist any GPIO exposed by this configuration page.");
|
|
|
+ if (notice) notice.style.display = pins.length ? "none" : "";
|
|
|
+ if (!pins.length) {
|
|
|
+ unavailable("The active board profile (" + profile.profile +
|
|
|
+ ") does not whitelist any user GPIO pins. Board-owned pins remain reserved.");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- knownPins.forEach(function (pin) {
|
|
|
- var allowed = available.find(function (item) { return item.gpio === pin; });
|
|
|
- document.querySelectorAll(".GPIO_IO" + pin).forEach(function (row) {
|
|
|
- row.style.display = allowed ? "" : "none";
|
|
|
- row.querySelectorAll("input, select, textarea").forEach(function (element) {
|
|
|
- element.disabled = !allowed;
|
|
|
- });
|
|
|
- });
|
|
|
- if (!allowed) return;
|
|
|
-
|
|
|
- var modes = document.getElementById("GPIO_IO" + pin + "_value1");
|
|
|
- if (modes) {
|
|
|
- Array.from(modes.options).forEach(function (option) {
|
|
|
- var modeAllowed =
|
|
|
- (option.value === "input" && (allowed.capabilities & capability.input)) ||
|
|
|
- (option.value === "input-pullup" &&
|
|
|
- (allowed.capabilities & capability.input) && (allowed.capabilities & capability.pullUp)) ||
|
|
|
- (option.value === "input-pulldown" &&
|
|
|
- (allowed.capabilities & capability.input) && (allowed.capabilities & capability.pullDown)) ||
|
|
|
- (option.value === "output" && (allowed.capabilities & capability.output)) ||
|
|
|
- (option.value === "output-pwm" && (allowed.capabilities & capability.output) &&
|
|
|
- (allowed.capabilities & capability.pwm));
|
|
|
- option.disabled = !modeAllowed;
|
|
|
- });
|
|
|
- }
|
|
|
- var interrupts = document.getElementById("GPIO_IO" + pin + "_value2");
|
|
|
- if (interrupts) {
|
|
|
- interrupts.disabled = !(allowed.capabilities & capability.interrupt);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- if (categoryCheckbox) categoryCheckbox.disabled = false;
|
|
|
- if (typeof category !== "undefined" && category.GPIO) {
|
|
|
- category.GPIO.enabled = false;
|
|
|
+ if (categoryCheckbox) {
|
|
|
+ categoryCheckbox.disabled = false;
|
|
|
+ categoryCheckbox.checked = !!category.GPIO.enabled;
|
|
|
}
|
|
|
+ window.GPIO_AVAILABLE_PINS.forEach(function (pin) {
|
|
|
+ WriteParameter(param, category, "GPIO", "IO" + pin, true);
|
|
|
+ });
|
|
|
+ setVisible("GPIO_item", !!category.GPIO.enabled);
|
|
|
})
|
|
|
.catch(function (error) {
|
|
|
- showUnavailable("Could not read the firmware board profile (" + error.message +
|
|
|
+ unavailable("Could not read the firmware board profile (" + error.message +
|
|
|
"). GPIO stays locked for safety.");
|
|
|
});
|
|
|
-})();
|
|
|
+})();;
|
|
|
|
|
|
</script>
|
|
|
</body>
|