Skip to content

Commit

Permalink
Version 1.2
Browse files Browse the repository at this point in the history
+ Enable/disable fields depending on checkboxes
+ Add field hints
+ Add "prot_stall"
+ Add BEC voltage drop-down menu

Absorb changes from ESP-IDF 5.2.1
  • Loading branch information
neoxic committed May 1, 2024
1 parent 3c1e193 commit 7b9c75c
Show file tree
Hide file tree
Showing 4 changed files with 79 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.1)
set(PROJECT_VER 1.2)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(ESCape32-WiFi-Link)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Installation

Download the latest pre-built combined image [here](https://github.com/neoxic/ESCape32-WiFi-Link/releases).

Flash your board using the [ESP Flash Tool](https://www.espressif.com/en/support/download/other-tools) or any DFU utility, e.g. dfu-util.
Flash the image at offset 0x0 using the [ESP Flash Tool](https://www.espressif.com/en/support/download/other-tools) or any DFU utility, e.g. dfu-util.

Visit the [ESCape32 Wiki / Wi-Fi Link](https://github.com/neoxic/ESCape32/wiki/WiFiLink) page for more information.

Expand Down
2 changes: 1 addition & 1 deletion main/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ void app_main(void) {
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.source_clk = UART_SCLK_DEFAULT,
};
ESP_ERROR_CHECK(uart_driver_install(CONFIG_UART_NUM, UART_FIFO_LEN * 2, 0, 10, &queue, 0));
ESP_ERROR_CHECK(uart_driver_install(CONFIG_UART_NUM, UART_HW_FIFO_LEN(CONFIG_UART_NUM) * 2, 0, 10, &queue, 0));
ESP_ERROR_CHECK(uart_param_config(CONFIG_UART_NUM, &ucfg));
ESP_ERROR_CHECK(uart_set_pin(CONFIG_UART_NUM, CONFIG_UART_TX, CONFIG_UART_RX, -1, -1));
ESP_ERROR_CHECK(uart_set_mode(CONFIG_UART_NUM, UART_MODE_RS485_HALF_DUPLEX));
Expand Down
80 changes: 76 additions & 4 deletions main/root.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@
text-align: left;
width: 12em;
}
.show .greyed {
color: #bbb;
}
.result {
font-weight: bold;
padding-left: 0.5em;
Expand Down Expand Up @@ -226,9 +229,54 @@
input_mode: ['servo', 'analog', 'serial', 'iBUS', 'SBUS', 'CRSF'],
telem_mode: ['KISS', 'KISS auto', 'iBUS', 'S.Port', 'CRSF'],
music: '',
bec: ['5.5V', '6.5V', '7.4V', '8.4V'],
led: bitfield(4),
};

const hints = {
arm: 'wait for zero throttle on startup',
damp: 'complementary PWM',
revdir: 'reversed motor direction',
brushed: 'brushed mode',
timing: 'motor timing',
sine_range: 'sine startup range',
sine_power: 'sine startup power',
freq_min: 'minimum PWM frequency',
freq_max: 'maximum PWM frequency',
duty_min: 'minimum throttle power',
duty_max: 'maximum throttle power',
duty_spup: 'maximum spin-up power',
duty_ramp: 'maximum power @ kERPM',
duty_rate: 'acceleration slew rate',
duty_drag: 'drag brake amount',
throt_set: 'preset throttle',
throt_cal: 'automatic throttle calibration',
throt_min: 'minimum throttle setpoint',
throt_mid: 'middle throttle setpoint',
throt_max: 'maximum throttle setpoint',
input_chid: 'serial channel ID',
telem_phid: 'telemetry physical ID',
telem_poles: 'number of motor poles',
prot_stall: 'stall protection ERPM',
prot_temp: 'temperature threshold',
prot_volt: 'low voltage cutoff per cell',
prot_cells: 'number of battery cells',
prot_curr: 'maximum current',
volume: 'sound volume',
beacon: 'beacon volume',
bec: 'if equipped',
};

const deps = [
{ // Disable if checked
arm: ['throt_set'],
brushed: ['timing', 'sine_range', 'sine_power', 'freq_max', 'duty_spup', 'prot_stall'],
},
{ // Enable if checked
damp: ['sine_range', 'sine_power'],
},
];

let tabnum, tabvis = {};
let ws, bn, bi, ival, timer, target, throtval, blocked;

Expand Down Expand Up @@ -325,7 +373,7 @@
}, 2000);
}

function getinput(key, val) {
function getfield(key, val) {
const data = params[key];
switch (typeof data) {
case 'boolean':
Expand Down Expand Up @@ -354,6 +402,21 @@
}
}

function checkdeps() {
const res = {};
for (let i = 0; i < 2; ++i) {
const map = deps[i];
for (key in map) {
const elem = document.getElementById('field_' + key);
if (elem) map[key].forEach(function (key) {res[key] |= i ^ elem.checked});
}
}
for (key in res) {
const elem = document.getElementById('field_' + key);
if (elem) document.getElementById('label_' + key).className = (elem.disabled = res[key]) ? 'greyed' : '';
}
}

function handler1(data, key, val) { // 'get', 'set'
if (!data) {
if (!val) return;
Expand All @@ -368,8 +431,12 @@
return;
}
const elem = document.getElementById('field_' + key);
if (elem.type == 'checkbox') elem.checked = val != 0;
else elem.value = val;
if (elem.type != 'checkbox') {
elem.value = val;
return;
}
elem.checked = val != 0;
checkdeps();
}

function handler2(ok) { // 'save', 'reset'
Expand All @@ -388,9 +455,14 @@
const res = [];
for (let i = 0; i < data.length; ++i) {
const [key, val] = data[i].split(': ');
res.push(`<tr><td><label for="${key}">${key}</label></td><td class="min">${getinput(key, val)}</td></tr>`);
const hint = hints[key];
res.push('<tr>');
res.push(`<td><label for="${key}" id="label_${key}">${key}</label></td>`);
res.push(`<td class="min">${getfield(key, val)}${hint ? ` <span class="hint">(${hint})</span>` : ''}</td>`);
res.push('</tr>');
}
document.getElementById('show').innerHTML = res.join('');
checkdeps();
showtab(1);
},
get: handler1,
Expand Down

0 comments on commit 7b9c75c

Please sign in to comment.