we shall think about the Pulley as well, it looks like it should get its
own class just like Idler and Selector as it behaves very similarly in terms
of stepping and error checking
TogglePin was incorrectly using the PINx pin for toggling, causing the
current pins (in addition to the requested ones) to be toggled, causing
stepping havoc.
The parameter config::AxisConfig::uSteps was supposed to be
microstepping resolution, but it's instead being used as the driver's
MRES directly.
To avoid a runtime conversion, rename the field to mRes and define a new
enum listing all the possible (and valid) microstepping resolutions.
This simplifies the code and makes clear the stepsPerUnit scale.
Assign correct stepsPerUnit to all axes as a result, including working
limits.
Introduces a nasty hack to forcefully write into the constexpr SPI descriptor's registers
(which is the correct way in ASM, but kind of cumbersome in C++ now)
Make ReadPin return the last value set by WritePin for proper testing.
Add a slow-path to TogglePin that goes through a read-write cycle. This
is useful both for testing and for platforms that don't have an
efficient toggle like AVR.
The cast to Level is incorrect, since the expression returns either 0 or
a positive value if the pin is set. The value is directly assigned to
the underlying uint8_t, meaning that Level::high won't match for levels
greater than 0.
Return a boolean and cast that to Level instead.
Instead of adding #ifdefs for missing headers, create a shim that can be
included everywhere.
"limits.h" includes a bare-bone implementation of numeric_limits (to be
extended as needed).
Make ReadPin return the last value set by WritePin for proper testing.
Add a slow-path to TogglePin that goes through a read-write cycle. This
is useful both for testing and for platforms that don't have an
efficient toggle like AVR.
The cast to Level is incorrect, since the expression returns either 0 or
a positive value if the pin is set. The value is directly assigned to
the underlying uint8_t, meaning that Level::high won't match for levels
greater than 0.
Return a boolean and cast that to Level instead.
- Remove the combined PlanMove(a,b,c,rate) call. If we allow the units
of the various motors to be changed at compile time, the unit of
rate can vary between axes.
- Build PlanMove on top of the absolute PlanMoveTo.
- Add required stubs for TMC2130.
- Allow each axis mode to be set independently, since we have this
feature for free anyway.
- Rework internals to use PulseGen data types and structs.
To generate optimal code, size itself needs to be of the same type as
the index to avoid promotion to the largest type.
In full(), wrap the subtraction explicity in another type cast to avoid
another automatic type promotion.
The empty/full distinction fails to work if size matches the number of
representable positions for the index type.
Add a static check to ensure this invariant is met where possible.
Comparing head/tail indexes cannot distinguish between empty/full cases,
so we end up wasting one item in the circular buffer. This also limits
the smallest and efficient size choice to be 4.
If the circular buffer is large, there's no issue, however for the
motion planner the block size is significant, and I was planning to use
exactly a ring buffer of two: one busy block, plus one planned.
Modify the indexer to store the internal "index" (aka cursor) pointer to
be one extra bit deeper than the final index. Comparing the underlying
cursor allow to distinguish the empty/full case due to the extra bit,
while producing the final index requires simple masking.
This is just as efficient if the size is a power of two with
2-complement wrap-around logic, which is the optimized case. However
the implementation also works for non-power-of-two sizes.
Add tests for more failure cases in the CircularBuffer which is built on
top.
(tecnique described in the Art of Computer Programming by Knuth)
Allow the lower-level index to be used without an actual container by
splitting off the index management into CircularIndex.
Rebuild CircularBuffer using CircularIndex itself.
Remove the constructor from GPIO_pin so that we can use brace
initialization at compile time.
Rewrite the contents of pins.h to construct GPIO_pin types directly by
the use of a simple preprocessor macro.
Makes the code type-check and easier to read/extend.
To keep these methods efficient no member should be accessed away.
That's the reason MotorParams is passed explicitly for each.
Mark all stepping methods as static.
Change the TMC2130 class after starting to review the Motion API.
Move motor mode handling and stepping to this module.
Create a new MotorParams class for compile-time settings (currently
pins, direction, microstepping).
Keep other settings separate, so that we can pass constexpr expressions
while stepping and still get 1 instruction without overhead.
+ start shaping up main.cpp
+ make the usage of namespaces and class names more consistent throughout the whole project
+ refactor related unit tests accordingly