Skip to content

Commit

Permalink
outputs tab preview label motor numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
sensei-hacker committed Nov 23, 2024
1 parent 3c6197d commit 2d685df
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
15 changes: 14 additions & 1 deletion src/css/tabs/motors.css
Original file line number Diff line number Diff line change
Expand Up @@ -463,4 +463,17 @@

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

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

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

.tab-motors .mixer-preview-image-numbers {
width: fit-content;
}
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
35 changes: 35 additions & 0 deletions tabs/outputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,8 @@ TABS.outputs.initialize = function (callback) {
$motorSliders.append('<div class="motor-slider-container"><input type="range" min="1000" max="2000" value="1000" disabled="disabled" class="master"/></div>');
$motorValues.append('<li style="font-weight: bold" data-i18n="motorsMaster"></li>');

labelMotorNumbers();

for (let i = 0; i < FC.SERVO_RULES.getServoCount(); i++) {

let opacity = "";
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 2d685df

Please sign in to comment.