Implement the prev button
parent
298117ee90
commit
8705519c0b
|
@ -150,7 +150,8 @@ fn main() -> ! {
|
|||
tokens.next();
|
||||
}
|
||||
if down_button.update() == button::Event::PressUp {
|
||||
todo!("To be implemented");
|
||||
changed = true;
|
||||
tokens.prev();
|
||||
}
|
||||
let curr_time = INTERVAL - (timestamp % INTERVAL);
|
||||
if curr_time == last_time {
|
||||
|
|
|
@ -59,7 +59,15 @@ impl<'a> Tokens<'a> {
|
|||
}
|
||||
|
||||
pub fn prev(&mut self) -> Option<u16> {
|
||||
todo!();
|
||||
let mut index = self.current.unwrap();
|
||||
for _ in 0..self.capacity {
|
||||
index = (index - 1) % self.capacity;
|
||||
if self.mem.read_byte(index * SECRET_KEY_FULL_LEN) != ENDL {
|
||||
self.current = Some(index);
|
||||
return Some(index);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
pub fn read(&self, index: u16, name: &mut [u8], key: &mut [u8]) -> Result<(usize, usize), ()> {
|
||||
|
|
Loading…
Reference in New Issue