avr-oxide 0.0.2

An extremely simply Rusty operating system for AVR microcontrollers
/* led.rs
 *
 * Developed by Tim Walls <tim.walls@snowgoons.com>
 * Copyright (c) All Rights Reserved, Tim Walls
 */
//! @todo documentation for this module
//!
//!

// Imports ===================================================================
use crate::hal::generic::port::Pin;

// Declarations ==============================================================
pub struct Led<P>
where
  P: Pin
{
  pin: P
}

// Code ======================================================================
impl<P> Led<P>
where
  P: Pin
{
  pub fn using_pin(pin: P) -> Self {
    Led { pin }
  }

  pub fn set_on(&mut self) {
    todo!()
  }

  pub fn set_off(&mut self) {
    todo!()
  }

  pub fn set(&mut self, on: bool) {
    match on {
      true => self.set_on(),
      false => self.set_off()
    }
  }

  pub fn toggle(&mut self) {
    self.pin.toggle()
  }
}