mirror of
https://github.com/System-End/hackpad.git
synced 2026-04-19 21:05:15 +00:00
Add files via upload
This commit is contained in:
parent
6850fd1f94
commit
d750199241
3 changed files with 104 additions and 0 deletions
23
hackpads/YippeePad/Firmware/KMK/kb.py
Normal file
23
hackpads/YippeePad/Firmware/KMK/kb.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import board
|
||||
from kmk.kmk_keyboard import KMKKeyboard
|
||||
from kmk.scanners import DiodeOrientation
|
||||
from kmk.modules.mcp23017 import MCP23017
|
||||
from kmk.modules.encoder import EncoderHandler
|
||||
|
||||
class CustomKeyboard(KMKKeyboard):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
# Define MCP23017 Expander for 12 switches
|
||||
self.mcp = MCP23017(address=0x20) # Default I2C address
|
||||
self.modules.append(self.mcp)
|
||||
|
||||
# Define key matrix pins
|
||||
self.col_pins = (self.mcp.gpioa[0], self.mcp.gpioa[1], self.mcp.gpioa[2])
|
||||
self.row_pins = (self.mcp.gpiob[0], self.mcp.gpiob[1], self.mcp.gpiob[2], self.mcp.gpiob[3])
|
||||
self.diode_orientation = DiodeOrientation.COL2ROW
|
||||
|
||||
# Rotary Encoder Setup
|
||||
self.encoder_handler = EncoderHandler()
|
||||
self.encoder_handler.pins = [(board.GP6, board.GP7), (board.GP8, board.GP9)]
|
||||
self.modules.append(self.encoder_handler)
|
||||
58
hackpads/YippeePad/Firmware/KMK/main.py
Normal file
58
hackpads/YippeePad/Firmware/KMK/main.py
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import board
|
||||
import digitalio
|
||||
from kmk.kmk_keyboard import KMKKeyboard
|
||||
from kmk.keys import KC
|
||||
from kmk.modules.mcp23017 import MCP23017
|
||||
from kmk.modules.encoder import EncoderHandler
|
||||
from kmk.extensions.peg_oled_display import Oled, OledDisplayMode, OledData
|
||||
from kmk.handlers.sequences import send_string
|
||||
|
||||
keyboard = KMKKeyboard()
|
||||
|
||||
# Add I2C MCP23017 Expander
|
||||
mcp23017 = MCP23017(address=0x20)
|
||||
keyboard.modules.append(mcp23017)
|
||||
|
||||
# Add Rotary Encoders
|
||||
encoder_handler = EncoderHandler()
|
||||
encoder_handler.pins = [(board.GP6, board.GP7), (board.GP8, board.GP9)]
|
||||
keyboard.modules.append(encoder_handler)
|
||||
|
||||
# Define Websites (Modify URLs as needed)
|
||||
website_shortcuts = [
|
||||
send_string("https://gmail.com\n"),
|
||||
send_string("https://youtube.com\n"),
|
||||
send_string("https://github.com\n"),
|
||||
send_string("https://reddit.com\n"),
|
||||
send_string("https://twitter.com\n"),
|
||||
send_string("https://discord.com\n"),
|
||||
send_string("https://twitch.tv\n"),
|
||||
send_string("https://spotify.com\n"),
|
||||
send_string("https://stackoverflow.com\n"),
|
||||
send_string("https://chatgpt.com\n"),
|
||||
send_string("https://amazon.com\n"),
|
||||
send_string("https://netflix.com\n"),
|
||||
]
|
||||
|
||||
# Define Keymap for Switches
|
||||
keyboard.keymap = [website_shortcuts]
|
||||
|
||||
# Rotary Encoders Functionality
|
||||
encoder_handler.map = [
|
||||
((KC.VOLU, KC.VOLD)), # Encoder 1: Volume up/down
|
||||
((KC.BRIU, KC.BRID)), # Encoder 2: Brightness up/down
|
||||
]
|
||||
|
||||
# OLED Display (GIF Support)
|
||||
oled = Oled(
|
||||
OledData(
|
||||
gif="user_gif.gif", # Replace with the actual GIF file you upload
|
||||
mode=OledDisplayMode.GIF,
|
||||
),
|
||||
flip=True
|
||||
)
|
||||
keyboard.extensions.append(oled)
|
||||
|
||||
# Start Keyboard
|
||||
if __name__ == '__main__':
|
||||
keyboard.go()
|
||||
23
hackpads/YippeePad/Firmware/README.md
Normal file
23
hackpads/YippeePad/Firmware/README.md
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
## Breakdown of Firmware
|
||||
|
||||
First things first, the firmware runs on KMK!
|
||||
|
||||
To summarize the code:
|
||||
|
||||
Switches
|
||||
Corresponding website shortcut when pressed for each key
|
||||
|
||||
Encoder #1
|
||||
Turning Clockwise -> Volume Up
|
||||
Turning Counterclockwise -> Volume Down
|
||||
Click Down -> Turns LEDs On/Off
|
||||
|
||||
Encoder #2
|
||||
Turning Clockwise -> Brightness Up
|
||||
Turning Counterclockwise -> Brightness Down
|
||||
Click Down -> Toggle Different LED Modes
|
||||
|
||||
OLED
|
||||
Display Custom GIFS
|
||||
Requires user to upload GIF file to microcontroller and name it user_gif.gif
|
||||
The screen will continuously display GIF unless changed or powered off
|
||||
Loading…
Add table
Reference in a new issue