Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add back motor numbers on Outputs tab preview diagram #2263

Merged
merged 3 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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