Havin all Instances as separate variable works fine
Having them in an array somehow breaks input
would be nice to be able to iterate through the instances
separate (works):
Loop track1(D30, D6, 1, buffer1),
track2(D26, D7, 2, buffer2),
track3(D22, D8, 3, buffer3),
track4(D18, D12, 4, buffer4),
track5(D17, D13, 5, buffer5);
int main(void)
{
track1.ResetTrack();
track2.ResetTrack();
track3.ResetTrack();
track4.ResetTrack();
track5.ResetTrack();
while(1) {
track1.UpdateButton();
track2.UpdateButton();
track3.UpdateButton();
track4.UpdateButton();
track5.UpdateButton();
}
}
array (dos NOT work):
Loop tracks[5] = { Loop(D30, D6, 1, buffer1),
Loop(D26, D7, 2, buffer2),
Loop(D22, D8, 3, buffer3),
Loop(D18, D12, 4, buffer4),
Loop(D17, D13, 5, buffer5) };
int main(void)
{
for (Loop track : tracks) {
track.ResetTrack();
}
while(1) {
for (Loop track : tracks) {
track.UpdateButton();
}
}
}
The class initializer
Loop(Pin button1Pin, Pin button2Pin, int no, float* buf) {
buttonLow.Init(button1Pin);
buttonTop.Init(button2Pin);
buttonLow.Debounce();
buttonTop.Debounce();
loopNumber = no;
buffer = buf;
}