feat(core/rust): expose display offset handling to rust

pull/2448/head
tychovrahe 2 years ago committed by TychoVrahe
parent 29a5b0a770
commit af77816c2f

@ -253,6 +253,7 @@ fn generate_trezorhal_bindings() {
.allowlist_function("storage_next_counter")
// display
.allowlist_function("display_init")
.allowlist_function("display_offset")
.allowlist_function("display_refresh")
.allowlist_function("display_backlight")
.allowlist_function("display_text")

@ -1,5 +1,6 @@
use super::ffi;
use core::ptr;
use cty::c_int;
pub struct ToifInfo {
pub width: u16,
@ -140,3 +141,12 @@ pub fn set_window(x0: u16, y0: u16, x1: u16, y1: u16) {
ffi::display_set_window(x0, y0, x1, y1);
}
}
pub fn get_offset() -> (i32, i32) {
unsafe {
let mut x: c_int = 0;
let mut y: c_int = 0;
ffi::display_offset(ptr::null_mut(), &mut x, &mut y);
(x as i32, y as i32)
}
}

@ -229,6 +229,11 @@ pub fn pixeldata_dirty() {
display::pixeldata_dirty();
}
pub fn get_offset() -> Offset {
let offset = display::get_offset();
Offset::new(offset.0, offset.1)
}
pub fn set_window(window: Rect) {
display::set_window(
window.x0 as u16,

Loading…
Cancel
Save