summaryrefslogtreecommitdiffstats
path: root/src/ADS1115_WE.cpp
diff options
context:
space:
mode:
authorWolfgang (Wolle) Ewald <wolfgang.ewald@wolles-elektronikkiste.de>2020-08-08 11:38:20 +0200
committerGitHub <noreply@github.com>2020-08-08 11:38:20 +0200
commit1f26c3979751e7ad0285d0c4f5811ec184907597 (patch)
tree98b6ca319e96f30b0f5ef9143685802aedbe1b5e /src/ADS1115_WE.cpp
parentAdd files via upload (diff)
downloadADS1115_WE-1f26c3979751e7ad0285d0c4f5811ec184907597.tar
ADS1115_WE-1f26c3979751e7ad0285d0c4f5811ec184907597.tar.gz
ADS1115_WE-1f26c3979751e7ad0285d0c4f5811ec184907597.tar.bz2
ADS1115_WE-1f26c3979751e7ad0285d0c4f5811ec184907597.tar.lz
ADS1115_WE-1f26c3979751e7ad0285d0c4f5811ec184907597.tar.xz
ADS1115_WE-1f26c3979751e7ad0285d0c4f5811ec184907597.tar.zst
ADS1115_WE-1f26c3979751e7ad0285d0c4f5811ec184907597.zip
Diffstat (limited to 'src/ADS1115_WE.cpp')
-rw-r--r--src/ADS1115_WE.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/ADS1115_WE.cpp b/src/ADS1115_WE.cpp
index 9da6d48..6ccd3f4 100644
--- a/src/ADS1115_WE.cpp
+++ b/src/ADS1115_WE.cpp
@@ -163,14 +163,29 @@ float ADS1115_WE::getResult_mV(){
return result;
}
+int16_t ADS1115_WE::getRawResult(){
+ int16_t rawResult = readRegister(ADS1115_CONV_REG);
+ return rawResult;
+}
+
int16_t ADS1115_WE::getResultWithRange(int16_t min, int16_t max){
int16_t rawResult = readRegister(ADS1115_CONV_REG);
- //rawResult = (int) (rawResult * (voltageRange * 1.0 / 6144));
int16_t result = 0;
- result = map(rawResult, 0, 32767, min, max);
+ result = map(rawResult, -32767, 32767, min, max);
return result;
}
+int16_t ADS1115_WE::getResultWithRange(int16_t min, int16_t max, int16_t maxMillivolt){
+ int16_t rawResult = readRegister(ADS1115_CONV_REG);
+ int16_t result = 0;
+ result = map(rawResult, -32767, 32767, min, max);
+ result = (int16_t) (1.0 * result * voltageRange / maxMillivolt);
+ return result;
+}
+
+uint16_t ADS1115_WE::getVoltageRange_mV(){
+ return voltageRange;
+}
void ADS1115_WE::setAlertPinToConversionReady(){
writeRegister(ADS1115_LO_THRESH_REG, (0<<15));