-
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.
Add preliminary function to read from INA219
- Loading branch information
1 parent
bb1b221
commit b1102c1
Showing
5 changed files
with
174 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,18 @@ | ||
use ina219::{INA219, INA219_ADDR}; | ||
use rppal::i2c::I2c; | ||
use tracing::debug; | ||
|
||
pub async fn read_current() { | ||
let device = I2c::new().unwrap(); | ||
let mut ina = INA219::new(device, INA219_ADDR); | ||
debug!("Initialized I2C and INA219"); | ||
|
||
ina.calibrate(0x0100).unwrap(); | ||
debug!("Calibrating INA219"); | ||
|
||
loop { | ||
tokio::time::sleep(std::time::Duration::from_millis(500)).await; | ||
let current = ina.current().unwrap(); | ||
println!("current: {:?}", current); | ||
} | ||
} |
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 +1,2 @@ | ||
pub mod ina219; | ||
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