update interactive.py
Signed-off-by: Thomas Schmid <tom@lfence.de>
This commit is contained in:
parent
fa5fbeeb15
commit
69809ac140
@ -106,6 +106,9 @@ class LabelSlider(urwid.WidgetWrap):
|
||||
self.slider.set_value(value, emit=False)
|
||||
self.render_text(value)
|
||||
|
||||
def get_value(self):
|
||||
return self.slider.value
|
||||
|
||||
def get_slider(self):
|
||||
return self.slider
|
||||
|
||||
@ -162,7 +165,7 @@ class View:
|
||||
self.mode = LabelSlider(min = 0, max = 0xFF)
|
||||
self.animation = LabelSlider(min = 0, max=0xFF)
|
||||
self.strobe = LabelSlider(min = 0, max = 0xFF)
|
||||
self.effect = LabelSlider(min = 0, max = 0xFF)
|
||||
self.point_speed = LabelSlider(min = 0, max = 0xFF)
|
||||
self.x = LabelSlider(min = 0, max = 0xFF)
|
||||
self.y = LabelSlider(min = 0, max = 0xFF)
|
||||
self.zoom = LabelSlider(min = 0, max = 0xFF)
|
||||
@ -173,7 +176,7 @@ class View:
|
||||
signals.connect_signal(self.mode.get_slider(), "value_changed", self.value_changed_callback)
|
||||
signals.connect_signal(self.animation.get_slider(), "value_changed", self.value_changed_callback)
|
||||
signals.connect_signal(self.strobe.get_slider(), "value_changed", self.value_changed_callback)
|
||||
signals.connect_signal(self.effect.get_slider(), "value_changed", self.value_changed_callback)
|
||||
signals.connect_signal(self.point_speed.get_slider(), "value_changed", self.value_changed_callback)
|
||||
signals.connect_signal(self.x.get_slider(), "value_changed", self.value_changed_callback)
|
||||
signals.connect_signal(self.y.get_slider(), "value_changed", self.value_changed_callback)
|
||||
signals.connect_signal(self.zoom.get_slider(), "value_changed", self.value_changed_callback)
|
||||
@ -198,7 +201,7 @@ class View:
|
||||
self.mode,
|
||||
self.animation,
|
||||
self.strobe,
|
||||
self.effect,
|
||||
self.point_speed,
|
||||
self.x,
|
||||
self.y,
|
||||
self.zoom,
|
||||
@ -212,28 +215,28 @@ class View:
|
||||
|
||||
def value_changed_callback(self, slider, value):
|
||||
if slider == self.x or slider == self.y:
|
||||
move_laser(client, (self.x.value, self.y.value))
|
||||
move_laser(client, (self.x.get_value(), self.y.get_value()))
|
||||
elif slider == self.mode:
|
||||
pass
|
||||
laser_set("mode", self.mode.get_value())
|
||||
elif slider == self.animation:
|
||||
pass
|
||||
laser_set("animation", self.animation.get_value())
|
||||
elif slider == self.strobe:
|
||||
pass
|
||||
elif slider == self.effect:
|
||||
pass
|
||||
laser_set("strobe", self.strobe.get_value())
|
||||
elif slider == self.point_speed:
|
||||
laser_set("point_speed", self.point_speed.get_value())
|
||||
elif slider == self.zoom:
|
||||
pass
|
||||
laser_set("zoom", self.zoom.get_value())
|
||||
elif slider == self.color:
|
||||
pass
|
||||
laser_set("color", self.color.get_value())
|
||||
elif slider == self.reset:
|
||||
pass
|
||||
laser_set("reset", self.reset.get_value())
|
||||
elif slider == self.color_effect:
|
||||
pass
|
||||
laser_set("color_effect", self.color_effect.get_value())
|
||||
|
||||
def update_channels(self, channels):
|
||||
self.animation.set_value(channels[1])
|
||||
self.strobe.set_value(channels[2])
|
||||
self.effect.set_value(channels[3])
|
||||
self.point_speed.set_value(channels[3])
|
||||
self.x.set_value(channels[4])
|
||||
self.y.set_value(channels[5])
|
||||
self.zoom.set_value(channels[6])
|
||||
@ -251,6 +254,10 @@ def move_laser(client, pos):
|
||||
}}
|
||||
client.publish("kitchen/laser/state/cmd", payload = json.dumps(cmd))
|
||||
|
||||
def laser_set(attribute, value):
|
||||
cmd = {"laser": { attribute: value}}
|
||||
client.publish("kitchen/laser/state/cmd", payload = json.dumps(cmd))
|
||||
|
||||
def on_state_changed(client, user_data, message):
|
||||
data = json.loads(message.payload)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user