parent
b3f36c1d1f
commit
65fee42217
28
boot.py
28
boot.py
|
@ -1,16 +1,16 @@
|
|||
from board import *
|
||||
import digitalio
|
||||
import storage
|
||||
# from board import *
|
||||
# import digitalio
|
||||
# import storage
|
||||
|
||||
noStorageStatus = False
|
||||
noStoragePin = digitalio.DigitalInOut(GP0)
|
||||
noStoragePin.switch_to_input(pull=digitalio.Pull.UP)
|
||||
noStorageStatus = not noStoragePin.value
|
||||
# noStorageStatus = False
|
||||
# noStoragePin = digitalio.DigitalInOut(GP0)
|
||||
# noStoragePin.switch_to_input(pull=digitalio.Pull.UP)
|
||||
# noStorageStatus = not noStoragePin.value
|
||||
|
||||
if(noStorageStatus == False):
|
||||
# don't show USB drive to host PC
|
||||
storage.disable_usb_drive()
|
||||
print("Disabling USB drive")
|
||||
else:
|
||||
# normal boot
|
||||
print("USB drive enabled")
|
||||
# if(noStorageStatus == False):
|
||||
# # don't show USB drive to host PC
|
||||
# storage.disable_usb_drive()
|
||||
# print("Disabling USB drive")
|
||||
# else:
|
||||
# # normal boot
|
||||
# print("USB drive enabled")
|
||||
|
|
47
code.py
47
code.py
|
@ -4,6 +4,7 @@ import time
|
|||
import usb_hid
|
||||
from adafruit_hid.consumer_control_code import ConsumerControlCode
|
||||
from adafruit_hid.consumer_control import ConsumerControl
|
||||
from adafruit_hid.mouse import Mouse
|
||||
|
||||
clkPin = digitalio.DigitalInOut(board.GP2)
|
||||
dtPin = digitalio.DigitalInOut(board.GP1)
|
||||
|
@ -12,16 +13,48 @@ clkPin.direction = digitalio.Direction.INPUT
|
|||
clkPin.pull = digitalio.Pull.UP
|
||||
dtPin.pull = digitalio.Pull.UP
|
||||
|
||||
previousValue = True
|
||||
global buttonPin
|
||||
buttonPin = digitalio.DigitalInOut(board.GP15)
|
||||
buttonPin.direction = digitalio.Direction.INPUT
|
||||
buttonPin.pull = digitalio.Pull.UP
|
||||
|
||||
global consumer_control
|
||||
consumer_control = ConsumerControl(usb_hid.devices)
|
||||
|
||||
while True:
|
||||
if previousValue != clkPin.value:
|
||||
if clkPin.value == False:
|
||||
if dtPin.value == False:
|
||||
print('left')
|
||||
global mode
|
||||
mode = 0
|
||||
global previousValue
|
||||
previousValue = True
|
||||
|
||||
def control_volumen(pinStatus):
|
||||
if pinStatus == False:
|
||||
print('Volumen down')
|
||||
consumer_control.send(ConsumerControlCode.VOLUME_DECREMENT)
|
||||
else:
|
||||
print('right')
|
||||
print('Volumen up')
|
||||
consumer_control.send(ConsumerControlCode.VOLUME_INCREMENT)
|
||||
|
||||
def mute_volumen():
|
||||
consumer_control.send(ConsumerControlCode.MUTE)
|
||||
print('Mute')
|
||||
|
||||
|
||||
while True:
|
||||
if buttonPin.value == False:
|
||||
if mode == 0:
|
||||
mute_volumen()
|
||||
else:
|
||||
mode = 0
|
||||
mute_volumen()
|
||||
print('Button pressed')
|
||||
time.sleep(0.5)
|
||||
else:
|
||||
if previousValue != clkPin.value:
|
||||
if clkPin.value == False:
|
||||
if mode == 0:
|
||||
control_volumen(dtPin.value)
|
||||
else:
|
||||
mode = 0
|
||||
control_volumen(dtPin.value)
|
||||
previousValue = clkPin.value
|
||||
print('Rotary Status: ' + str(clkPin.value))
|
||||
|
|
Loading…
Reference in New Issue