added the dependency to the project to circumvent crates.io and updated all projects

This commit is contained in:
Zenn 2023-08-06 18:34:36 +02:00
parent c591b2c272
commit 50819abc50
31 changed files with 1422 additions and 14 deletions

View file

@ -0,0 +1,69 @@
//! A list of all six buttons available on the Arduboy
/// Just a `const` for the UP button
pub const UP: ButtonSet = ButtonSet {
flag_set: 0b10000000,
};
/// Just a `const` for the RIGHT button
pub const RIGHT: ButtonSet = ButtonSet {
flag_set: 0b01000000,
};
/// Just a `const` for the LEFT button
pub const LEFT: ButtonSet = ButtonSet {
flag_set: 0b00100000,
};
/// Just a `const` for the DOWN button
pub const DOWN: ButtonSet = ButtonSet {
flag_set: 0b00010000,
};
/// Just a `const` for the A button
pub const A: ButtonSet = ButtonSet {
flag_set: 0b00001000,
};
/// Just a `const` for the B button
pub const B: ButtonSet = ButtonSet {
flag_set: 0b00000100,
};
/// Just a `const` for the UP button
pub const UP_BUTTON: ButtonSet = UP;
/// Just a `const` for the RIGHT button
pub const RIGHT_BUTTON: ButtonSet = RIGHT;
/// Just a `const` for the DOWN button
pub const DOWN_BUTTON: ButtonSet = DOWN;
/// Just a `const` for the LEFT button
pub const LEFT_BUTTON: ButtonSet = LEFT;
/// Just a `const` for the A button
pub const A_BUTTON: ButtonSet = A;
/// Just a `const` for the B button
pub const B_BUTTON: ButtonSet = B;
///This struct gives the library a understanding what Buttons on the Arduboy are.
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub struct ButtonSet {
pub flag_set: u8,
}
impl ButtonSet {
pub unsafe fn pressed(&self) -> bool {
crate::library::arduboy::pressed(self.flag_set)
}
pub unsafe fn just_pressed(&self) -> bool {
crate::library::arduboy::just_pressed(self.flag_set)
}
pub unsafe fn just_released(&self) -> bool {
crate::library::arduboy::just_released(self.flag_set)
}
pub unsafe fn not_pressed(&self) -> bool {
crate::library::arduboy::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

@ -0,0 +1 @@
pub mod buttons;