summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorWolfgang (Wolle) Ewald <wolfgang.ewald@wolles-elektronikkiste.de>2021-04-16 17:18:32 +0200
committerGitHub <noreply@github.com>2021-04-16 17:18:32 +0200
commit74b35152cfb8e5642957706adabe948f27f1d18b (patch)
treedd78c75944a2a3b8b9522a9292e68e785626da45 /src
parentUpdate library.properties (diff)
parentadded setSingleChannel (diff)
downloadADS1115_WE-74b35152cfb8e5642957706adabe948f27f1d18b.tar
ADS1115_WE-74b35152cfb8e5642957706adabe948f27f1d18b.tar.gz
ADS1115_WE-74b35152cfb8e5642957706adabe948f27f1d18b.tar.bz2
ADS1115_WE-74b35152cfb8e5642957706adabe948f27f1d18b.tar.lz
ADS1115_WE-74b35152cfb8e5642957706adabe948f27f1d18b.tar.xz
ADS1115_WE-74b35152cfb8e5642957706adabe948f27f1d18b.tar.zst
ADS1115_WE-74b35152cfb8e5642957706adabe948f27f1d18b.zip
Diffstat (limited to 'src')
-rw-r--r--src/ADS1115_WE.cpp8
-rw-r--r--src/ADS1115_WE.h5
2 files changed, 12 insertions, 1 deletions
diff --git a/src/ADS1115_WE.cpp b/src/ADS1115_WE.cpp
index debe73a..01cb4fa 100644
--- a/src/ADS1115_WE.cpp
+++ b/src/ADS1115_WE.cpp
@@ -218,7 +218,13 @@ void ADS1115_WE::setCompareChannels(ADS1115_MUX mux){
delayAccToRate(rate);
}
}
-
+
+void ADS1115_WE::setSingleChannel(size_t channel) {
+ if (channel >= 4)
+ return;
+ setCompareChannels((ADS1115_MUX)(ADS1115_COMP_0_GND + ADS1115_COMP_INC*channel));
+}
+
bool ADS1115_WE::isBusy(){
uint16_t currentConfReg = readRegister(ADS1115_CONFIG_REG);
return (!(currentConfReg>>15) & 1);
diff --git a/src/ADS1115_WE.h b/src/ADS1115_WE.h
index 6d68123..395d4d0 100644
--- a/src/ADS1115_WE.h
+++ b/src/ADS1115_WE.h
@@ -95,6 +95,7 @@ typedef enum ADS1115_MUX{
ADS1115_COMP_2_GND = 0x6000,
ADS1115_COMP_3_GND = 0x7000
} mux;
+#define ADS1115_COMP_INC 0x1000 // increment to next channel
typedef enum ADS1115_STATUS_OR_START{
ADS1115_BUSY = 0x0000,
@@ -213,6 +214,10 @@ public:
*/
void setCompareChannels(ADS1115_MUX mux);
+ /* Set to channel (0-3) in single ended mode
+ */
+ void setSingleChannel(size_t channel);
+
bool isBusy();
void startSingleMeasurement();
float getResult_V();