• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

eldruin / mlx9061x-rs / 21473701106

29 Jan 2026 09:58AM UTC coverage: 94.248% (-4.9%) from 99.177%
21473701106

Pull #10

github

web-flow
Merge 478e3481a into 9a1cd9e5e
Pull Request #10: Introduce Temperature struct

16 of 28 new or added lines in 3 files covered. (57.14%)

213 of 226 relevant lines covered (94.25%)

8.27 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

42.86
/src/types.rs
1
/// All possible errors in this crate
2
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
3
#[derive(Debug)]
4
pub enum Error<E> {
5
    /// I²C bus error
6
    I2C(E),
7
    /// CRC checksum mismatch (PEC)
8
    ChecksumMismatch,
9
    /// Invalid input data
10
    InvalidInputData,
11
}
12

13
/// IC marker
14
pub mod ic {
15
    /// MLX90614 IC marker
16
    pub struct Mlx90614;
17
    /// MLX90615 IC marker
18
    pub struct Mlx90615;
19
}
20

21
/// Possible slave addresses
22
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
23
#[derive(Debug, Clone, Copy, PartialEq)]
24
pub enum SlaveAddr {
25
    /// Default slave address
26
    Default,
27
    /// Alternative slave address
28
    Alternative(u8),
29
}
30

31
impl Default for SlaveAddr {
32
    /// Default slave address
33
    fn default() -> Self {
34✔
34
        SlaveAddr::Default
34✔
35
    }
34✔
36
}
37

38
/// Temperature value
39
#[cfg_attr(feature = "defmt-03", derive(defmt::Format))]
40
#[derive(Debug, Clone, Copy, PartialEq)]
41
pub struct Temperature(
42
    /// Raw temperature value
43
    pub u16,
44
);
45

46
impl Temperature {
47
    /// Temperature in kelvin
48
    pub fn kelvin(&self) -> f32 {
22✔
49
        self.0 as f32 * 0.02
22✔
50
    }
22✔
51

52
    /// Temperature in celsius
53
    pub fn celsius(&self) -> f32 {
22✔
54
        self.kelvin() - 273.15
22✔
55
    }
22✔
56

57
    /// Temperature in fahrenheit
NEW
58
    pub fn fahrenheit(&self) -> f32 {
×
NEW
59
        self.kelvin() * 9.0 / 5.0 - 459.67
×
NEW
60
    }
×
61

62
    /// Temperature in millikelvin
NEW
63
    pub fn millikelvin(&self) -> u32 {
×
NEW
64
        self.0 as u32 * 20
×
NEW
65
    }
×
66

67
    /// Temperature in millicelsius
NEW
68
    pub fn millicelsius(&self) -> i32 {
×
NEW
69
        self.millikelvin() as i32 - 273150
×
NEW
70
    }
×
71

72
    /// Temperature in millifahrenheit
NEW
73
    pub fn millifahrenheit(&self) -> i32 {
×
NEW
74
        self.millikelvin() as i32 * 9 / 5 - 459670
×
NEW
75
    }
×
76
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc