Skip to content

Commit 3e4280d

Browse files
authored
Merge pull request #3 from mzrks/milbeta-460-norn-config-ui-branch
Milbeta 460 norn config UI branch
2 parents 4b6a925 + bb78543 commit 3e4280d

File tree

12 files changed

+1206
-7
lines changed

12 files changed

+1206
-7
lines changed

locales/en/messages.json

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,60 @@
368368
"tabOptions": {
369369
"message": "Options"
370370
},
371-
371+
"tabNornConfig": {
372+
"message": "NORN Config"
373+
},
374+
"nornManticore": {
375+
"message": "Manticore"
376+
},
377+
"nornVtx": {
378+
"message": "VTX"
379+
},
380+
"nornNone": {
381+
"message": "None"
382+
},
383+
"nornGenerate": {
384+
"message": "Generate"
385+
},
386+
"nornOutput": {
387+
"message": "NORN Configuration"
388+
},
389+
"nornDrone": {
390+
"message": "Drone"
391+
},
392+
"nornController": {
393+
"message": "Controller"
394+
},
395+
"nornRadioController": {
396+
"message": "Radio Controller"
397+
},
398+
"nornSize": {
399+
"message": "Size"
400+
},
401+
"nornCraftName": {
402+
"message": "Craft Name"
403+
},
404+
"nornMBId": {
405+
"message": "MB ID"
406+
},
407+
"nornFailSafe": {
408+
"message": "FailSafe"
409+
},
410+
"nornVideoFormat": {
411+
"message": "Video Format"
412+
},
413+
"nornCamera": {
414+
"message": "Camera"
415+
},
416+
"nornGPS": {
417+
"message": "GPS"
418+
},
419+
"nornCopy": {
420+
"message": "Copy to clipboard"
421+
},
422+
"nornSave": {
423+
"message": "Save"
424+
},
372425
"tabSetup": {
373426
"message": "Setup"
374427
},

