library for using load cell with hx711
Dependents: Loadcellfinal_last_worked_copy ColdStorageSystem
Fork of HX711 by
Diff: HX711.cpp
- Revision:
- 1:a2666eae3d06
- Parent:
- 0:716e1cbdac61
diff -r 716e1cbdac61 -r a2666eae3d06 HX711.cpp --- a/HX711.cpp Wed Nov 25 20:21:30 2015 +0000 +++ b/HX711.cpp Mon Mar 20 13:07:36 2017 +0000 @@ -14,11 +14,11 @@ * see HX711.h * * SPECIAL THANKS: - * Inspiré du travail de Weihong Guan (@aguegu) + * * https://github.com/aguegu/Arduino * http://aguegu.net * - * Inspiré du travail de bodge + * Inspired by bodge work * https://github.com/bogde/HX711 * */ @@ -26,12 +26,12 @@ #include "HX711.h" #include "mbed.h" -#define SCALE_VALUE 259.79 //multiple propre à chaque hardware +//#define SCALE_VALUE 259.79 //Multiple hardware-specific -HX711::HX711(PinName pinData, PinName pinSck, uint8_t gain) +HX711::HX711(PinName pinData, PinName pinSck , uint8_t gain) { - _pinData = pinData; - _pinSck = pinSck; + _pinData = pinData ; + _pinSck = pinSck ; this->setGain(gain); @@ -42,8 +42,8 @@ wait_us(100); sck = 0; - this->setOffset(averageValue(10)); //TARE de la balance - this->setScale(SCALE_VALUE); //Réglage du valeur du SCALE + this->setOffset(averageValue()); //TARE de la balance + this->setScale(); //Setting the SCALE value } HX711::~HX711() @@ -51,10 +51,10 @@ } -int HX711::averageValue(uint8_t times) //Calcule une moyenne sur plusieurs mesures +int HX711::averageValue(uint8_t times) //Calculates an average over several measurements { int sum = 0; - for (int i = 0; i < times; i++) + for (uint8_t i = 0; i < times; i++) { sum += getValue(); } @@ -62,7 +62,7 @@ return sum / times; } -int HX711::getValue() //Obtenir la valeur brut du controller +int HX711::getValue() //Obtain the controller raw value { int buffer; buffer = 0 ; @@ -110,7 +110,7 @@ float HX711::getGram() { - long val = (averageValue(2) - _offset); + long val = (averageValue() - _offset); return (float) val / _scale; } @@ -153,4 +153,4 @@ int sum = averageValue(times); setOffset(sum); } - \ No newline at end of file + \ No newline at end of file