-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add networktables keyboard test
- Loading branch information
1 parent
910217b
commit 1e3ab78
Showing
1 changed file
with
21 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import time | ||
import ntcore # pip install robotpy | ||
import keyboard # pip install keyboard | ||
|
||
inst = ntcore.NetworkTableInstance.getDefault() | ||
table = inst.getTable("keyboard") | ||
inst.startClient4("keyboard") | ||
|
||
# pick one of these | ||
# inst.setServer("10.te.am.2") | ||
# inst.setServerTeam(4096) | ||
# inst.startDSClient() | ||
|
||
while not inst.isConnected(): | ||
print("not connected") | ||
time.sleep(1) | ||
|
||
while True: | ||
event = keyboard.read_event() | ||
if event.name: | ||
table.putBoolean(event.name, event.event_type == keyboard.KEY_DOWN) |