From 7d731f50ea09920ab59fb864dd8433b48832a8f4 Mon Sep 17 00:00:00 2001 From: Henk Dieter Oordt Date: Thu, 14 Nov 2019 11:29:46 +0100 Subject: [PATCH] Bump version to 0.1.1, fix data conversion --- Cargo.toml | 2 +- src/data.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e2375ae..fd8ef4e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ads129xx" -version = "0.1.0" +version = "0.1.1" authors = ["Henk Dieter "] edition = "2018" readme = "README.md" diff --git a/src/data.rs b/src/data.rs index 84d977f..07cbba9 100644 --- a/src/data.rs +++ b/src/data.rs @@ -1,5 +1,6 @@ use core::fmt; +#[derive(Default, Copy, Clone)] pub struct LeadOffStatus { /// The status. Bits [5:7] are unused pub status: u8, @@ -106,7 +107,7 @@ impl ChannelData { impl From for i32 { fn from(channel_data: ChannelData) -> Self { - unsafe { core::mem::transmute([0, channel_data.0, channel_data.1, channel_data.2]) } + i32::from_be_bytes([channel_data.0, channel_data.1, channel_data.2, 0]) >> 8 } }