diff options
author | Diego Barrios Romero <eldruin@gmail.com> | 2018-11-17 13:55:59 +0100 |
---|---|---|
committer | Diego Barrios Romero <eldruin@gmail.com> | 2018-11-17 13:55:59 +0100 |
commit | 58980304a2768ceca623b2125aafc02461aa7ef8 (patch) | |
tree | b4cf6bb8ea4a0ee3d6a9015de53073f5a66b260a /src | |
parent | 8724ff8565d56bfd88a2bfb397839059884fdab6 (diff) | |
download | ads1x1x-async-58980304a2768ceca623b2125aafc02461aa7ef8.tar.gz ads1x1x-async-58980304a2768ceca623b2125aafc02461aa7ef8.tar.xz ads1x1x-async-58980304a2768ceca623b2125aafc02461aa7ef8.zip |
Add comparator configuration example
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -159,6 +159,29 @@ //! # } //! ``` //! +//! ### Configure the comparator +//! Configure the comparator to assert when the voltage drops below -1.5V +//! or goes above 1.5V in at least two consecutive conversions. Then the +//! ALERT/RDY pin will be set high and it will be kept so until the +//! measurement is read or an appropriate SMBus alert response is sent by +//! the master. +//! +//! ```no_run +//! extern crate linux_embedded_hal as hal; +//! extern crate ads1x1x; +//! use ads1x1x::{ Ads1x1x, SlaveAddr, ComparatorQueue, ComparatorPolarity, +//! ComparatorMode, ComparatorLatching }; +//! +//! # fn main() { +//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap(); +//! let address = SlaveAddr::default(); +//! let mut adc = Ads1x1x::new_ads1015(dev, address); +//! adc.set_comparator_queue(ComparatorQueue::Two).unwrap(); +//! adc.set_comparator_polarity(ComparatorPolarity::ActiveHigh).unwrap(); +//! adc.set_comparator_mode(ComparatorMode::Window).unwrap(); +//! adc.set_low_threshold(-1500).unwrap(); +//! adc.set_high_threshold(1500).unwrap(); +//! adc.set_comparator_latching(ComparatorLatching::Latching).unwrap(); //! # } //! ``` |