def needs_repaint(self):
     if not self.displaying_ready: # displaying progress, so repaint often
         now = millis()
         if now - self.last_repaint_time > self.repaint_delay:
             self.last_repaint_time = now
             return True
     return super().needs_repaint()
Exemple #2
0
 def update(self):
     if self.is_sweeping():
         now = millis()
         if now - self.last_step_time > self.step_delay:
             self.last_step_time = now
             print('setting angle to ' + str(self.angle + self.direction))
             self.set_angle(self.angle + self.direction)
Exemple #3
0
 def get_time_until_next_dose(self):
     if self.last_dose_times[0] > 0:
         for i in range(0, self.max_dose):
             time_since_last_dose = millis() - self.last_dose_times[i]
             time_until_next_dose = self.dose_window * (i + 1) - time_since_last_dose
             if time_until_next_dose >= 0:
                 return time_until_next_dose
     return 0
Exemple #4
0
 def get_available_doses(self):
     available = 0
     now = millis()
     for i in range(0, self.max_dose):
         if self.last_dose_times == 0:
             available += 1
         else:
             current_window = self.dose_window * (i + 1)
             if now - self.last_dose_times[i] > current_window:
                 available += 1
     return available
Exemple #5
0
 def update(self):
     if self.is_stepping():
         now = millis()
         if now - self.last_step_time > self.step_delay:
             self.last_step_time = now
             if self.direction == 1:
                 self.current_step += 1
                 if self.current_step == self.n_steps:
                     self.current_step = 0
             else:
                 if self.current_step == 0:
                     self.current_step = self.n_steps
                 self.current_step -= 1
             signal = Stepper.STEP_SIGNALS[self.current_step % 4]
             self.send_signal(*signal)
 def update(self):
     if not self.is_stepper_lined_up():
         if not self.stepper.is_stepping():
             self.stepper.step(self.steps_per_slot)
         else:
             self.stepper.update()
     else:
         now = millis()
         if now - self.last_servo_time > self.servo_wait:
             self.last_servo_time = now
             if self.servo.angle == self.servo_start:
                 self.servo.set_angle(self.servo_end)
             elif self.servo.angle == self.servo_end:
                 self.servo.set_angle(self.servo_start)
                 self.number_to_dispense -= 1
                 self.count -= 1
 def update_ask_time(self):
     self.last_ask_time = millis()
 def should_ask(self):
     return self.last_ask_time == 0 or millis(
     ) - self.last_ask_time > self.ask_window
Exemple #9
0
 def use(self, count):
     for i in reversed(range(0, self.max_dose)):
         self.last_dose_times[i] = self.last_dose_times[i - 1]
     now = millis()
     for i in range(0, count):
         self.last_dose_times[i] = now