Skip to content

Commit

Permalink
Version 1.1
Browse files Browse the repository at this point in the history
+ Add "CRSF" to drop-down menus
+ Treat "led" as bit-field
+ Accept *.bin files only

Minor fixes
  • Loading branch information
neoxic committed Jan 6, 2024
1 parent 569ece8 commit 3c1e193
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16)
set(PROJECT_VER 1.0)
set(PROJECT_VER 1.1)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(ESCape32-WiFi-Link)
3 changes: 2 additions & 1 deletion main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@ int processdns(uint8_t *buf, int len) {
cur += 4;
if (type != 1 || class != 1) continue;
DNSAnswer *answer = (DNSAnswer *)pos;
pos += sizeof *answer;
if (pos - buf > 512) return 0;
answer->name = htons(0xc000 | (name - buf));
answer->type = htons(type);
answer->class = htons(class);
answer->ttl = htonl(60);
answer->len = htons(4);
answer->addr = htonl(0xc0a80401); // 192.168.4.1
pos += sizeof *answer;
++cnt;
}
memmove(cur, end, pos - end); // Ignore other sections
Expand Down
37 changes: 32 additions & 5 deletions main/root.html
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
</div>
<div class="tab" id="tab3on">
<table>
<tr><td><label for="image">Image</label></td><td><input type="file" id="image"></td></tr>
<tr><td><label for="image">Image</label></td><td><input type="file" id="image" accept=".bin"></td></tr>
<tr><td><label for="boot">Type</label></td><td>
<select id="boot">
<option value="0">firmware</option>
Expand Down Expand Up @@ -198,17 +198,36 @@
<div id="footer">ESCape32 Wi-Fi Link @PROJECT_VER@ (escape32.org)</div>
</div>
<script>
const bitvals = {};

function bitfield(n) {
return function (key, val) {
const res = [];
for (let i = 0; i < n; ++i) {
let bit = 1 << i;
res.push(`<input type="checkbox" class="field_${key}"${val & bit ? ' checked' : ''} onchange="setbit('${key}', ${bit}, checked)">`);
}
bitvals[key] = val;
return res.join('');
}
}

function setbit(key, bit, on) {
setparam(key, (on ? bitvals[key] | bit : bitvals[key] & ~bit).toString());
}

const params = {
arm: false,
damp: false,
revdir: false,
brushed: false,
throt_mode: ['forward', 'forward/reverse', 'forward/brake/reverse'],
throt_cal: false,
input_mode: ['servo', 'analog', 'serial', 'iBUS', 'SBUS'],
telem_mode: ['KISS', 'KISS auto', 'iBUS', 'S.Port'],
input_mode: ['servo', 'analog', 'serial', 'iBUS', 'SBUS', 'CRSF'],
telem_mode: ['KISS', 'KISS auto', 'iBUS', 'S.Port', 'CRSF'],
music: '',
}
led: bitfield(4),
};

let tabnum, tabvis = {};
let ws, bn, bi, ival, timer, target, throtval, blocked;
Expand Down Expand Up @@ -319,6 +338,8 @@
for (let i = 0; i < data.length; ++i) res.push(`<option value="${i}"${val == i ? ' selected' : ''}>${data[i]}</option>`);
res.push('</select>');
return res.join('');
case 'function':
return data(key, val);
default:
return `<input type="text" maxlength="5" id="field_${key}" value="${val}" class="val" onchange="setparam('${key}', value)">`;
}
Expand All @@ -340,6 +361,12 @@
return;
}
[key, val] = data[0].split(': ');
if (key in bitvals) {
const elems = document.getElementsByClassName('field_' + key);
for (let i = 0; i < elems.length; ++i) elems[i].checked = val & 1 << i;
bitvals[key] = val;
return;
}
const elem = document.getElementById('field_' + key);
if (elem.type == 'checkbox') elem.checked = val != 0;
else elem.value = val;
Expand Down Expand Up @@ -414,7 +441,7 @@
document.getElementById('wrp').value = 0;
document.getElementById('force').checked = false;
},
}
};

function connect() {
resettimer();
Expand Down

0 comments on commit 3c1e193

Please sign in to comment.