mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-06-27 10:22:34 +00:00
TEST: Homescreen notification
This commit is contained in:
parent
fa192605ff
commit
b0dd1544b1
@ -2,7 +2,10 @@ mod render;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
trezorhal::{ble::start_advertising, usb::usb_configured},
|
trezorhal::{
|
||||||
|
ble::{ble_connected, start_advertising},
|
||||||
|
usb::usb_configured,
|
||||||
|
},
|
||||||
ui::{
|
ui::{
|
||||||
component::{Component, Event, EventCtx, Pad, TimerToken},
|
component::{Component, Event, EventCtx, Pad, TimerToken},
|
||||||
display::{self, tjpgd::jpeg_info, toif::Icon, Color, Font},
|
display::{self, tjpgd::jpeg_info, toif::Icon, Color, Font},
|
||||||
@ -21,10 +24,10 @@ use crate::{
|
|||||||
tjpgd::{jpeg_test, BufferInput},
|
tjpgd::{jpeg_test, BufferInput},
|
||||||
toif::Toif,
|
toif::Toif,
|
||||||
},
|
},
|
||||||
display::{tjpgd::BufferInput, toif::Toif},
|
|
||||||
event::{ButtonEvent, PhysicalButton},
|
event::{ButtonEvent, PhysicalButton},
|
||||||
model_tt::component::homescreen::render::{
|
model_tt::{
|
||||||
HomescreenJpeg, HomescreenToif, HOMESCREEN_TOIF_SIZE,
|
component::homescreen::render::{HomescreenJpeg, HomescreenToif, HOMESCREEN_TOIF_SIZE},
|
||||||
|
theme::{BLUE, ICON_MAGIC},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -86,13 +89,19 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_notification(&self) -> Option<HomescreenNotification> {
|
fn get_notification(&self) -> Option<HomescreenNotification> {
|
||||||
if !usb_configured() {
|
if !usb_configured() && !ble_connected() {
|
||||||
let (color, icon) = Self::level_to_style(0);
|
let (color, icon) = Self::level_to_style(0);
|
||||||
Some(HomescreenNotification {
|
Some(HomescreenNotification {
|
||||||
text: "NO USB CONNECTION",
|
text: "NO CONNECTION",
|
||||||
icon,
|
icon,
|
||||||
color,
|
color,
|
||||||
})
|
})
|
||||||
|
} else if ble_connected() {
|
||||||
|
Some(HomescreenNotification {
|
||||||
|
text: "BLE CONNECTED",
|
||||||
|
icon: ICON_MAGIC,
|
||||||
|
color: BLUE,
|
||||||
|
})
|
||||||
} else if let Some((notification, level)) = &self.notification {
|
} else if let Some((notification, level)) = &self.notification {
|
||||||
let (color, icon) = Self::level_to_style(*level);
|
let (color, icon) = Self::level_to_style(*level);
|
||||||
Some(HomescreenNotification {
|
Some(HomescreenNotification {
|
||||||
@ -188,7 +197,7 @@ where
|
|||||||
Self::event_usb(self, ctx, event);
|
Self::event_usb(self, ctx, event);
|
||||||
if self.hold_to_lock {
|
if self.hold_to_lock {
|
||||||
if Self::event_hold(self, ctx, event) {
|
if Self::event_hold(self, ctx, event) {
|
||||||
return Some(HomescreenMsg::Dismissed)
|
return Some(HomescreenMsg::Dismissed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +208,6 @@ where
|
|||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn paint(&mut self) {
|
fn paint(&mut self) {
|
||||||
|
Loading…
Reference in New Issue
Block a user