Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Loadcellfinal_last_worked_copy ColdStorageSystem
Fork of HX711 by
Revision 1:a2666eae3d06, committed 2017-03-20
- Comitter:
- padte
- Date:
- Mon Mar 20 13:07:36 2017 +0000
- Parent:
- 0:716e1cbdac61
- Commit message:
- hx711
Changed in this revision
| HX711.cpp | Show annotated file Show diff for this revision Revisions of this file |
| HX711.h | Show annotated file Show diff for this revision Revisions of this file |
--- 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
--- a/HX711.h Wed Nov 25 20:21:30 2015 +0000
+++ b/HX711.h Mon Mar 20 13:07:36 2017 +0000
@@ -33,12 +33,12 @@
{
public:
- HX711(PinName pinData, PinName pinSck,uint8_t gain = 128);
+ HX711(PinName , PinName ,uint8_t gain = 128);
~HX711();
int getValue(void);
- int averageValue(uint8_t times);
+ int averageValue(uint8_t times = 25 );
void setOffset(int offset);
- void setScale(float scale);
+ void setScale(float scale = 1990.f);
float getGram();
void setGain(uint8_t gain);
void powerDown();
