-->
Page 1 of 2

Stepper Motor while displaying scrolling text on OLED displa

PostPosted: Tue Aug 20, 2019 4:10 pm
by sblantipodi
Guys,
is it possible to move a stepper motor on ESP8266 whle displaying a scrolling text on an OLED display?

am trying to write a stepper motor non blocking code
I am able to turn on and off a led using the famous non blocking piece of code
but I'm not able to write a loop that moves the stepper motor without blocking the code
basically I need to do a loop, that loops 4000 times delaying 1 milliseconds on each loop
how can I do it?

Code: Select allint stepLeft = 4500;
while (stepsLeft > 0) {   
      doSomething();
      stepsLeft--;
      delay(1);
}


how can I write this loop without blocking my display?

Re: Stepper Motor while displaying scrolling text on OLED di

PostPosted: Wed Aug 21, 2019 2:53 am
by btidey
Use a timer interrupt routine to run the stepper logic so that it is done in the background. Then other foreground tasks can execute fairly independently of the stepper timing.

Re: Stepper Motor while displaying scrolling text on OLED di

PostPosted: Wed Aug 21, 2019 7:23 am
by johny5
Try Timer Interrupt Routine to run the Stepper Motors.

Re: Stepper Motor while displaying scrolling text on OLED di

PostPosted: Wed Aug 21, 2019 9:32 am
by sblantipodi
btidey wrote:Use a timer interrupt routine to run the stepper logic so that it is done in the background. Then other foreground tasks can execute fairly independently of the stepper timing.


I'm not able to smoothly run the stepper motor and scroll text on oled display at the same time

it all happen in the same loop, but every time I call the draw function, the motor rettle because the diplay function need a lot of microseconds, any solution to the problem?