-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check both feature sets during linting
- Update checks workflow and precommit hooks - Resolve clippy lint issues - Create mod for GPIO mocks
- Loading branch information
Showing
14 changed files
with
86 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"rust-analyzer.cargo.features": [ | ||
// "rpi" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,50 @@ | ||
use tracing::info; | ||
|
||
/// Pin logic levels, copied from rppal::gpio | ||
#[derive(Debug, PartialEq, Eq, Copy, Clone)] | ||
#[repr(u8)] | ||
pub enum Level { | ||
Low = 0, | ||
High = 1, | ||
} | ||
|
||
/// Mock for GPIO InputPin | ||
pub struct InputPin { | ||
pub(crate) pin: u8, | ||
} | ||
|
||
impl InputPin { | ||
pub fn read(&self) -> Level { | ||
info!("Mocking reading pin {} as low", self.pin); | ||
Level::Low | ||
#[cfg(not(feature = "gpio"))] | ||
pub mod gpio { | ||
use tracing::{debug, info}; | ||
|
||
/// Pin logic levels, copied from rppal::gpio | ||
#[derive(Debug, PartialEq, Eq, Copy, Clone)] | ||
#[repr(u8)] | ||
#[allow(dead_code)] | ||
pub enum Level { | ||
Low = 0, | ||
High = 1, | ||
} | ||
|
||
pub fn is_low(&self) -> bool { | ||
info!("Mocking reading pin {} as low", self.pin); | ||
true | ||
/// Mock for GPIO InputPin | ||
pub struct InputPin { | ||
pub(crate) pin: u8, | ||
} | ||
|
||
pub fn is_high(&self) -> bool { | ||
info!("Mocking reading pin {} as low", self.pin); | ||
false | ||
impl InputPin { | ||
pub fn read(&self) -> Level { | ||
debug!("Mocking reading pin {} as low", self.pin); | ||
Level::Low | ||
} | ||
|
||
pub fn is_low(&self) -> bool { | ||
debug!("Mocking reading pin {} as low", self.pin); | ||
true | ||
} | ||
|
||
pub fn is_high(&self) -> bool { | ||
debug!("Mocking reading pin {} as low", self.pin); | ||
false | ||
} | ||
} | ||
} | ||
|
||
/// Mock for GPIO OutputPin | ||
pub struct OutputPin { | ||
pub(crate) pin: u8, | ||
} | ||
|
||
impl OutputPin { | ||
pub fn set_low(&self) { | ||
info!("Mocking pin {} to low", self.pin); | ||
/// Mock for GPIO OutputPin | ||
pub struct OutputPin { | ||
pub(crate) pin: u8, | ||
} | ||
|
||
pub fn set_high(&self) { | ||
info!("Mocking pin {} to high", self.pin); | ||
impl OutputPin { | ||
pub fn set_low(&self) { | ||
info!("Mocking pin {} to low", self.pin); | ||
} | ||
|
||
pub fn set_high(&self) { | ||
info!("Mocking pin {} to high", self.pin); | ||
} | ||
} | ||
} |