locales/uk/messages.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7510,5 +7510,44 @@
75107510
"osdDescElementLidar": {
75117511
"message": "$t(osdTextElementLidar.message)",
75127512
"description": "Don't translate!!!"
7513+
},
7514+
"nornManticore": {
7515+
"message": "Manticore"
7516+
},
7517+
"nornVtx": {
7518+
"message": "VTX"
7519+
},
7520+
"nornNone": {
7521+
"message": "Немає"
7522+
},
7523+
"nornGenerate": {
7524+
"message": "Згенерувати"
7525+
},
7526+
"nornOutput": {
7527+
"message": "Конфігурація"
7528+
},
7529+
"nornDrone": {
7530+
"message": "Дрон"
7531+
},
7532+
"nornController": {
7533+
"message": "Контролер"
7534+
},
7535+
"nornSize": {
7536+
"message": "Розмір"
7537+
},
7538+
"nornCraftName": {
7539+
"message": "Назва дрона"
7540+
},
7541+
"nornGPS": {
7542+
"message": "GPS"
7543+
},
7544+
"nornCopy": {
7545+
"message": "Копіювати в буффер"
7546+
},
7547+
"nornSave": {
7548+
"message": "Зберегти"
7549+
},
7550+
"tabNornConfig": {
7551+
"message": "NORN Налаштування"
75137552
}
75147553
}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
"node": "20.x"
4242
},
4343
"dependencies": {
44+
"ejs": "^3.1.9",
45+
"handlebars": "^4.7.8",
4446
"@capacitor/android": "^7.0.1",
4547
"@capacitor/core": "^7.0.1",
4648
"@fortawesome/fontawesome-free": "^6.5.2",

src/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,14 @@
130130
<li class="tab_help" id="tab_help"><a href="#" i18n="tabHelp" class="tabicon ic_help" i18n_title="tabHelp"></a></li>
131131
<li class="tab_options" id="tab_options"><a href="#" i18n="tabOptions" class="tabicon ic_config" i18n_title="tabOptions"></a></li>
132132
<li class="tab_firmware_flasher" id="tabFirmware"><a href="#" i18n="tabFirmwareFlasher" class="tabicon ic_flasher" i18n_title="tabFirmwareFlasher"></a></li>
133+
<li class="tab_norn_config"><a href="#" i18n="tabNornConfig" class="tabicon ic_setup" i18n_title="tabNornConfig"></a></li>
133134
</ul>
134135
<ul class="mode-connected">
135136
<li class="tab_setup"><a href="#" i18n="tabSetup" class="tabicon ic_setup" i18n_title="tabSetup"></a></li>
136137
<li class="tab_setup_osd"><a href="#" i18n="tabSetupOSD" class="tabicon ic_setup" i18n_title="tabSetupOSD"></a></li>
137138
<li class="tab_ports"><a href="#" i18n="tabPorts" class="tabicon ic_ports" i18n_title="tabPorts"></a></li>
138139
<li class="tab_configuration"><a href="#" i18n="tabConfiguration" class="tabicon ic_config" i18n_title="tabConfiguration"></a></li>
140+
<li class="tab_norn_config"><a href="#" i18n="tabNornConfig" class="tabicon ic_setup" i18n_title="tabNornConfig"></a></li>
139141
<li class="tab_power"><a href="#" i18n="tabPower" class="tabicon ic_power" i18n_title="tabPower"></a></li>
140142
<li class="tab_failsafe"><a href="#" i18n="tabFailsafe" class="tabicon ic_failsafe" i18n_title="tabFailsafe"></a></li>
141143
<li class="tab_presets"><a href="#" i18n="tabPresets" class="tabicon ic_wizzard" i18n_title="tabPresets"></a></li>

src/js/gui.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ class GuiControl {
1919
this.timeout_array = [];
2020
this.buttonDisabledClass = "disabled";
2121

22-
this.defaultAllowedTabsWhenDisconnected = ["landing", "firmware_flasher", "privacy_policy", "options", "help"];
22+
this.defaultAllowedTabsWhenDisconnected = [
23+
"landing",
24+
"firmware_flasher",
25+
"privacy_policy",
26+
"options",
27+
"help",
28+
"norn_config",
29+
];
2330

2431
this.defaultAllowedTabs = [
2532
"setup",
@@ -30,6 +37,7 @@ class GuiControl {
3037
"presets",
3138
"cli",
3239
"configuration",
40+
"norn_config",
3341
"logging",
3442
"onboard_logging",
3543
"modes",

src/js/main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ function startProcess() {
279279
configuration.initialize(content_ready),
280280
);
281281
break;
282+
case "norn_config":
283+
import("./tabs/norn_config").then(({ norn_config }) => norn_config.initialize(content_ready));
284+
break;
282285
case "pid_tuning":
283286
import("./tabs/pid_tuning").then(({ pid_tuning }) => pid_tuning.initialize(content_ready));
284287
break;

src/js/tabs/firmware_flasher.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,10 +740,60 @@ firmware_flasher.initialize = async function (callback) {
740740
STM32.rebootMode = 0;
741741
GUI.connect_lock = false;
742742
startFlashing();
743+
} else {
744+
// Auto-detect board when firmware flasher tab is active and no flash-on-connect
745+
console.log(`${self.logHead} Auto-detecting board for connected USB device`);
746+
AutoDetect.verifyBoard();
747+
}
748+
}
749+
750+
function detectedSerialDevice(device) {
751+
const isFlashOnConnect = $("input.flash_on_connect").is(":checked");
752+
753+
console.log(`${self.logHead} Detected serial device:`, device);
754+
console.log(`${self.logHead} Reboot mode: %s, flash on connect`, STM32.rebootMode, isFlashOnConnect);
755+
756+
if (STM32.rebootMode || isFlashOnConnect) {
757+
STM32.rebootMode = 0;
758+
GUI.connect_lock = false;
759+
startFlashing();
760+
} else {
761+
// Auto-detect board when firmware flasher tab is active and no flash-on-connect
762+
console.log(`${self.logHead} Auto-detecting board for connected serial device`);
763+
AutoDetect.verifyBoard();
743764
}
744765
}
745766

746767
EventBus.$on("port-handler:auto-select-usb-device", detectedUsbDevice);
768+
EventBus.$on("port-handler:auto-select-serial-device", detectedSerialDevice);
769+
770+
// Also listen for port changes to catch reconnections
771+
function onPortChange(port) {
772+
console.log(`${self.logHead} Port changed to:`, port);
773+
// Auto-detect board when port changes and we're on firmware flasher tab
774+
if (port && port !== "0" && !$("input.flash_on_connect").is(":checked") && !STM32.rebootMode) {
775+
console.log(`${self.logHead} Auto-detecting board for port change`);
776+
setTimeout(() => {
777+
AutoDetect.verifyBoard();
778+
}, 500); // Small delay to ensure port is ready
779+
} else if (!port || port === "0") {
780+
// Clear board selection when no port is selected
781+
console.log(`${self.logHead} Clearing board selection - no port selected`);
782+
$('select[name="board"]').val("0").trigger("change");
783+
}
784+
}
785+
786+
// Listen for device removal to clear board selection
787+
function onDeviceRemoved(devicePath) {
788+
console.log(`${self.logHead} Device removed:`, devicePath);
789+
// Clear board selection when device is removed
790+
$('select[name="board"]').val("0").trigger("change");
791+
// Also clear any loaded firmware
792+
clearBufferedFirmware();
793+
}
794+
795+
EventBus.$on("ports-input:change", onPortChange);
796+
EventBus.$on("port-handler:device-removed", onDeviceRemoved);
747797

748798
async function saveFirmware() {
749799
const fileType = self.firmware_type;
@@ -1458,6 +1508,17 @@ firmware_flasher.initialize = async function (callback) {
14581508
$("a.exit_dfu").removeClass("disabled");
14591509
}
14601510

1511+
// Auto-detect board if a drone is already connected when tab becomes active
1512+
if (
1513+
(PortHandler.portAvailable && !$('select[name="board"]').val()) ||
1514+
$('select[name="board"]').val() === "0"
1515+
) {
1516+
console.log(`${self.logHead} Auto-detecting board for already connected device`);
1517+
setTimeout(() => {
1518+
AutoDetect.verifyBoard();
1519+
}, 1000); // Small delay to ensure tab is fully loaded
1520+
}
1521+
14611522
GUI.content_ready(callback);
14621523
}
14631524

@@ -1476,6 +1537,12 @@ firmware_flasher.cleanup = function (callback) {
14761537
$(document).unbind("keypress");
14771538
$(document).off("click", "span.progressLabel a");
14781539

1540+
// Clean up EventBus listeners
1541+
EventBus.$off("port-handler:auto-select-usb-device");
1542+
EventBus.$off("port-handler:auto-select-serial-device");
1543+
EventBus.$off("ports-input:change");
1544+
EventBus.$off("port-handler:device-removed");
1545+
14791546
if (callback) callback();
14801547
};
14811548

0 commit comments

Comments
 (0)