Explorar o código

Apply explicit defaults to new dynamic GPIO entries

SybexXx hai 3 días
pai
achega
d41cb92cb6
Modificáronse 1 ficheiros con 14 adicións e 2 borrados
  1. 14 2
      sd-card/html/edit_config_template.html

+ 14 - 2
sd-card/html/edit_config_template.html

@@ -3066,8 +3066,20 @@ window.GPIO_AVAILABLE_PINS = [];
             throw new Error("GPIO" + pin + " has no supported input/output mode");
         }
         mode.value = supportedModes[0].value;
-        if (!param.GPIO["IO" + pin].found && typeof param.GPIO["IO" + pin].value1 === "undefined") {
-            param.GPIO["IO" + pin].value1 = mode.value;
+
+        // Match getCamConfig()'s fallback semantics for a GPIO entry that
+        // does not yet exist in config.ini: mark it found and populate every
+        // field with a valid, explicit default before binding the controls.
+        var gpioParameter = param.GPIO["IO" + pin];
+        if (!gpioParameter.found) {
+            gpioParameter.found = true;
+            gpioParameter.enabled = false;
+            gpioParameter.value1 = mode.value;
+            gpioParameter.value2 = "disabled";
+            gpioParameter.value3 = "10";
+            gpioParameter.value4 = "false";
+            gpioParameter.value5 = "false";
+            gpioParameter.value6 = "GPIO" + pin;
         }
 
         first.appendChild(labelCell);