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