Skip to content

Commit

Permalink
refactor constructor after fix #50 (#51)
Browse files Browse the repository at this point in the history
- fix #50, bug in constructor (thanks Mathieu!)
  - refactor constructor
  • Loading branch information
RobTillaart authored Jun 17, 2024
1 parent 1c72c6b commit fbd4b79
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 15 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG..md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [0.5.0] - 2024-06-17
- fix #50, bug in constructor (thanks Mathieu!)
- refactor constructor

----

## [0.4.0] - 2024-03-02
- add fastProcessor option in **begin()** (Thanks to palmerr23)
- updated license
Expand Down
12 changes: 10 additions & 2 deletions HX711.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FILE: HX711.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.4.0
// VERSION: 0.5.0
// PURPOSE: Library for load cells for UNO
// URL: https://github.com/RobTillaart/HX711_MP
// URL: https://github.com/RobTillaart/HX711
Expand All @@ -12,6 +12,13 @@

HX711::HX711()
{
_gain = HX711_CHANNEL_A_GAIN_128;
_offset = 0;
_scale = 1;
_lastRead = 0;
_price = 0;
_mode = HX711_AVERAGE_MODE;
_fastProcessor = false;
}


Expand All @@ -38,10 +45,11 @@ void HX711::reset()
{
power_down();
power_up();
_gain = HX711_CHANNEL_A_GAIN_128;
_offset = 0;
_scale = 1;
_gain = HX711_CHANNEL_A_GAIN_128;
_lastRead = 0;
_price = 0;
_mode = HX711_AVERAGE_MODE;
}

Expand Down
21 changes: 11 additions & 10 deletions HX711.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@
//
// FILE: HX711.h
// AUTHOR: Rob Tillaart
// VERSION: 0.4.0
// VERSION: 0.5.0
// PURPOSE: Library for load cells for Arduino
// URL: https://github.com/RobTillaart/HX711_MP
// URL: https://github.com/RobTillaart/HX711
//
// NOTES
// Superset of interface of HX711 class of Bogde
// float instead of long as float has 23 bits mantissa.
// uses float instead of long as float has 23 bits mantissa
// which almost perfectly matches the 24 bit ADC.


#include "Arduino.h"

#define HX711_LIB_VERSION (F("0.4.0"))
#define HX711_LIB_VERSION (F("0.5.0"))


const uint8_t HX711_AVERAGE_MODE = 0x00;
Expand Down Expand Up @@ -175,16 +176,16 @@ class HX711
uint8_t _dataPin;
uint8_t _clockPin;

uint8_t _gain = 128; // default channel A
long _offset = 0;
float _scale = 1;
uint32_t _lastRead = 0;
float _price = 0;
uint8_t _mode = HX711_AVERAGE_MODE;
uint8_t _gain;
long _offset;
float _scale;
uint32_t _lastRead;
float _price;
uint8_t _mode;
bool _fastProcessor;

void _insertSort(float * array, uint8_t size);
uint8_t _shiftIn();
bool _fastProcessor = false;
};


Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ See https://github.com/RobTillaart/HX711/issues/40
- example the adding scale
- void weight_clr(), void weight_add(), float weight_get() - adding scale
- decide pricing keep/not => move to .cpp
- add **setRate()** and **getRate()**
- add **setRate()** and **getRate()** - sample rate 10/80 SPS
- optional?


Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/HX711"
},
"version": "0.4.0",
"version": "0.5.0",
"license": "MIT",
"frameworks": "*",
"platforms": "*",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=HX711
version=0.4.0
version=0.5.0
author=Rob Tillaart <[email protected]>
maintainer=Rob Tillaart <[email protected]>
sentence=Arduino library for HX711 load cell amplifier
Expand Down

0 comments on commit fbd4b79

Please sign in to comment.