Skip to content

Commit d6b57e3

Browse files
authored
Merge pull request #2263 from sensei-hacker/outputs_preview_motor_numbers
2 parents 1c44787 + eab0a9a commit d6b57e3

File tree

4 files changed

+55
-5
lines changed

4 files changed

+55
-5
lines changed

src/css/tabs/motors.css

+15-1
Original file line numberDiff line numberDiff line change
@@ -463,4 +463,18 @@
463463

464464
.tab-motors .config-section .number input {
465465
margin-right: 4px;
466-
}
466+
}
467+
468+
.tab-motors .mixerPreview {
469+
position: relative;
470+
}
471+
472+
.tab-motors .motorNumber {
473+
position: absolute;
474+
font-size: 1.4em;
475+
visibility: hidden;
476+
}
477+
478+
.tab-motors .mixer-preview-image-numbers {
479+
width: fit-content;
480+
}

tabs/mixer.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
476476
$("#motorNumber"+index).css("left", left_px + "px");
477477
$("#motorNumber"+index).css("top", top_px + "px");
478478
$("#motorNumber"+index).removeClass("is-hidden");
479+
$("#motorNumber"+index).css("visibility", "visible");
479480
}
480481
}
481482
}
@@ -544,7 +545,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
544545
}
545546

546547
}
547-
labelMotorNumbers();
548+
labelMotorNumbers();
548549
i18n.localize();;
549550
}
550551

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

612613
}
613-
614614
return (errorCount == 0);
615615
}
616616

@@ -661,7 +661,6 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
661661
const path = './resources/motor_order/'
662662
+ currentMixerPreset.image + (isReversed ? "_reverse" : "") + '.svg';
663663
$('.mixerPreview img').attr('src', path);
664-
665664
renderServoOutputImage();
666665
};
667666

tabs/outputs.html

+5-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,11 @@
117117
<div class="motors right">
118118
<div class="half">
119119
<div class="mixerPreview">
120-
<img src="./resources/motor_order/custom.svg" />
120+
<img src="./resources/motor_order/custom.svg" id="motor-mixer-preview-img" />
121+
<div class="motorNumber" id="motorNumber1">1</div>
122+
<div class="motorNumber" id="motorNumber2">2</div>
123+
<div class="motorNumber" id="motorNumber3">3</div>
124+
<div class="motorNumber" id="motorNumber4">4</div>
121125
</div>
122126
</div>
123127
<div class="half">

tabs/outputs.js

+33
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ TABS.outputs.initialize = function (callback) {
257257
const path = './resources/motor_order/'
258258
+ mixer.getById(val).image + (isReversed ? "_reverse" : "") + '.svg';
259259
$('.mixerPreview img').attr('src', path);
260+
labelMotorNumbers();
260261
}
261262

262263
function process_servos() {
@@ -717,6 +718,38 @@ TABS.outputs.initialize = function (callback) {
717718
GUI.content_ready(callback);
718719
}
719720

721+
function labelMotorNumbers() {
722+
723+
if (mixer.getById(FC.MIXER_CONFIG.appliedMixerPreset).image != 'quad_x') {
724+
return;
725+
}
726+
727+
728+
let index = 0;
729+
var rules = FC.MOTOR_RULES.get();
730+
731+
for (const i in rules) {
732+
if (rules.hasOwnProperty(i)) {
733+
const rule = rules[i];
734+
index++;
735+
736+
let top_px = 30;
737+
let left_px = 28;
738+
if (rule.getRoll() < -0.5) {
739+
left_px = $("#motor-mixer-preview-img").width() - 20;
740+
}
741+
742+
if (rule.getPitch() > 0.5) {
743+
top_px = $("#motor-mixer-preview-img").height() - 20;
744+
}
745+
$("#motorNumber"+index).css("left", left_px + "px");
746+
$("#motorNumber"+index).css("top", top_px + "px");
747+
$("#motorNumber"+index).css("visibility", "visible");
748+
}
749+
}
750+
}
751+
752+
720753
};
721754

722755
TABS.outputs.cleanup = function (callback) {

0 commit comments

Comments
 (0)