Skip to content

Commit

Permalink
Update NBGL spinner
Browse files Browse the repository at this point in the history
  • Loading branch information
yogh333 committed Jan 29, 2025
1 parent c476847 commit d8b1037
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions ledger_device_sdk/src/nbgl/nbgl_spinner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ use alloc::ffi::CString;
/// 800 ms, provided the IO event loop is running to process TickerEvents.
#[derive(Debug, Default)]
pub struct NbglSpinner {
text: [Option<CString>; 2],
text: [CString; 2],
write_idx: usize,
read_idx: usize,
}

impl NbglSpinner {
pub fn new() -> NbglSpinner {
NbglSpinner {
text: [None, None],
text: [CString::default(), CString::default()],
write_idx: 0,
read_idx: 0,
}
Expand All @@ -24,13 +24,11 @@ impl NbglSpinner {
/// Shows the spinner with the current text.
/// Every call make the spinner "turn" to the next text.
pub fn show(&mut self, text: &str) {
self.text[self.write_idx] = Some(CString::new(text).unwrap());
self.text[self.write_idx] = CString::new(text).unwrap();
self.read_idx = self.write_idx;
self.write_idx = (self.write_idx + 1) % 2;
unsafe {
nbgl_useCaseSpinner(
self.text[self.read_idx].as_ref().unwrap().as_ptr() as *const c_char
);
nbgl_useCaseSpinner(self.text[self.read_idx].as_ptr() as *const c_char);
}
}
}

0 comments on commit d8b1037

Please sign in to comment.