Skip to content

Commit 447ff7e

Browse files
committed
Added logic
1 parent ffd84f3 commit 447ff7e

File tree

6 files changed

+278
-27
lines changed

6 files changed

+278
-27
lines changed

locales/en/messages.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,27 @@
386386
"nornOutput": {
387387
"message": "NORN Configuration"
388388
},
389-
389+
"nornDrone": {
390+
"message": "Drone"
391+
},
392+
"nornController": {
393+
"message": "Controller"
394+
},
395+
"nornSize": {
396+
"message": "Size"
397+
},
398+
"nornCraftName": {
399+
"message": "Craft Name"
400+
},
401+
"nornGPS": {
402+
"message": "GPS"
403+
},
404+
"nornCopy": {
405+
"message": "Copy to clipboard"
406+
},
407+
"nornSave": {
408+
"message": "Save"
409+
},
390410
"tabSetup": {
391411
"message": "Setup"
392412
},

locales/uk/messages.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7526,6 +7526,27 @@
75267526
"nornOutput": {
75277527
"message": "Конфігурація"
75287528
},
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+
},
75297550
"tabNornConfig": {
75307551
"message": "NORN Налаштування"
75317552
}

src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
<li class="tab_setup_osd"><a href="#" i18n="tabSetupOSD" class="tabicon ic_setup" i18n_title="tabSetupOSD"></a></li>
137137
<li class="tab_ports"><a href="#" i18n="tabPorts" class="tabicon ic_ports" i18n_title="tabPorts"></a></li>
138138
<li class="tab_configuration"><a href="#" i18n="tabConfiguration" class="tabicon ic_config" i18n_title="tabConfiguration"></a></li>
139-
<li class="tab_norn_config"><a href="#" i18n="tabNornConfig" class="tabicon ic_config" i18n_title="tabNornConfig"></a></li>
139+
<li class="tab_norn_config"><a href="#" i18n="tabNornConfig" class="tabicon ic_setup" i18n_title="tabNornConfig"></a></li>
140140
<li class="tab_power"><a href="#" i18n="tabPower" class="tabicon ic_power" i18n_title="tabPower"></a></li>
141141
<li class="tab_failsafe"><a href="#" i18n="tabFailsafe" class="tabicon ic_failsafe" i18n_title="tabFailsafe"></a></li>
142142
<li class="tab_presets"><a href="#" i18n="tabPresets" class="tabicon ic_wizzard" i18n_title="tabPresets"></a></li>

src/js/tabs/norn_config.js

