+6
-5
Cargo.lock
+6
-5
Cargo.lock
···
82
"embedded-io",
83
"embedded-io-async",
84
"futures-intrusive",
85
-
"heapless 0.8.0",
86
]
87
88
[[package]]
···
1044
[[package]]
1045
name = "sachy-battery"
1046
version = "0.1.0"
1047
-
source = "git+https://tangled.org/sachy.dev/sachy-embed-core#da0ffed807760563c59c9d6360190aaf028878a9"
1048
1049
[[package]]
1050
name = "sachy-bthome"
1051
version = "0.1.0"
1052
-
source = "git+https://tangled.org/sachy.dev/sachy-embed-core#da0ffed807760563c59c9d6360190aaf028878a9"
1053
dependencies = [
1054
"defmt 1.0.1",
1055
"heapless 0.9.2",
···
1059
[[package]]
1060
name = "sachy-fmt"
1061
version = "0.1.0"
1062
-
source = "git+https://tangled.org/sachy.dev/sachy-embed-core#da0ffed807760563c59c9d6360190aaf028878a9"
1063
dependencies = [
1064
"defmt 1.0.1",
1065
]
···
1079
"embassy-sync",
1080
"embassy-time",
1081
"embedded-hal 1.0.0",
1082
"embedded-io",
1083
"nrf-mpsl",
1084
"nrf-sdc",
···
1095
[[package]]
1096
name = "sachy-shtc3"
1097
version = "0.1.0"
1098
-
source = "git+https://tangled.org/sachy.dev/sachy-embed-core#da0ffed807760563c59c9d6360190aaf028878a9"
1099
dependencies = [
1100
"defmt 1.0.1",
1101
"embedded-hal 1.0.0",
···
82
"embedded-io",
83
"embedded-io-async",
84
"futures-intrusive",
85
+
"heapless 0.9.2",
86
]
87
88
[[package]]
···
1044
[[package]]
1045
name = "sachy-battery"
1046
version = "0.1.0"
1047
+
source = "git+https://tangled.org/sachy.dev/sachy-embed-core#24c6e6058b733cad84234854941ac25836158b79"
1048
1049
[[package]]
1050
name = "sachy-bthome"
1051
version = "0.1.0"
1052
+
source = "git+https://tangled.org/sachy.dev/sachy-embed-core#24c6e6058b733cad84234854941ac25836158b79"
1053
dependencies = [
1054
"defmt 1.0.1",
1055
"heapless 0.9.2",
···
1059
[[package]]
1060
name = "sachy-fmt"
1061
version = "0.1.0"
1062
+
source = "git+https://tangled.org/sachy.dev/sachy-embed-core#24c6e6058b733cad84234854941ac25836158b79"
1063
dependencies = [
1064
"defmt 1.0.1",
1065
]
···
1079
"embassy-sync",
1080
"embassy-time",
1081
"embedded-hal 1.0.0",
1082
+
"embedded-hal-async",
1083
"embedded-io",
1084
"nrf-mpsl",
1085
"nrf-sdc",
···
1096
[[package]]
1097
name = "sachy-shtc3"
1098
version = "0.1.0"
1099
+
source = "git+https://tangled.org/sachy.dev/sachy-embed-core#24c6e6058b733cad84234854941ac25836158b79"
1100
dependencies = [
1101
"defmt 1.0.1",
1102
"embedded-hal 1.0.0",
+1
Cargo.toml
+1
Cargo.toml
+1
-1
src/constants.rs
+1
-1
src/constants.rs
+10
-16
src/shtc3.rs
+10
-16
src/shtc3.rs
···
2
Peri, peripherals,
3
twim::{self, Twim},
4
};
5
-
use embassy_time::Timer;
6
-
use embedded_hal::i2c::SevenBitAddress;
7
-
use sachy_fmt::{info, error, unwrap};
8
use sachy_shtc3::{Error as ShtError, Measurement, PowerMode, ShtC3};
9
use static_cell::ConstStaticCell;
10
···
15
16
async fn measure<I>(sht: &mut ShtC3<I>) -> Result<Measurement, ShtError<I::Error>>
17
where
18
-
I: embedded_hal::i2c::I2c<SevenBitAddress>,
19
{
20
-
sht.start_wakeup()?;
21
22
-
Timer::after_micros(sht.wakeup_duration() as u64).await;
23
24
let divisor = 4;
25
let mut m = Measurement::default();
26
27
for _ in 0..divisor {
28
-
sht.start_measurement()?;
29
-
30
-
Timer::after_micros(sht.max_measurement_duration() as u64).await;
31
-
32
-
m += sht.get_measurement_result()?;
33
34
Timer::after_millis(5).await;
35
}
···
42
m.humidity.as_percent()
43
);
44
45
-
sht.sleep()?;
46
47
Ok(m)
48
}
49
50
async fn reset<I>(sht: &mut ShtC3<I>) -> Result<(), ShtError<I::Error>>
51
where
52
-
I: embedded_hal::i2c::I2c<SevenBitAddress>,
53
{
54
-
sht.start_reset()?;
55
-
56
-
Timer::after_micros(sht.reset_duration() as u64).await;
57
58
Ok(())
59
}
···
2
Peri, peripherals,
3
twim::{self, Twim},
4
};
5
+
use embassy_time::{Delay, Timer};
6
+
use embedded_hal_async::i2c::{I2c, SevenBitAddress};
7
+
use sachy_fmt::{error, info, unwrap};
8
use sachy_shtc3::{Error as ShtError, Measurement, PowerMode, ShtC3};
9
use static_cell::ConstStaticCell;
10
···
15
16
async fn measure<I>(sht: &mut ShtC3<I>) -> Result<Measurement, ShtError<I::Error>>
17
where
18
+
I: I2c<SevenBitAddress>,
19
{
20
+
let mut delay = Delay;
21
22
+
sht.wakeup_async(&mut delay).await?;
23
24
let divisor = 4;
25
let mut m = Measurement::default();
26
27
for _ in 0..divisor {
28
+
m += sht.measure_async(&mut delay).await?;
29
30
Timer::after_millis(5).await;
31
}
···
38
m.humidity.as_percent()
39
);
40
41
+
sht.sleep_async().await?;
42
43
Ok(m)
44
}
45
46
async fn reset<I>(sht: &mut ShtC3<I>) -> Result<(), ShtError<I::Error>>
47
where
48
+
I: I2c<SevenBitAddress>,
49
{
50
+
sht.reset_async(&mut Delay).await?;
51
52
Ok(())
53
}