Screen Rotation
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
- Prototype
- Example
void initialize() {
ez::as::initialize();
// Brain is mounted sideways
ez::screen_rotation_set(90);
}
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
- Prototype
- Example
ez::screen_line_set(0, "Hello!");
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
- Prototype
- Example
ez::screen_line_clear(0);
void screen_line_clear(int line);
screen_lines_clear()
Clears all 8 print lines, through the same routing as screen_line_set().
- Prototype
- Example
ez::screen_lines_clear();
void screen_lines_clear();
Getters
screen_rotation_get()
Returns the current rotation, in degrees (0, 90, 180, or 270).
- Prototype
- Example
ez::screen_rotation_set(90);
printf("%i\n", ez::screen_rotation_get()); // Prints 90
int screen_rotation_get();
screen_portrait_enabled()
Returns true while the portrait screen is the loaded screen (rotation 90 or 270).
- Prototype
- Example
ez::screen_rotation_set(90);
printf("%i\n", ez::screen_portrait_enabled()); // Prints true
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
- Prototype
- Example
pros::screen_touch_status_s_t status = pros::screen_touch_status();
ez::screen_point p = ez::screen_touch_rotate(ez::screen_rotation_get(), 480, 272, status.x, status.y);
printf("x: %i, y: %i\n", p.x, p.y);
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);