Lines changed: 101 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,36 @@ norn_config.initialize = function (callback) {
2828
function update_ui() {
2929
i18n.localizePage();
3030

31+
// Populate Flight Controller list (explicit options)
32+
const fcSelect = $("select[name='norn_fc']");
33+
if (fcSelect.length) {
34+
fcSelect.empty();
35+
fcSelect.append(`<option value="">${i18n.getMessage("nornNone")}</option>`);
36+
fcSelect.append(`<option value="f4">FLASHHOBBYF405</option>`);
37+
fcSelect.append(`<option value="f7">SPEEDYBEEF405V3</option>`);
38+
fcSelect.append(`<option value="h7">TAKERF722SE</option>`);
39+
fcSelect.append(`<option value="h7">GEPRCF722</option>`);
40+
fcSelect.on("change", function () {
41+
self.analyticsChanges["NornFC"] = $(this).val() || null;
42+
});
43+
}
44+
45+
// Populate Drone Size list (explicit options)
46+
const droneSizeSelect = $("select[name='norn_drone_size']");
47+
if (droneSizeSelect.length) {
48+
droneSizeSelect.empty();
49+
droneSizeSelect.append(`<option value="">${i18n.getMessage("nornNone")}</option>`);
50+
droneSizeSelect.append(`<option value="7">7</option>`);
51+
droneSizeSelect.append(`<option value="8">8</option>`);
52+
droneSizeSelect.append(`<option value="9">9</option>`);
53+
droneSizeSelect.append(`<option value="10">10</option>`);
54+
droneSizeSelect.append(`<option value="13">13</option>`);
55+
droneSizeSelect.append(`<option value="15">15</option>`);
56+
droneSizeSelect.on("change", function () {
57+
self.analyticsChanges["NornDroneSize"] = $(this).val() || null;
58+
});
59+
}
60+
3161
// Populate Manticore models (allow None) with explicit options
3262
const manticoreSelect = $("select[name='norn_manticore']");
3363
if (manticoreSelect.length) {
@@ -54,16 +84,24 @@ norn_config.initialize = function (callback) {
5484
}
5585

5686
// Example dropdown wiring
57-
const exampleSelect = $("select[name='norn_mode']");
58-
if (exampleSelect.length) {
59-
exampleSelect.on("change", function () {
60-
const value = $(this).val();
61-
self.analyticsChanges["NornMode"] = value;
62-
});
63-
}
87+
// none for now
6488

65-
// Example button wiring
89+
// Button wiring
6690
$("a.generate").on("click", on_generate_handler);
91+
$("a.copy").on("click", on_copy_handler);
92+
$("a.save").on("click", on_save_handler);
93+
94+
// GPS toggle wiring
95+
const gpsToggle = $("#norn_gps");
96+
gpsToggle.on("change", function () {
97+
self.analyticsChanges["NornGPS"] = $(this).is(":checked");
98+
});
99+
100+
// Craft name input wiring
101+
const craftNameInput = $("#norn_craft_name");
102+
craftNameInput.on("input", function () {
103+
self.analyticsChanges["NornCraftName"] = $(this).val() || null;
104+
});
67105
}
68106

69107
function on_tab_loaded_handler() {
@@ -94,9 +132,13 @@ norn_config.initialize = function (callback) {
94132
}
95133

96134
function getSelectedKeys() {
135+
const fcKey = $("select[name='norn_fc']").val() || "";
136+
const droneSize = $("select[name='norn_drone_size']").val() || "";
97137
const manticoreKey = $("select[name='norn_manticore']").val() || "";
98138
const vtxKey = $("select[name='norn_vtx']").val() || "";
99-
return { manticoreKey, vtxKey };
139+
const gpsEnabled = $("#norn_gps").is(":checked");
140+
const craftName = $("#norn_craft_name").val() || "";
141+
return { fcKey, droneSize, manticoreKey, vtxKey, gpsEnabled, craftName };
100142
}
101143

102144
function on_generate_handler(e) {
@@ -122,6 +164,56 @@ norn_config.initialize = function (callback) {
122164
$("#norn_config_output").val(result);
123165
}
124166

167+
function on_copy_handler(e) {
168+
e?.preventDefault?.();
169+
const text = $("#norn_config_output").val();
170+
if (text) {
171+
navigator.clipboard
172+
?.writeText(text)
173+
.then(() => {
174+
console.log("Config copied to clipboard");
175+
})
176+
.catch((err) => {
177+
console.error("Failed to copy to clipboard:", err);
178+
});
179+
}
180+
}
181+
182+
function on_save_handler(e) {
183+
e?.preventDefault?.();
184+
const text = $("#norn_config_output").val();
185+
if (!text) return;
186+
187+
// Generate filename based on selected options
188+
const parts = [];
189+
const fcKey = $("select[name='norn_fc']").val();
190+
const droneSize = $("select[name='norn_drone_size']").val();
191+
const manticoreKey = $("select[name='norn_manticore']").val();
192+
const vtxKey = $("select[name='norn_vtx']").val();
193+
const gpsEnabled = $("#norn_gps").is(":checked");
194+
const craftName = $("#norn_craft_name").val();
195+
196+
if (fcKey) parts.push(fcKey);
197+
if (droneSize) parts.push(`${droneSize}inch`);
198+
if (manticoreKey) parts.push(manticoreKey);
199+
if (vtxKey) parts.push(vtxKey);
200+
if (gpsEnabled) parts.push("GPS");
201+
if (craftName) parts.push(craftName);
202+
203+
const filename = parts.length > 0 ? `norn_config_${parts.join("_")}.txt` : "norn_config.txt";
204+
205+
// Create and trigger download
206+
const blob = new Blob([text], { type: "text/plain" });
207+
const url = URL.createObjectURL(blob);
208+
const a = document.createElement("a");
209+
a.href = url;
210+
a.download = filename;
211+
document.body.appendChild(a);
212+
a.click();
213+
document.body.removeChild(a);
214+
URL.revokeObjectURL(url);
215+
}
216+
125217
load_configuration_from_fc();
126218
};
127219

src/norn-configs/template.ejs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,44 @@ batch start
44

55
defaults nosave
66

7+
<% if (fcKey === 'f4') { %>
8+
# Flight Controller: F4 tweaks
9+
set pid_process_denom = 2
10+
<% } %>
11+
12+
<% if (fcKey === 'f7') { %>
13+
# Flight Controller: F7 tweaks
14+
set pid_process_denom = 1
15+
<% } %>
716

17+
<% if (fcKey === 'h7') { %>
18+
# Flight Controller: H7 tweaks
19+
set pid_process_denom = 1
20+
set cpu_overclock = ON
21+
<% } %>
22+
23+
<% if (droneSize) { %>
24+
# Drone Size: <%= droneSize %>"
25+
<% if (droneSize === '7') { %>
26+
set motor_pwm_rate = 32000
27+
set motor_poles = 12
28+
<% } else if (droneSize === '8') { %>
29+
set motor_pwm_rate = 24000
30+
set motor_poles = 14
31+
<% } else if (droneSize === '9') { %>
32+
set motor_pwm_rate = 24000
33+
set motor_poles = 16
34+
<% } else if (droneSize === '10') { %>
35+
set motor_pwm_rate = 16000
36+
set motor_poles = 18
37+
<% } else if (droneSize === '13') { %>
38+
set motor_pwm_rate = 12000
39+
set motor_poles = 20
40+
<% } else if (droneSize === '15') { %>
41+
set motor_pwm_rate = 8000
42+
set motor_poles = 22
43+
<% } %>
44+
<% } %>
845
946
<% if (manticoreKey === 'uart') { %>
1047
# Manticore UART variant
@@ -39,4 +76,15 @@ set vtx_channel = 2
3976
set vtx_power = 50
4077
<% } %>
4178
79+
<% if (gpsEnabled) { %>
80+
# GPS Enabled
81+
feature GPS
82+
set gps_baudrate = AUTO
83+
<% } %>
84+
85+
<% if (craftName) { %>
86+
# Craft name
87+
set craft_name = <%= craftName %>
88+
<% } %>
89+
4290

src/tabs/norn_config.html

Lines changed: 86 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,94 @@
77

88
<div class="grid-row grid-box col2">
99
<div class="col-span-1">
10-
<div class="gui_box grey">
11-
<div class="gui_box_titlebar">
12-
<div class="spacer_box_title" i18n="nornManticore"></div>
10+
<div class="grid-row grid-box col2">
11+
<div class="col-span-1">
12+
<div class="gui_box grey">
13+
<div class="gui_box_titlebar">
14+
<div class="spacer_box_title" i18n="nornController"></div>
15+
</div>
16+
<div class="spacer_box">
17+
<div class="select">
18+
<select name="norn_fc" id="norn_fc">
19+
<option value="" i18n="nornNone"></option>
20+
</select>
21+
</div>
22+
</div>
23+
</div>
1324
</div>
14-
<div class="spacer_box">
15-
<div class="select">
16-
<select name="norn_manticore" id="norn_manticore">
17-
<option value="" i18n="nornNone"></option>
18-
</select>
25+
<div class="col-span-1">
26+
<div class="gui_box grey">
27+
<div class="gui_box_titlebar">
28+
<div class="spacer_box_title" i18n="nornSize"></div>
29+
</div>
30+
<div class="spacer_box">
31+
<div class="select">
32+
<select name="norn_drone_size" id="norn_drone_size">
33+
<option value="" i18n="nornNone"></option>
34+
</select>
35+
</div>
36+
</div>
1937
</div>
2038
</div>
2139
</div>
2240

23-
<div class="gui_box grey" style="margin-top: 16px;">
24-
<div class="gui_box_titlebar">
25-
<div class="spacer_box_title" i18n="nornVtx"></div>
41+
<div class="grid-row grid-box col2">
42+
<div class="col-span-1">
43+
<div class="gui_box grey">
44+
<div class="gui_box_titlebar">
45+
<div class="spacer_box_title" i18n="nornManticore"></div>
46+
</div>
47+
<div class="spacer_box">
48+
<div class="select">
49+
<select name="norn_manticore" id="norn_manticore">
50+
<option value="" i18n="nornNone"></option>
51+
</select>
52+
</div>
53+
</div>
54+
</div>
2655
</div>
27-
<div class="spacer_box">
28-
<div class="select">
29-
<select name="norn_vtx" id="norn_vtx">
30-
<option value="" i18n="nornNone"></option>
31-
</select>
56+
<div class="col-span-1">
57+
<div class="gui_box grey">
58+
<div class="gui_box_titlebar">
59+
<div class="spacer_box_title" i18n="nornVtx"></div>
60+
</div>
61+
<div class="spacer_box">
62+
<div class="select">
63+
<select name="norn_vtx" id="norn_vtx">
64+
<option value="" i18n="nornNone"></option>
65+
</select>
66+
</div>
67+
</div>
68+
</div>
69+
</div>
70+
</div>
71+
72+
<div class="grid-row grid-box col2">
73+
<div class="col-span-1">
74+
<div class="gui_box grey">
75+
<div class="gui_box_titlebar">
76+
<div class="spacer_box_title" i18n="nornCraftName"></div>
77+
</div>
78+
<div class="spacer_box">
79+
<div class="select">
80+
<input type="text" id="norn_craft_name" placeholder="Enter craft name" style="width: 100%;" />
81+
</div>
82+
</div>
83+
</div>
84+
</div>
85+
<div class="col-span-1">
86+
<div class="gui_box grey">
87+
<div class="gui_box_titlebar">
88+
<div class="spacer_box_title" i18n="nornGPS"></div>
89+
</div>
90+
<div class="spacer_box">
91+
<div class="select">
92+
<div>
93+
<input type="checkbox" id="norn_gps" class="toggle" />
94+
</div>
95+
<span class="freelabel" i18n="nornGPS"></span>
96+
</div>
97+
</div>
3298
</div>
3399
</div>
34100
</div>
@@ -45,6 +111,10 @@
45111
</div>
46112
<div class="spacer_box">
47113
<textarea id="norn_config_output" rows="20" style="width: 100%;" readonly></textarea>
114+
<div class="buttons" style="margin-top: 8px;">
115+
<a href="#" class="copy regular-button" i18n="nornCopy"></a>
116+
<a href="#" class="save regular-button" i18n="nornSave"></a>
117+
</div>
48118
</div>
49119
</div>
50120
</div>

0 commit comments

Comments
 (0)