Device

Trait Device 

Source
pub trait Device {
    type Network: Network;
    type Serial: Serial;
    type Dir: Dir;

    // Required methods
    fn now(&self) -> Instant;
    fn delay(&self, d: Duration);
    fn read_input(&mut self) -> Option<InputState>;
    fn log_debug<D: Display>(&self, src: &str, msg: D);
    fn log_error<D: Display>(&self, src: &str, msg: D);
    fn random(&mut self) -> u32;
    fn open_dir(&mut self, path: &[&str]) -> Result<Self::Dir, FSError>;
    fn network(&mut self) -> Self::Network;
    fn serial(&self) -> Self::Serial;
    fn has_headphones(&mut self) -> bool;
    fn get_audio_buffer(&mut self) -> &mut [i16];
    fn get_battery_status(&mut self) -> Option<BatteryStatus>;
}

Required Associated Types§

Required Methods§

Source

fn now(&self) -> Instant

The current time.

Should be precise enough for adjusting the delay between frames.

Usually implemented as rtic_time.Monotonic. May also sometimes be implemented as rtic_monotonic.Monotonic.

Source

fn delay(&self, d: Duration)

Suspends the current thread for the given duration.

Should be precise enough for adjusting the delay between frames.

Usually implemented as embedded_hal.DelayNs.

Source

fn read_input(&mut self) -> Option<InputState>

Read gamepad input.

Source

fn log_debug<D: Display>(&self, src: &str, msg: D)

Log a debug message into console.

On hosted environments, it just prints into stdout. On embedded systems, use defmt.

Source

fn log_error<D: Display>(&self, src: &str, msg: D)

Log an error into console.

On hosted environments, it just prints into stderr. On embedded systems, use defmt.

Source

fn random(&mut self) -> u32

Get a random number.

Source

fn open_dir(&mut self, path: &[&str]) -> Result<Self::Dir, FSError>

Source

fn network(&mut self) -> Self::Network

Source

fn serial(&self) -> Self::Serial

Access the USB serial port.

Both read and write operations are non-blocking.

Source

fn has_headphones(&mut self) -> bool

Returns true if headphones are connected.

Source

fn get_audio_buffer(&mut self) -> &mut [i16]

Get a writable slice of free audio buffer region.

Source

fn get_battery_status(&mut self) -> Option<BatteryStatus>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§