vex_sdk/
display.rs

1//! Brain Display
2
3use core::ffi::c_char;
4
5/// A decoded image written to by VEXos.
6#[repr(C, packed)]
7#[derive(Debug, Copy, Clone, Eq, PartialEq)]
8pub struct v5_image {
9    /// Definitive width of the output image.
10    pub width: u16,
11
12    /// Definitive height of the output image.
13    pub height: u16,
14
15    /// Buffer of RGB8 pixels that containing the image's data.
16    ///
17    /// This field must be set before the read operation as a pointer to the pre-allocated pixel buffer.
18    /// After an image read operation, said image’s pixels are written to the location specified by this field.
19    pub data: *mut u32,
20
21    /// Points to the first pixel of the second row in the pixel buffer.
22    ///
23    /// Only set by the SDK after a [`vexImageBmpRead`] call.
24    pub p: *mut u32,
25}
26
27unsafe extern "system" {
28    pub fn vexDisplayForegroundColor(col: u32);
29    pub fn vexDisplayBackgroundColor(col: u32);
30    pub fn vexDisplayErase();
31    pub fn vexDisplayScroll(nStartLine: i32, nLines: i32);
32    pub fn vexDisplayScrollRect(x1: i32, y1: i32, x2: i32, y2: i32, nLines: i32);
33    pub fn vexDisplayCopyRect(x1: i32, y1: i32, x2: i32, y2: i32, pSrc: *mut u32, srcStride: i32);
34    pub fn vexDisplayPixelSet(x: u32, y: u32);
35    pub fn vexDisplayPixelClear(x: u32, y: u32);
36    pub fn vexDisplayLineDraw(x1: i32, y1: i32, x2: i32, y2: i32);
37    pub fn vexDisplayLineClear(x1: i32, y1: i32, x2: i32, y2: i32);
38    pub fn vexDisplayRectDraw(x1: i32, y1: i32, x2: i32, y2: i32);
39    pub fn vexDisplayRectClear(x1: i32, y1: i32, x2: i32, y2: i32);
40    pub fn vexDisplayRectFill(x1: i32, y1: i32, x2: i32, y2: i32);
41    pub fn vexDisplayCircleDraw(xc: i32, yc: i32, radius: i32);
42    pub fn vexDisplayCircleClear(xc: i32, yc: i32, radius: i32);
43    pub fn vexDisplayCircleFill(xc: i32, yc: i32, radius: i32);
44    pub fn vexDisplayTextSize(n: u32, d: u32);
45    pub fn vexDisplayFontNamedSet(pFontName: *const c_char);
46    pub fn vexDisplayForegroundColorGet() -> u32;
47    pub fn vexDisplayBackgroundColorGet() -> u32;
48    pub fn vexDisplayStringWidthGet(pString: *const c_char) -> i32;
49    pub fn vexDisplayStringHeightGet(pString: *const c_char) -> i32;
50    pub fn vexDisplayClipRegionSet(x1: i32, y1: i32, x2: i32, y2: i32);
51    pub fn vexDisplayRender(bVsyncWait: bool, bRunScheduler: bool);
52    pub fn vexDisplayDoubleBufferDisable();
53    pub fn vexDisplayClipRegionSetWithIndex(index: i32, x1: i32, y1: i32, x2: i32, y2: i32);
54    pub fn vexImageBmpRead(ibuf: *const u8, oBuf: *mut v5_image, maxw: u32, maxh: u32) -> u32;
55    pub fn vexImagePngRead(
56        ibuf: *const u8,
57        oBuf: *mut v5_image,
58        maxw: u32,
59        maxh: u32,
60        ibuflen: u32,
61    ) -> u32;
62}
63
64unsafe extern "C" {
65    pub unsafe fn vexDisplayPrintf(xpos: i32, ypos: i32, bOpaque: i32, format: *const c_char, ...);
66    pub unsafe fn vexDisplayString(nLineNumber: i32, format: *const c_char, ...);
67    pub unsafe fn vexDisplayStringAt(xpos: i32, ypos: i32, format: *const c_char, ...);
68    pub unsafe fn vexDisplayBigString(nLineNumber: i32, format: *const c_char, ...);
69    pub unsafe fn vexDisplayBigStringAt(xpos: i32, ypos: i32, format: *const c_char, ...);
70    pub unsafe fn vexDisplaySmallStringAt(xpos: i32, ypos: i32, format: *const c_char, ...);
71    pub unsafe fn vexDisplayCenteredString(nLineNumber: i32, format: *const c_char, ...);
72    pub unsafe fn vexDisplayBigCenteredString(nLineNumber: i32, format: *const c_char, ...);
73}