aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2021-06-04 22:03:16 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2021-06-04 22:03:16 +0200
commit1ee6040a847d386afc7d7e64945c3a5ff87aa6d7 (patch)
tree43378e23978261e711c13465fdd00708668422ad
parent442709985fe3adfe9d2688167585ff37279d11b6 (diff)
downloadpicardy-1ee6040a847d386afc7d7e64945c3a5ff87aa6d7.tar.gz
picardy-1ee6040a847d386afc7d7e64945c3a5ff87aa6d7.tar.bz2
picardy-1ee6040a847d386afc7d7e64945c3a5ff87aa6d7.zip
eval-kit: port variable speed VFO from picardy
-rw-r--r--sw/eval-clock-cw-tx/src/state.rs19
-rw-r--r--sw/eval-clock-cw-tx/src/ui.rs30
2 files changed, 15 insertions, 34 deletions
diff --git a/sw/eval-clock-cw-tx/src/state.rs b/sw/eval-clock-cw-tx/src/state.rs
index 87527bf..44c64d2 100644
--- a/sw/eval-clock-cw-tx/src/state.rs
+++ b/sw/eval-clock-cw-tx/src/state.rs
@@ -13,13 +13,6 @@ pub enum VFOSelection {
B,
}
-#[derive(Clone)]
-pub enum TuneSpeed {
- Slow,
- Mid,
- Fast
-}
-
#[derive(PartialEq, Eq, Clone, Copy)]
pub enum CWMode {
StraightKey,
@@ -52,7 +45,6 @@ pub struct State {
pub vfo_b : u32,
pub vfo_sel : VFOSelection,
pub mode : Mode,
- pub tune_speed : TuneSpeed,
pub sequence_state : SequenceState,
pub update_disp_counter : u8,
pub cw_wpm : u32,
@@ -66,10 +58,9 @@ impl State {
vfo_sel : VFOSelection::A,
vfo_a : INITIAL_VFO,
vfo_b : INITIAL_VFO,
- tune_speed : TuneSpeed::Mid,
sequence_state : SequenceState::Rx,
update_disp_counter : 0,
- cw_wpm : 12,
+ cw_wpm : 14,
}
}
@@ -97,14 +88,6 @@ impl State {
}
}
- pub fn vfo_incr(&self) -> i32 {
- match self.tune_speed {
- TuneSpeed::Slow => 10,
- TuneSpeed::Mid => 200,
- TuneSpeed::Fast => 1000,
- }
- }
-
pub fn allow_feldhell_keying(&self) -> bool {
self.sequence_state == SequenceState::Tx(SequenceMode::FeldHell)
}
diff --git a/sw/eval-clock-cw-tx/src/ui.rs b/sw/eval-clock-cw-tx/src/ui.rs
index 38355e5..809dd8d 100644
--- a/sw/eval-clock-cw-tx/src/ui.rs
+++ b/sw/eval-clock-cw-tx/src/ui.rs
@@ -47,6 +47,8 @@ struct ButtonState {
pub enc : bool,
}
+const VFO_INCR : i32 = 2;
+
impl ButtonState {
fn edge_detection(&self, old_state : &ButtonState) -> ButtonState {
ButtonState {
@@ -182,11 +184,6 @@ impl UI {
}
if button_updates.d {
- state.tune_speed = match state.tune_speed {
- TuneSpeed::Slow => TuneSpeed::Mid,
- TuneSpeed::Mid => TuneSpeed::Fast,
- TuneSpeed::Fast => TuneSpeed::Slow,
- };
result.display_update = true;
}
@@ -204,26 +201,33 @@ impl UI {
result
}
- pub fn update_encoder(&mut self, state: &mut State, delta : i32) {
+ pub fn update_encoder(&mut self, state: &mut State, counter_delta : i32) {
+
+ let delta = (17 * counter_delta + 3 * (counter_delta * counter_delta * counter_delta))/20;
+
match state.ui_sel {
UISelection::VFO => {
match state.vfo_sel {
VFOSelection::A => {
- state.vfo_a = (state.vfo_a as i32 + delta * state.vfo_incr()) as u32;
+ state.vfo_a = (state.vfo_a as i32 + delta * VFO_INCR) as u32;
},
VFOSelection::B => {
- state.vfo_b = (state.vfo_b as i32 + delta * state.vfo_incr()) as u32;
+ state.vfo_b = (state.vfo_b as i32 + delta * VFO_INCR) as u32;
},
}
},
UISelection::Mode => {
match state.mode {
Mode::CW(CWMode::Iambic) => {
- let mut new_wpm = state.cw_wpm as i32 + delta / 4;
+ let mut new_wpm = state.cw_wpm as i32 + counter_delta / 4;
if new_wpm < 1 {
new_wpm = 1;
}
+ if new_wpm > 40 {
+ new_wpm = 40;
+ }
+
let wpm = new_wpm as u32;
state.cw_wpm = wpm;
state.mode = Mode::CW(CWMode::Iambic);
@@ -262,13 +266,7 @@ pub fn update_disp<T: hd44780_driver::bus::DataBus>(lcd: &mut HD44780<T>, state:
Mode::FeldHell => "HEL",
};
- let speed = match state.tune_speed {
- TuneSpeed::Slow => "SLO",
- TuneSpeed::Mid => "MID",
- TuneSpeed::Fast => "FST",
- };
-
- write!(string, "{} {}", mode, speed).unwrap();
+ write!(string, "{} ", mode).unwrap();
lcd.set_cursor_pos(40, delay).unwrap();
lcd.write_str(&string, delay).unwrap();