replace number of motors with a constant
This commit is contained in:
parent
1ab11a72b1
commit
636f18d70d
10
main.cpp
10
main.cpp
|
@ -1,7 +1,9 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "motor_control.h"
|
#include "motor_control.h"
|
||||||
|
|
||||||
MotorControl motors[4] = {
|
#define NUM_MOTORS 4
|
||||||
|
|
||||||
|
MotorControl motors[NUM_MOTORS] = {
|
||||||
MotorControl(5, 2),
|
MotorControl(5, 2),
|
||||||
MotorControl(6, 3),
|
MotorControl(6, 3),
|
||||||
MotorControl(7, 4),
|
MotorControl(7, 4),
|
||||||
|
@ -11,9 +13,9 @@ MotorControl motors[4] = {
|
||||||
void handle_tick(unsigned long cur_micros) {
|
void handle_tick(unsigned long cur_micros) {
|
||||||
// Randomize the order we process motor ticks every time
|
// Randomize the order we process motor ticks every time
|
||||||
// This helps reduce the minor frequency discrepancies between each motor
|
// This helps reduce the minor frequency discrepancies between each motor
|
||||||
unsigned long start_val = (cur_micros / 10) % 4;
|
unsigned long start_val = (cur_micros / 10) % NUM_MOTORS;
|
||||||
for (unsigned long i = start_val; i < start_val + 4; i++) {
|
for (unsigned long i = start_val; i < start_val + NUM_MOTORS; i++) {
|
||||||
motors[i % 4].Tick(cur_micros);
|
motors[i % NUM_MOTORS].Tick(cur_micros);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue