led brightness argument

This commit is contained in:
Luis Andrade
2024-02-08 01:05:42 -05:00
parent 8850100ca6
commit 00188fa5da
2 changed files with 7 additions and 3 deletions
+3
View File
@@ -385,4 +385,7 @@ Try a voice command and see if the LEDs change. Use `journalctl` to check the lo
journalctl -u 2mic_leds.service -f journalctl -u 2mic_leds.service -f
``` ```
If you encounter any issues, you can add the `--debug` argument to the command line to increase the log level.
To control the brightness of the LEDS, use the `--led-brightness ` argument, which accepts integer numbers from 1 to 31.
Make sure to run `sudo systemctl daemon-reload` every time you make changes to the service. Make sure to run `sudo systemctl daemon-reload` every time you make changes to the service.
+4 -3
View File
@@ -41,8 +41,8 @@ async def main() -> None:
"""Main entry point.""" """Main entry point."""
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("--uri", required=True, help="unix:// or tcp://") parser.add_argument("--uri", required=True, help="unix:// or tcp://")
#
parser.add_argument("--debug", action="store_true", help="Log DEBUG messages") parser.add_argument("--debug", action="store_true", help="Log DEBUG messages")
parser.add_argument("--led-brightness", type=int, default=31, help="LED brightness (integer from 1 to 31)")
args = parser.parse_args() args = parser.parse_args()
logging.basicConfig(level=logging.DEBUG if args.debug else logging.INFO) logging.basicConfig(level=logging.DEBUG if args.debug else logging.INFO)
@@ -54,7 +54,7 @@ async def main() -> None:
led_power = gpiozero.LED(LEDS_GPIO, active_high=False) led_power = gpiozero.LED(LEDS_GPIO, active_high=False)
led_power.on() led_power.on()
leds = APA102(num_led=NUM_LEDS) leds = APA102(num_led=NUM_LEDS, global_brightness=args.led_brightness)
# Start server # Start server
server = AsyncServer.from_uri(args.uri) server = AsyncServer.from_uri(args.uri)
@@ -148,7 +148,7 @@ class APA102:
def __init__( def __init__(
self, self,
num_led, num_led,
global_brightness=MAX_BRIGHTNESS, global_brightness,
order="rgb", order="rgb",
bus=0, bus=0,
device=1, device=1,
@@ -162,6 +162,7 @@ class APA102:
self.global_brightness = self.MAX_BRIGHTNESS self.global_brightness = self.MAX_BRIGHTNESS
else: else:
self.global_brightness = global_brightness self.global_brightness = global_brightness
_LOGGER.debug("LED brightness: %d", self.global_brightness)
self.leds = [self.LED_START, 0, 0, 0] * self.num_led # Pixel buffer self.leds = [self.LED_START, 0, 0, 0] * self.num_led # Pixel buffer
self.spi = spidev.SpiDev() # Init the SPI device self.spi = spidev.SpiDev() # Init the SPI device