Skip to content

Commit

Permalink
start on fluid display rs
Browse files Browse the repository at this point in the history
  • Loading branch information
vk2seb committed Mar 3, 2024
1 parent a81a09e commit 966d49a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
24 changes: 23 additions & 1 deletion firmware/polyvec-lib/src/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,27 @@ where
}
}

if opts.screen.value == opt::Screen::Fluid {
Rectangle::new(Point::new(0, 0), Size::new(128, 64))
.into_styled(thin_stroke)
.draw(d)?;

let n_width = 8;
for (n_touch, touch) in touch.iter().enumerate() {
let px = 8 + 16 * (n_touch % n_width) as i32;
let py = 8 + 16 * (n_touch / n_width) as i32;
Line::new(Point::new(px-1, py),
Point::new(px+1, py))
.into_styled(thin_stroke)
.draw(d)?;
Line::new(Point::new(px, py-1),
Point::new(px, py+1))
.into_styled(thin_stroke)
.draw(d)?;
}

}

draw_options(d, &opts)?;

let mut s: String<16> = String::new();
Expand Down Expand Up @@ -395,7 +416,7 @@ mod tests {
let mut opts = opt::Options::new();
let mut voice_manager = VoiceManager::new();
let scope_samples = [0i16; 128];
let mut touch = [0u8; 8];
let mut touch = [0u8; 32];
touch[1] = 128;
touch[4] = 255;

Expand All @@ -408,6 +429,7 @@ mod tests {
(Screen::Adsr, "adsr.png"),
(Screen::Scope, "scope.png"),
(Screen::Touch, "touch.png"),
(Screen::Fluid, "fluid.png"),
];

for (screen, filename) in screens {
Expand Down
23 changes: 23 additions & 0 deletions firmware/polyvec-lib/src/opt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub enum Screen {
Adsr,
Scope,
Touch,
Fluid,
}

#[derive(Clone)]
Expand All @@ -82,6 +83,12 @@ pub struct TouchOptions {
pub led_mirror: EnumOption<TouchLedMirror>,
}

#[derive(Clone)]
pub struct FluidOptions {
pub selected: Option<usize>,
pub fluid_speed: NumOption<u32>,
}

macro_rules! impl_option_view {
($struct_name:ident, $($field:ident),*) => {
impl OptionView for $struct_name {
Expand Down Expand Up @@ -115,6 +122,9 @@ impl_option_view!(ScopeOptions,
impl_option_view!(TouchOptions,
note_control, led_mirror);

impl_option_view!(FluidOptions,
fluid_speed);


#[derive(Clone)]
pub struct Options {
Expand All @@ -124,6 +134,7 @@ pub struct Options {
pub adsr: AdsrOptions,
pub scope: ScopeOptions,
pub touch: TouchOptions,
pub fluid: FluidOptions,
}

impl Options {
Expand Down Expand Up @@ -199,6 +210,16 @@ impl Options {
name: "led".into(),
value: TouchLedMirror::MirrorOn,
},
},
fluid: FluidOptions {
selected: None,
fluid_speed: NumOption{
name: "speed".into(),
value: 1000,
step: 100,
min: 100,
max: 5000,
},
}
}
}
Expand Down Expand Up @@ -241,6 +262,7 @@ impl Options {
Screen::Adsr => &self.adsr,
Screen::Scope => &self.scope,
Screen::Touch => &self.touch,
Screen::Fluid => &self.fluid,
}
}

Expand All @@ -250,6 +272,7 @@ impl Options {
Screen::Adsr => &mut self.adsr,
Screen::Scope => &mut self.scope,
Screen::Touch => &mut self.touch,
Screen::Fluid => &mut self.fluid,
}
}
}
Expand Down

0 comments on commit 966d49a

Please sign in to comment.