Skip to content

feat(capi): dasher_reset_cps() + remove [RATE] debug fprintfs (#44)#45

Merged
willwade merged 1 commit into
mainfrom
feat/speed-average-reset
Jul 20, 2026
Merged

feat(capi): dasher_reset_cps() + remove [RATE] debug fprintfs (#44)#45
willwade merged 1 commit into
mainfrom
feat/speed-average-reset

Conversation

@willwade

Copy link
Copy Markdown

Closes #44. Also subsumes #43 (the fprintf fix).

What is new

dasher_reset_cps(dasher_ctx* ctx)

Clears the typing-rate measurement window (the rateTimestamps deque) so CPS/WPM restart from zero. Frontends use this for a reset-averages button in the speed display.

The auto-speed-controller (BP_AUTO_SPEEDCONTROL) re-reads LP_MAX_BITRATE on every frame, so a frontend that wants a full reset calls:
dasher_set_speed_percent(ctx, 100); // reset to default baseline dasher_reset_cps(ctx); // clear the measurement window

Debug fprintf removal

Two leftover fprintf(stderr, [RATE]...) statements removed from CAPI.cpp (one fired per keystroke, one per CPS read). Found by owenpkent in Dasher-GTK issue 35.

Tests

Two new tests in test_capi_extended.cpp:

  • cps_reset_clears_measurement_window: verifies reset on fresh ctx, null safety, CPS returns 0 after reset
  • cps_reset_after_reset_settings: verifies consistency with dasher_reset() (which also clears timestamps)

Files changed

  • src/dasher.h: declaration + docs
  • src/CAPI.cpp: implementation + fprintf removal
  • tests/test_capi_extended.cpp: 2 new tests

Add dasher_reset_cps(dasher_ctx* ctx) — clears the typing-rate
measurement window so CPS/WPM restart from zero. Frontends use this for
a 'reset averages' button in the speed display (Dasher-GTK #35,
Dasher-Windows, Dasher-Apple, Dasher-Android all want this).

The auto-speed-controller (BP_AUTO_SPEEDCONTROL) re-reads LP_MAX_BITRATE
on every frame, so calling dasher_set_speed_percent() before
dasher_reset_cps() resets both the measurement window and the baseline.

Also removes two leftover debug fprintf(stderr, ...) statements from
the CPS/WPM rate-tracking code (one per keystroke, one per CPS read)
found by @owenpkent in Dasher-GTK #35.

Tests: two new tests in test_capi_extended.cpp covering the reset
behaviour (fresh context, null safety, consistency with dasher_reset).

Closes #44.

Signed-off-by: will wade <willwade@gmail.com>
@willwade
willwade merged commit 4fd3184 into main Jul 20, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add API for auto-speed-control average + reset

1 participant