pub struct Display { /* private fields */ }
Expand description
Represents the physical display on the V5 Brain.
Implementations§
Source§impl Display
impl Display
Sourcepub const HEADER_HEIGHT: i16 = 32i16
pub const HEADER_HEIGHT: i16 = 32i16
Vertical height taken by the user program header when visible.
Sourcepub const HORIZONTAL_RESOLUTION: i16 = 480i16
pub const HORIZONTAL_RESOLUTION: i16 = 480i16
The horizontal resolution of the display.
Sourcepub const VERTICAL_RESOLUTION: i16 = 240i16
pub const VERTICAL_RESOLUTION: i16 = 240i16
The vertical resolution of the writable part of the display.
Sourcepub const REFRESH_INTERVAL: Duration
pub const REFRESH_INTERVAL: Duration
The amount of time it takes for the Brain display to fully re-render. The Brain display is 60fps.
Sourcepub unsafe fn new() -> Self
pub unsafe fn new() -> Self
Create a new display.
§Safety
Creating new display
s 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.
Sourcepub fn set_render_mode(&mut self, mode: RenderMode)
pub fn set_render_mode(&mut self, mode: RenderMode)
Set the render mode for the display.
For more info on render modes, see RenderMode
.
Sourcepub const fn render_mode(&self) -> RenderMode
pub const fn render_mode(&self) -> RenderMode
Returns the current RenderMode
of the display.
Sourcepub fn render(&mut self)
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.
Sourcepub fn scroll(&mut self, start: i16, offset: i16)
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.
Sourcepub fn scroll_region(&mut self, region: Rect, offset: i16)
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.
Sourcepub fn fill(&mut self, shape: &impl Fill, color: impl Into<Rgb<u8>>)
pub fn fill(&mut self, shape: &impl Fill, color: impl Into<Rgb<u8>>)
Draw a filled object to the display.
Sourcepub fn draw_text(
&mut self,
text: &Text,
color: impl Into<Rgb<u8>>,
bg_color: Option<Rgb<u8>>,
)
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)));
Sourcepub fn stroke(&mut self, shape: &impl Stroke, color: impl Into<Rgb<u8>>)
pub fn stroke(&mut self, shape: &impl Stroke, color: impl Into<Rgb<u8>>)
Draw an outlined object to the display.
Sourcepub fn erase(&mut self, color: impl Into<Rgb<u8>>)
pub fn erase(&mut self, color: impl Into<Rgb<u8>>)
Wipe the entire display buffer, filling it with a specified color.
Sourcepub fn draw_buffer<T, I>(&mut self, region: Rect, buf: T, src_stride: i32)
pub fn draw_buffer<T, I>(&mut self, region: Rect, buf: T, src_stride: i32)
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.
Sourcepub fn touch_status(&self) -> TouchEvent
pub fn touch_status(&self) -> TouchEvent
Returns the current touch status of the display.