summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Barrios Romero <eldruin@gmail.com>2018-11-17 13:55:59 +0100
committerDiego Barrios Romero <eldruin@gmail.com>2018-11-17 13:55:59 +0100
commit58980304a2768ceca623b2125aafc02461aa7ef8 (patch)
treeb4cf6bb8ea4a0ee3d6a9015de53073f5a66b260a
parent8724ff8565d56bfd88a2bfb397839059884fdab6 (diff)
downloadads1x1x-async-58980304a2768ceca623b2125aafc02461aa7ef8.tar.gz
ads1x1x-async-58980304a2768ceca623b2125aafc02461aa7ef8.tar.xz
ads1x1x-async-58980304a2768ceca623b2125aafc02461aa7ef8.zip
Add comparator configuration example
-rw-r--r--src/lib.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index ba78b3a..537a0b3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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();
//! # }
//! ```