Skip to content

Commit 3b7b261

Browse files
author
Richard Unger
committed
fix channel counting
1 parent 0051af4 commit 3b7b261

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/drivers/hardware_specific/stm32_mcu.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,15 +307,15 @@ int scoreCombination(int numPins, PinMap* pinTimers[]) {
307307
return -4; // bad combination - duplicated channel
308308
}
309309
}
310-
int score = 1;
310+
int score = 0;
311311
for (int i=0; i<numPins; i++) {
312312
// count distinct timers
313-
for (int j=1; j<i; j++) {
313+
bool found = false;
314+
for (int j=i+1; j<numPins; j++) {
314315
if (pinTimers[i]->peripheral == pinTimers[j]->peripheral)
315-
break;
316-
if (i==j)
317-
score++;
316+
found = true;
318317
}
318+
if (!found) score++;
319319
}
320320
if (numPins==6) {
321321
// check for inverted channels - best: 1 timer, 3 channels, 3 matching inverted channels

0 commit comments

Comments
 (0)