Compare commits

...

2 Commits

Author SHA1 Message Date
m3philis
c09655c2ba flush LEDs before applying color/template to make sure the mode is set correctly even on new devices 2025-03-17 20:54:35 +01:00
m3philis
40bc3b09f2 add REQUIREMNTS.txt 2025-03-17 20:50:12 +01:00
2 changed files with 18 additions and 9 deletions

4
REQUIREMENTS.txt Normal file
View File

@@ -0,0 +1,4 @@
argcomplete
argparse
rgbw_colorspace_converter

View File

@@ -1,6 +1,7 @@
#! /usr/bin/env python3
# PYTHON_ARGCOMPLETE_OK
import argparse
import argcomplete, argparse
import subprocess
from rgbw_colorspace_converter.colors.converters import RGB
@@ -33,7 +34,7 @@ PANSEXUAL_PRIDE_SPIRO_DISCO_BALL = [27, 179, 255]
def template_pansexual():
command = ""
command = "echo 0 > /proc/led/led_mode;"
for port in range(1, 19):
if port < 7:
@@ -51,7 +52,7 @@ def template_pansexual():
def template_bisexual():
command = ""
command = "echo 0 > /proc/led/led_mode;"
for port in range(1, 19):
if port < 8:
@@ -69,7 +70,7 @@ def template_bisexual():
def template_trans():
command = ""
command = "echo 0 > /proc/led/led_mode;"
for port in range(1, 19):
if port < 5:
@@ -93,7 +94,7 @@ def template_trans():
def template_lesbian():
command = ""
command = "echo 0 > /proc/led/led_mode;"
for port in range(1, 19):
if port < 5:
@@ -117,7 +118,7 @@ def template_lesbian():
def template_lgbtq():
command = ""
command = "echo 0 > /proc/led/led_mode;"
for port in range(1, 19):
if port < 4:
@@ -143,7 +144,10 @@ def template_lgbtq():
def get_color_commands(port, red, green, blue, white):
command = ""
if args.color:
command = "echo 0 > /proc/led/led_mode;"
else:
command = ""
command += "echo {} r {} > /proc/led/led_color; ".format(port, red * 64)
command += "echo {} g {} > /proc/led/led_color; ".format(port, green * 64)
command += "echo {} b {} > /proc/led/led_color; ".format(port, blue * 64)
@@ -153,7 +157,7 @@ def get_color_commands(port, red, green, blue, white):
def flush_leds():
command = "echo 0 > /proc/led/led_mode"
command = "echo 0 > /proc/led/led_mode;"
return command
@@ -184,7 +188,7 @@ if __name__ == "__main__":
group.add_argument(
"-t",
"--template",
help="sets a predefined template. Valid options are LESBIAN or LGBTQ",
help="Sets a predefined pride template.",
choices=["lesbian", "lgbtq", "trans", "bisexual", "pansexual"],
)
group.add_argument(
@@ -196,6 +200,7 @@ if __name__ == "__main__":
metavar=("PORT", "RED", "GREEN", "BLUE"),
)
argcomplete.autocomplete(parser)
args = parser.parse_args()
if args.flush: