tof_control/helper/
ltb_type.rs

1use serde::{Deserialize, Serialize};
2
3/// LTB Data Type
4// All LTB Monitoring Types
5#[derive(Debug, Serialize, Deserialize)]
6pub struct LTBMoniData {
7    pub ltb_temp: LTBTemp,
8    pub ltb_thresh: LTBThreshold,
9}
10// LTB Temperature Sensor Data Type
11#[derive(Debug, Serialize, Deserialize)]
12pub struct LTBTemp {
13    pub trenz_temp: f32,
14    pub board_temp: f32,
15}
16// LTB Threshold Voltage Data Type
17#[derive(Debug, Serialize, Deserialize)]
18pub struct LTBThreshold {
19    pub thresh_0: f32,
20    pub thresh_1: f32,
21    pub thresh_2: f32,
22}
23
24/// LTB Error Type
25#[derive(Debug)]
26pub enum LTBError {
27    // I2C Error
28    I2C(i2cdev::linux::LinuxI2CError),
29    // Setting Threshold Error
30    SetThreshold,
31}
32
33impl std::fmt::Display for LTBError {
34    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
35        write!(f, "LTBError")
36    }
37}
38
39impl From<i2cdev::linux::LinuxI2CError> for LTBError {
40    fn from(e: i2cdev::linux::LinuxI2CError) -> Self {
41        LTBError::I2C(e)
42    }
43}