Skip to content

Commit baefd4f

Browse files
author
Ulf Lilleengen
committed
adjust sampling
1 parent 98a2502 commit baefd4f

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

firmware/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

firmware/app/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
edition = "2021"
33
name = "watchful"
4-
version = "0.2.1"
4+
version = "0.2.2"
55
license = "MIT OR Apache-2.0"
66
build = "build.rs"
77

firmware/app/src/main.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ async fn main(s: Spawner) {
171171
bat_config.resistor = saadc::Resistor::BYPASS;
172172
bat_config.reference = saadc::Reference::INTERNAL;
173173
bat_config.time = saadc::Time::_40US;
174-
let adc_config = saadc::Config::default();
174+
let mut adc_config = saadc::Config::default();
175+
adc_config.resolution = saadc::Resolution::_10BIT;
175176
let saadc = saadc::Saadc::new(p.SAADC, Irqs, adc_config, [bat_config]);
176177
let mut battery = Battery::new(saadc, Input::new(p.P0_12.degrade(), Pull::Up));
177178

@@ -430,8 +431,8 @@ impl<'a> Battery<'a> {
430431
pub async fn measure(&mut self) -> u32 {
431432
let mut buf = [0i16; 1];
432433
self.adc.sample(&mut buf).await;
433-
//let voltage = buf[0] as u32 * (8 * 600) / 1024;
434-
let voltage = buf[0] as u32 * 2000 / 1241;
434+
let voltage = buf[0] as u32 * (8 * 600) / 1024;
435+
//let voltage = buf[0] as u32 * 2000 / 1241;
435436
approximate_charge(voltage)
436437
}
437438

0 commit comments

Comments
 (0)