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:
| element | dits |
|---|---|
| dit pulse | 1 |
| dah pulse | 3 |
| intra-character gap | 1 |
| inter-character gap | 3 |
| inter-word gap | 7 |
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.