Commit Graph

151 Commits (5018c4448972d0973fd989b34318806ce2668591)

Author SHA1 Message Date
Alan Dragomirecký 5018c44489 Do not include the utils directory 2021-07-12 09:09:21 +02:00
Alan Dragomirecký 09819cb1aa Split the main CMakeLists.txt into more files within subdirectories 2021-07-12 09:09:21 +02:00
Alan Dragomirecký ed72b07e04 Remove `include` from header search paths 2021-07-12 09:09:21 +02:00
Alan Dragomirecký 6f68fc6e76 Remove empty CMakeLists from the utils directory 2021-07-12 09:09:21 +02:00
Alan Dragomirecký 99b847bf98 Remove the PRINTER cmake option and other irrelevant code 2021-07-12 09:09:21 +02:00
Yuri D'Elia b3f3f0538e Shim <limits> on AVR
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).
2021-07-12 09:02:05 +02:00
Alan Dragomirecký 3dbba6ca88 holly: Temporarily disable builds of the firmware (as there is no
avr-gcc available)
2021-07-12 08:52:57 +02:00
Alan Dragomirecký ba19208469 Add Dockerfile/Jenkinsfile for Holly 2021-07-12 08:52:57 +02:00
Alan Dragomirecký 8361bd1027 Replace urls for gcc-avr with dummy (but working) ones 2021-07-12 08:52:57 +02:00
Alan Dragomirecký 86f5e19b54 Remove unused Python dependecies 2021-07-12 08:52:57 +02:00
Yuri D'Elia 2db97c0f5e Fix CMake "files" expression in pre-commit 2021-07-12 08:51:10 +02:00
Alan Dragomirecký 996f0f5dc0 Fix formatting of cmake files 2021-07-07 16:33:16 +02:00
Alan Dragomirecký e3d8147890 Ignore .cmake-format.py file by cmake-format 2021-07-07 16:33:16 +02:00
Alan Dragomirecký 9448c04b36 Disable preprocessor code indentation 2021-07-07 16:33:03 +02:00
Yuri D'Elia f95c47638d CircularIndex: fight against type promotion in size checks
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.
2021-07-06 12:51:56 +02:00
Yuri D'Elia f57a1c3b17 CircularIndex: add static checks for index/size limits
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.
2021-07-06 12:51:56 +02:00
Yuri D'Elia 4362d77083 CircularIndex: alternate index management for full capacity
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)
2021-07-06 12:51:56 +02:00
Yuri D'Elia 477539c791 Split CircularBuffer into CircularIndex+CircularBuffer
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.
2021-07-06 12:51:56 +02:00
D.R.racer 43a423f299 Change buttons' ADC limits into an array
as proposed by @vintagePC

cleaned-up some of the unit tests by this change
2021-07-05 18:07:54 +02:00
D.R.racer 552fec9abf Parametrize Idler and Selector in common config.h 2021-07-05 18:07:54 +02:00
D.R.racer ccda84df80 Make buttons' ADC decision levels "inclusive"
especially because of the zero level, which is very likely to be a valid button0 level
2021-07-05 18:07:54 +02:00
D.R.racer b484eeacb6 Start using config.h
Added some constexpr vars for buttons, finda, fsensor and
applied them in the FW and unit tests accordingly.
2021-07-05 18:07:54 +02:00
Yuri D'Elia dd5c036d38 GPIO: reformat affected files 2021-07-05 15:20:11 +02:00
Yuri D'Elia 3ccfc3adfb GPIO: correctly stub known ports
- Use the correct port name in the #define
- Fully qualify all references
2021-07-05 15:20:11 +02:00
Yuri D'Elia 32b2ec7f8d Remove GPIOI 2021-07-05 15:20:11 +02:00
Yuri D'Elia 067deb7e55 Completely remove PIN macros 2021-07-05 15:20:11 +02:00
Yuri D'Elia 7c7aa95445 Mock GPIO when building tests
Add some conditional statements in gpio.h so that we can mock the GPIO
registers when building tests.
2021-07-05 15:20:11 +02:00
Yuri D'Elia 169665331e Change the pin definitions in order to be valid types
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.
2021-07-05 15:20:11 +02:00
Yuri D'Elia e9627ad0d4 TMC2130: Reformat 2021-07-05 13:34:08 +02:00
Yuri D'Elia f491072614 TMC2130: Make stepping methods static
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.
2021-07-05 13:34:08 +02:00
Yuri D'Elia 28c9e55a79 Add vSense to MotorCurrents 2021-07-05 13:34:08 +02:00
Yuri D'Elia c78ed77ccc Revise the TMC2130 interface for stepping
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.
2021-07-05 13:34:08 +02:00
Yuri D'Elia ea8b335f8d progmem: fix for AVR
- Fix header name
- Rename pgm_read_word to read_word since pgm_read_word is a macro
  and cannot be scoped
2021-07-05 13:33:49 +02:00
Yuri D'Elia a9937b94e2 Add initial AVR PROGMEM abstraction in hal::progmem 2021-07-05 13:33:49 +02:00
D.R.racer 9efb127acb Explain and fix the LED states while cutting filament
now the test is correct including LEDs
2021-07-01 08:12:47 +02:00
D.R.racer d81b00a0f8 Test all filament slots 2021-07-01 08:12:47 +02:00
D.R.racer 974c1ba6db Verify Cut filament state machine + update unit tests 2021-07-01 07:03:39 +02:00
D.R.racer 75fe7b20b5 Verify and fix Tool Change state machine + unit tests 2021-07-01 07:03:02 +02:00
vintagepc e2ec745286
Simple config header with example (#39)
Simple config header with example
2021-07-01 06:47:40 +02:00
Yuri D'Elia ab01413116 Call LED::Step() correctly 2021-06-30 12:39:03 +02:00
D.R.racer 9122a33693 Rebase onto upstream/main, adapt to cleaned-up circular buffer interface 2021-06-30 07:39:31 +02:00
D.R.racer ffae941a28 Fix unit tests of load/unload filament 2021-06-30 07:39:31 +02:00
D.R.racer 9a8038ccb6 Add user_input module and use it instead of raw buttons
Encapsulates buttons and commands coming from the communication
2021-06-30 07:39:31 +02:00
D.R.racer af8c866f1a Update doxygen main page 2021-06-30 07:39:31 +02:00
D.R.racer 2c89b14de1 Add doxygen main page dox file 2021-06-30 07:39:31 +02:00
D.R.racer 4df4bf59b4 Update doxyfile + document modules namespace 2021-06-30 07:39:31 +02:00
D.R.racer 3f98ec03ca Fix doxygen documentation for the logic layer 2021-06-30 07:39:31 +02:00
D.R.racer c15b1d59c4 Introduce Doxyfile + fix modules documentation 2021-06-30 07:39:31 +02:00
D.R.racer f6e5d4ae76 Improve and verify Load filament alg and unit tests 2021-06-30 07:39:31 +02:00
D.R.racer 46a40f7488 Extend Unload filament unit tests
+ now error states are covered as well
+ greatly cleaned-up code
2021-06-30 07:39:31 +02:00