Struct linux_max6675::Max6675

source ·
pub struct Max6675 { /* private fields */ }
Expand description

A representation of the MAX6675 thermocouple digitizer.

Implementations§

source§

impl Max6675

source

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}");
    }
}
source

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()?);
source

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()?);
source

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()?);
source

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§

source§

impl Debug for Max6675

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.