-
Notifications
You must be signed in to change notification settings - Fork 108
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 #116 from michalpokusa/layout-write-delay
KeyboardLayout.write() delay parameter
- Loading branch information
Showing
4 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
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
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
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
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 @@ | ||
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries | ||
# SPDX-License-Identifier: MIT | ||
|
||
import time | ||
import board | ||
import digitalio | ||
import usb_hid | ||
|
||
from adafruit_hid.keyboard import Keyboard | ||
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS | ||
|
||
keyboard = Keyboard(usb_hid.devices) | ||
layout = KeyboardLayoutUS(keyboard) | ||
|
||
|
||
# define buttons. these can be any physical switches/buttons, but the values | ||
# here work out-of-the-box with a CircuitPlayground Express' A and B buttons. | ||
slow_write = digitalio.DigitalInOut(board.D4) | ||
slow_write.direction = digitalio.Direction.INPUT | ||
slow_write.pull = digitalio.Pull.DOWN | ||
|
||
fast_write = digitalio.DigitalInOut(board.D5) | ||
fast_write.direction = digitalio.Direction.INPUT | ||
fast_write.pull = digitalio.Pull.DOWN | ||
|
||
while True: | ||
# Write `Hello World!` slowly | ||
if slow_write.value: | ||
layout.write("Hello World!", delay=0.2) | ||
|
||
# Write `Hello World!` normally | ||
elif fast_write.value: | ||
layout.write("Hello World!") | ||
|
||
time.sleep(0.1) |