Librairie HX711 fonctionnel sur Nucleo L152RE

Dependents:   Nucleo_HX711_Demo STM32_StrainGauge

Committer:
BB50
Date:
Fri Jun 12 16:05:39 2015 +0000
Revision:
0:f82840dd806a
1st release.; Work.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
BB50 0:f82840dd806a 1 /*
BB50 0:f82840dd806a 2 * FILE: HX711.h
BB50 0:f82840dd806a 3 *
BB50 0:f82840dd806a 4 * VERSION: 0.1
BB50 0:f82840dd806a 5 * PURPOSE: HX711 weight library for Nucleo STM32
BB50 0:f82840dd806a 6 * AUTHOR: Bertrand Bouvier
BB50 0:f82840dd806a 7 * LICENSE: GPL v3 (http://www.gnu.org/licenses/gpl.html)
BB50 0:f82840dd806a 8 *
BB50 0:f82840dd806a 9 * DATASHEET: http://www.dfrobot.com/image/data/SEN0160/hx711_english.pdf
BB50 0:f82840dd806a 10 * URL:
BB50 0:f82840dd806a 11 *
BB50 0:f82840dd806a 12 * HISTORY:
BB50 0:f82840dd806a 13 * 24/05/2015 - Bertrand Bouvier - Original version
BB50 0:f82840dd806a 14 * see HX711.cpp
BB50 0:f82840dd806a 15 *
BB50 0:f82840dd806a 16 * SPECIAL THANKS:
BB50 0:f82840dd806a 17 * Inspiré du travail de Weihong Guan (@aguegu)
BB50 0:f82840dd806a 18 * https://github.com/aguegu/Arduino
BB50 0:f82840dd806a 19 * http://aguegu.net
BB50 0:f82840dd806a 20 *
BB50 0:f82840dd806a 21 * Inspiré du travail de bodge
BB50 0:f82840dd806a 22 * https://github.com/bogde/HX711
BB50 0:f82840dd806a 23 *
BB50 0:f82840dd806a 24 */
BB50 0:f82840dd806a 25
BB50 0:f82840dd806a 26 #ifndef HX711_H
BB50 0:f82840dd806a 27 #define HX711_H
BB50 0:f82840dd806a 28
BB50 0:f82840dd806a 29 #include "mbed.h"
BB50 0:f82840dd806a 30
BB50 0:f82840dd806a 31
BB50 0:f82840dd806a 32 class HX711
BB50 0:f82840dd806a 33 {
BB50 0:f82840dd806a 34
BB50 0:f82840dd806a 35 public:
BB50 0:f82840dd806a 36 HX711(PinName pinData, PinName pinSck,uint8_t gain = 128);
BB50 0:f82840dd806a 37 ~HX711();
BB50 0:f82840dd806a 38 int getValue(void);
BB50 0:f82840dd806a 39 int averageValue(uint8_t times);
BB50 0:f82840dd806a 40 void setOffset(int offset);
BB50 0:f82840dd806a 41 void setScale(float scale);
BB50 0:f82840dd806a 42 float getGram();
BB50 0:f82840dd806a 43 void setGain(uint8_t gain);
BB50 0:f82840dd806a 44 void powerDown();
BB50 0:f82840dd806a 45 void powerUp();
BB50 0:f82840dd806a 46 void tare(uint8_t times = 10);
BB50 0:f82840dd806a 47
BB50 0:f82840dd806a 48
BB50 0:f82840dd806a 49 private:
BB50 0:f82840dd806a 50 PinName _pinData;
BB50 0:f82840dd806a 51 PinName _pinSck;
BB50 0:f82840dd806a 52 int _offset;
BB50 0:f82840dd806a 53 float _scale;
BB50 0:f82840dd806a 54 uint8_t _gain; //[128|32|64]
BB50 0:f82840dd806a 55
BB50 0:f82840dd806a 56
BB50 0:f82840dd806a 57 };
BB50 0:f82840dd806a 58
BB50 0:f82840dd806a 59 #endif