From 5091f3e6d3e9f909c210bd1cdd067d238e3c398b Mon Sep 17 00:00:00 2001 From: Lukas Bielesch Date: Thu, 19 Dec 2024 16:18:56 +0100 Subject: [PATCH] fixup! chore(core): add missing parameter to set_brightness function --- .../src/ui/model_mercury/flow/set_brightness.rs | 12 +----------- .../embed/rust/src/ui/model_mercury/ui_firmware.rs | 10 ++++++++++ core/embed/rust/src/ui/model_tt/ui_firmware.rs | 14 +++++++++++--- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/core/embed/rust/src/ui/model_mercury/flow/set_brightness.rs b/core/embed/rust/src/ui/model_mercury/flow/set_brightness.rs index f3c384d775..004e45c010 100644 --- a/core/embed/rust/src/ui/model_mercury/flow/set_brightness.rs +++ b/core/embed/rust/src/ui/model_mercury/flow/set_brightness.rs @@ -64,17 +64,7 @@ impl FlowController for SetBrightness { static BRIGHTNESS: AtomicU8 = AtomicU8::new(0); -pub fn new_set_brightness(brightness: Option) -> Result { - let brightness = brightness - .map(|value| { - // If brightness value is provided, set display brightness to that value - display::backlight(value as _); - BRIGHTNESS.store(value as u8, Ordering::Relaxed); - let _ = storage::set_brightness(BRIGHTNESS.load(Ordering::Relaxed)); - value - }) - .unwrap_or_else(|| theme::backlight::get_backlight_normal() as _); - +pub fn new_set_brightness(brightness: u8) -> Result { let content_slider = Frame::left_aligned( TR::brightness__title.into(), NumberInputSliderDialog::new( diff --git a/core/embed/rust/src/ui/model_mercury/ui_firmware.rs b/core/embed/rust/src/ui/model_mercury/ui_firmware.rs index 716eabdf20..6f555c2bf1 100644 --- a/core/embed/rust/src/ui/model_mercury/ui_firmware.rs +++ b/core/embed/rust/src/ui/model_mercury/ui_firmware.rs @@ -4,8 +4,10 @@ use crate::{ error::{value_error, Error}, io::BinaryData, micropython::{gc::Gc, iter::IterBuf, list::List, obj::Obj, util}, + storage, strutil::TString, translations::TR, + trezorhal::display, ui::{ component::{ connect::Connect, @@ -787,6 +789,14 @@ impl FirmwareUI for UIMercury { } fn set_brightness(current_brightness: Option) -> Result { + let current_brightness = current_brightness + .map(|value| { + // If brightness value is provided, set display brightness to that value + display::backlight(value as _); + let _ = storage::set_brightness(value); + value + }) + .unwrap_or_else(|| theme::backlight::get_backlight_normal() as _); let flow = flow::set_brightness::new_set_brightness(current_brightness)?; Ok(flow) } diff --git a/core/embed/rust/src/ui/model_tt/ui_firmware.rs b/core/embed/rust/src/ui/model_tt/ui_firmware.rs index 4f9b0c5085..38d9a9b0c2 100644 --- a/core/embed/rust/src/ui/model_tt/ui_firmware.rs +++ b/core/embed/rust/src/ui/model_tt/ui_firmware.rs @@ -4,8 +4,10 @@ use crate::{ error::{value_error, Error}, io::BinaryData, micropython::{gc::Gc, iter::IterBuf, list::List, obj::Obj, util}, + storage, strutil::TString, translations::TR, + trezorhal::display, ui::{ component::{ connect::Connect, @@ -725,12 +727,18 @@ impl FirmwareUI for UIModelTT { } fn set_brightness(current_brightness: Option) -> Result { + let current_brightness = current_brightness + .map(|value| { + // If brightness value is provided, set display brightness to that value + display::backlight(value as _); + let _ = storage::set_brightness(value); + value + }) + .unwrap_or_else(|| theme::backlight::get_backlight_normal() as _); let layout = RootComponent::new(Frame::centered( theme::label_title(), TR::brightness__title.into(), - SetBrightnessDialog::new( - current_brightness.unwrap_or(theme::backlight::get_backlight_normal()), - ), + SetBrightnessDialog::new(current_brightness), )); Ok(layout)