Commit 2d65174
authored
fix(as5600): initialize prev_count_ to prevent incorrect first diff
Initialize prev_count_ to the first sensor reading in init() to avoid
calculating an incorrect diff on the first update() call. Previously,
prev_count_ defaulted to 0 while count_ was set to the actual sensor
reading, causing a large erroneous jump in the accumulator on startup.
- Set prev_count_ = count after reading initial angle
- Ensures diff calculation is correct from the first update
- Prevents accumulator corruption on initialization1 parent 4d9a7ec commit 2d65174
1 file changed
+1
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
99 | | - | |
100 | 98 | | |
101 | 99 | | |
102 | 100 | | |
| |||
176 | 174 | | |
177 | 175 | | |
178 | 176 | | |
179 | | - | |
180 | | - | |
181 | 177 | | |
182 | 178 | | |
183 | 179 | | |
| |||
237 | 233 | | |
238 | 234 | | |
239 | 235 | | |
| 236 | + | |
240 | 237 | | |
241 | 238 | | |
242 | 239 | | |
| |||
0 commit comments