-
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.
- Loading branch information
1 parent
02c6c1f
commit 0f4ae82
Showing
5 changed files
with
30 additions
and
19 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod ina219; | ||
pub mod pressure_transducer; | ||
pub mod signal_light; |
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,21 @@ | ||
use crate::components::ina219::read_current; | ||
use ina219::INA219; | ||
use rppal::i2c::I2c; | ||
use tracing::debug; | ||
|
||
pub struct PressureTransducer { | ||
ina: INA219<I2c>, | ||
} | ||
|
||
impl PressureTransducer { | ||
pub fn new(ina219_addr: u8) -> Self { | ||
let device = I2c::new().unwrap(); | ||
let ina219 = INA219::new(device, ina219_addr); | ||
debug!("Initialized I2C and INA219"); | ||
PressureTransducer { ina: ina219 } | ||
} | ||
|
||
pub fn read(&mut self) -> f32 { | ||
read_current(&mut self.ina) | ||
} | ||
} |
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