aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sw/picardy/src/cw.rs16
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
}