Skip to content

Python Guide

Chris Vig edited this page Sep 15, 2025 · 5 revisions

This page documents the Python scripts found in the scripts directory. These scripts are the primary way of configuring and interacting with the SuperKey hardware.

A standalone library (superkey) is provided, which acts as a wrapper for SuperKey's serial interface. The scripts directory also contains several handy standalone scripts:

  • autokey.py allows controlling the keyer directly with your keyboard.
  • interactive.py creates an "interactive" environment for interfacing with SuperKey with a Python REPL-like experience.

The superkey library and the standalone scripts have no dependencies other than the built-in Python standard library. A future improvement is to improve the packaging for this library, to make it more consumable by other Python projects.

AutoKeyer (autokey.py)

The autokey.py script provides a convenient interface for using the keyer's autokey mode. When using the keyer to actively work the radio, this is normally the script you'll want to have running on your computer — it provides convenient access to send text and to set the most commonly-used options of the keyer, like the WPM.

The following command line arguments are supported:

  • --port - Serial port name.
  • --baudrate - Serial port baud rate. (This should always be 19200.)
  • --timeout - Serial port timeout, in seconds.
  • --immediate - Activate "immediate" mode.
  • --silent - If specified, input will not be echoed back to the console (only applicable to immediate mode).

There are two primary modes of operation, as discussed below.

Normal / Buffered Mode

In normal mode, you enter messages line-by-line in a console-like environment. Each message can be proof-read and edited, and is not sent to the keyer until the Enter key is pressed. In addition to text entry, several commands are supported, including:

  • :q or :quit or :exit - exits the keyer.
  • :! or :panic - immediately stops all keyer output.
  • :wpm - prints current WPM.
  • :wpm [value] - sets WPM to value.
  • :buzzer - prints current buzzer state.
  • :buzzer [on/off] - turns buzzer on or off.
  • :buzzer frequency [freq] - sets the buzzer's audio frequency.
  • :paddle - prints the current paddle mode.
  • :paddle [mode] - sets paddle mode to mode.
  • :trainer - prints the current trainer mode status.
  • :trainer [on/off] - enables or disables trainer mode.
  • :qm [num] - keys the specified quick message.
  • :qm get [num] - prints the specified quick message.
  • :qm set [num] [text] - sets the specified quick message.

Immediate Mode

Immediate mode is activated by invoking the script with the --immediate argument. In immediate mode, the script accepts user input from the keyboard, and immediately forwards it on to the keyer to be keyed. Any key press which is a valid Morse code character will be queued, and immediately transmitted if the queue is empty. Any key press which is not a valid Morse code character is ignored.

The following special key presses are supported:

  • Backspace - Immediately stops keying any string which was previously entered. This can be used to "cancel" input.
  • Escape - Exits the tool.

Notes

Prosigns

The autokey script supports prosigns using the \ key. For example, the string \ar\ will be keyed · — · — ·, while the string \sos\ will be keyed · · · — — — · · · (with no spaces between the letters). This works in both normal and immediate modes.

Interactive Python Environment (interactive.py)

The interactive.py script can be used to quickly enter a REPL-like environment for interfacing with your SuperKey. It supports the following command line arguments to set up the serial connection:

  • --port - Serial port name.
  • --baudrate - Serial port baud rate. (This should always be 19200.)
  • --timeout - Serial port timeout, in seconds.

In most cases, the only required argument will be --port.

Once the interactive session has started, you can interact with your SuperKey by directly calling any public instance function declared on the Interface class. No instance is required.

>>> set_buzzer_enabled(True)
>>> get_buzzer_frequency()
700
>>> set_buzzer_frequency(800)
>>> autokey('cq cq de n0vig n0vig k')

The dir() function may be used to get a list of available functions.

Clone this wiki locally