Skip to content

Commit

Permalink
Add colors to easilly distinguish between timer outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
DzikuVx committed Sep 29, 2023
1 parent 55046e5 commit 637acdd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
22 changes: 22 additions & 0 deletions js/outputMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ let OutputMappingCollection = function () {
const OUTPUT_TYPE_MOTOR = 0;
const OUTPUT_TYPE_SERVO = 1;

const outputColor = [
"#8ecae6",
"#2a9d8f",
"#e9c46a",
"#f4a261",
"#e76f51",
"#ef476f",
"#ffc300"
];

self.TIMER_OUTPUT_MODE_AUTO = 0;
self.TIMER_OUTPUT_MODE_MOTORS = 1;
self.TIMER_OUTPUT_MODE_SERVOS = 2;
Expand All @@ -36,6 +46,18 @@ let OutputMappingCollection = function () {
return timerOverrides[timer];
}

self.getTimerColor = function (timer) {
let timerIndex = OUTPUT_MAPPING.getUsedTimerIds().indexOf(String(timer));

return outputColor[timerIndex % outputColor.length];
}

self.getOutputTimerColor = function (output) {
let timerId = OUTPUT_MAPPING.getTimerId(output);

return self.getTimerColor(timerId);
}

self.getUsedTimerIds = function (timer) {
let used = {};
let outputCount = self.getOutputCount();
Expand Down
2 changes: 1 addition & 1 deletion tabs/mixer.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<div class="gui_box_titlebar">
<div class="spacer_box_title" data-i18n="timerOutputs"></div>
</div>
<div class="spacer_box" id="timerOutputsList"></div>
<div class="spacer_box" id="timerOutputsList" style="padding: 0; width: calc(100% - 12px)"></div>
</div>

</div>
Expand Down
10 changes: 7 additions & 3 deletions tabs/mixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,13 @@ TABS.mixer.initialize = function (callback, scrollPosition) {

$outputRow.append('<th data-i18n="mappingTableOutput"></th>');
$functionRow.append('<th data-i18n="mappingTableFunction"></th>');

for (let i = 1; i <= outputCount; i++) {
$outputRow.append('<td>S' + i + ' (T' + (OUTPUT_MAPPING.getTimerId(i -1)) + ')</td>');

let timerId = OUTPUT_MAPPING.getTimerId(i - 1);
let color = OUTPUT_MAPPING.getOutputTimerColor(i - 1);

$outputRow.append('<td style="background-color: ' + color + '">S' + i + ' (T' + (timerId) + ')</td>');
$functionRow.append('<td id="function-' + i +'">-</td>');
}

Expand Down Expand Up @@ -107,7 +111,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
for (t of usedTimers) {
var usageMode = OUTPUT_MAPPING.getTimerOverride(t);
$container.append(
'<div class="select">' +
'<div class="select" style="padding: 5px; margin: 1px; background-color: ' + OUTPUT_MAPPING.getTimerColor(t) + '">' +
'<select id="timer-output-' + t + '">' +
'<option value=' + OUTPUT_MAPPING.TIMER_OUTPUT_MODE_AUTO + '' + (usageMode == OUTPUT_MAPPING.TIMER_OUTPUT_MODE_AUTO ? ' selected' : '')+ '>AUTO</option>'+
'<option value=' + OUTPUT_MAPPING.TIMER_OUTPUT_MODE_MOTORS + '' + (usageMode == OUTPUT_MAPPING.TIMER_OUTPUT_MODE_MOTORS ? ' selected' : '')+ '>MOTORS</option>'+
Expand Down

0 comments on commit 637acdd

Please sign in to comment.