Skip to content

Implement LED switching #5574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Implement LED switching #5574

wants to merge 6 commits into from

Conversation

bieleluk
Copy link
Contributor

@bieleluk bieleluk commented Aug 18, 2025

Enable LED switching off, similar to the haptic feedback.
Required by Figma

LED driver:

  • new enabled field in the driver struct
  • new functions
    • rgb_led_set_enabled
    • rgb_led_get_enabled

Device menu

  • new input param for show_device_menu FwUI function
  • new DeviceMenuResult variant
  • new device menu item for LED switching

Syscalls

  • new syscalls:
    • SYSCALL_RGB_LED_SET_ENABLED
    • SYSCALL_RGB_LED_GET_ENABLED

Python

  • new trezorio module rgb_led with rgb_led_set_enabled function
  • new constant USE_RGB_LED

Storage

  • new entry for storing whether the LED is enabled or not
  • new set_rgb_led and get_rgb_led() functions

TODO

  • rename commit message
  • add changelog entry

@bieleluk bieleluk added this to the UI Eckhart milestone Aug 18, 2025
@bieleluk bieleluk self-assigned this Aug 18, 2025
@bieleluk bieleluk added the T3W1 label Aug 18, 2025
@github-project-automation github-project-automation bot moved this to 🔎 Needs review in Firmware Aug 18, 2025
Copy link

github-actions bot commented Aug 18, 2025

en main(all)

model device_test click_test persistence_test
T2T1 test(all) main(all) test(all) main(all) test(all) main(all)
T3B1 test(all) main(all) test(all) main(all) test(all) main(all)
T3T1 test(all) main(all) test(all) main(all) test(all) main(all)
T3W1 test(all) main(all) test(all) main(all) test(all) main(all)

Latest CI run: 17175285187

@bieleluk bieleluk requested a review from romanz August 18, 2025 12:08
return;
}

driver->enabled = enabled;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we turn off the LED here too? (similar to how it was done in other drivers)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say yes. It follows the same structure as the haptic driver drv2625.c

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree, lets turn in off

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bieleluk bieleluk requested a review from romanz August 19, 2025 13:54
@obrusvit obrusvit requested a review from cepetr August 19, 2025 16:40
@obrusvit
Copy link
Contributor

@cepetr this PR touches some drivers code. Can you take a look? Thank you.

@bieleluk bieleluk force-pushed the bieleluk/led-switching branch from 4f37de2 to 9377ab3 Compare August 21, 2025 18:14
@bieleluk bieleluk mentioned this pull request Aug 22, 2025
6 tasks

while (pm_turn_on() != PM_OK) {
rgb_led_set_color(0x400000);
#ifdef USE_RGB_LED
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we don't use LED, we don't need the delays either

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// Set RGB LED color
// color: 24-bit RGB color, 0x00RRGGBB
void rgb_led_set_color(uint32_t color);

#define RGBLED_GREEN 0x040D04
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can probably keep this for now but these values seem entirely UI-specific, so it should not be defined at driver level. i am thinking that the led blinking in bootloader should be seprate rust UI function exposed to bootloader

@@ -364,6 +364,7 @@ pub trait FirmwareUI {
device_name: Option<TString<'static>>,
paired_devices: Vec<TString<'static>, 1>,
auto_lock_delay: TString<'static>,
led: Option<bool>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the parameter name isn't very helpful

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rgb_led_set_color(RGBLED_YELLOW);
#endif
systick_delay_ms(1000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for delay without led

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return;
}

driver->enabled = enabled;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree, lets turn in off

@bieleluk bieleluk force-pushed the bieleluk/led-switching branch from 9377ab3 to 437a492 Compare August 23, 2025 12:10
@bieleluk bieleluk requested a review from TychoVrahe August 23, 2025 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 🔎 Needs review
Development

Successfully merging this pull request may close these issues.

4 participants