Skip to content

Commit

Permalink
Fix output display when a remmaped led output overlaps motors/servos
Browse files Browse the repository at this point in the history
  • Loading branch information
mmosca committed May 12, 2024
1 parent c98bf6e commit b7b81b4
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions js/outputMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var OutputMappingCollection = function () {
self.TIMER_OUTPUT_MODE_AUTO = 0;
self.TIMER_OUTPUT_MODE_MOTORS = 1;
self.TIMER_OUTPUT_MODE_SERVOS = 2;
self.TIMER_OUTPUT_MODE_LED = 3;

self.flushTimerOverrides = function() {
timerOverrides = {};
Expand Down Expand Up @@ -80,10 +81,15 @@ var OutputMappingCollection = function () {
for (let i = 0; i < data.length; i++) {
timerMap[i] = null;

if (servosToGo > 0 && BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_SERVO)) {
if (servosToGo > 0 && BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_LED)) {
console.log(i + ": LED");
timerMap[i] = OUTPUT_TYPE_LED;
} else if (servosToGo > 0 && BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_SERVO)) {
console.log(i + ": SERVO");
servosToGo--;
timerMap[i] = OUTPUT_TYPE_SERVO;
} else if (motorsToGo > 0 && BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_MOTOR)) {
console.log(i + ": MOTOR");
motorsToGo--;
timerMap[i] = OUTPUT_TYPE_MOTOR;
}
Expand All @@ -99,7 +105,7 @@ var OutputMappingCollection = function () {
outputMap = [],
offset = getFirstOutputOffset();


console.log("Offset: " + offset)
for (let i = 0; i < self.getOutputCount(); i++) {

let assignment = timerMap[i + offset];
Expand Down Expand Up @@ -130,8 +136,6 @@ var OutputMappingCollection = function () {

self.getOutputCount = function () {
let retVal = 0;
let testFlag = 1 << TIM_USE_LED;
testFlag = testFlag + 1;

for (let i = 0; i < data.length; i++) {
let flags = data[i]['usageFlags'];
Expand All @@ -140,7 +144,6 @@ var OutputMappingCollection = function () {
BitHelper.bit_check(flags, TIM_USE_SERVO) ||
BitHelper.bit_check(flags, TIM_USE_LED)
) {
//alert("Found motor, servo or led");
retVal++;
};
}
Expand All @@ -152,7 +155,8 @@ var OutputMappingCollection = function () {
for (let i = 0; i < data.length; i++) {
if (
BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_MOTOR) ||
BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_SERVO)
BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_SERVO) ||
BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_LED)
) {
return i;
}
Expand Down

0 comments on commit b7b81b4

Please sign in to comment.