pub struct ControllerScreen { /* private fields */ }
Expand description
Controller LCD Console
Implementations§
Source§impl ControllerScreen
impl ControllerScreen
Sourcepub const MAX_COLUMNS: usize = 19usize
pub const MAX_COLUMNS: usize = 19usize
Maximum number of characters that can be drawn to a text line.
Sourcepub const MAX_LINES: usize = 3usize
pub const MAX_LINES: usize = 3usize
Number of available text lines on the controller before clearing the screen.
Sourcepub fn clear_line(&mut self, line: u8) -> ControllerScreenWriteFuture<'_> ⓘ
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
- A
ControllerError::Offline
error is returned if the controller is not connected.
§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;
}
Sourcepub fn try_clear_line(&mut self, line: u8) -> Result<(), ControllerError>
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
- A
ControllerError::Offline
error is returned if the controller is not connected. - A
ControllerError::WriteBusy
error is returned if a screen write occurred too quickly after the previous write attempt.
§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);
}
Sourcepub fn clear_screen(&mut self) -> ControllerScreenWriteFuture<'_> ⓘ
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
- A
ControllerError::Offline
error is returned if the controller is not connected.
§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;
}
Sourcepub fn try_clear_screen(&mut self) -> Result<(), ControllerError>
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
- A
ControllerError::Offline
error is returned if the controller is not connected. - A
ControllerError::WriteBusy
error is returned if a screen write occurred too quickly after the previous write attempt.
§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();
}
Sourcepub fn set_text(
&mut self,
text: impl AsRef<str>,
line: u8,
col: u8,
) -> ControllerScreenWriteFuture<'_> ⓘ
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 toSelf::MAX_LINES
. - Panics if
col
is greater than or equal toSelf::MAX_COLUMNS
. - Panics if a NUL (0x00) character was found anywhere in the specified text.
§Errors
- A
ControllerError::Offline
error is returned if the controller is not connected.
§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;
}
Sourcepub fn try_set_text(
&mut self,
text: impl AsRef<str>,
line: u8,
column: u8,
) -> Result<(), ControllerError>
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 toSelf::MAX_LINES
. - Panics if
col
is greater than or equal toSelf::MAX_COLUMNS
. - Panics if a NUL (0x00) character was found anywhere in the specified text.
§Errors
- A
ControllerError::Offline
error is returned if the controller is not connected. - A
ControllerError::WriteBusy
error is returned if a screen write occurred too quickly after the previous write attempt.
§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);
}