This commit is contained in:
ZennDev1337 2023-10-12 11:14:44 +02:00
parent 3c1f94ab0a
commit cca197bf45
8 changed files with 42 additions and 31 deletions

View file

@ -44,30 +44,3 @@ pub const B_BUTTON: ButtonSet = B;
pub struct ButtonSet {
pub flag_set: u8,
}
impl ButtonSet {
pub fn pressed(&self) -> bool {
unsafe { crate::libraries::arduboy2_library::binding::pressed(self.flag_set) }
}
pub fn just_pressed(&self) -> bool {
unsafe { crate::libraries::arduboy2_library::binding::just_pressed(self.flag_set) }
}
pub fn just_released(&self) -> bool {
unsafe { crate::libraries::arduboy2_library::binding::just_released(self.flag_set) }
}
pub fn not_pressed(&self) -> bool {
unsafe { crate::libraries::arduboy2_library::binding::not_pressed(self.flag_set) }
}
}
impl core::ops::BitOr for ButtonSet {
type Output = Self;
fn bitor(self, other: Self) -> Self {
Self {
flag_set: self.flag_set | other.flag_set,
}
}
}

View file

@ -27,7 +27,8 @@
extern crate panic_halt;
pub mod hardware;
mod libraries;
#[doc(hidden)]
pub mod libraries;
pub mod prelude;
#[doc(inline)]

View file

@ -665,3 +665,30 @@ impl Arduboy2 {
unsafe { arduboy_exit_to_bootloader() }
}
}
impl ButtonSet {
pub fn pressed(&self) -> bool {
unsafe { pressed(self.flag_set) }
}
pub fn just_pressed(&self) -> bool {
unsafe { just_pressed(self.flag_set) }
}
pub fn just_released(&self) -> bool {
unsafe { just_released(self.flag_set) }
}
pub fn not_pressed(&self) -> bool {
unsafe { not_pressed(self.flag_set) }
}
}
impl core::ops::BitOr for ButtonSet {
type Output = Self;
fn bitor(self, other: Self) -> Self {
Self {
flag_set: self.flag_set | other.flag_set,
}
}
}

View file

@ -4,7 +4,7 @@
#[doc(hidden)]
pub mod arduboy2;
#[doc(hidden)]
pub mod binding;
mod binding;
#[doc(hidden)]
pub mod print;

View file

@ -9,7 +9,8 @@ pub use crate::hardware::buttons::*;
#[doc(inline)]
pub use crate::hardware::led::*;
pub use crate::heapless::{LinearMap, String, Vec};
pub use crate::libraries::arduboy2_library::*;
pub use crate::libraries::arduboy2_library::arduboy2::*;
pub use crate::libraries::arduboy2_library::{print, sprites};
pub use crate::libraries::arduboy_tones_library::*;
pub use crate::libraries::arduboyfx_library::*;
pub use crate::libraries::arduino_system::arduino::*;