tof_control/tcpc_control/
tcpc_temp.rs1use crate::constant::*;
2use crate::helper::tcpc_type::{TCPCTemp, TCPCTempError};
3use crate::device::tmp1075;
4
5impl TCPCTemp {
6 pub fn new() -> Self {
7 match Self::read_temp() {
8 Ok(tcpc_temp) => {
9 tcpc_temp
10 }
11 Err(_) => {
12 Self {
13 tcpc_temp: f32::MAX,
14 }
15 }
16 }
17 }
18 pub fn read_temp() -> Result<TCPCTemp, TCPCTempError> {
19 let tcpc_tmp1075 = tmp1075::TMP1075::new(1, TCPC_TMP1075_ADDRESS);
20 tcpc_tmp1075.config()?;
21 let tcpc_temp = tcpc_tmp1075.read()?;
22
23 Ok(
24 TCPCTemp {
25 tcpc_temp,
26 }
27 )
28 }
29}