pub struct Max6675 { /* private fields */ }Expand description
A representation of the MAX6675 thermocouple digitizer.
Implementations§
Source§impl Max6675
impl Max6675
Sourcepub fn new(spi_connection_path: impl AsRef<str>) -> Result<Self, Max6675Error>
pub fn new(spi_connection_path: impl AsRef<str>) -> Result<Self, Max6675Error>
Tries to create a new Max6675 based on the given SPI path.
A valid SPI path usually looks like /dev/spidev0.0.
§Example
use linux_max6675::Max6675;
match Max6675::new("/dev/spidev0.0") {
Ok(_thermo) => {
println!("success! woohoo");
}
Err(e) => {
println!("oh noooo big scary error {e}");
}
}Sourcepub fn read_celsius(&mut self) -> Result<Temperature, Max6675Error>
pub fn read_celsius(&mut self) -> Result<Temperature, Max6675Error>
Tries to read the thermocouple’s temperature in Celsius.
§Example
let mut thermo = Max6675::new("/dev/spidev0.0")?;
println!("it's {}° celsius in here!", thermo.read_celsius()?);Sourcepub fn read_fahrenheit(&mut self) -> Result<Temperature, Max6675Error>
pub fn read_fahrenheit(&mut self) -> Result<Temperature, Max6675Error>
Tries to read the thermocouple’s temperature in Fahrenheit.
§Example
let mut thermo = Max6675::new("/dev/spidev0.0")?;
println!("oh man! it's {}° fahrenheit in here!", thermo.read_fahrenheit()?);Sourcepub fn read_kelvin(&mut self) -> Result<Temperature, Max6675Error>
pub fn read_kelvin(&mut self) -> Result<Temperature, Max6675Error>
Tries to read the thermocouple’s temperature in Kelvin.
§Example
let mut thermo = Max6675::new("/dev/spidev0.0")?;
println!("i'm a nerd and i use kelvin! and it's {}° kelvin!", thermo.read_kelvin()?);Sourcepub fn read_raw(&mut self) -> Result<[u8; 2], Max6675Error>
pub fn read_raw(&mut self) -> Result<[u8; 2], Max6675Error>
Tries to return the thermocouple’s raw data for data science. (and other fun little things)
Refer to page 5 of Maxim Integrated’s MAX6675 specsheet for info on how to interpret this raw data.
§Example
let mut thermo = Max6675::new("/dev/spidev0.0")?;
let res = thermo.read_raw()?;
println!("oOoo here's my favorite bytes: [{}, {}]", res[0], res[1]);Trait Implementations§
Auto Trait Implementations§
impl Freeze for Max6675
impl RefUnwindSafe for Max6675
impl Send for Max6675
impl Sync for Max6675
impl Unpin for Max6675
impl UnwindSafe for Max6675
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more