Struct Display

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

Represents the physical display on the V5 Brain.

Implementations§

Source§

impl Display

Source

pub const HEADER_HEIGHT: i16 = 32i16

Vertical height taken by the user program header when visible.

Source

pub const HORIZONTAL_RESOLUTION: i16 = 480i16

The horizontal resolution of the display.

Source

pub const VERTICAL_RESOLUTION: i16 = 240i16

The vertical resolution of the writable part of the display.

Source

pub const REFRESH_INTERVAL: Duration

The amount of time it takes for the Brain display to fully re-render. The Brain display is 60fps.

Source

pub unsafe fn new() -> Self

Create a new display.

§Safety

Creating new displays is inherently unsafe due to the possibility of constructing more than one display at once allowing multiple mutable references to the same hardware device. Prefer using Peripherals to register devices if possible.

Source

pub fn set_render_mode(&mut self, mode: RenderMode)

Set the render mode for the display.

For more info on render modes, see RenderMode.

Source

pub const fn render_mode(&self) -> RenderMode

Returns the current RenderMode of the display.

Source

pub fn render(&mut self)

Flushes the displays double buffer if it is enabled. This is a no-op with the Immediate rendering mode, but is necessary for anything to be displayed on the displayed when using the DoubleBuffered mode.

Source

pub fn scroll(&mut self, start: i16, offset: i16)

Scroll the pixels at or below the specified y-coordinate.

This function y-offsets the pixels in the display buffer which are at or below the given start point (start) by a number (offset) of pixels. Positive values move the pixels upwards, and pixels that are moved out of the scroll region are discarded. Empty spaces are then filled with the display’s background color.

Source

pub fn scroll_region(&mut self, region: Rect, offset: i16)

Scroll a region of the display.

This function y-offsets the pixels in the display buffer which are contained in the specified scroll region (region) by a number (offset) of pixels. Positive values move the pixels upwards, and pixels that are moved out of the scroll region are discarded. Empty spaces are then filled with the display’s background color.

Source

pub fn fill(&mut self, shape: &impl Fill, color: impl Into<Rgb<u8>>)

Draw a filled object to the display.

Source

pub fn draw_text( &mut self, text: &Text, color: impl Into<Rgb<u8>>, bg_color: Option<Rgb<u8>>, )

Fill text with a specified color and background color to the display.

§Example
use vexide::prelude::*;

let mut display = Display::new();
// Create a new text widget.
let text = Text::new("Hello, World!", TextSize::Medium, Point2::new(10, 10));
// Write red text with a blue background to the display.
display.fill_text(&text, Rgb::new(255, 0, 0), Some(Rgb::new(0, 0, 255)));
Source

pub fn stroke(&mut self, shape: &impl Stroke, color: impl Into<Rgb<u8>>)

Draw an outlined object to the display.

Source

pub fn erase(&mut self, color: impl Into<Rgb<u8>>)

Wipe the entire display buffer, filling it with a specified color.

Source

pub fn draw_buffer<T, I>(&mut self, region: Rect, buf: T, src_stride: i32)
where T: IntoIterator<Item = I>, I: Into<Rgb<u8>>,

Draw a buffer of pixels to a specified region of the display.

This function copies the pixels in the specified buffer to the specified region of the display. The stride parameter is defined as the number of pixels per row.

§Panics

This function panics if buf does not have the correct number of bytes to fill the specified region.

Source

pub fn touch_status(&self) -> TouchEvent

Returns the current touch status of the display.

Trait Implementations§

Source§

impl Debug for Display

Source§

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

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

impl PartialEq for Display

Source§

fn eq(&self, other: &Display) -> 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 Write for Display

Source§

fn write_str(&mut self, text: &str) -> Result

Writes a string slice into this writer, returning whether the write succeeded. Read more
1.1.0 · Source§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more
Source§

impl Eq for Display

Source§

impl StructuralPartialEq for Display

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.