pykob.kob - MorseKOB/PyKOB GitHub Wiki
pykob.kob — key and sounder support
Source code: pykob/kob.py
This module defines a class whose objects correspond to a key and sounder. Either or both may be attached to the computer by a serial port.
- Key inputs can be processed synchronously by using the key function, or asynchronously by specifying the optional callback parameter.
- The speakers may be used as a simulated sounder, in addition to or instead of a real sounder, by setting the audio parameter to True.
- The echo parameter should be set to True if a sounder driver is used rather than a loop interface.
- This module requires pySerial if the serial port is used, and PyAudio if the simulated sounder is used.
KOB class
class pykob.kob.KOB(port=None, audio=False, echo=False, callback=None)
- port: device name or None; typical device names are 'COM3' for Windows or '/dev/ttyUSB0' for Linux
- audio: send simulated sounder audio to the speakers (True or False)
- echo: cause sounder output to follow key input (True or False)
- callback: function called whenever a code sequence is received from the key
KOB methods
KOB.key()
- returns a code sequence received from the key
KOB.sounder(code)
- code: the code sequence to be sent to the sounder
KOB.callback(code)
- code: a code sequence received from the key