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§
Sourcefn now(&self) -> Instant
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.
Sourcefn delay(&self, d: Duration)
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.
Sourcefn read_input(&mut self) -> Option<InputState>
fn read_input(&mut self) -> Option<InputState>
Read gamepad input.
Sourcefn log_debug<D: Display>(&self, src: &str, msg: D)
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.
Sourcefn log_error<D: Display>(&self, src: &str, msg: D)
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.
fn open_dir(&mut self, path: &[&str]) -> Result<Self::Dir, FSError>
fn network(&mut self) -> Self::Network
Sourcefn serial(&self) -> Self::Serial
fn serial(&self) -> Self::Serial
Access the USB serial port.
Both read and write operations are non-blocking.
Sourcefn has_headphones(&mut self) -> bool
fn has_headphones(&mut self) -> bool
Returns true if headphones are connected.
Sourcefn get_audio_buffer(&mut self) -> &mut [i16]
fn get_audio_buffer(&mut self) -> &mut [i16]
Get a writable slice of free audio buffer region.
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.