Fork of hx711
Fork of HX711 by
Revision 1:cb1c777e3d22, committed 2017-07-01
- Comitter:
- atoy40
- Date:
- Sat Jul 01 13:55:15 2017 +0000
- Parent:
- 0:f82840dd806a
- Commit message:
- handle 2's complement negative values
Changed in this revision
HX711.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r f82840dd806a -r cb1c777e3d22 HX711.cpp --- a/HX711.cpp Fri Jun 12 16:05:39 2015 +0000 +++ b/HX711.cpp Sat Jul 01 13:55:15 2017 +0000 @@ -92,8 +92,10 @@ sck=1; sck=0; } - - buffer = buffer ^ 0x800000; + + if (buffer & 0x800000) { + buffer ^= 0xFF000000; + } return buffer; }