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 9, 2024
1 parent 217dd8c commit 0537f0c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
11 changes: 10 additions & 1 deletion core/embed/rust/src/ui/model_mercury/flow/set_brightness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,16 @@ impl FlowController for SetBrightness {
static BRIGHTNESS: AtomicU8 = AtomicU8::new(0);

pub fn new_set_brightness(brightness: Option<u8>) -> Result<SwipeFlow, Error> {
let brightness = brightness.unwrap_or(theme::backlight::get_backlight_normal());
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 _);

let content_slider = Frame::left_aligned(
TR::brightness__title.into(),
NumberInputSliderDialog::new(
Expand Down
9 changes: 8 additions & 1 deletion core/embed/rust/src/ui/model_tt/component/set_brightness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ pub struct SetBrightnessDialog(NumberInputSliderDialog);

impl SetBrightnessDialog {
pub fn new(current: Option<u8>) -> Self {
let current = current.unwrap_or(theme::backlight::get_backlight_normal());
let current = current
.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 _);
Self(NumberInputSliderDialog::new(
theme::backlight::get_backlight_min() as u16,
theme::backlight::get_backlight_max() as u16,
Expand Down

0 comments on commit 0537f0c

Please sign in to comment.