File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
src/components/i2c/drivers Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -83,11 +83,7 @@ class WipperSnapper_I2C_Driver_NAU7802 : public WipperSnapper_I2C_Driver {
8383 }
8484
8585 // Take 10 readings to flush out old readings (10 samples per second)
86- for (uint8_t skipCounter = 0 ; skipCounter < 10 ; skipCounter++) {
87- while (!_nau7802->available ())
88- delay (1 );
89- _nau7802->read ();
90- }
86+ flushNAU7802 (10 );
9187
9288 for (int retries = 0 ; retries < 3 ; retries++) {
9389 if (_nau7802->calibrate (NAU7802_CALMOD_INTERNAL)) {
@@ -101,6 +97,19 @@ class WipperSnapper_I2C_Driver_NAU7802 : public WipperSnapper_I2C_Driver {
10197 return false ;
10298 }
10399
100+ /* ******************************************************************************/
101+ /* !
102+ @brief Gets datapoints from sensor and discards (flushes old data).
103+ */
104+ /* ******************************************************************************/
105+ void flushNAU7802 (uint8_t count) {
106+ for (uint8_t skipCounter = 0 ; skipCounter < count; skipCounter++) {
107+ while (!_nau7802->available ())
108+ delay (1 );
109+ _nau7802->read ();
110+ }
111+ }
112+
104113 /* ******************************************************************************/
105114 /* !
106115 @brief Gets the sensor's raw "force" value.
You can’t perform that action at this time.
0 commit comments