endail / hx711-rpi-py

Python bindings for Raspberry Pi HX711 C++ Library
MIT License
11 stars 4 forks source link

error while using options in .weight, .read #3

Closed aero9560 closed 2 years ago

aero9560 commented 2 years ago

hello m = hx.weight(10) is working.

m = hx.weight(Options( stratType=StrategyType.Samples, readType=ReadType.Median, samples=10))
but this is giving an error error m = hx.weight(Options( TypeError: init(): incompatible constructor arguments. The following argument types are supported:

  1. HX711.Options()
  2. HX711.Options(s: int)
  3. HX711.Options(t: datetime.timedelta)

Invoked with: kwargs: stratType=<StrategyType.Samples: 0>, readType=<ReadType.Median: 0>, samples=10

can some one provide solution for this. thanks

endail commented 2 years ago

Thank you for reporting this. I will fix it ASAP. In the meantime, you can do this:

opt = Options(10)
opt.stratType = StrategyType.Samples
opt.readType = ReadType.Median

m = hx.weight(opt)
endail commented 2 years ago

I've updated the C++ library and this repository as well. Follow the installation instructions again to completely update.

I have also updated the documentation here so you can see some newer examples.

Please let me know if you have any other issues.

aero9560 commented 2 years ago

Hello Thanks for update, now options are working perfectly fine . i want to perform some function on reading obtained for load cell but as hx.weight return a object i can't do that, is there a way to converts raw reading obtained from hx.read to convert them to reading like obtained from hx.weight so additional operation can be done on them. Thanks