Struct RibbonController

Source
pub struct RibbonController<const BUFFER_CAPACITY: usize> { /* private fields */ }
Expand description

A synthesizer ribbon controller is represented here.

It is expected to use the provided sample_rate_to_capacity(sr) const function to calculate the const generic BUFFER_CAPACITY argument. If in the future Rust offers a way to calculate the buffer capacity in a more straightforward way this should be changed.

Implementations§

Source§

impl<const BUFFER_CAPACITY: usize> RibbonController<BUFFER_CAPACITY>

Source

pub fn new( sample_rate_hz: f32, softpot_ohms: f32, dropper_resistor_ohms: f32, pullup_resistor_ohms: f32, ) -> Self

Ribbon::new(sr, sp, dr, pu) is a new Ribbon controller

§Arguments:
  • sample_rate_hz - The sample rate in Hertz

  • softpot_ohms - The end-to-end resistance of the softpot used, typically 10k or 20k

  • dropper_resistor_ohms - The value of the resistor which sits between the top of the softpot and the positive voltage reference.

  • pullup_resistor_ohms - The value of the wiper pullup reistor, shoudl be at least 10x softpot_ohms or larger

Source

pub fn poll(&mut self, raw_adc_value: f32)

rib.poll(raw_adc_value) updates the controller by polling the raw ADC signal. Must be called at the sample rate

§Arguments
  • raw_adc_value - the raw ADC signal to poll in [0.0, 1.0], represents the finger position on the ribbon. Inputs outside of the range [0.0, 1.0] are undefined. Note that a small portion of the range at the top near +1.0 is expected to be “eaten” by the series resistor
Source

pub fn value(&self) -> f32

rib.value() is the current position value of the ribbon in [0.0, 1.0]

If the user’s finger is not pressing on the ribbon, the last valid value before they lifted their finger is returned.

The value is expanded to take up the whole [0.0, 1.0]range, so even though the input will not quite reach +1.0 at the top end (due to the series resistance) the output will reach or at least come very close to +1.0

Source

pub fn finger_is_pressing(&self) -> bool

rib.finger_is_pressing() is true iff the user is pressing on the ribbon.

Source

pub fn finger_just_pressed(&mut self) -> bool

rib.finger_just_pressed() is true iff the user has just pressed the ribbon after having not touched it.

Self clearing

Source

pub fn finger_just_released(&mut self) -> bool

rib.finger_just_released() is true iff the user has just lifted their finger off the ribbon.

Self clearing

Auto Trait Implementations§

§

impl<const BUFFER_CAPACITY: usize> Freeze for RibbonController<BUFFER_CAPACITY>

§

impl<const BUFFER_CAPACITY: usize> RefUnwindSafe for RibbonController<BUFFER_CAPACITY>

§

impl<const BUFFER_CAPACITY: usize> Send for RibbonController<BUFFER_CAPACITY>

§

impl<const BUFFER_CAPACITY: usize> Sync for RibbonController<BUFFER_CAPACITY>

§

impl<const BUFFER_CAPACITY: usize> Unpin for RibbonController<BUFFER_CAPACITY>

§

impl<const BUFFER_CAPACITY: usize> UnwindSafe for RibbonController<BUFFER_CAPACITY>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.