From 78164b287d4bfed75886a1e0d503ff367e364130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ebbe=20Ba=C3=9F?= Date: Fri, 12 Aug 2022 02:06:17 +0200 Subject: [PATCH] changed some stuff for pc client MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Ebbe Baß --- code.py | 90 +-------------------------------- code.py.v2 => pc-client/main.py | 0 2 files changed, 2 insertions(+), 88 deletions(-) rename code.py.v2 => pc-client/main.py (100%) diff --git a/code.py b/code.py index 4ff3129..0a8d643 100644 --- a/code.py +++ b/code.py @@ -1,10 +1,6 @@ import board import digitalio 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) @@ -18,96 +14,14 @@ buttonPin = digitalio.DigitalInOut(board.GP15) buttonPin.direction = digitalio.Direction.INPUT buttonPin.pull = digitalio.Pull.UP -global consumer_control -consumer_control = ConsumerControl(usb_hid.devices) - -global mouse -mouse = Mouse(usb_hid.devices) - -global mode -mode = 0 global previousValue previousValue = True -#volume controller -def control_volumen(pinStatus): - if pinStatus == True: - print('Volumen down') - consumer_control.send(ConsumerControlCode.VOLUME_DECREMENT) - else: - print('Volumen up') - consumer_control.send(ConsumerControlCode.VOLUME_INCREMENT) - -def mute_volumen(): - consumer_control.send(ConsumerControlCode.MUTE) - print('Mute') - - - -#quickscroll -def scroll_up_down(pinStatus): - if pinStatus == False: - print('Scroll down') - mouse.move(wheel=3) - else: - print('Scroll up') - mouse.move(wheel=-3) - -def middle_mouse_button(): - mouse.click(Mouse.MIDDLE_BUTTON) - -#media control -def previous_next_track(pinStatus): - if pinStatus == True: - print('Previous track') - consumer_control.send(ConsumerControlCode.SCAN_PREVIOUS_TRACK) - else: - print('Next track') - consumer_control.send(ConsumerControlCode.SCAN_NEXT_TRACK) - -def play_pause(): - consumer_control.send(ConsumerControlCode.PLAY_PAUSE) - print('Play/Pause') - - while True: if buttonPin.value == False: - if mode == 0: - mute_volumen() - elif mode == 1: - play_pause() - elif mode == 2: - middle_mouse_button() - else: - mode = 0 - mute_volumen() - print('Button pressed') - time.sleep(0.3) - if buttonPin.value == False: - if mode == 0: - mute_volumen() - mode += 1 - elif mode == 1: - play_pause() - mode += 1 - elif mode == 2: - middle_mouse_button() - mode += 1 - else: - mode = 0 - mute_volumen() - print("changed mode: " + str(mode)) - time.sleep(1) + print("0x0") else: if previousValue != clkPin.value: if clkPin.value == False: - if mode == 0: - control_volumen(dtPin.value) - elif mode == 1: - previous_next_track(dtPin.value) - elif mode == 2: - scroll_up_down(dtPin.value) - else: - mode = 0 - control_volumen(dtPin.value) + print("1x"+str(dtPin.value)) previousValue = clkPin.value diff --git a/code.py.v2 b/pc-client/main.py similarity index 100% rename from code.py.v2 rename to pc-client/main.py