Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions advanced/i2c-driver/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ fn main() -> Result<()> {
println!("Sensor init");
let device_id = sensor.read_device_id_register()?;

assert_eq!(device_id, 96_u8);
println!("Hello, world, I am sensor {}", device_id);
println!("Hello, world, I am sensor {:#02x}", device_id);

loop {
FreeRtos.delay_ms(500u32);
Expand Down
7 changes: 2 additions & 5 deletions advanced/i2c-sensor-reading/examples/part_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn main() -> Result<()> {
let device_id = sht.device_identifier().unwrap();

// 4. Read and print the sensor's device ID.
println!("Device ID SHTC3: {}", device_id);
println!("Device ID SHTC3: {:#02x}", device_id);

loop {
// 5. This loop initiates measurements, reads values and prints humidity in % and Temperature in °C.
Expand All @@ -41,10 +41,7 @@ fn main() -> Result<()> {
let measurement = sht.get_measurement_result().unwrap();

println!(
"TEMP: {} °C\n
HUM: {:?} %\n
\n
",
"TEMP: {:.2} °C | HUM: {:.2} %",
measurement.temperature.as_degrees_celsius(),
measurement.humidity.as_percent(),
);
Expand Down
14 changes: 5 additions & 9 deletions advanced/i2c-sensor-reading/examples/part_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ fn main() -> Result<()> {

// 6. Read and print the device ID.
let device_id = sht.device_identifier().unwrap();
println!("Device ID SHTC3: {}", device_id);
println!("Device ID SHTC3: {:#02x}", device_id);

// 7. Create an instance of ICM42670p sensor. Pass the second proxy and the sensor's address.
let mut imu = Icm42670::new(proxy_2, Address::Primary).unwrap();

// 8. Read the device's ID register and print the value.
let device_id = imu.device_id().unwrap();
println!("Device ID ICM42670p: {}", device_id);
println!("Device ID ICM42670p: {:#02x}", device_id);

// 9. Start the ICM42670p in low noise mode.
imu.set_power_mode(imuPowerMode::GyroLowNoise).unwrap();
Expand All @@ -62,16 +62,12 @@ fn main() -> Result<()> {

// 11. Print all values
println!(
" GYRO: X: {:.2} Y: {:.2} Z: {:.2}\n
TEMP: {} °C\n
HUM: {:?} %\n
\n
",
"TEMP: {:.2} °C | HUM: {:.2} % | GYRO: X= {:.2} Y= {:.2} Z= {:.2}",
measurement.temperature.as_degrees_celsius(),
measurement.humidity.as_percent(),
gyro_data.x,
gyro_data.y,
gyro_data.z,
measurement.temperature.as_degrees_celsius(),
measurement.humidity.as_percent(),
);

FreeRtos.delay_ms(500u32);
Expand Down