This commit is contained in:
Peter Lorenz 2021-11-04 14:49:14 +02:00
commit d9c9d673fc

View file

@ -59,8 +59,7 @@ class Scroll:
self.c += self._dir
def _stop(self, pin):
self.a_pin.value(0)
self.b_pin.value(0)
self.speed = 0
@property
def dir(self):
@ -78,10 +77,10 @@ class Scroll:
@speed.setter
def speed(self, speed):
self._speed = speed
self.en_pin.duty_u16(speed * (_PWM_MAX // 100))
self.dir = (1 if speed > 0 else
(-1 if speed < 0 else 0))
self._speed = speed
pwm_bl = PWM(Pin(_PIN_EN_BACKLIGHT))
pwm_bl.freq(_PWM_FREQ)
@ -193,9 +192,14 @@ def recording(timeout):
time.sleep_ms(50)
return 'OK'
def rewind(*opts):
print(f'rewind({opts})')
scroll_h.speed = -100
scroll_v.speed = -100
while (scroll_h.speed + scroll_v.speed) > 0:
time.sleep_ms(10)
scroll_h.c = 0
scroll_v.c = 0
return 'OK'
###############################################################################
@ -205,6 +209,7 @@ choice_map = {
CMD_BL: backlight,
CMD_FL: frontlight,
CMD_UI: user_interaction,
CMD_RC: recording,
CMD_RW: rewind
}