From 16165b61bd19a1d38f3c4d552a58e2d66e944c7c Mon Sep 17 00:00:00 2001 From: jpunkt Date: Fri, 29 Oct 2021 18:40:27 +0200 Subject: [PATCH] Serial communication HAL on pi side works. --- pizzactrl/hal_serial.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pizzactrl/hal_serial.py b/pizzactrl/hal_serial.py index 00c267c..e30d8db 100644 --- a/pizzactrl/hal_serial.py +++ b/pizzactrl/hal_serial.py @@ -61,7 +61,7 @@ class PizzaHAL: def send_cmd(self, command: SerialCommands, *options): self.blocked = True opt_str = '+'.join(str(x) for x in options) - cmd_str = f'{command.value}:{opt_str}' + cmd_str = f'{command.value}:{opt_str}\n' self.serialcon.write(cmd_str.encode('utf-8')) resp = self.serialcon.readline() self.blocked = False @@ -137,7 +137,7 @@ def wait_for_input(hal: PizzaHAL, go_callback: Any, @blocking -def light_layer(hal: PizzaHAL, intensity: float, fade: float = 0.0, **kwargs): +def light_layer(hal: PizzaHAL, intensity: float, fade: float = 0.0, steps: int = 100, **kwargs): """ Turn on the light to illuminate the upper scroll @@ -146,8 +146,10 @@ def light_layer(hal: PizzaHAL, intensity: float, fade: float = 0.0, **kwargs): Default 0, time in seconds to fade in or out :param intensity: float Intensity of the light in percent + :param steps: int + How many steps for the fade (default: 100) """ - hal.send_cmd(SerialCommands.FRONTLIGHT, int(intensity * 100), int(fade * 1000)) + hal.send_cmd(SerialCommands.FRONTLIGHT, int(intensity * 100), int(fade * 1000), steps) @blocking @@ -162,9 +164,9 @@ def backlight(hal: PizzaHAL, intensity: float, fade: float = 0.0, :param intensity: float Intensity of the light in percent :param steps: int - How many steps for the fade (default: 10) + How many steps for the fade (default: 100) """ - hal.send_cmd(SerialCommands.BACKLIGHT, int(intensity * 100), int(fade * 1000)) + hal.send_cmd(SerialCommands.BACKLIGHT, int(intensity * 100), int(fade * 1000), steps) @blocking def play_sound(hal: PizzaHAL, sound: Any, **kwargs):