feat(capi): dasher_reset_cps() + remove [RATE] debug fprintfs (#44)#45
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 windowDebug 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:
Files changed