From 79fa34e2de96c35762aa9205403ac25b1015f76d Mon Sep 17 00:00:00 2001 From: olkal Date: Sat, 16 Jun 2018 16:47:41 +0200 Subject: [PATCH] 1.0.2 --- README.md | 5 ++++- library.properties | 2 +- src/HX711_ADC.cpp | 6 ++++++ src/HX711_ADC.h | 3 ++- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cb5b3ea..cb23750 100644 --- a/README.md +++ b/README.md @@ -24,4 +24,7 @@ Hardware and ADC noise: Wires between HX711 and load cell should be twisted and kept as short as possible. Most available HX711 modules seems to follow the reference design, but be aware that some modules are poorly designed with under-sized capacitors, and noisy readings. The Sparkfun module seems to differ from most other available modules as it has some additional components for noise reduction. - + +Update 1.0.2: +- Implemented requested function setTareOffset(long newoffset) +- Initializing of the index counter in the class declaration: readIndex = 0 diff --git a/library.properties b/library.properties index d63c9e7..1be276a 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=HX711_ADC -version=1.0.1 +version=1.0.2 author=Olav Kallhovd maintainer=Olav Kallhovd sentence=Arduino library for the HX711 24-bit ADC for weight scales diff --git a/src/HX711_ADC.cpp b/src/HX711_ADC.cpp index de1c918..b146ae2 100644 --- a/src/HX711_ADC.cpp +++ b/src/HX711_ADC.cpp @@ -207,11 +207,17 @@ void HX711_ADC::powerUp() digitalWrite(sckPin, LOW); } +//get the tare offset (raw data value output without the scale "CalFactor") long HX711_ADC::getTareOffset() { return tareOffset; } +//set new tare offset (raw data value input without the scale "CalFactor") +void HX711_ADC::setTareOffset(long newoffset) +{ + tareOffset = newoffset; +} //for testing only: //if ready: returns 24 bit data and starts the next conversion, else returns -1 diff --git a/src/HX711_ADC.h b/src/HX711_ADC.h index 70181a6..5571f70 100644 --- a/src/HX711_ADC.h +++ b/src/HX711_ADC.h @@ -55,6 +55,7 @@ class HX711_ADC void powerUp(); bool getTareStatus(); // returns 1 if tareNoDelay() operation is complete long getTareOffset(); + void setTareOffset(long newoffset); uint8_t update(); //if conversion is ready; read out 24 bit data and add to data set protected: @@ -66,7 +67,7 @@ class HX711_ADC float calFactor; long dataSampleSet[DATA_SET + 1]; // data set, make voltile if interrupt is used long tareOffset; - int readIndex; + int readIndex = 0; long timeStamp; uint8_t isFirst = 1; uint8_t tareTimes;