Struct ControllerScreen

Source
pub struct ControllerScreen { /* private fields */ }
Expand description

Controller LCD Console

Implementations§

Source§

impl ControllerScreen

Source

pub const MAX_COLUMNS: usize = 19usize

Maximum number of characters that can be drawn to a text line.

Source

pub const MAX_LINES: usize = 3usize

Number of available text lines on the controller before clearing the screen.

Source

pub fn clear_line(&mut self, line: u8) -> ControllerScreenWriteFuture<'_>

Clears the contents of a specific text line, waiting until the controller successfully clears the line. Lines are 1-indexed.

Controller text setting is a slow process, so calls to this function at intervals faster than 10ms on wired connection or 50ms over VEXnet will take longer to complete.

§Errors
§Examples
use vexide::prelude::*;

#[vexide::main]
async fn main(peripherals: Peripherals) {
    let mut controller = peripherals.primary_controller;

    // Write to line 0
    _ = controller.screen.set_text("Hello, world!", 0, 0).await;

    sleep(Duration::from_millis(500)).await;

    // Clear line 0
    _ = controller.screen.clear_line(0).await;
}
Source

pub fn try_clear_line(&mut self, line: u8) -> Result<(), ControllerError>

Attempts to clear the contents of a specific text line. Lines are 1-indexed. Unlike clear_line this function will fail if the controller screen is busy.

Controller text setting is a slow process, so updates faster than 10ms when on a wired connection or 50ms over VEXnet will not be applied to the controller.

§Errors
§Examples
use vexide::prelude::*;

#[vexide::main]
async fn main(peripherals: Peripherals) {
    let mut controller = peripherals.primary_controller;

    // Write to line 0
    _ = controller.screen.set_text("Hello, world!", 0, 0).await;

    sleep(Duration::from_millis(500)).await;

    // Clear line 0
    _ = controller.screen.try_clear_line(0);
}
Source

pub fn clear_screen(&mut self) -> ControllerScreenWriteFuture<'_>

Clears the whole screen, waiting until the controller successfully clears the screen.

This includes the default widget displayed by the controller if it hasn’t already been cleared.

Controller text setting is a slow process, so calls to this function at intervals faster than 10ms on wired connection or 50ms over VEXnet will take longer to complete.

§Errors
§Examples
use vexide::prelude::*;

#[vexide::main]
async fn main(peripherals: Peripherals) {
    let mut controller = peripherals.primary_controller;

    // Remove the default widget on the controller screen that displays match time.
    _ = controller.screen.clear_screen().await;
}
Source

pub fn try_clear_screen(&mut self) -> Result<(), ControllerError>

Clears the whole screen, including the default widget displayed by the controller if it hasn’t already been cleared. Unlike clear_screen this function will fail if the controller screen is busy.

Controller text setting is a slow process, so updates faster than 10ms when on a wired connection or 50ms over VEXnet will not be applied to the controller.

§Errors
§Examples
use vexide::prelude::*;

#[vexide::main]
async fn main(peripherals: Peripherals) {
    let mut controller = peripherals.primary_controller;

    // Remove the default widget on the controller screen that displays match time.
    _ = controller.screen.try_clear_screen();
}
Source

pub fn set_text( &mut self, text: impl AsRef<str>, line: u8, col: u8, ) -> ControllerScreenWriteFuture<'_>

Set the text contents at a specific row/column offset, waiting until the controller successfully writes the text. Both lines and columns are 1-indexed.

Controller text setting is a slow process, so calls to this function at intervals faster than 10ms on wired connection or 50ms over VEXnet will take longer to complete.

§Panics
  • Panics if line is greater than or equal to Self::MAX_LINES.
  • Panics if col is greater than or equal to Self::MAX_COLUMNS.
  • Panics if a NUL (0x00) character was found anywhere in the specified text.
§Errors
§Examples
use vexide::prelude::*;

#[vexide::main]
async fn main(peripherals: Peripherals) {
    let mut controller = peripherals.primary_controller;
    _ = controller.screen.set_text("Hello, world!", 0, 0).await;
    _ = controller.screen.set_text("Hello, world!", 1, 0).await;
}
Source

pub fn try_set_text( &mut self, text: impl AsRef<str>, line: u8, column: u8, ) -> Result<(), ControllerError>

Set the text contents at a specific row/column offset. Both lines and columns are 1-indexed. Unlike set_text this function will fail if the controller screen is busy.

Controller text setting is a slow process, so updates faster than 10ms when on a wired connection or 50ms over VEXnet will not be applied to the controller.

§Panics
  • Panics if line is greater than or equal to Self::MAX_LINES.
  • Panics if col is greater than or equal to Self::MAX_COLUMNS.
  • Panics if a NUL (0x00) character was found anywhere in the specified text.
§Errors
§Examples
use vexide::prelude::*;

#[vexide::main]
async fn main(peripherals: Peripherals) {
    let mut controller = peripherals.primary_controller;

    _ = controller.try_set_text("Hello, world!", 0, 0);
}

Trait Implementations§

Source§

impl Debug for ControllerScreen

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ControllerScreen

Source§

fn eq(&self, other: &ControllerScreen) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for ControllerScreen

Source§

impl StructuralPartialEq for ControllerScreen

Auto Trait Implementations§

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.