Open tim-seoss opened 5 years ago
I'm happy to create a PR btw.
Good catch :slightly_smiling_face: Using an i32 is probably the best approach.
In the mcp3425 crate, I also added a feature flag that allows using types from the measurements
crate (See Temperature
). But I doubt a lot of people would use that, especially on embedded devices (since it uses f64
).
OK, I think it's probably adding measurements::temperature::Temperature like you did in the mcp3425 crate. In the meantime I've added temperature and humidity (both in thousandths and stored as i32 using the "newtype" pattern). Please take a look at the pull request which I'll open in a minute to see what you think...
The temperature method currently returns an i16 (which is documented as being milli-degrees Celsius), so will overflow at temperatures over 32.767°C, or below -32.768°C. The SHT21 operating range is -40°C to +125°C
Possible solutions would be to reduce the number of decimal places (e.g. to 2) or use an i32.