Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: HX711.cpp
- Revision:
- 5:4af2b666387b
- Parent:
- 4:d7a5cd03ed09
--- a/HX711.cpp Wed Sep 13 09:11:22 2017 +0000
+++ b/HX711.cpp Sun May 16 23:32:47 2021 +0000
@@ -305,8 +305,22 @@
}
// Update data to get the average
- myAuxData ^= 0x800000;
- myNewRawData->myRawValue += myAuxData;
+ //myAuxData ^= 0x800000;
+ int32_t signed_value = (static_cast<int32_t>( myAuxData << 8 ) ) >> 8;
+
+ /*
+ uint32_t* temp_ptr;
+ //temp_ptr = static_cast<uint32_t*>(&myAuxData);
+ temp_ptr = &myAuxData;
+ printf("N: %d\n", *temp_ptr);
+
+ int32_t mySignedAuxData = 0;
+ mySignedAuxData = ( (static_cast<int32_t>(temp_ptr[1]) << 24)
+ | (static_cast<int32_t>(temp_ptr[2]) << 16)
+ | (static_cast<int32_t>(temp_ptr[3]) << 8)) >> 8;
+ */
+
+ myNewRawData->myRawValue += signed_value;
}
myNewRawData->myRawValue /= ( float )myAverage;
@@ -526,7 +540,7 @@
for ( i = 0; i < myTime; i++ ) {
aux = HX711_ReadRawData ( myChannel_Gain, myNewRawData, 10 );
myAuxData += myNewRawData->myRawValue;
- wait(1);
+ //wait(1);
}
myNewRawData->myRawValue = ( float )( myAuxData / myTime );