Last active
October 19, 2025 07:43
-
-
Save alessaba/742d9bb29348ec7f930d60b9cc2eb013 to your computer and use it in GitHub Desktop.
Barebones GUI to interact with dcsd (with argv support too for automations)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter | |
import pylibftdi | |
from sys import argv | |
# DYLD_LIBRARY_PATH="/opt/homebrew/lib:$DYLD_LIBRARY_PATH" | |
#pylibftdi.Driver("/opt/homebrew/lib/libftdi1.dylib") | |
pylibftdi.USB_PID_LIST.append(0x8a88) # PID | |
pylibftdi.USB_VID_LIST.append(0x0403) # VID | |
luciDevice = pylibftdi.BitBangDevice("AH022NWG") # Device Serial for the Status LED FTDI. | |
if luciDevice.device_id: | |
print(f"Found FTDI chip with requested Serial Number: {luciDevice.device_id}") | |
luciDevice.open() | |
def dcsd_lights_set(green = 0, yellow = 0, red = 0): | |
lights_map = { | |
(0,0,0): 0xF0, | |
(0,0,1): 0xF1, | |
(1,0,0): 0xF2, | |
(1,0,1): 0xF3, | |
(0,1,0): 0xF8, | |
(0,1,1): 0xF9, | |
(1,1,0): 0xFA, | |
(1,1,1): 0xFB | |
} | |
tuple_key = tuple([green,yellow,red]) | |
luciDevice.ftdi_fn.ftdi_set_bitmode(lights_map[tuple_key], 0x20) # CBUS Bitmode | |
class DcsdGui(tkinter.Frame): | |
def __init__(self, master=None): | |
super().__init__(master) | |
self.master = master | |
self.pack() | |
self.create_widgets() | |
dcsd_lights_set() | |
def create_widgets(self): | |
self.green_var = tkinter.IntVar() | |
self.green = tkinter.Checkbutton(self, text="Green (PASS)", variable=self.green_var, fg="green", selectcolor="green", command=self.update_lights) | |
self.green.pack(side="top") | |
self.yellow_var = tkinter.IntVar() | |
self.yellow = tkinter.Checkbutton(self, text="Yellow (BUSY)", variable=self.yellow_var, fg="yellow", selectcolor="yellow", command=self.update_lights) | |
self.yellow.pack(side="top") | |
self.red_var = tkinter.IntVar() | |
self.red = tkinter.Checkbutton(self, text="Red (FAIL) ", variable=self.red_var, fg="red", selectcolor="red", command=self.update_lights) | |
self.red.pack(side="top") | |
def update_lights(self): | |
green_value = self.green_var.get() | |
yellow_value = self.yellow_var.get() | |
red_value = self.red_var.get() | |
dcsd_lights_set(green_value, yellow_value, red_value) | |
def chiudi(self): | |
dcsd_lights_set() | |
self.luci.close() | |
self.master.destroy() | |
exit() | |
def main(): | |
if len(argv) > 1: | |
dcsd_lights_set(*map(int, argv[1:4])) | |
else: | |
root = tkinter.Tk() | |
app = DcsdGui(master=root) | |
app.mainloop() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment