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