summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Barrios Romero <eldruin@gmail.com>2018-11-17 14:21:12 +0100
committerDiego Barrios Romero <eldruin@gmail.com>2018-11-17 14:21:12 +0100
commit950120f4a2d0199a63b59b523f1a1638e20c4f13 (patch)
tree633516fff3fad0cb582c990cf56cb0e30f0119d4
parent1de0700f63b82e4c649ef0d73443946d74df5b05 (diff)
downloadads1x1x-async-950120f4a2d0199a63b59b523f1a1638e20c4f13.tar.gz
ads1x1x-async-950120f4a2d0199a63b59b523f1a1638e20c4f13.tar.xz
ads1x1x-async-950120f4a2d0199a63b59b523f1a1638e20c4f13.zip
Rename threshold methods
-rw-r--r--README.md2
-rw-r--r--src/devices/features/tier2.rs8
-rw-r--r--src/lib.rs11
-rw-r--r--tests/tier2_i2c.rs4
4 files changed, 13 insertions, 12 deletions
diff --git a/README.md b/README.md
index 615e9aa..46ae708 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,7 @@ This driver allows you to:
- Set the operating mode to one-shot or continuous. See: `into_continuous()`.
- Make a measurement in one-shot mode. See: `read()`.
- Set the data rate. See: `set_data_rate()`.
-- Set the low and high thresholds. See: `set_high_threshold()`.
+- Set the low and high thresholds. See: `set_high_threshold_raw()`.
- Set the comparator mode. See: `set_comparator_mode()`.
- Set the comparator polarity. See: `set_comparator_polarity()`.
- Set the comparator latching. See: `set_comparator_latching()`.
diff --git a/src/devices/features/tier2.rs b/src/devices/features/tier2.rs
index 067139a..2a35f7c 100644
--- a/src/devices/features/tier2.rs
+++ b/src/devices/features/tier2.rs
@@ -31,14 +31,14 @@ where
Ok(())
}
- /// Set comparator lower threshold
- pub fn set_low_threshold(&mut self, value: i16) -> Result<(), Error<E>> {
+ /// Set raw comparator lower threshold
+ pub fn set_low_threshold_raw(&mut self, value: i16) -> Result<(), Error<E>> {
let register_value = CONV::convert_threshold(value)?;
self.iface.write_register(Register::LOW_TH, register_value)
}
- /// Set comparator upper threshold
- pub fn set_high_threshold(&mut self, value: i16) -> Result<(), Error<E>> {
+ /// Set raw comparator upper threshold
+ pub fn set_high_threshold_raw(&mut self, value: i16) -> Result<(), Error<E>> {
let register_value = CONV::convert_threshold(value)?;
self.iface.write_register(Register::HIGH_TH, register_value)
}
diff --git a/src/lib.rs b/src/lib.rs
index 1d1fc4d..4382e61 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -9,7 +9,7 @@
//! - Make a measurement in one-shot mode. See: [`read()`].
//! - Set the data rate. See: [`set_data_rate()`].
//! - Set the full-scale range (gain amplifier). See [`set_full_scale_range()`].
-//! - Set the low and high thresholds. See: [`set_high_threshold()`].
+//! - Set the low and high thresholds. See: [`set_high_threshold_raw()`].
//! - Set the comparator mode. See: [`set_comparator_mode()`].
//! - Set the comparator polarity. See: [`set_comparator_polarity()`].
//! - Set the comparator latching. See: [`set_comparator_latching()`].
@@ -20,7 +20,7 @@
//! [`read()`]: struct.Ads1x1x.html#method.read
//! [`set_data_rate()`]: struct.Ads1x1x.html#method.set_data_rate
//! [`set_full_scale_range()`]: struct.Ads1x1x.html#method.set_full_scale_range
-//! [`set_high_threshold()`]: struct.Ads1x1x.html#method.set_high_threshold
+//! [`set_high_threshold_raw()`]: struct.Ads1x1x.html#method.set_high_threshold_raw
//! [`set_comparator_mode()`]: struct.Ads1x1x.html#method.set_comparator_mode
//! [`set_comparator_polarity()`]: struct.Ads1x1x.html#method.set_comparator_polarity
//! [`set_comparator_latching()`]: struct.Ads1x1x.html#method.set_comparator_latching
@@ -172,7 +172,7 @@
//! extern crate linux_embedded_hal as hal;
//! extern crate ads1x1x;
//! use ads1x1x::{ Ads1x1x, SlaveAddr, ComparatorQueue, ComparatorPolarity,
-//! ComparatorMode, ComparatorLatching };
+//! ComparatorMode, ComparatorLatching, FullScaleRange };
//!
//! # fn main() {
//! let dev = hal::I2cdev::new("/dev/i2c-1").unwrap();
@@ -181,8 +181,9 @@
//! 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_full_scale_range(FullScaleRange::Within2_048V).unwrap();
+//! adc.set_low_threshold_raw(-1500).unwrap();
+//! adc.set_high_threshold_raw(1500).unwrap();
//! adc.set_comparator_latching(ComparatorLatching::Latching).unwrap();
//! # }
//! ```
diff --git a/tests/tier2_i2c.rs b/tests/tier2_i2c.rs
index 00eaad8..7d17270 100644
--- a/tests/tier2_i2c.rs
+++ b/tests/tier2_i2c.rs
@@ -29,8 +29,8 @@ macro_rules! config_test {
mod can_set_comparator_thresholds {
use super::*;
- set_value_test!(low, set_low_threshold, 2047, LOW_TH, 0x7F, 0xF0);
- set_value_test!(high, set_high_threshold, 2047, HIGH_TH, 0x7F, 0xF0);
+ set_value_test!(low, set_low_threshold_raw, 2047, LOW_TH, 0x7F, 0xF0);
+ set_value_test!(high, set_high_threshold_raw, 2047, HIGH_TH, 0x7F, 0xF0);
}
mod can_set_comparator_mode {