def step(self):
if self.cancelled or self.finished:<EOL><INDENT>return<EOL><DEDENT>if not self.pwm_stages:<EOL><INDENT>self._finish()<EOL>return<EOL><DEDENT>if self.duration == <NUM_LIT:0>:<EOL><INDENT>progress = <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>run_time = time.time() - self._start_time<EOL>progress = max(<NUM_LIT:0>, min(<NUM_LIT:1>, run_time / self.duration))<EOL><DEDENT>self.stage_index = math.ceil((len(self.pwm_stages) - <NUM_LIT:1>) * progress)<EOL>stage = self.pwm_stages[self.stage_index]<EOL>self._driver.set_pwm(stage)<EOL>if progress == <NUM_LIT:1>:<EOL><INDENT>self._finish()<EOL><DEDENT>
Apply the current stage of the transition based on current time.