Skip to content

Instantly share code, notes, and snippets.

@jfurcean
Created April 17, 2021 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfurcean/438e67a15311303906ff1a1d7cb67ed5 to your computer and use it in GitHub Desktop.
Save jfurcean/438e67a15311303906ff1a1d7cb67ed5 to your computer and use it in GitHub Desktop.
CPX Mute Example
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