aboutsummaryrefslogtreecommitdiffstats
path: root/sw/eval-clock-cw-tx/src/ui.rs
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 /sw/eval-clock-cw-tx/src/ui.rs
parent442709985fe3adfe9d2688167585ff37279d11b6 (diff)
downloadpicardy-1ee6040a847d386afc7d7e64945c3a5ff87aa6d7.tar.gz
picardy-1ee6040a847d386afc7d7e64945c3a5ff87aa6d7.tar.bz2
picardy-1ee6040a847d386afc7d7e64945c3a5ff87aa6d7.zip
eval-kit: port variable speed VFO from picardy
Diffstat (limited to 'sw/eval-clock-cw-tx/src/ui.rs')
-rw-r--r--sw/eval-clock-cw-tx/src/ui.rs30
1 files changed, 14 insertions, 16 deletions
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();