fn display_data(&mut self, 
                    data: i16, unit: char, 
                    lo_thresh: Option<i16>, hi_thresh: Option<i16>, 
                    min_val: i16, max_val: i16) -> Result<(), Error<E>> {

        let mut min_limit = -99;
        let mut max_limit = 999;

        // check if limits can be accepted, if not reset to -99/999                                    
        if min_val > (-100) {
            min_limit = min_val
        }

        if max_val < 1000 {
            max_limit = max_val
        }           

        // thresholds initialized as min/max limits
        let mut lo_th: i16 = min_limit; 
        let mut hi_th: i16 = max_limit;

        if let Some(val) = lo_thresh {
            lo_th = val
        } 

        if let Some(val) = hi_thresh {
            hi_th = val
        } 

        // display -LL- and -HH- for data exceding thresholds, 
        // e.g. -20 and +50 for a temperature sensor
        
        if data < min_val || data > max_val {
            for (pos,ch) in "----".chars().enumerate() {
                self.display_char(pos as u8, ch)?                
            }                
        } else if data < lo_th {
            for (pos,ch) in "-LL-".chars().enumerate() {
                self.display_char(pos as u8, ch)?
                
            }    
            
        } else if data > hi_th {
            for (pos,ch) in "-HH-".chars().enumerate() {                
                self.display_char(pos as u8, ch)?                
            }    
            
        } else {        
            let hundreds: u8 = (data.abs() / 100) as u8;
            let decimals: u8 = ((data.abs() % 100) / 10) as u8; 
           
            // position 0 (hundreds or minus sign)
            if data < 0 {                
                self.display_char(0, '-')?
            } else if hundreds == 0 {
                self.display_char(0, ' ')?                
                
            } else {
                self.display_digit(0, hundreds)?                             
            }

            // position 1 (decimals)
            if (hundreds == 0 || data < 0) && decimals == 0 {
                self.display_char(1, ' ')?
                //self.write(&[Register::POSITION_SETTING, 1, ' ' as u8])?
            } else {              
                self.display_digit(1, decimals)?
            }

            // position 2             
            self.display_digit(2, (data.abs() % 10) as u8)?;

            // position 3 (unit)            
            self.display_char(3, unit)?;

        }

        Ok(())

    }
/// Display data with units (temperature, humidity) and defined thresholds
Display data with units (temperature, humidity) and defined thresholds
Display data with units ( temperature humidity ) and defined thresholds
fn display_data(&mut self, 
                    data: i16, unit: char, 
                    lo_thresh: Option<i16>, hi_thresh: Option<i16>, 
                    min_val: i16, max_val: i16) -> Result<(), Error<E>> {
        let mut min_limit = -99;
        let mut max_limit = 999;
        // check if limits can be accepted, if not reset to -99/999                                    
        if min_val > (-100) {
            min_limit = min_val
        }
        if max_val < 1000 {
            max_limit = max_val
        }           
        // thresholds initialized as min/max limits
        let mut lo_th: i16 = min_limit; 
        let mut hi_th: i16 = max_limit;
        if let Some(val) = lo_thresh {
            lo_th = val
        } 
        if let Some(val) = hi_thresh {
            hi_th = val
        } 
        // display -LL- and -HH- for data exceding thresholds, 
        // e.g. -20 and +50 for a temperature sensor
        if data < min_val || data > max_val {
            for (pos,ch) in "----".chars().enumerate() {
                self.display_char(pos as u8, ch)?                
            }                
        } else if data < lo_th {
            for (pos,ch) in "-LL-".chars().enumerate() {
                self.display_char(pos as u8, ch)?
            }    
        } else if data > hi_th {
            for (pos,ch) in "-HH-".chars().enumerate() {                
                self.display_char(pos as u8, ch)?                
            }    
        } else {        
            let hundreds: u8 = (data.abs() / 100) as u8;
            let decimals: u8 = ((data.abs() % 100) / 10) as u8; 
            // position 0 (hundreds or minus sign)
            if data < 0 {                
                self.display_char(0, '-')?
            } else if hundreds == 0 {
                self.display_char(0, ' ')?                
            } else {
                self.display_digit(0, hundreds)?                             
            }
            // position 1 (decimals)
            if (hundreds == 0 || data < 0) && decimals == 0 {
                self.display_char(1, ' ')?
                //self.write(&[Register::POSITION_SETTING, 1, ' ' as u8])?
            } else {              
                self.display_digit(1, decimals)?
            }
            // position 2             
            self.display_digit(2, (data.abs() % 10) as u8)?;
            // position 3 (unit)            
            self.display_char(3, unit)?;
        }
        Ok(())
    }
fn display_data ( & mut self , data : i16 , unit : char , lo_thresh : Option < i16 > , hi_thresh : Option < i16 > , min_val : i16 , max_val : i16 ) -> Result < ( ) , Error < E > > { let mut min_limit = - 99 ; let mut max_limit = 999 ; // check if limits can be accepted, if not reset to -99/999                                     if min_val > ( - 100 ) { min_limit = min_val } if max_val < 1000 { max_limit = max_val } // thresholds initialized as min/max limits let mut lo_th : i16 = min_limit ; let mut hi_th : i16 = max_limit ; if let Some ( val ) = lo_thresh { lo_th = val } if let Some ( val ) = hi_thresh { hi_th = val } // display -LL- and -HH- for data exceding thresholds,  // e.g. -20 and +50 for a temperature sensor if data < min_val || data > max_val { for ( pos , ch ) in " " . chars ( ) . enumerate ( ) { self . display_char ( pos as u8 , ch ) ? } } else if data < lo_th { for ( pos , ch ) in " " . chars ( ) . enumerate ( ) { self . display_char ( pos as u8 , ch ) ? } } else if data > hi_th { for ( pos , ch ) in " " . chars ( ) . enumerate ( ) { self . display_char ( pos as u8 , ch ) ? } } else { let hundreds : u8 = ( data . abs ( ) / 100 ) as u8 ; let decimals : u8 = ( ( data . abs ( ) % 100 ) / 10 ) as u8 ; // position 0 (hundreds or minus sign) if data < 0 { self . display_char ( 0 , '-' ) ? } else if hundreds == 0 { self . display_char ( 0 , ' ' ) ? } else { self . display_digit ( 0 , hundreds ) ? } // position 1 (decimals) if ( hundreds == 0 || data < 0 ) && decimals == 0 { self . display_char ( 1 , ' ' ) ? //self.write(&[Register::POSITION_SETTING, 1, ' ' as u8])? } else { self . display_digit ( 1 , decimals ) ? } // position 2              self . display_digit ( 2 , ( data . abs ( ) % 10 ) as u8 ) ? ; // position 3 (unit)             self . display_char ( 3 , unit ) ? ; } Ok ( ( ) ) }
Display data with units (temperature, humidity) and defined thresholds
Display data with units ( temperature humidity ) and defined thresholds
&mut self
data
i16
unit
char
lo_thresh
Option<i16>
hi_thresh
Option<i16>
min_val
i16
max_val
i16
&mut self
data
i16
unit
char
lo_thresh
Option<i16>
hi_thresh
Option<i16>
min_val
i16
max_val
i16