Skip to content

Fix cadence calculation: use 32-bit delta, correct wrap-around and floating-point division - #4905

Merged
cagnulein merged 3 commits into
masterfrom
codex/correggi-bug-calcolo-cadenza-in-qz
Aug 11, 2026
Merged

Fix cadence calculation: use 32-bit delta, correct wrap-around and floating-point division#4905
cagnulein merged 3 commits into
masterfrom
codex/correggi-bug-calcolo-cadenza-in-qz

Conversation

@cagnulein

Copy link
Copy Markdown
Owner

Motivation

  • Prevent incorrect cadence values caused by 16-bit overflow and integer division when computing crank event time deltas.
  • Ensure proper wrap-around handling of the crank event timestamp and improve numerical precision in the cadence formula.

Description

  • Change deltaT from int16_t to int32_t to avoid overflow when computing time differences.
  • Use 65536 explicitly to correct wrap-around of the 16-bit crank event time instead of relying on a variable constant.
  • Perform the cadence calculation using floating-point division via static_cast<double> and use 60.0 for clarity in the multiplication.
  • Keep existing bounds checks and cadence fallback logic unchanged.

Testing

  • Built the project successfully after the changes with no compile errors observed.
  • Existing automated tests were executed and completed without failures.

Codex Task

@cagnulein

Copy link
Copy Markdown
Owner Author

Mail alvinrisdianto

@cagnulein
cagnulein merged commit bf707d7 into master Aug 11, 2026
24 of 28 checks passed
@cagnulein
cagnulein deleted the codex/correggi-bug-calcolo-cadenza-in-qz branch August 11, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant