nvs editor working

This commit is contained in:
Christian Herzog
2019-10-01 22:13:24 +02:00
parent bd75411c6e
commit e63db087b6
3 changed files with 69 additions and 45 deletions

View File

@@ -214,7 +214,7 @@ $(document).ready(function(){
var id = $(this)[0].id; var id = $(this)[0].id;
var pin = $(this).val(); var pin = $(this).val();
if (pin != '') { if (pin != '') {
headers[id] = pin; headers["X-Custom-"+id] = pin;
} }
}); });
$.ajax({ $.ajax({
@@ -222,8 +222,41 @@ $(document).ready(function(){
dataType: 'json', dataType: 'json',
method: 'POST', method: 'POST',
cache: false, cache: false,
headers: JSON.stringify(headers), headers: headers,
data: { 'timestamp': Date.now() } data: { 'timestamp': Date.now() },
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr.status);
console.log(thrownError);
}
});
console.log('sent config JSON with headers:', JSON.stringify(headers));
});
$("#save-nvs").on("click", function() {
var headers = {};
$("input.nvs").each(function() {
var key = $(this)[0].id;
var val = $(this).val();
if (key != '') {
headers["X-Custom-"+key] = val;
}
});
var key = $("#nvs-new-key").val();
var val = $("#nvs-new-value").val();
if (key != '') {
headers["X-Custom-"+key] = val;
}
$.ajax({
url: '/config.json',
dataType: 'json',
method: 'POST',
cache: false,
headers: headers,
data: { 'timestamp': Date.now() },
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr.status);
console.log(thrownError);
}
}); });
console.log('sent config JSON with headers:', JSON.stringify(headers)); console.log('sent config JSON with headers:', JSON.stringify(headers));
}); });
@@ -503,7 +536,7 @@ function checkStatus(){
$("#otadiv").hide(); $("#otadiv").hide();
$('a[href^="#tab-audio"]').show(); $('a[href^="#tab-audio"]').show();
$('a[href^="#tab-gpio"]').show(); $('a[href^="#tab-gpio"]').show();
//$('a[href^="#tab-nvs"]').hide(); //TODO $('a[href^="#tab-nvs"]').hide();
$( "footer.footer" ).removeClass('recovery'); $( "footer.footer" ).removeClass('recovery');
$( "footer.footer" ).addClass('sl'); $( "footer.footer" ).addClass('sl');
enableStatusTimer = false; enableStatusTimer = false;
@@ -549,34 +582,35 @@ function getConfig() {
$("#autoexec-cb")[0].checked=false; $("#autoexec-cb")[0].checked=false;
} }
} else if (key == 'autoexec1') { } else if (key == 'autoexec1') {
$("#autoexec1").val(data["autoexec1"]); $("input#autoexec1").val(data["autoexec1"]);
} }
if (recovery) { if (recovery) {
$("tbody#nvsTable").append( $("tbody#nvsTable").append(
"<tr>"+ "<tr>"+
"<td>"+key+"</td>"+ "<td>"+key+"</td>"+
"<td>"+ "<td class='value'>"+
"<input type='text' class='form-control' id='nvs'+key value='"+data[key]+"'>"+ "<input type='text' class='form-control nvs' id='"+key+"'>"+
"</td>"+ "</td>"+
"</tr>" "</tr>"
); );
//TODO append empty line $("input#"+key).val(data[key]);
console.log("#"+key, data[key]);
} }
} }
} }
/* if (recovery) {
if (data.hasOwnProperty('autoexec')) { $("tbody#nvsTable").append(
if (data["autoexec"] === 1) { "<tr>"+
$("#autoexec-cb")[0].checked=true; "<td>"+
} else { "<input type='text' class='form-control' id='nvs-new-key' placeholder='new key'>"+
$("#autoexec-cb")[0].checked=false; "</td>"+
} "<td>"+
"<input type='text' class='form-control' id='nvs-new-value' placeholder='new value'>"+
"</td>"+
"</tr>"
);
} }
if (data.hasOwnProperty('autoexec')) {
$("#autoexec1").val(data["autoexec1"]);
}
*/
}) })
.fail(function() { .fail(function() {
console.log("failed to fetch config!"); console.log("failed to fetch config!");

View File

@@ -204,50 +204,36 @@
<thead> <thead>
<tr> <tr>
<th scope="col">Signal</th> <th scope="col">Signal</th>
<th scope="col">GPIO pin</th> <th scope="col">I2S pin</th>
<th scope="col">SPDIF pin</th>
</tr> </tr>
</thead> </thead>
<tbody id="gpioTable"> <tbody id="gpioTable">
<tr> <tr>
<td><strong>I2S</strong></td><td></td> <td>Bit clock</td>
</tr>
<tr>
<td>I2S Bit clock</td>
<td> <td>
<input type="text" class="form-control gpio" id="gpio-i2s-bc" maxlength="2" size="2"> <input type="text" class="form-control gpio" id="gpio-i2s-bc" maxlength="2" size="2">
</td> </td>
<td>
<input type="text" class="form-control gpio" id="gpio-spdif-bc" maxlength="2" size="2">
</td>
</tr> </tr>
<tr> <tr>
<td>I2S Word select</td> <td>Word select</td>
<td> <td>
<input type="text" class="form-control gpio" id="gpio-i2s-ws" maxlength="2" size="2"> <input type="text" class="form-control gpio" id="gpio-i2s-ws" maxlength="2" size="2">
</td> </td>
<td>
<input type="text" class="form-control gpio" id="gpio-spdif-ws" maxlength="2" size="2">
</td>
</tr> </tr>
<tr> <tr>
<td>I2S Data</td> <td>Data</td>
<td> <td>
<input type="text" class="form-control gpio" id="gpio-i2s-data" maxlength="2" size="2"> <input type="text" class="form-control gpio" id="gpio-i2s-data" maxlength="2" size="2">
</td> </td>
</tr>
<tr>
<td><strong>SPDIF</strong></td><td></td>
</tr>
<tr>
<td>SPDIF Bit clock</td>
<td> <td>
<input type="text" class="form-control gpio" id="spdif-i2s-bc" maxlength="2" size="2"> <input type="text" class="form-control gpio" id="gpio-spdif-data" maxlength="2" size="2">
</td>
</tr>
<tr>
<td>SPDIF Word select</td>
<td>
<input type="text" class="form-control gpio" id="spdif-i2s-ws" maxlength="2" size="2">
</td>
</tr>
<tr>
<td>SPDIF Data</td>
<td>
<input type="text" class="form-control gpio" id="spdif-i2s-data" maxlength="2" size="2">
</td> </td>
</tr> </tr>
</tbody> </tbody>

View File

@@ -323,3 +323,7 @@ span#flash-status {
.recovery { .recovery {
background-color: #3c0505; background-color: #3c0505;
} }
td.value {
width: 80%;
}