In development. It changes without notice.
Topic
Trackball Driver
The trackball: four direction lines and a click.
QuadratureTrackball counts each falling edge of a direction as a step and keeps when the last one came. A trackball has no bus and no identity to probe, so the board's configuration says whether there is one; NullTrackball stands in where there is none.
- See also
- Input Sources & the Wake Rule
Files | |
| file | src/ |
| Device-level quadrature-trackball driver contract. | |
| file | src/ |
| No-op trackball driver for the boards without a trackball. | |
| file | src/ |
| Generic four-direction + click GPIO quadrature trackball driver. | |
| file | src/ |
| Factory for the quadrature-trackball driver. | |
| file | src/ |
| Pure decision helpers for the kleidos:: | |
Classes | |
| struct | kleidos:: |
| One atomic snapshot of the quadrature accumulators + velocity timing. More about kleidos:: | |
| class | kleidos:: |
| Device-level quadrature-trackball driver interface. More about kleidos:: | |
| class | kleidos:: |
| No-op trackball driver used on the boards that have no trackball. More about kleidos:: | |
| struct | kleidos:: |
| GPIO pin mapping for a four-direction + click quadrature trackball. More about kleidos:: | |
| class | kleidos:: |
| Generic GPIO quadrature trackball driver (four directions + center click). More about kleidos:: | |
Enumerations | |
| enum class | kleidos:: |
| Trackball family selected by the board's compile-time flag + pin mapping. More about kleidos:: | |
Functions | |
| constexpr bool | kleidos:: |
| Whether the four direction pins are all assigned. | |
| constexpr TrackballFamily | kleidos:: |
| Classify a trackball from its pin-mapping sanity check (pure). | |
| ITrackball * | kleidos:: |
| Resolve and return the fitted trackball driver. | |
| constexpr bool | kleidos:: |
| Whether the drained step counters read back all-zero after a reset. | |
| constexpr bool | kleidos:: |
| Whether the click line reads its expected idle level (pull-up → HIGH). | |
| constexpr bool | kleidos:: |
| Overall pass decision for the passive-device self-test. | |
Enumeration Type Documentation
TrackballFamily #
Function Documentation
classifyTrackball() #
Classify a trackball from its pin-mapping sanity check (pure).
A passive GPIO device cannot be probed, so the only decision a factory can make before hardware is whether the family's pins are wired. The caller runs the check only for the family compiled into the build and passes its result, so an un-compiled family can never match.
- Parameters
-
Name Direction Meaning quadraturePinsValid in Whether the quadrature direction pins are assigned.
- Returns
- TrackballFamily::
Quadrature when valid, else TrackballFamily:: None.
createTrackball() #
Resolve and return the fitted trackball driver.
For the trackball family compiled into this build, checks the direction-pin mapping and returns the matching driver (constructed but not yet initialized — the caller runs ITrackball::
- Parameters
-
Name Direction Meaning pins in Direction + click GPIO mapping for this board.
- Returns
- A driver owned by function-local
staticstorage (never delete, nevernullptr).
quadratureDirectionsValid() #
Whether the four direction pins are all assigned.
A quadrature trackball needs its four motion pins; the click pin is optional. This is the passive-device analogue of an address ACK — the only pre-hardware "detection" a factory can make for a device with no bus.
- Parameters
-
Name Direction Meaning pins in Candidate pin mapping.
- Return values
-
Value Meaning true All four direction pins are valid GPIO numbers (>= 0). false At least one direction pin is unassigned.
selfTestClickIdleHigh() #
Whether the click line reads its expected idle level (pull-up → HIGH).
Informational only: the center button is active LOW under an internal pull-up, so at rest the line idles HIGH. A physically held button legitimately reads LOW, so the self-test never fails on this — it only annotates the level in the detail string.
- Parameters
-
Name Direction Meaning clickLevel in Raw click-pin level (true = HIGH).
- Return values
-
Value Meaning true The line idles HIGH as expected at rest. false The line reads LOW (button held, or a wiring fault).
selfTestCountersCleared() #
Whether the drained step counters read back all-zero after a reset.
A drain must read and clear the four direction accumulators; an immediate re-drain returning all zeros proves the read-and-reset path is coherent (no counter is stuck or aliased). Any non-zero value signals a broken accumulator or a reset that did not take.
- Parameters
-
Name Direction Meaning up in UP counter from the confirming re-drain. down in DOWN counter from the confirming re-drain. left in LEFT counter from the confirming re-drain. right in RIGHT counter from the confirming re-drain.
- Return values
-
Value Meaning true All four counters are zero (accumulators drained coherently). false At least one counter did not reset.
selfTestPassed() #
Overall pass decision for the passive-device self-test.
The verifiable pass gate is: the driver initialized (pins configured as inputs, edge ISRs armed) AND the step accumulators drained coherently. The click idle level is deliberately excluded from the gate (see selfTestClickIdleHigh).
- Parameters
-
Name Direction Meaning ready in Whether init()configured the pins and armed the ISRs.countersCleared in Whether the confirming re-drain read all-zero.
- Return values
-
Value Meaning true Both verifiable preconditions hold. false The driver did not initialize, or a counter did not reset.