Skip to content

Commit

Permalink
fixup! chore(core): add missing parameter to set_brightness function
Browse files Browse the repository at this point in the history
  • Loading branch information
bieleluk committed Dec 19, 2024
1 parent fdb7f04 commit 5091f3e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
12 changes: 1 addition & 11 deletions core/embed/rust/src/ui/model_mercury/flow/set_brightness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,7 @@ impl FlowController for SetBrightness {

static BRIGHTNESS: AtomicU8 = AtomicU8::new(0);

pub fn new_set_brightness(brightness: Option<u8>) -> Result<SwipeFlow, Error> {
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<SwipeFlow, Error> {
let content_slider = Frame::left_aligned(
TR::brightness__title.into(),
NumberInputSliderDialog::new(
Expand Down
10 changes: 10 additions & 0 deletions core/embed/rust/src/ui/model_mercury/ui_firmware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -787,6 +789,14 @@ impl FirmwareUI for UIMercury {
}

fn set_brightness(current_brightness: Option<u8>) -> Result<impl LayoutMaybeTrace, Error> {
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)
}
Expand Down
14 changes: 11 additions & 3 deletions core/embed/rust/src/ui/model_tt/ui_firmware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -725,12 +727,18 @@ impl FirmwareUI for UIModelTT {
}

fn set_brightness(current_brightness: Option<u8>) -> Result<impl LayoutMaybeTrace, Error> {
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)
Expand Down

0 comments on commit 5091f3e

Please sign in to comment.