Skip to content

Commit

Permalink
refactor constructor after fix #50
Browse files Browse the repository at this point in the history
  • Loading branch information
RobTillaart committed Jun 17, 2024
1 parent 1c72c6b commit d8e6935
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 13 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-03-02
- 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
18 changes: 9 additions & 9 deletions HX711.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// 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
Expand All @@ -14,7 +14,7 @@

#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 +175,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 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 <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for HX711 load cell amplifier
Expand Down

0 comments on commit d8e6935

Please # to comment.