"Two Switch Scanning" is a technique used in Assistive Technology where the user will use a two switches to jump between options and activate the option they'd like. Often, the switches are called "Next" and "Select", but this is an approach that should seem familiar to most web users: it's basically the equivalent of using the Tab key to find the button you want and then the Enter key to activate it.
The approach is commonly used in operating systems like iOS, Android and MacOS (Windows has yet to add switch support!), and is supported by all of the major Speech Generating Devices (SGDs) including Open Source tools like WeaveChat and CoughDrop as well as pricier commercial offerings like TouchChat and LAMP from PRC, and Snap+Core from Tobii.
With the TRRS Trinkey, we can access all of that Two Switch Scanning goodness without having to have a dedicated device or buy an expensive Switch Interface! Let's see how!
Assembly couldn't be simpler: just connect the wires between the components - no soldering needed!
- Connect your "Next" switch (labeled B here) to the Red jack on the Stereo splitter
- Connect your "Select" switch (labeled A here) to the White jack on the Stereo Splitter
- Connect the TRS Stereo end of the splitter to the TRRS Trinkey's 3.5mm jack
- [Optional] Connect the USB A plug of the TRRS Trinkey to a USB C or Lightning OTG adapter (if using a tablet or phone)
- Connect the OTG Adapter (or the USB A plug if no adapter is used) into your PC/Mac/phone/tablet.
CircuitPython Usage
To use with CircuitPython, you need to first install the HID library into the lib folder onto your CIRCUITPY drive. Then you need to update code.py with the example script.
Thankfully, we can do this in one go. In the example below, click the Download Project Bundle button below to download the necessary libraries and the code.py file in a zip file. Extract the contents of the zip file, and copy the entire lib folder and the code.py file to your CIRCUITPY drive.
# SPDX-FileCopyrightText: 2024 Bill Binko # # SPDX-License-Identifier: MIT import digitalio import board import keypad import usb_hid from adafruit_hid.keyboard import Keyboard from adafruit_hid.keycode import Keycode #We are only using Ring1 and Tip as input - set Ring2 & sleeve to GND ground = digitalio.DigitalInOut(board.RING_2) ground.direction=digitalio.Direction.OUTPUT ground.value = False ground2 = digitalio.DigitalInOut(board.SLEEVE) ground2.direction=digitalio.Direction.OUTPUT ground2.value = False # Initialize Keyboard to send HID to host kbd = Keyboard(usb_hid.devices) #Setup which keystrokes to send on each switch press #Any Keycodes can be sent #Common AT device keystrokes: # Web Browser: Enter/Space #keycodeList = [Keycode.ENTER, Keycode.SPACE] # Speech Devices (Tobii/PRC): ONE/TWO #keycodeList = [Keycode.ONE, Keycode.TWO] # iOS Switch Control: A/B (reads only from "Switch Keyboard" not other keyboards) keycodeList = [Keycode.A, Keycode.B] #Use Keypad library to read buttons wired between ground and Tip/Ring1 keys = keypad.Keys((board.TIP,board.RING_1), value_when_pressed=False, pull=True) #Main loop for events while True: event=keys.events.get() if event: if event.pressed: kbd.press(keycodeList[event.key_number]) else: kbd.release(keycodeList[event.key_number])
Our CircuitPython code is very similar to the "AT Switch Example" from the previous section. It sends two keycodes (by default "A" and "B") as an HID Keyboard when the two AT Switches are pressed. We add three important details to make things work a bit smoother with AT systems:
- We use the keypad library to handle debouncing, pullup management and state management for us.
- We've restructured the code to send "press" and "release" HID messages when the user presses and releases the switches. This allows for systems like iOS that support "long press" vs. "short press" to work
- We've omitted the insertion detection for clarity - but it can be added back as an exercise for the reader
Configure iOS Switch Control
Configuring Switch Control on iOS or iPadOS is beyond the scope of this guide: luckily, our friend, Chris Young, wrote a full Guide on the subject! Check out this section which details how to configure Switch Control.
Remember, you'll be using the USB switches instead of the Bluetooth options, so you can skip the pairing process. Otherwise, all the steps and features apply.
Using iOS Switch Control
Now, your iPhone or iPad can be controlled with just two switches. You can type, activate buttons, even using a "gliding cursor" to grab and move items around the screen! You can configure each button to have different actions for "short" and "long" presses, you can even write macros and "recipes" to automate your actions.
For a great example of what a pro can do using switch control, check out Todd Stabelfeldt's amazing YouTube video clip:
Speech Generating Devices
Unfortunately, Speech Generating Devices (SGDs) and the software that runs on them is notoriously expensive. So, there's not a great way to demonstrate that for you, other than to demonstrate the device on CoughDrop (which used to be Open Source) in the video above and to assure you that all of the major Speech Software systems support two switch scanning and will work with a keyboard-style switch interface like ours.
Here's some videos to help with a few popular SGD software systems:
- Setting up Scanning In CoughDrop
- LAMP Word For Life Scanning Settings
- All about Scanning in Tobii Snap+Core
Text editor powered by tinymce.