esp32s3-buttons-driver 0.1.0

Buttons driver for ESP32-S3
use anyhow::Result;
use esp_idf_hal::gpio::{Input, PinDriver, Pull};

use crate::ButtonsIO;
pub struct Button<'a> {
    boot: PinDriver<'a, Input>,
    key: PinDriver<'a, Input>,
}
impl<'a> Button<'a> {
    pub fn new(io: ButtonsIO<'static>) -> Result<Self> {
        let boot = PinDriver::input(io.boot, Pull::Up)?;
        let key = PinDriver::input(io.key, Pull::Up)?;
        Ok(Self { boot, key })
    }

    pub fn is_boot_pressed(&self) -> bool {
        self.boot.is_low()
    }

    pub fn is_key_pressed(&self) -> bool {
        self.key.is_low()
    }
}