| Algorithm 7. Step detection framework |
| Initiate adaptive filter frequencies and coefficients |
| Repeat for each sample: |
| ------- peak extraction and update section ------- |
| If in motion |
| Filter measurements |
| S ← Detect candidate |
| If S = 1 |
| If = −1 && time_since_valley > |
| Valid peak detected |
| Elseif = S |
| = peak update (, , ) |
| If step duration && significant motion detected |
| Account for valley miss |
| Endif |
| Endif |
| Elseif S = −1 |
| If = 1 && time_since_peak > |
| Valid valley detected |
| Elseif = S |
| = peak update (, , ) |
| If step duration && significant motion detected |
| Account for peak miss |
| Endif |
| Endif |
| Endif |
| ------- peak validation from gyroscope and magnetometer ------- |
| dominant axis extraction(ω(n), m(n)) If dr > 0 ← Detect candidate(ω(n), m(n)) |
| If = 1 || = −1 |
| peak matching(, , ) |
| validate matching peaks |
| Endif |
| Endif |
| ------- step validation ------- |
| step validation () |
| adaptive filter frequency selector (LPD) |