Features `micropython` and `protobuf` are defined. Protobuf implies micropython because our protobuf impl is pretty much _for_ micropython. The respective subdirs are included only if the matching feature is defined. util.rs is moved to micropython because it mostly concerns micropython interop ResultExt, useful only for ui_debug, is moved to ui::util. A new module `trezorhal::time` is provided. It mirrors functionality of `micropython::time` via stmlib functions. The intended use is to always use functions from `trezorhal::time`. The right micropython variants are used when micropython is available, otherwise the pure stmlib versions are called. ui::*::layout is conditional for micropython feature, because it only concerns micropython layouts. If we want to reuse layouts defined there, we will need to export them to not depend on Objs and Qstrs etc.pull/2342/head
parent
7d37109eb8
commit
2aa427a6e3
@ -0,0 +1,13 @@
|
||||
use crate::time::Duration;
|
||||
|
||||
use super::ffi;
|
||||
|
||||
pub fn ticks_ms() -> u32 {
|
||||
unsafe { ffi::hal_ticks_ms() as _ }
|
||||
}
|
||||
|
||||
pub fn sleep(delay: Duration) {
|
||||
unsafe {
|
||||
ffi::hal_delay(delay.to_millis() as _);
|
||||
}
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
pub mod component;
|
||||
pub mod constant;
|
||||
pub mod layout;
|
||||
pub mod theme;
|
||||
|
||||
#[cfg(feature = "micropython")]
|
||||
pub mod layout;
|
||||
|
@ -1,4 +1,6 @@
|
||||
pub mod component;
|
||||
pub mod constant;
|
||||
pub mod layout;
|
||||
pub mod theme;
|
||||
|
||||
#[cfg(feature = "micropython")]
|
||||
pub mod layout;
|
||||
|
@ -1,5 +1,7 @@
|
||||
pub mod component;
|
||||
pub mod constant;
|
||||
pub mod event;
|
||||
pub mod layout;
|
||||
pub mod theme;
|
||||
|
||||
#[cfg(feature = "micropython")]
|
||||
pub mod layout;
|
||||
|
@ -0,0 +1,12 @@
|
||||
pub trait ResultExt {
|
||||
fn assert_if_debugging_ui(self, message: &str);
|
||||
}
|
||||
|
||||
impl<T, E> ResultExt for Result<T, E> {
|
||||
fn assert_if_debugging_ui(self, #[allow(unused)] message: &str) {
|
||||
#[cfg(feature = "ui_debug")]
|
||||
if self.is_err() {
|
||||
panic!("{}", message);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue