use super::*;
extern crate alloc;
use alloc::ffi::CString;
#[derive(Debug, Default)]
pub struct NbglSpinner {
text: [CString; 2],
write_idx: usize,
read_idx: usize,
}
impl NbglSpinner {
pub fn new() -> NbglSpinner {
NbglSpinner {
text: [CString::default(), CString::default()],
write_idx: 0,
read_idx: 0,
}
}
pub fn show(&mut self, text: &str) {
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_ptr() as *const c_char);
}
}
}