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 {
83
83
}
84
84
85
85
// 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 );
91
87
92
88
for (int retries = 0 ; retries < 3 ; retries++) {
93
89
if (_nau7802->calibrate (NAU7802_CALMOD_INTERNAL)) {
@@ -101,6 +97,19 @@ class WipperSnapper_I2C_Driver_NAU7802 : public WipperSnapper_I2C_Driver {
101
97
return false ;
102
98
}
103
99
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
+
104
113
/* ******************************************************************************/
105
114
/* !
106
115
@brief Gets the sensor's raw "force" value.
You can’t perform that action at this time.
0 commit comments