Skip to main content

Controller

Struct Controller 

Source
pub struct Controller<const B: usize = MAX_BUTTONS, const E: usize = MAX_ENCODERS> { /* private fields */ }
Expand description

Unified timing controller. Owns all stateful input processing.

§Usage

let mut ctrl = Controller::new();
// On each input poll:
let result = ctrl.process(event, now_ms, &config);
// Send result.midi via MIDI output
// Update display from result.display
// Re-render LEDs if result.leds_changed

Implementations§

Source§

impl<const B: usize, const E: usize> Controller<B, E>

Source

pub fn new() -> Self

Source

pub fn with_state(store: PresetStateStore<B, E>) -> Self

Create with a restored state store (from EEPROM/persistence).

Source

pub fn process<const A: usize>( &mut self, event: Event, now_ms: u32, config: &Config<B, E, A>, ) -> Output

Process a single input event. Returns all MIDI output, display events, and flags. System actions (preset switch, tap tempo) are handled internally.

Source

pub fn button_held(&self) -> bool

Returns true if any button is currently held.

Source

pub fn button_states(&self) -> &[bool; B]

Returns the current button active state (toggle ON / momentary held).

Source

pub fn active_preset(&self) -> u8

Get the active preset index.

Source

pub fn encoder_values(&self) -> [u8; E]

Get the encoder values.

Source

pub fn snapshot_store(&self) -> PresetStateStore<B, E>

Get a snapshot of the state store (with current working state saved). Use this for persistence — the caller decides the serialization format.

Source

pub fn select_preset<const A: usize>( &mut self, preset_idx: u8, config: &Config<B, E, A>, ) -> Output

Manually switch to a preset (e.g., on boot or from external command). Returns on_enter + recall MIDI in the result.

Source

pub fn set_encoder_value(&mut self, index: usize, value: u8)

Set encoder value (for initial state setup from config defaults).

Trait Implementations§

Source§

impl<const B: usize, const E: usize> Default for Controller<B, E>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<const B: usize, const E: usize> Freeze for Controller<B, E>

§

impl<const B: usize, const E: usize> RefUnwindSafe for Controller<B, E>

§

impl<const B: usize, const E: usize> Send for Controller<B, E>

§

impl<const B: usize, const E: usize> Sync for Controller<B, E>

§

impl<const B: usize, const E: usize> Unpin for Controller<B, E>

§

impl<const B: usize, const E: usize> UnsafeUnpin for Controller<B, E>

§

impl<const B: usize, const E: usize> UnwindSafe for Controller<B, E>

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.