From c54301d14ecf55d4add6e9fb344072b8dfa56327 Mon Sep 17 00:00:00 2001 From: jpunkt Date: Thu, 4 Nov 2021 12:52:42 +0100 Subject: [PATCH] all commands implemented, untested. --- micropizza/main.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/micropizza/main.py b/micropizza/main.py index 4939144..73d6737 100644 --- a/micropizza/main.py +++ b/micropizza/main.py @@ -55,8 +55,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): @@ -74,10 +73,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) @@ -189,9 +188,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' ############################################################################### @@ -201,6 +205,7 @@ choice_map = { CMD_BL: backlight, CMD_FL: frontlight, CMD_UI: user_interaction, + CMD_RC: recording, CMD_RW: rewind }