[C] how to have linearized, scalar IO arrays (for motors, sensors)?


#1

(I don’t know where my last post has gone or if it has vanished, so again…)

how would it be feasable to have linearized, scalar IO arrays (for motors, sensors)?

e.g.

motor[0] => BP3[0] & PORT_A
motor[1] => BP3[0] & PORT_B
motor[2] => BP3[0] & PORT_C
motor[3] => BP3[0] & PORT_D

motor[4] => BP3[1] & PORT_A
motor[5] => BP3[1] & PORT_B
motor[6] => BP3[1] & PORT_C
motor[7] => BP3[1] & PORT_D

motor[8] => BP3[2] & PORT_A
motor[9] => BP3[2] & PORT_B

the goal would be to implement things like

for (int i=0; i<6, i++) {
   MotorOn (i, -40);
}
for (int i=6; i<10, i++) {
   MotorOff (i);
}

the port part is feasable of course -

but how to linearize the BP3 shield numbers and init them all as an array?