From 2d685df081705635ec6216fbc22d8b93e68f00ba Mon Sep 17 00:00:00 2001 From: Ray Morris Date: Sat, 23 Nov 2024 12:44:50 -0600 Subject: [PATCH 1/3] outputs tab preview label motor numbers --- src/css/tabs/motors.css | 15 ++++++++++++++- tabs/outputs.html | 6 +++++- tabs/outputs.js | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/src/css/tabs/motors.css b/src/css/tabs/motors.css index 11048ab49..5d2f00b36 100644 --- a/src/css/tabs/motors.css +++ b/src/css/tabs/motors.css @@ -463,4 +463,17 @@ .tab-motors .config-section .number input { margin-right: 4px; -} \ No newline at end of file +} + +.tab-motors .mixerPreview { + position: relative; +} + +.tab-motors .motorNumber { + position: absolute; + font-size: 1.4em; +} + +.tab-motors .mixer-preview-image-numbers { + width: fit-content; +} diff --git a/tabs/outputs.html b/tabs/outputs.html index d57cc76d6..64a714762 100644 --- a/tabs/outputs.html +++ b/tabs/outputs.html @@ -117,7 +117,11 @@
- + +
1
+
2
+
3
+
4
diff --git a/tabs/outputs.js b/tabs/outputs.js index d936d18af..c7f259445 100644 --- a/tabs/outputs.js +++ b/tabs/outputs.js @@ -501,6 +501,8 @@ TABS.outputs.initialize = function (callback) { $motorSliders.append('
'); $motorValues.append('
  • '); + labelMotorNumbers(); + for (let i = 0; i < FC.SERVO_RULES.getServoCount(); i++) { let opacity = ""; @@ -717,6 +719,39 @@ TABS.outputs.initialize = function (callback) { GUI.content_ready(callback); } + function labelMotorNumbers() { + let index = 0; + var rules = FC.MOTOR_RULES.get(); + + for (const i in rules) { + if (rules.hasOwnProperty(i)) { + const rule = rules[i]; + index++; + + /* + if (currentMixerPreset.image != 'quad_x') { + $("#motorNumber"+index).css("visibility", "hidden"); + continue; + } + */ + + let top_px = 30; + let left_px = 28; + if (rule.getRoll() < -0.5) { + left_px = $("#motor-mixer-preview-img").width() - 20; + } + + if (rule.getPitch() > 0.5) { + top_px = $("#motor-mixer-preview-img").height() - 20; + } + $("#motorNumber"+index).css("left", left_px + "px"); + $("#motorNumber"+index).css("top", top_px + "px"); + $("#motorNumber"+index).css("visibility", "visible"); + } + } + } + + }; TABS.outputs.cleanup = function (callback) { From 921a462081187a4758a89f8ca1191792cc325a81 Mon Sep 17 00:00:00 2001 From: Ray Morris Date: Fri, 29 Nov 2024 00:31:18 -0600 Subject: [PATCH 2/3] Don't show motor numbers for non-quad, do show onChange --- src/css/tabs/motors.css | 1 + tabs/mixer.js | 6 +++--- tabs/outputs.js | 16 +++++++--------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/css/tabs/motors.css b/src/css/tabs/motors.css index 5d2f00b36..3802d31c1 100644 --- a/src/css/tabs/motors.css +++ b/src/css/tabs/motors.css @@ -472,6 +472,7 @@ .tab-motors .motorNumber { position: absolute; font-size: 1.4em; + visibility: hidden; } .tab-motors .mixer-preview-image-numbers { diff --git a/tabs/mixer.js b/tabs/mixer.js index 6e6c83f07..18ec6d8d5 100644 --- a/tabs/mixer.js +++ b/tabs/mixer.js @@ -476,6 +476,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) { $("#motorNumber"+index).css("left", left_px + "px"); $("#motorNumber"+index).css("top", top_px + "px"); $("#motorNumber"+index).removeClass("is-hidden"); + $("#motorNumber"+index).css("visibility", "visible"); } } } @@ -544,7 +545,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) { } } - labelMotorNumbers(); + labelMotorNumbers(); i18n.localize();; } @@ -610,7 +611,6 @@ TABS.mixer.initialize = function (callback, scrollPosition) { } } - return (errorCount == 0); } @@ -661,7 +661,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) { const path = './resources/motor_order/' + currentMixerPreset.image + (isReversed ? "_reverse" : "") + '.svg'; $('.mixerPreview img').attr('src', path); - + // labelMotorNumbers(); renderServoOutputImage(); }; diff --git a/tabs/outputs.js b/tabs/outputs.js index c7f259445..68b95811f 100644 --- a/tabs/outputs.js +++ b/tabs/outputs.js @@ -257,6 +257,7 @@ TABS.outputs.initialize = function (callback) { const path = './resources/motor_order/' + mixer.getById(val).image + (isReversed ? "_reverse" : "") + '.svg'; $('.mixerPreview img').attr('src', path); + labelMotorNumbers(); } function process_servos() { @@ -501,8 +502,6 @@ TABS.outputs.initialize = function (callback) { $motorSliders.append('
    '); $motorValues.append('
  • '); - labelMotorNumbers(); - for (let i = 0; i < FC.SERVO_RULES.getServoCount(); i++) { let opacity = ""; @@ -720,6 +719,12 @@ TABS.outputs.initialize = function (callback) { } function labelMotorNumbers() { + + if (mixer.getById(FC.MIXER_CONFIG.appliedMixerPreset).image != 'quad_x') { + return; + } + + let index = 0; var rules = FC.MOTOR_RULES.get(); @@ -728,13 +733,6 @@ TABS.outputs.initialize = function (callback) { const rule = rules[i]; index++; - /* - if (currentMixerPreset.image != 'quad_x') { - $("#motorNumber"+index).css("visibility", "hidden"); - continue; - } - */ - let top_px = 30; let left_px = 28; if (rule.getRoll() < -0.5) { From eab0a9a260ce3f30f93e2b5a881ee577382cfbf1 Mon Sep 17 00:00:00 2001 From: Ray Morris Date: Fri, 29 Nov 2024 00:33:15 -0600 Subject: [PATCH 3/3] remove commented label_motors --- tabs/mixer.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tabs/mixer.js b/tabs/mixer.js index 18ec6d8d5..6ccb2c9de 100644 --- a/tabs/mixer.js +++ b/tabs/mixer.js @@ -661,7 +661,6 @@ TABS.mixer.initialize = function (callback, scrollPosition) { const path = './resources/motor_order/' + currentMixerPreset.image + (isReversed ? "_reverse" : "") + '.svg'; $('.mixerPreview img').attr('src', path); - // labelMotorNumbers(); renderServoOutputImage(); };