update main.py to support all channels in manual mode
Signed-off-by: Thomas Schmid <tom@lfence.de>
This commit is contained in:
parent
eb40d8b108
commit
ade567081c
51
main.py
51
main.py
@ -44,6 +44,10 @@ class Laser:
|
||||
def _set_channel(self, channel, value):
|
||||
self.channels[channel - 1] = value
|
||||
|
||||
def _set_and_send_channel(self, channel, value):
|
||||
self._set_channel(channel, value)
|
||||
self._send_channels([channel])
|
||||
|
||||
def set_pos(self, x, y):
|
||||
x = clamp(x, 1, 127)
|
||||
y = clamp(y, 1, 127)
|
||||
@ -52,11 +56,28 @@ class Laser:
|
||||
self._send_channels([5,6])
|
||||
|
||||
def set_color(self, color):
|
||||
pass
|
||||
self._set_and_send_channel(8, color)
|
||||
|
||||
def set_strobe(self, strobe):
|
||||
self._set_and_send_channel(3, strobe)
|
||||
|
||||
def set_point_speed(self, point_speed):
|
||||
self._set_and_send_channel(4, point_speed)
|
||||
|
||||
def set_mode(self, mode):
|
||||
self._set_channel(1, mode)
|
||||
self._send_channels([1])
|
||||
self._set_and_send_channel(1, mode)
|
||||
|
||||
def set_animation(self, animation):
|
||||
self._set_and_send_channel(2, animation)
|
||||
|
||||
def set_zoom(self, zoom):
|
||||
self._set_and_send_channel(7, zoom)
|
||||
|
||||
def set_reset(self, reset):
|
||||
self._set_and_send_channel(9, reset)
|
||||
|
||||
def set_color_effect(self, color_effect):
|
||||
self._set_and_send_channel(10, color_effect)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@ -164,6 +185,30 @@ def manual_mode(laser, mqtt_client, stop_evt):
|
||||
if mode:
|
||||
laser.set_mode(mode)
|
||||
|
||||
strobe = laser_commanded_state.get("strobe")
|
||||
if strobe:
|
||||
laser.set_strobe(strobe)
|
||||
|
||||
zoom = laser_commanded_state.get("zoom")
|
||||
if zoom:
|
||||
laser.set_point_speed(zoom)
|
||||
|
||||
animation = laser_commanded_state.get("animation")
|
||||
if animation:
|
||||
laser.set_point_speed(animation)
|
||||
|
||||
point_speed = laser_commanded_state.get("point_speed")
|
||||
if point_speed:
|
||||
laser.set_point_speed(point_speed)
|
||||
|
||||
color = laser_commanded_state.get("color")
|
||||
if color:
|
||||
laser.set_color(color)
|
||||
|
||||
color_effect = laser_commanded_state.get("color_effect")
|
||||
if color_effect:
|
||||
laser.set_color_effect(color_effect)
|
||||
|
||||
mqtt_send_laser_state(mqtt_client, laser)
|
||||
state_changes_cv.wait()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user