Timecontrolled finite state machine (without delay)

Hello,

I am currently writing a sketch that controls my DLSR (exposure control for timelapse), currently, in pseudo-pseudocode, it looks like this:

if (num_img < max_img) {
     if (can_wait) { //Waiting between images
          display_wait();    
          delay(delay_wait);
     }

     if (can_sva) { //mirror-lockup
          display_sva();    
          open_shutter();
          delay(delay_sva);    
     } else {
          if (can_exp)
               open_shutter();
     }
     delay(500 ms);

     if (can_exp) //can_exp is true if the arduino controls the duration of the exposure, not the camera
          display_exp();    
          open_shutter();
          delay(delay_exp);    
          close_shutter();
     } else {
          open_shutter();
          delay(50 ms);
          close_shutter();
     }

     delay(100 ms);
     move_motors(axis1, axis2); //motor-library uses a delay and whileloops, I'm currently trying to rewrite this too, so it no   
                                          //longer blocks, but the duration of this can take an unknown time, so I'm rewriting it, that 
                                          //it returns a flag depending whether the movement is finished or not.
     
     num_img++;
}

How can I replace the delays so it doesn't block anymore?

How can I replace the delays so it doesn't block anymore?

How would YOU perform the needed actions? All you have is a pencil (assignment statements), paper (variables), and a watch (millis()).

On any pass through loop(), it is time to do something, or it isn't. If it is, then the only decision to be made is what to do, and then you do it. Typically, you record when you did it, so you know when it is time to do the next thing.

Embrace Blink Without Delay and / or watch this video.