diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2021-01-31 21:25:26 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2021-01-31 21:25:26 +0100 |
commit | e4e52a365ad9e8964756322c07c25383d999dba1 (patch) | |
tree | ca9a86d11f7f42ab075ac1066884226e260ea9fd /sw | |
parent | 536f36abca366d24ff863c3781b5a037c408c35b (diff) | |
download | picardy-e4e52a365ad9e8964756322c07c25383d999dba1.tar.gz picardy-e4e52a365ad9e8964756322c07c25383d999dba1.tar.bz2 picardy-e4e52a365ad9e8964756322c07c25383d999dba1.zip |
Fix keyer timing
Diffstat (limited to 'sw')
-rw-r--r-- | sw/picardy/src/cw.rs | 16 |
1 files 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<MorseSign>}, @@ -70,6 +70,18 @@ enum KeyerState { LastPause{next: Option<MorseSign>}, } +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 } |