Skip to content

Fix typos and stale documentation comments (comments/docs only) - #570

Open
stijncarelsbergh wants to merge 5 commits into
simplefoc:devfrom
stijncarelsbergh:docs/fix-comment-typos
Open

stijncarelsbergh wants to merge 5 commits into
simplefoc:devfrom
stijncarelsbergh:docs/fix-comment-typos

Conversation

@stijncarelsbergh

Copy link
Copy Markdown

Fix typos and stale documentation comments (comments/docs only - no behaviour change)

While auditing the library sources and examples against docs.simplefoc.com I collected a
large number of spelling mistakes and a handful of documentation comments that no longer
match the code. They are all comment/prose level, but they show up in the published Doxygen
output and in the Arduino examples, so it is worth cleaning them up.

This PR deliberately contains no behaviour change, so it can be merged without hardware
testing. The actual logic bugs found during the same audit are being submitted separately.

What is in here

1. Typos in comments, strings and markdown (3652fa4) - 228 words in 92 files

Recurring ones:

wrong right count
intial / intialisation / intially initial / initialization / initially 30+
speciffic specific 41
contoller / controll controller / control 38
variabels / vairables variables 11
currnet / currrent current 8
hadware / harware hardware 11
overriden overridden 3
listenning / listenner listening / listener 6
interraction interaction 3
compatibilty compatibility 6
chanage / chaning change / changing 11
paramters parameters 4
number od pole pairs number of pole pairs 2
initalise ... sampling tims Ts initialize ... sampling time Ts 2

plus aboout, addional, alignemt, architecure, assuning, begining, commad,
complemetary, corrent, defintion, doen't, driectly, ecoder, electirical,
ellapsed, explicilty, fammilies, fileter, han't, injeted, instad, lewline,
measuremnt, numer, oscilating, perfomed, seperate, throught, wuing,
demistifying, comunity, Arudino and a few singles.

2. Stale/incorrect documentation comments (1fd4841)

  • Commander.h - the E command is documented the wrong way round: it says
    '0' - enable, '1' - disable. The implementation in Commander::motor() and
    Commander::motion() does target == 0 -> disable(), i.e. E1 enables, E0 disables.
    Anyone following the current header comment disables their motor instead of enabling it.
  • BLDCDriver.h / StepperDriver.h - setPhaseState() lists its @params in reverse
    order (sc, sb, sa) compared to the signature (sa, sb, sc). Same for the 2-phase
    stepper (sc, sb) vs (sa, sb).
  • hardware_api.h - _configure1PWM() is documented as Stepper driver - 2PWM setting;
    _configure6PWM() documents pinB/pinC as pinA (copied from the pinA lines).
  • HallSensor.h - the constructor documents a parameter doIndex and an index pin.
    The class has neither: the parameter is doC and there is no index channel.
  • Encoder.h - @param encA encoder B pin.
  • FOCMotor.h - sensor_direction claimed default is CW, while the default is
    Direction::UNKNOWN and it is resolved during calibration.
  • FOCMotor.cpp - the comment on updateVelocityLimit() describes the cascade the wrong
    way round. It is the velocity limit that clips the angle controller output (the
    velocity set point), not an angle controller limit.
  • defaults.h - DEF_CURR_FILTER_Tf is described as a "velocity filter" (both AVR and
    default sections carry the current-filter comment next to a current constant).
  • library.properties - demistifying -> demystifying.

How it was checked

