Hi! I am using the timerOne library, to allow me to step a motor while doing a bunch of other somewhat processor intensive things.
I am also still using the accellstepper library, because I do not need too much performance. For brief background, accellstepper library abstracts a lot of things and works primarily by this way: You call "stepper.run()" very frequently in a loop, and if it's time for a step, it steps [and returns TRUE, otherwise FALSE]. Viola.
So my basic goal was this:
I tried both with "stepper.run" and with "stepper.run()"
I found however I would get this error (attached):
"error: initializing argument 1 of 'void TimerOne::attachInterrupt(void(*)(), long unsigned int)' [-fpermissive]
Simply put, it seems to me that the issue (as stated in the error message) is that stepper.run() returns a bool whether a step was made or not, and the attachInterrupt requires a void function.
Now, my solution - which I tested to work- was to do something so corny as this:
void stepperInterrupt(){
stepper.run();
}
And I call that instead.
But, conceptually, I am not quite sure why the first solution was forbidden, if the second solution isn't forbidden but seems to not cause any problems. I think there might be some sort of software convention thing I could learn from by asking this question. At least, if anyone googles this problem like me they might find my solution and the discussion.
I am also still using the accellstepper library, because I do not need too much performance. For brief background, accellstepper library abstracts a lot of things and works primarily by this way: You call "stepper.run()" very frequently in a loop, and if it's time for a step, it steps [and returns TRUE, otherwise FALSE]. Viola.
So my basic goal was this:
Code:
uint16_t timerInterval = 1000000/motorMaxSpeed;
Timer1.initialize(timerInterval);
Timer1.attachInterrupt(stepper.run,timerInterval);
Timer1.start();
I tried both with "stepper.run" and with "stepper.run()"
I found however I would get this error (attached):
"error: initializing argument 1 of 'void TimerOne::attachInterrupt(void(*)(), long unsigned int)' [-fpermissive]
Simply put, it seems to me that the issue (as stated in the error message) is that stepper.run() returns a bool whether a step was made or not, and the attachInterrupt requires a void function.
Now, my solution - which I tested to work- was to do something so corny as this:
void stepperInterrupt(){
stepper.run();
}
And I call that instead.
But, conceptually, I am not quite sure why the first solution was forbidden, if the second solution isn't forbidden but seems to not cause any problems. I think there might be some sort of software convention thing I could learn from by asking this question. At least, if anyone googles this problem like me they might find my solution and the discussion.