Skip to main content

Crate radio_utils_cw_decoder

Crate radio_utils_cw_decoder 

Source
Expand description

Streaming CW (Morse code) decoder.

no_std, no allocator. All state lives inline in Decoder: a packed u8 accumulator for the in-flight character and a heapless::Deque<u8, 32> ring of recently decoded ASCII bytes.

§Usage

Feed the decoder with Decoder::on_transition whenever the keyed line flips (key-down → key-up or vice versa), passing the current timestamp in microseconds and the sender’s WPM. Call Decoder::poll periodically (e.g. every UI tick) so the decoder can flush a completed character once the inter-character silence threshold elapses — without Decoder::poll the trailing character of a transmission would only appear when the next key-down arrives.

§Timing model

At wpm words per minute the canonical dit duration is 1_200_000 / wpm microseconds. Standard Morse spacing is:

elementdits
dit pulse1
dah pulse3
intra-character gap1
inter-character gap3
inter-word gap7

The decoder uses these thresholds:

  • pulse ≥ 2 × dit → dah (otherwise dit)
  • gap ≥ 2 × dit → emit the in-flight character (inter-character)
  • gap ≥ 6 × dit → also emit a space (inter-word; 6 leaves a one-dit tolerance below the canonical 7-dit boundary so slightly-clipped sending still produces word breaks)

Structs§

Decoder
Streaming CW decoder. See the module docs for usage.

Constants§

HISTORY_CAPACITY
Maximum decoded characters retained in the recent-history ring. Older characters are evicted from the front on overflow.