The typo pass is applied by a small scanner that only rewrites text inside comments
(//, /* */), inside string literals and in markdown prose - identifiers, macros and
expressions are never rewritten. To prove it, the changed sources are re-parsed with
comments and string contents stripped out and compared to the original:

code files checked: 91, with code changes: 0

The only non-comment change in the whole PR is the text of two Serial messages in the
step_dir_listener_* examples ("Step/Dir listenning." -> "Step/Dir listening."), which
is the intent.

No build was run on purpose: since not a single code token changed, a compile would only
re-verify the compiler, not this PR.

Suggested review path

git diff --stat shows 95 files / +237 -238, all one-line changes. Reviewing
git show 1fd4841 (the documentation-comment commit, 12 hunks) is probably the most
useful part.

DevinJM3 and others added 4 commits August 21, 2026 10:49
Comment-only corrections found while auditing the documentation against the
source. No behaviour change.

- Commander.h: the 'E' command sub-commands are documented the wrong way
  round (E1 enables, E0 disables, as implemented in Commander::motor()).
- BLDCDriver.h / StepperDriver.h: setPhaseState() @PARAM names were listed in
  reverse order (sc, sb, sa) compared to the actual signature (sa, sb, sc).
- hardware_api.h: _configure1PWM() was documented as a '2PWM setting';
  _configure6PWM() documented pinB/pinC as pinA.
- HallSensor.h: constructor documented a non-existent 'doIndex' parameter and
  an 'index' pin that the class does not have (it is doC).
- Encoder.h: @PARAM encA was described as 'encoder B pin'.
- FOCMotor.h: sensor_direction comment said 'default is CW' while the default
  is Direction::UNKNOWN (set by calibration).
- FOCMotor.cpp: inverted explanation of the angle/velocity limit cascade.
- defaults.h: DEF_CURR_FILTER_Tf described as a 'velocity' filter.
- StepperMotor.cpp / HybridStepperMotor.cpp: 'number od pole pairs'.
- pid.cpp / lowpass_filter.cpp: fixed sampling '{tims}' -> 'time'.
- library.properties: 'demistifying' -> 'demystifying'.
Spelling fixes in library sources, examples and docs. Applied only inside
comments, string literals and markdown prose - verified with a scanner that
strips comments/strings and compares the remaining code token-for-token, so
no identifier, macro or expression is touched (0 code changes over 82 files,
228 words corrected).

Notable ones: intial/intialisation, contoller, speciffic, variabels, currnet,
hadware, overriden, interraction, listenning, number od pole pairs.
Copilot AI balanced review requested due to automatic review settings October 5, 2026 10:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@askuric

askuric commented Oct 7, 2026

Copy link
Copy Markdown
Member

Ok so, a looooot of changes.

I dont really like PRs like this one usually. They are really hard to check. But with AIs today we can do it a bit faster.
I would argue that the utility of it is limited, but it is also probably annoying to see these typos in the comments all the time.

Ok so first of all merge the dev into your branch so that it passes the checks. I'll go through it and try to verify that the changes are only comments. If they are I will probably merge it.

Two conflicts, both 'our comment fix vs a code change on dev':
- FOCMotor.h: dev changed LPF_angle{0.0} to {0.0f}; kept dev's code and
  re-applied the 'commad' -> 'command' comment fix.
- atmega32u4_mcu.cpp: dev fixed the _writeDutyCycle3PWM() signature (PR simplefoc#553);
  kept dev's signature and re-applied 'speciffic' -> 'specific'.
Both resolutions keep upstream's code unchanged.
@stijncarelsbergh

Copy link
Copy Markdown
Author

Merged dev into the branch, so the checks should now be green. The failing STM32 jobs were
inherited, not caused by this PR: they fail the same way on master, and dev is where the
"Add compatibility for STM32 Core V3" work lives. The two conflicts were both "comment fix here
vs a code change on dev", and in both cases I kept dev's code and re-applied only the comment
wording:

On verifying that it really is comments only - I did that mechanically instead of by eye, since
90 files is a lot to skim. The check strips comments and string-literal contents from every
changed file and compares what is left with dev:

code files checked: 90, with code changes: 0

i.e. token-for-token identical to dev's code, with only comment/prose text differing. Script is
here if you want to run it yourself (3 files, no dependencies, Python 3):

https://gist.github.com/stijncarelsbergh/ae11d6259850aa2082cba8985dff639e

python verify_lib_doc_diff.py <repo-checkout> dev

It also re-checks that every changed word in README.md, the example readmes and
library.properties maps to a known typo correction, so nothing else sneaked in.

One honest caveat so it is not a surprise: the only non-comment changes in the PR are two
Serial messages in examples/utils/communication_test/step_dir/*
("Step/Dir listenning." -> "Step/Dir listening."). Both are in the same category of "visible
typo", but if you would rather have the PR strictly comment-only, say so and I will drop those
two lines.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants