Skip to content

Commit

Permalink
adjust sampling
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulf Lilleengen committed Aug 27, 2023
1 parent 98a2502 commit baefd4f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion firmware/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion firmware/app/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
edition = "2021"
name = "watchful"
version = "0.2.1"
version = "0.2.2"
license = "MIT OR Apache-2.0"
build = "build.rs"

Expand Down
7 changes: 4 additions & 3 deletions firmware/app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ async fn main(s: Spawner) {
bat_config.resistor = saadc::Resistor::BYPASS;
bat_config.reference = saadc::Reference::INTERNAL;
bat_config.time = saadc::Time::_40US;
let adc_config = saadc::Config::default();
let mut adc_config = saadc::Config::default();
adc_config.resolution = saadc::Resolution::_10BIT;
let saadc = saadc::Saadc::new(p.SAADC, Irqs, adc_config, [bat_config]);
let mut battery = Battery::new(saadc, Input::new(p.P0_12.degrade(), Pull::Up));

Expand Down Expand Up @@ -430,8 +431,8 @@ impl<'a> Battery<'a> {
pub async fn measure(&mut self) -> u32 {
let mut buf = [0i16; 1];
self.adc.sample(&mut buf).await;
//let voltage = buf[0] as u32 * (8 * 600) / 1024;
let voltage = buf[0] as u32 * 2000 / 1241;
let voltage = buf[0] as u32 * (8 * 600) / 1024;
//let voltage = buf[0] as u32 * 2000 / 1241;
approximate_charge(voltage)
}

Expand Down

0 comments on commit baefd4f

Please sign in to comment.