Skip to content

Commit

Permalink
Merge pull request #3 from BrunoB81HK/getweigth_quickfix
Browse files Browse the repository at this point in the history
Fixed the allow_negative_weights flag who was inverted
  • Loading branch information
BrunoB81HK authored Jul 10, 2021
2 parents cbd662d + 360f504 commit 7e81134
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions PyNAU7802/NAU7802.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,15 @@ def getCalibrationFactor(self) -> float:
""" Ask library for this value.Useful for storing value into NVM. """
return self._calibrationFactor

def getWeight(self, allow_negative_weights: bool = False, samples_to_take: int = 8) -> float:
def getWeight(self, allow_negative_weights: bool = True, samples_to_take: int = 8) -> float:
""" Once you 've set zero offset and cal factor, you can ask the library to do the calculations for you. """
on_scale = self.getAverage(samples_to_take)

# Prevent the current reading from being less than zero offset. This happens when the scale
# is zero'd, unloaded, and the load cell reports a value slightly less than zero value
# causing the weight to be negative or jump to millions of pounds

if allow_negative_weights:
if not allow_negative_weights:
if on_scale < self._zeroOffset:
on_scale = self._zeroOffset # Force reading to zero

Expand Down

0 comments on commit 7e81134

Please sign in to comment.