Skip to content

Python Guide

Chris Vig edited this page Sep 6, 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.
  • example.py shows a demonstration of using the superkey library, as well as demonstrating some of SuperKey's hardware features.
  • interactive.py creates an "interactive" environment for interfacing with SuperKey with a console-like REPL 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

The autokey.py script provides a convenient interface for using the keyer's autokey mode. 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 modes of operation, as discussed below.

Normal / Buffered Mode

Immediate Mode

Immediate mode is activated by invoking the script with theThe autokey.py script accepts user input from the keyboard, and immediately forwards it on to the keyer to be keyed. 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.

The following notes should be observed in immediate mode:

  • Characters are queued for transmission as they are typed.
  • Newlines may be typed to help separate messages, but are ignored by the keyer.
  • Prosigns may be entered by preceding the characters with a backslash.
    • (e.g., entering \ar will result in the prosign · — · — · being keyed).
  • Prosigns with between 2 and 9 characters are supported by immediately following the backslash with a digit.
    • (e.g., entering \3sos will result in the prosign · · · — — — · · · being keyed).

Interactive Python Environment

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