#![no_std]

use libtock::leds::LedsDriver;
use libtock::result::TockResult;
use libtock::timer::Duration;

#[libtock::main]
async fn main() -> TockResult<()> {
    let mut drivers = libtock::retrieve_drivers()?;

    let leds_driver = drivers.leds.init_driver()?;
    let mut timer_driver = drivers.timer.create_timer_driver();
    let timer_driver = timer_driver.activate()?;

    // blink_nibble assumes 4 leds.
    assert_eq!(leds_driver.num_leds(), 4);

    let mut buf = [0; 64];
    loop {
        drivers.rng.fill_buffer(&mut buf).await?;

        for &x in buf.iter() {
            blink_nibble(&leds_driver, x)?;
            timer_driver.sleep(Duration::from_ms(100)).await?;
            blink_nibble(&leds_driver, x >> 4)?;
            timer_driver.sleep(Duration::from_ms(100)).await?;
        }
    }
}

// Takes the 4 least-significant bits of x, and turn the 4 leds on/off accordingly.
fn blink_nibble(leds_driver: &LedsDriver, x: u8) -> TockResult<()> {
    for i in 0..4 {
        let led = leds_driver.get(i)?;
        if (x >> i) & 1 != 0 {
            led.on()?;
        } else {
            led.off()?;
        }
    }
    Ok(())
}
