Skip to content

Commit fbd4b79

Browse files
authored
refactor constructor after fix #50 (#51)
- fix #50, bug in constructor (thanks Mathieu!) - refactor constructor
1 parent 1c72c6b commit fbd4b79

File tree

6 files changed

+30
-15
lines changed

6 files changed

+30
-15
lines changed

CHANGELOG..md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

77

8+
## [0.5.0] - 2024-06-17
9+
- fix #50, bug in constructor (thanks Mathieu!)
10+
- refactor constructor
11+
12+
----
13+
814
## [0.4.0] - 2024-03-02
915
- add fastProcessor option in **begin()** (Thanks to palmerr23)
1016
- updated license

HX711.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// FILE: HX711.cpp
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.4.0
4+
// VERSION: 0.5.0
55
// PURPOSE: Library for load cells for UNO
66
// URL: https://github.com/RobTillaart/HX711_MP
77
// URL: https://github.com/RobTillaart/HX711
@@ -12,6 +12,13 @@
1212

1313
HX711::HX711()
1414
{
15+
_gain = HX711_CHANNEL_A_GAIN_128;
16+
_offset = 0;
17+
_scale = 1;
18+
_lastRead = 0;
19+
_price = 0;
20+
_mode = HX711_AVERAGE_MODE;
21+
_fastProcessor = false;
1522
}
1623

1724

@@ -38,10 +45,11 @@ void HX711::reset()
3845
{
3946
power_down();
4047
power_up();
48+
_gain = HX711_CHANNEL_A_GAIN_128;
4149
_offset = 0;
4250
_scale = 1;
43-
_gain = HX711_CHANNEL_A_GAIN_128;
4451
_lastRead = 0;
52+
_price = 0;
4553
_mode = HX711_AVERAGE_MODE;
4654
}
4755

HX711.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22
//
33
// FILE: HX711.h
44
// AUTHOR: Rob Tillaart
5-
// VERSION: 0.4.0
5+
// VERSION: 0.5.0
66
// PURPOSE: Library for load cells for Arduino
77
// URL: https://github.com/RobTillaart/HX711_MP
88
// URL: https://github.com/RobTillaart/HX711
99
//
1010
// NOTES
1111
// Superset of interface of HX711 class of Bogde
12-
// float instead of long as float has 23 bits mantissa.
12+
// uses float instead of long as float has 23 bits mantissa
13+
// which almost perfectly matches the 24 bit ADC.
1314

1415

1516
#include "Arduino.h"
1617

17-
#define HX711_LIB_VERSION (F("0.4.0"))
18+
#define HX711_LIB_VERSION (F("0.5.0"))
1819

1920

2021
const uint8_t HX711_AVERAGE_MODE = 0x00;
@@ -175,16 +176,16 @@ class HX711
175176
uint8_t _dataPin;
176177
uint8_t _clockPin;
177178

178-
uint8_t _gain = 128; // default channel A
179-
long _offset = 0;
180-
float _scale = 1;
181-
uint32_t _lastRead = 0;
182-
float _price = 0;
183-
uint8_t _mode = HX711_AVERAGE_MODE;
179+
uint8_t _gain;
180+
long _offset;
181+
float _scale;
182+
uint32_t _lastRead;
183+
float _price;
184+
uint8_t _mode;
185+
bool _fastProcessor;
184186

185187
void _insertSort(float * array, uint8_t size);
186188
uint8_t _shiftIn();
187-
bool _fastProcessor = false;
188189
};
189190

190191

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ See https://github.com/RobTillaart/HX711/issues/40
386386
- example the adding scale
387387
- void weight_clr(), void weight_add(), float weight_get() - adding scale
388388
- decide pricing keep/not => move to .cpp
389-
- add **setRate()** and **getRate()**
389+
- add **setRate()** and **getRate()** - sample rate 10/80 SPS
390390
- optional?
391391

392392

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"type": "git",
1616
"url": "https://github.com/RobTillaart/HX711"
1717
},
18-
"version": "0.4.0",
18+
"version": "0.5.0",
1919
"license": "MIT",
2020
"frameworks": "*",
2121
"platforms": "*",

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=HX711
2-
version=0.4.0
2+
version=0.5.0
33
author=Rob Tillaart <rob.tillaart@gmail.com>
44
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
55
sentence=Arduino library for HX711 load cell amplifier

0 commit comments

Comments
 (0)