update: led control working
This commit is contained in:
parent
cde8a1bd15
commit
c3e5f0313b
@ -61,10 +61,18 @@ class WLEDController:
|
||||
"""Turn off all lights."""
|
||||
self.send_command('{"ps":"4"}')
|
||||
|
||||
def change_effect(self):
|
||||
"""Change the color effect."""
|
||||
def blink_yellow(self):
|
||||
"""Blink in yellow."""
|
||||
self.send_command('{"ps":"5"}')
|
||||
|
||||
def blink_red(self):
|
||||
"""blink in red."""
|
||||
self.send_command('{"ps":"7"}')
|
||||
|
||||
def blink_green(self):
|
||||
"""blink in green."""
|
||||
self.send_command('{"ps":"6"}')
|
||||
|
||||
# Example usage:
|
||||
if __name__ == "__main__":
|
||||
controller = WLEDController(port="/dev/serial/by-path/pci-0000:00:14.0-usbv2-0:1:1.0-port0")
|
||||
|
32
workflow2.py
32
workflow2.py
@ -514,7 +514,7 @@ class Ui_MainWindow(object):
|
||||
self.yellowLightBtn.setText(_translate("MainWindow", "Turn on yellow LED"))
|
||||
self.greenLightBtn.setText(_translate("MainWindow", "Turn on green LED"))
|
||||
self.offLightBtn.setText(_translate("MainWindow", "Turn off all LEDs"))
|
||||
self.blinkLightBtn.setText(_translate("MainWindow", "Blink last LED"))
|
||||
self.blinkLightBtn.setText(_translate("MainWindow", "Blink Yellow LED"))
|
||||
|
||||
def mousePressEvent(self, event):
|
||||
print("Das MainWindow wurde angeklickt.")
|
||||
@ -920,10 +920,20 @@ class LightControl(QtWidgets.QMainWindow):
|
||||
self.ui.yellowLightBtn.clicked.connect(self.yellow_on)
|
||||
self.ui.greenLightBtn.clicked.connect(self.green_on)
|
||||
self.ui.offLightBtn.clicked.connect(self.leds_off)
|
||||
self.ui.blinkLightBtn.clicked.connect(self.leds_blink)
|
||||
self.ui.blinkLightBtn.clicked.connect(self.blink_yellow)
|
||||
self.w = wledControl.WLEDController(port="/dev/serial/by-path/pci-0000:00:14.0-usbv2-0:1:1.0-port0")
|
||||
# self.w.switch_to_green() # at appstart the light is green
|
||||
# self.w.change_effect() # and switches to green blinking until the workflow gets started successfully
|
||||
self.w.connect()
|
||||
#self.w.switch_to_green() # at appstart the light is green
|
||||
self.w.blink_green() # and switches to green blinking until the workflow gets started successfully#
|
||||
|
||||
# Connect app exit signal to the cleanup method
|
||||
app.aboutToQuit.connect(self.cleanup)
|
||||
|
||||
def cleanup(self):
|
||||
"""Clean up resources and switch off LEDs."""
|
||||
print("Cleaning up resources and switching off LEDs")
|
||||
self.leds_off() # Turn off LEDs
|
||||
self.w.disconnect() # Disconnect WLED controller
|
||||
|
||||
def map_color(self, color):
|
||||
"""
|
||||
@ -973,9 +983,17 @@ class LightControl(QtWidgets.QMainWindow):
|
||||
print("LEDs are off")
|
||||
self.w.turn_off_all()
|
||||
|
||||
def leds_blink(self):
|
||||
print("Previous color is blinking")
|
||||
self.w.change_effect()
|
||||
def blink_yellow(self):
|
||||
print("Yellow color is blinking")
|
||||
self.w.blink_yellow()
|
||||
|
||||
def blink_red(self):
|
||||
print("Red color is blinking")
|
||||
self.w.blink_red()
|
||||
|
||||
def blink_green(self):
|
||||
print("Green color is blinking")
|
||||
self.w.blink_green()
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
|
Loading…
Reference in New Issue
Block a user