Created
April 17, 2021 16:45
-
-
Save jfurcean/438e67a15311303906ff1a1d7cb67ed5 to your computer and use it in GitHub Desktop.
CPX Mute Example
This file contains 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
from adafruit_circuitplayground import cp | |
from adafruit_hid.keyboard import Keyboard | |
from adafruit_hid.keycode import Keycode | |
import usb_hid | |
import time | |
GREEN = (0,255,0) | |
RED = (255,0,0) | |
cp.pixels.brightness = .1 | |
kbd = Keyboard(usb_hid.devices) | |
button_a_held = False | |
mute = False | |
while True: | |
if cp.button_a and not button_a_held: | |
kbd.send(Keycode.COMMAND, Keycode.SHIFT, Keycode.A) | |
button_a_held = True | |
mute = not mute | |
if not cp.button_a: | |
button_a_held = False | |
if mute: | |
cp.pixels.fill(RED) | |
else: | |
cp.pixels.fill(GREEN) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment