Skip to content

Commit

Permalink
Merge pull request #2 from llluis/led_brightness
Browse files Browse the repository at this point in the history
Led brightness
  • Loading branch information
llluis authored Feb 8, 2024
2 parents c0e1b50 + ba7bf37 commit 0fff368
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/tutorial_2mic.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

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.
6 changes: 4 additions & 2 deletions examples/2mic_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ async def main() -> None:
parser = argparse.ArgumentParser()
parser.add_argument("--uri", required=True, help="unix:// or tcp://")
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)")
parser.add_argument("--log-format", default=logging.BASIC_FORMAT, help="Format for log messages")
args = parser.parse_args()

Expand All @@ -57,7 +58,7 @@ async def main() -> None:
led_power = gpiozero.LED(LEDS_GPIO, active_high=False)
led_power.on()

leds = APA102(num_led=NUM_LEDS)
leds = APA102(num_led=NUM_LEDS, global_brightness=args.led_brightness)

# GPIO Button
GPIO.setmode(GPIO.BCM)
Expand Down Expand Up @@ -167,7 +168,7 @@ class APA102:
def __init__(
self,
num_led,
global_brightness=MAX_BRIGHTNESS,
global_brightness,
order="rgb",
bus=0,
device=1,
Expand All @@ -181,6 +182,7 @@ def __init__(
self.global_brightness = self.MAX_BRIGHTNESS
else:
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.spi = spidev.SpiDev() # Init the SPI device
Expand Down

0 comments on commit 0fff368

Please sign in to comment.