Skip to content

Commit

Permalink
Merge pull request #2263 from sensei-hacker/outputs_preview_motor_num…
Browse files Browse the repository at this point in the history
…bers
  • Loading branch information
MrD-RC authored Nov 30, 2024
2 parents 1c44787 + eab0a9a commit d6b57e3
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 5 deletions.
16 changes: 15 additions & 1 deletion src/css/tabs/motors.css
Original file line number Diff line number Diff line change
Expand Up @@ -463,4 +463,18 @@

.tab-motors .config-section .number input {
margin-right: 4px;
}
}

.tab-motors .mixerPreview {
position: relative;
}

.tab-motors .motorNumber {
position: absolute;
font-size: 1.4em;
visibility: hidden;
}

.tab-motors .mixer-preview-image-numbers {
width: fit-content;
}
5 changes: 2 additions & 3 deletions tabs/mixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}
Expand Down Expand Up @@ -544,7 +545,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
}

}
labelMotorNumbers();
labelMotorNumbers();
i18n.localize();;
}

Expand Down Expand Up @@ -610,7 +611,6 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
}

}

return (errorCount == 0);
}

Expand Down Expand Up @@ -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);

renderServoOutputImage();
};

Expand Down
6 changes: 5 additions & 1 deletion tabs/outputs.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@
<div class="motors right">
<div class="half">
<div class="mixerPreview">
<img src="./resources/motor_order/custom.svg" />
<img src="./resources/motor_order/custom.svg" id="motor-mixer-preview-img" />
<div class="motorNumber" id="motorNumber1">1</div>
<div class="motorNumber" id="motorNumber2">2</div>
<div class="motorNumber" id="motorNumber3">3</div>
<div class="motorNumber" id="motorNumber4">4</div>
</div>
</div>
<div class="half">
Expand Down
33 changes: 33 additions & 0 deletions tabs/outputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -717,6 +718,38 @@ TABS.outputs.initialize = function (callback) {
GUI.content_ready(callback);
}

function labelMotorNumbers() {

if (mixer.getById(FC.MIXER_CONFIG.appliedMixerPreset).image != 'quad_x') {
return;
}


let index = 0;
var rules = FC.MOTOR_RULES.get();

for (const i in rules) {
if (rules.hasOwnProperty(i)) {
const rule = rules[i];
index++;

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) {
Expand Down

0 comments on commit d6b57e3

Please sign in to comment.