From e4e52a365ad9e8964756322c07c25383d999dba1 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 31 Jan 2021 21:25:26 +0100 Subject: Fix keyer timing --- sw/picardy/src/cw.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sw/picardy/src/cw.rs b/sw/picardy/src/cw.rs index 4ebebf9..045ef15 100644 --- a/sw/picardy/src/cw.rs +++ b/sw/picardy/src/cw.rs @@ -62,7 +62,7 @@ fn other_pressed(sign: MorseSign, dot_pressed: bool, dash_pressed: bool) -> bool } } -#[derive(PartialEq, Eq, Clone, Copy)] +#[derive(Eq, Clone, Copy)] enum KeyerState { Idle, Beep{current: MorseSign, next: Option}, @@ -70,6 +70,18 @@ enum KeyerState { LastPause{next: Option}, } +impl PartialEq for KeyerState { + fn eq(&self, rhs: &Self) -> bool { + match (self, rhs) { + (Self::Idle, Self::Idle) => true, + (Self::Beep{current : c1, next : _}, Self::Beep{current : c2, next : _}) => c1 == c2, + (Self::Pause{current : c1, next : _}, Self::Pause{current : c2, next : _}) => c1 == c2, + (Self::LastPause{next : _}, Self::LastPause{next : _}) => true, + _ => false, + } + } +} + pub struct Keyer { // All durations are in ticks dot_length : u32, @@ -179,8 +191,8 @@ impl Keyer { if next_state != self.state { self.time_last_state_change = ticks_now; - self.state = next_state; } + self.state = next_state; transmit } -- cgit v1.2.3