Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 1 | From c64d04d084f47b4cb3e1cdee6e96348fcc6a756e Mon Sep 17 00:00:00 2001 |
| 2 | From: Mihai Tudor Panu <mihai.tudor.panu@intel.com> |
| 3 | Date: Tue, 30 May 2017 15:14:09 -0700 |
| 4 | Subject: [PATCH 1/1] ads1x15: fixed case logic in getThresh() function |
| 5 | |
| 6 | Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com> |
| 7 | |
| 8 | Upstream-Status: Backported [c64d04d084f47b4cb3e1cdee6e96348fcc6a756e] |
| 9 | |
| 10 | Signed-off-by: Patrick Ohly <patrick.ohly@intel.com> |
| 11 | |
| 12 | --- |
| 13 | src/ads1x15/ads1x15.cxx | 4 ++-- |
| 14 | src/ads1x15/ads1x15.hpp | 2 +- |
| 15 | 2 files changed, 3 insertions(+), 3 deletions(-) |
| 16 | |
| 17 | diff --git a/src/ads1x15/ads1x15.cxx b/src/ads1x15/ads1x15.cxx |
| 18 | index 35782709..47701b2a 100644 |
| 19 | --- a/src/ads1x15/ads1x15.cxx |
| 20 | +++ b/src/ads1x15/ads1x15.cxx |
| 21 | @@ -116,7 +116,7 @@ ADS1X15::setContinuous(bool mode){ |
| 22 | |
| 23 | float |
| 24 | ADS1X15::getThresh(ADSTHRESH reg){ |
| 25 | - if( THRESH_HIGH && THRESH_LOW) return getLastSample(reg); |
| 26 | + if(reg == THRESH_HIGH || reg == THRESH_LOW) return getLastSample(reg); |
| 27 | else return 0.0; |
| 28 | } |
| 29 | |
| 30 | @@ -137,7 +137,7 @@ ADS1X15::setThresh(ADSTHRESH reg, float value){ |
| 31 | case 2: |
| 32 | case 3: |
| 33 | set_value = value / getMultiplier(); |
| 34 | - set_value = set_value << m_bitShift; |
| 35 | + set_value = set_value << m_bitShift; |
| 36 | if(i2c->writeWordReg(reg, swapWord(set_value)) != mraa::SUCCESS){ |
| 37 | throw std::runtime_error(std::string(__FUNCTION__) + ": I2c.write() failed"); |
| 38 | return; |
| 39 | diff --git a/src/ads1x15/ads1x15.hpp b/src/ads1x15/ads1x15.hpp |
| 40 | index 7524572d..efd8c8ec 100644 |
| 41 | --- a/src/ads1x15/ads1x15.hpp |
| 42 | +++ b/src/ads1x15/ads1x15.hpp |
| 43 | @@ -390,7 +390,7 @@ namespace upm { |
| 44 | * @param reg ADSTHRES enum value. |
| 45 | * Returns 0.0 unless THRESH_HIGH or THRESH_LOW requested. |
| 46 | */ |
| 47 | - float getThresh(ADSTHRESH reg = THRESH_LOW); |
| 48 | + float getThresh(ADSTHRESH reg = THRESH_DEFAULT); |
| 49 | |
| 50 | /** |
| 51 | * Sets threshold levels or configures for conversion ready |
| 52 | -- |
| 53 | 2.11.0 |
| 54 | |