Skip to main content
Version: 4.0.0-beta.1

Screen Rotation

note

Experimental, unverified on hardware. This uses LVGL's software rotation on the live display driver.

Setters

screen_rotation_set()

Rotates the brain screen in 90-degree steps, for brains mounted sideways or upside down.

Accepts 0, 90, 180, or 270 (measured clockwise); other values are rejected with a printed message. Call this after the screen is initialized (ez::as::initialize() or pros::lcd::initialize()).

At 90 and 270 the stock LLEMU screen is swapped for EZ's portrait screen. LLEMU builds its widgets at the resolution live when pros::lcd::initialize() ran (480x272), so once the canvas becomes 272x480 its text runs off the right edge. The portrait screen re-flows the same LLEMU theme, font, print lines, and three-button bar to the rotated resolution, wrapping long lines rather than clipping them, and replays its button presses onto LLEMU's own buttons so pros::lcd::register_btn*_cb callbacks behave identically. 0 and 180 restore LLEMU untouched.

Touch rotates with the pixels, so on-screen buttons respond where they are drawn. 90/270 swap the screen's width and height. The physical LLEMU buttons are unaffected.

degrees 0, 90, 180, or 270

void screen_rotation_set(int degrees);

screen_line_set()

Writes one of the 8 print lines, to the portrait screen when it is loaded and to LLEMU otherwise. ez::screen_print routes through here.

line 0 through 7
text the text to print

void screen_line_set(int line, std::string text);

screen_line_clear()

Clears one of the 8 print lines, through the same routing as screen_line_set().

line 0 through 7

void screen_line_clear(int line);

screen_lines_clear()

Clears all 8 print lines, through the same routing as screen_line_set().

void screen_lines_clear();

Getters

screen_rotation_get()

Returns the current rotation, in degrees (0, 90, 180, or 270).

int screen_rotation_get();

screen_portrait_enabled()

Returns true while the portrait screen is the loaded screen (rotation 90 or 270).

bool screen_portrait_enabled();

Touch Coordinates

screen_touch_rotate()

Maps a raw panel touch into the coordinate space of a screen rotated by degrees.

LVGL already applies this to its own pointer input, so widgets need no help; this is only for code that reads the panel directly (pros::screen_touch_status()) and so bypasses LVGL. Do not apply it to lv_indev data or the point is transformed twice.

degrees 0, 90, 180, or 270
panel_w the physical, unrotated panel width (480 on the V5)
panel_h the physical, unrotated panel height (272 on the V5)
raw_x raw touch x from the panel
raw_y raw touch y from the panel

struct screen_point {
int x;
int y;
};

screen_point screen_touch_rotate(int degrees, int panel_w, int panel_h, int raw_x, int raw_y);