Added define to adjust calibration precision. (#18613)

Co-authored-by: JeroenSt <nospam@nospam.org>
This commit is contained in:
Jeroen 2023-05-10 09:38:27 +02:00 committed by GitHub
parent bef49b4617
commit 632176765d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -991,6 +991,7 @@
// #define TM1638_MAX_LEDS 8 // Add support for 8 leds
//#define USE_HX711 // Add support for HX711 load cell (+1k5 code)
// #define USE_HX711_GUI // Add optional web GUI to HX711 as scale (+1k8 code)
// #define HX711_CAL_PRECISION 1 // When HX711 calibration is to course, raise this value
//#define USE_DINGTIAN_RELAY // Add support for the Dingian board using 74'595 et 74'165 shift registers
// #define DINGTIAN_INPUTS_INVERTED // Invert input states (Hi => OFF, Low => ON)

View File

@ -43,6 +43,10 @@
#ifndef HX_SCALE
#define HX_SCALE 120 // Default result of measured weight / reference weight when scale is 1
#endif
#ifndef HX711_CAL_PRECISION
#define HX711_CAL_PRECISION 1 // When calibration is to course, raise this value.
#endif
#define HX_TIMEOUT 120 // A reading at default 10Hz (pin RATE to Gnd on HX711) can take up to 100 milliseconds
#define HX_SAMPLES 10 // Number of samples for average calculation
@ -340,7 +344,7 @@ void HxEvery100mSecond(void) {
for (uint32_t i = 2; i < HX_SAMPLES -2; i++) {
sum_raw += Hx.reads[i];
}
Hx.raw_absolute = sum_raw / (HX_SAMPLES -4); // Uncalibrated value
Hx.raw_absolute = (sum_raw / (HX_SAMPLES -4)) * HX711_CAL_PRECISION; // Uncalibrated value
Hx.raw = Hx.raw_absolute / Hx.scale; // grams
if ((0 == Settings->weight_user_tare) && Hx.tare_flg) { // Reset scale based on current load