cwkeyer

package module
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2024 License: BSD-2-Clause Imports: 7 Imported by: 3

README

cwkeyer

Go Report Card License

CWKeyer is a library for sending morse code (CW) in Go. The library uses an asynchronous send queue that allows the caller to adjust the speed, stop a message, or send additional messages while a previous message is still being keyed.

Interface Compatibility

At the moment, the library has a Key that beeps and a Key that sets the DTR signal on a serial port. The latter one does everything I need to interface with my radios. If you need something else, make an issue or pull request. I'm happy to make this useful to more people.

Usage Example & Documentation

The usage example demonstrates the main functionalities. The documentation comments are fairly complete - Look to the documentation for everything else you can do.

This library is also used in the K3GDS REKL.

Documentation

Overview

CWKeyer is a library for sending morse code (CW). The library uses an asynchronous send queue that allows the caller to adjust the speed, stop a message, or send additional messages while a previous message is still being keyed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsKeyable

func IsKeyable(r rune) bool

IsKeyable accepts a rune and returns true if the rune is keyable as CW.

Types

type BeepKey

type BeepKey struct {
	// contains filtered or unexported fields
}

func NewBeepKey

func NewBeepKey(freq float64, sampleRate int, bufferSize int) (*BeepKey, error)

NewBeepKey creates a BeepKey. Suggested values based on testing: freq=700, sampleRate=48000, bufferSize=1200.

func (*BeepKey) CloseSpeaker

func (b *BeepKey) CloseSpeaker()

func (*BeepKey) Down

func (b *BeepKey) Down() error

func (*BeepKey) Up

func (b *BeepKey) Up() error

type Key

type Key interface {
	Down() error // Called when the keyer keys down
	Up() error   // Called when the keyer keys up
}

Key abstracts a CW key into a type with methods called when the key is circuit opened or closed.

type Keyer

type Keyer struct {
	// contains filtered or unexported fields
}

func New

func New(speed SpeedProvider, key Key) *Keyer

New creates a Keyer.

func (*Keyer) DrainSendQueue

func (k *Keyer) DrainSendQueue()

DrainSendQueue interrupts the current message by draining the send queue, returning when it is empty.

func (*Keyer) ProcessSendQueue

func (k *Keyer) ProcessSendQueue(returnOnEmptyQueue bool) error

ProcessSendQueue processes the send queue. A bool is accepted to indicate if ProcessSendQueue should return when the queue is empty. A method error from the Key will always cause a return.

func (*Keyer) QueueMessage

func (k *Keyer) QueueMessage(message string) error

QueueMessage adds a string to the send queue. An error is returned if the string contains an unsupported rune.

func (*Keyer) QueueRune

func (k *Keyer) QueueRune(r rune) error

QueueRune adds a rune to the send queue. An error is returned if the rune is unsupported.

func (*Keyer) SendQueueIsEmpty

func (k *Keyer) SendQueueIsEmpty() bool

SendQueueIsEmpty returns true when there is nothing waiting to be sent.

type SerialDTRKey

type SerialDTRKey struct {
	// contains filtered or unexported fields
}

func NewSerialDTRKey

func NewSerialDTRKey(portName string, baudrate int) (*SerialDTRKey, error)

NewSerialDTRKey creates a SerialDTRKey on the specified port. Suggested values based on testing: baudrate=115200.

func (*SerialDTRKey) ClosePort

func (s *SerialDTRKey) ClosePort() error

func (*SerialDTRKey) Down

func (s *SerialDTRKey) Down() error

func (*SerialDTRKey) Up

func (s *SerialDTRKey) Up() error

type SpeedProvider

type SpeedProvider interface {
	Speed() int
}

SpeedProvider provides the speed each time a CW event is keyed.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL