Compare commits

..

No commits in common. "0636253f068942a3ca8a5a64f2df4db1c887a859" and "298117ee901853f4925c85c5b2c3998fc3d1788f" have entirely different histories.

3 changed files with 30 additions and 24 deletions

View File

@ -150,8 +150,7 @@ fn main() -> ! {
tokens.next();
}
if down_button.update() == button::Event::PressUp {
changed = true;
tokens.prev();
todo!("To be implemented");
}
let curr_time = INTERVAL - (timestamp % INTERVAL);
if curr_time == last_time {

View File

@ -158,22 +158,37 @@ impl<
self.write_str(core::str::from_utf8(&buff[..=num_len]).unwrap());
}
pub fn write_u32(&mut self, mut num: u32) {
if num == 0 {
self.write_char('0');
return;
}
let mut buff = [0u8; 10];
let num_len = num.ilog10() as usize;
for i in (0..=num_len).rev() {
buff[i] = (num % 10) as u8 + '0' as u8;
num /= 10;
}
self.write_str(core::str::from_utf8(&buff[..=num_len]).unwrap());
pub fn write_u32(&mut self, num: u32) {
// This function is for debugging purposes only, it does not show
// The 0's to the right of the number
// The max number in an u32 is: 4,294,967,295
let mut buff = [0; 10];
let len = num_chars(num, &mut buff);
self.write_str(&core::str::from_utf8(&buff[..len]).unwrap());
}
}
fn last_bit(n: u8) -> bool {
(n & 1) != 0
}
fn num_rev(mut num: u32) -> u32 {
let mut rev_num = 0;
while num > 0 {
let digit = num % 10;
rev_num = rev_num * 10 + digit;
num /= 10;
}
rev_num
}
fn num_chars(n: u32, output: &mut [u8]) -> usize {
let mut n = num_rev(n);
let mut i = 0;
while n > 0 {
output[i] = (n % 10) as u8 + '0' as u8;
n = n / 10;
i += 1;
}
i
}

View File

@ -59,15 +59,7 @@ impl<'a> Tokens<'a> {
}
pub fn prev(&mut self) -> Option<u16> {
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
todo!();
}
pub fn read(&self, index: u16, name: &mut [u8], key: &mut [u8]) -> Result<(usize, usize), ()> {