-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from loretod/main
HID Keyboard CP Version
- Loading branch information
Showing
17 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions
1
...es/Software_Files/Rocket_Switch_Interface/CircuitPython/.vscode/ltex.dictionary.en-US.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CircuitPython |
4 changes: 4 additions & 0 deletions
4
Build_Files/Software_Files/Rocket_Switch_Interface/CircuitPython/.vscode/settings.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"python.languageServer": "Pylance", | ||
"python.linting.pylintEnabled": false | ||
} |
Binary file added
BIN
+358 KB
...Interface/CircuitPython/adafruit-circuitpython-adafruit_rotary_trinkey_m0-en_US-8.0.5.uf2
Binary file not shown.
Binary file added
BIN
+423 Bytes
Build_Files/Software_Files/Rocket_Switch_Interface/CircuitPython/adafruit_hid/__init__.mpy
Binary file not shown.
Binary file added
BIN
+659 Bytes
...es/Software_Files/Rocket_Switch_Interface/CircuitPython/adafruit_hid/consumer_control.mpy
Binary file not shown.
Binary file added
BIN
+354 Bytes
...ftware_Files/Rocket_Switch_Interface/CircuitPython/adafruit_hid/consumer_control_code.mpy
Binary file not shown.
Binary file added
BIN
+1.22 KB
Build_Files/Software_Files/Rocket_Switch_Interface/CircuitPython/adafruit_hid/keyboard.mpy
Binary file not shown.
Binary file added
BIN
+1.19 KB
...oftware_Files/Rocket_Switch_Interface/CircuitPython/adafruit_hid/keyboard_layout_base.mpy
Binary file not shown.
Binary file added
BIN
+330 Bytes
.../Software_Files/Rocket_Switch_Interface/CircuitPython/adafruit_hid/keyboard_layout_us.mpy
Binary file not shown.
Binary file added
BIN
+1.69 KB
Build_Files/Software_Files/Rocket_Switch_Interface/CircuitPython/adafruit_hid/keycode.mpy
Binary file not shown.
Binary file added
BIN
+843 Bytes
Build_Files/Software_Files/Rocket_Switch_Interface/CircuitPython/adafruit_hid/mouse.mpy
Binary file not shown.
64 changes: 64 additions & 0 deletions
64
Build_Files/Software_Files/Rocket_Switch_Interface/CircuitPython/code.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# SPDX-FileCopyrightText: 2018 Kattni Rembor for Adafruit Industries | ||
# | ||
# SPDX-License-Identifier: MIT | ||
# Modified by: Loreto Dumitrescu | ||
# CircuitPython code for the Rocket Switch Interface designed by Milad from Makers Making Change. | ||
# Project Details: https://makersmakingchange.com/project/rocket-switch-interface/ | ||
|
||
"""CircuitPython Rocket Switch Interface- Keyboard""" | ||
import time | ||
|
||
import board | ||
import digitalio | ||
import usb_hid | ||
from adafruit_hid.keyboard import Keyboard | ||
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS | ||
from adafruit_hid.keycode import Keycode | ||
|
||
# The pins we'll use, each will have an internal pullup | ||
keypress_pins = [board.ROTA, board.SWITCH] | ||
# Our array of key objects | ||
key_pin_array = [] | ||
# The Keycode sent for each button | ||
# To view a complete list of available keycodes: | ||
# https://docs.circuitpython.org/projects/hid/en/latest/_modules/adafruit_hid/keycode.html | ||
keys_pressed = [Keycode.TAB, Keycode.SPACE] | ||
|
||
# The keyboard object! | ||
time.sleep(1) # Sleep for a bit to avoid a race condition on some systems | ||
keyboard = Keyboard(usb_hid.devices) | ||
keyboard_layout = KeyboardLayoutUS(keyboard) # We're in the US :) | ||
|
||
# Make all pin objects inputs with pullups | ||
for pin in keypress_pins: | ||
key_pin = digitalio.DigitalInOut(pin) | ||
key_pin.direction = digitalio.Direction.INPUT | ||
key_pin.pull = digitalio.Pull.UP | ||
key_pin_array.append(key_pin) | ||
|
||
# Creates an instance of the on board light and sets it as an output | ||
led = digitalio.DigitalInOut(board.NEOPIXEL) | ||
led.direction = digitalio.Direction.OUTPUT | ||
|
||
print("Waiting for key pin...") | ||
|
||
while True: | ||
# Check each pin | ||
for key_pin in key_pin_array: | ||
if not key_pin.value: # Is it grounded? | ||
i = key_pin_array.index(key_pin) | ||
print("Pin #%d is grounded." % i) | ||
|
||
# Turn on the red LED | ||
led.value = True | ||
|
||
while not key_pin.value: | ||
pass # Wait for it to be ungrounded! | ||
key = keys_pressed[i] # Get the keycode to press | ||
keyboard.press(key) # "Press"... | ||
keyboard.release_all() # ..."Release"! | ||
|
||
# Turn off the red LED | ||
led.value = False | ||
|
||
time.sleep(0.01) |
35 changes: 35 additions & 0 deletions
35
Build_Files/Software_Files/Rocket_Switch_Interface/CircuitPython/instructions.md
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# CircuitPython Installation | ||
|
||
To install the CircuitPython Code: | ||
|
||
1. Download the following files and folders: | ||
|
||
- code.py | ||
- adafruit_hid folder | ||
- adafruit-circuitpython...uf2 | ||
|
||
2. If you haven't installed CircuitPython to the board previously, double-click the reset button on the board to enter bootloader mode. Drag the .uf2 files into the BOOT drive that appears. | ||
|
||
3. Drag and drop the code.py file into the drive. | ||
|
||
4. Drag the adafruit_hid folder into the lib folder in the drive. | ||
|
||
Note: If you are on a Mac and receive a memory error, you may need to copy the folder using command line instead of dragging and dropping. You will need to: | ||
|
||
- Open the Terminal app | ||
- Navigate to the location of the folder most likely you'll need to enter: </br> | ||
```cd Downloads``` | ||
|
||
- To copy the entire folder and internal files type: </br> | ||
```cp -rX adafruit-hid /Volumes/CIRCUITPY/lib``` | ||
|
||
You should now be able to see the adafruit-hid folder inside the lib folder. | ||
|
||
That's it! Your Rocket Switch Interface will now send a Tab and Space when your connected switches are pressed. | ||
|
||
If you'd like to change the keys being sent: | ||
1. visit the [Adafruit HID Documentation](https://docs.circuitpython.org/projects/hid/en/latest/_modules/adafruit_hid/keycode.html) for the complete list of keycodes. | ||
|
||
2. Open the ```code.py``` file in a simple text editor or better yet a code editor if you have one installed. | ||
3. Type the desired keycode on line number 25 replacing the TAB or SPACE. | ||
4. Save your file and the updates will automatically be applied. |