Skip to content

Fix twos complement#5

Open
Sthing wants to merge 2 commits intoqueuetue:masterfrom
Sthing:fix-twos-complement
Open

Fix twos complement#5
Sthing wants to merge 2 commits intoqueuetue:masterfrom
Sthing:fix-twos-complement

Conversation

@Sthing
Copy link

@Sthing Sthing commented Nov 12, 2016

This should fix the calculation of the correct value.
Simply flipping the MSB does not work.
This should address #1

The HX711 will enter power down when PD_SCK is high for more then 60μs.
On my demo board powerDown() lowers the current consumption from ~15mA to less than 0.01mA.
@Sthing
Copy link
Author

Sthing commented Nov 12, 2016

Oops- this Pull Request also include the two new functions from #4
Please let me know if you prefer a PR that only includes commit e938567.

@javieryanez
Copy link

Conversion can be done with a single line:

return (((int32_t) data[2] << 24) | ((int32_t) data[1] << 16) | ((int32_t) data[0] << 8)) >> 8;

It looks like Scott hasn't updated the library in a while...

@tatobari
Copy link

@Sthing Do you happen you have a fork of this project with the two's complement fixed? I'd rather use your's than fork one and modify it myself, adding one more repository which only I will use.

@tatobari
Copy link

@Sthing you do, found it, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants