Commit Graph

10 Commits (299a31b765695329871b8ac530c071cd2bba54cb)

Author SHA1 Message Date
Guðni Már Gilbert 0e625dc551 circular_buffer: implement reset()
reset() discards any data in the buffer (head == tail)

Change in memory:
Flash: -116 bytes
SRAM: 0 bytes
2022-10-25 07:21:33 +02:00
Guðni Már Gilbert 353affb9f3 Optimise Catch2 V3 includes + fix a few cases of missing includes 2022-10-22 15:41:44 +02:00
Guðni Már Gilbert 45f70e004c Update CMake integration for Catch v3.1.0 2022-10-22 15:41:44 +02:00
D.R.racer 8ce029a28c Fix unit tests
- circular buffer can return its count of elements (even though a better solution may be implemeted later)
- stub_motion can handle multiple planned moves
- improved load/unload filament tests
2022-05-10 20:03:16 +02:00
Alan Dragomirecký 9448c04b36 Disable preprocessor code indentation 2021-07-07 16:33:03 +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 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 f81ecf1294 Circular buffer - basic unit test 2021-06-29 12:17:10 +02:00
D.R.racer 7eb346a54d Add first unit test
+proof of concept of Catch2 builds working in our repo
2021-05-13 17:35:08 +02:00