Commit 4d9a7ec
authored
fix: convert static variables to instance members to enable supporting sampling multiple sensors
Replace static variables `prev_count` and `prev_time` with instance
member variables to support multiple AS5600 sensor instances running
simultaneously. Previously, all instances would share the same static
variables, causing incorrect position and velocity calculations in
multi-sensor configurations.
- Add `prev_count_` and `prev_time_` as class member variables
- Initialize `prev_count_` to 0 and `prev_time_` to current time
- Remove static keyword from variables in `update()` method
- Ensures each sensor instance maintains independent state1 parent c7e68b2 commit 4d9a7ec
1 file changed
+13
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
98 | 100 | | |
99 | 101 | | |
100 | 102 | | |
| |||
174 | 176 | | |
175 | 177 | | |
176 | 178 | | |
| 179 | + | |
| 180 | + | |
177 | 181 | | |
178 | 182 | | |
179 | 183 | | |
| |||
183 | 187 | | |
184 | 188 | | |
185 | 189 | | |
186 | | - | |
187 | | - | |
188 | | - | |
| 190 | + | |
| 191 | + | |
189 | 192 | | |
190 | | - | |
| 193 | + | |
191 | 194 | | |
192 | 195 | | |
193 | 196 | | |
| |||
199 | 202 | | |
200 | 203 | | |
201 | 204 | | |
202 | | - | |
203 | | - | |
| 205 | + | |
204 | 206 | | |
205 | | - | |
206 | | - | |
| 207 | + | |
| 208 | + | |
207 | 209 | | |
208 | 210 | | |
209 | 211 | | |
| |||
298 | 300 | | |
299 | 301 | | |
300 | 302 | | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
301 | 306 | | |
302 | 307 | | |
0 commit comments