Commit Graph

153 Commits (27f28973d35aa44f4b6f240ff45bdd21fbb88aba)

Author SHA1 Message Date
Guðni Már Gilbert 27f28973d3 Fix failed_load_to_finda_0-4_resolve_manual_no_FINDA unit test 2022-12-11 16:33:52 +00:00
Guðni Már Gilbert 4ef8d81bfc Fixed failed_load_to_finda_0-4_resolve_help_second_fail unit test 2022-12-11 15:52:55 +00:00
Guðni Már Gilbert 2fd651b028 Fix failed_load_to_finda_0-4_resolve_help_second_ok unit test 2022-12-11 15:50:18 +00:00
Guðni Már Gilbert 801a0d3349 Fix failed_load_to_finda_0-4_try_again unit test 2022-12-11 15:44:52 +00:00
Guðni Már Gilbert 559ed69678 Fix unlimited_load_manual_stop unit test 2022-12-11 15:40:40 +00:00
Guðni Már Gilbert bf9fec6941 Fix unit test load_fail_FINDA_resolve_btnL
If helping the filament triggers FINDA
we should set loading state to InSelector
2022-12-11 15:15:16 +00:00
Guðni Már Gilbert 7e2528d675 Fix unit test load_fail_FINDA_resolve_btnM
- If FINDA was not pressed, filament load state should be
AtPulley
- When a user presses the middle button, the pulley motor should be enabled =>feeding started
2022-12-11 15:08:26 +00:00
Guðni Már Gilbert 26be20e9aa Improve messages 2022-12-11 13:40:09 +00:00
Guðni Már Gilbert abc46a90eb Check return code from VerifyEnvironmentState 2022-12-11 13:13:26 +00:00
D.R.racer c0189d81af Distinguish among different error states when recovering ToolChange
Some errors need specific recovery, it seems it is no longer possible to "just" retry.
2022-11-18 22:42:05 +01:00
D.R.racer c8c39f7b69 Make sure ToolChange moves Selector to desired slot
and verify correct behaviour in unit tests - especially when Selector's start position is at a different slot.
2022-11-18 22:29:01 +01:00
D.R.racer 08f777b5cb Introduce FINDA_FLICKERS error code
Intended for scenarios when FINDA used to be OFF but accidentally became ON without a reason.
The user is obliged to inspect FINDA and tune its switching.
2022-11-17 07:32:38 +01:00
D.R.racer 3f09ba0c16 Unit tests: selector refused to move in ToolChange
Revealed all kinds of subtle issues (which is great). All have been fixed in this commit.
2022-11-17 07:32:38 +01:00
D.R.racer c74d418016 Invalidate Idler+Selector homing flags when Retry from ToolChange Error
If FSENSOR_DIDNT_SWITCH_ON was caused by misaligned Idler, rehoming it may fix the issue when auto retrying -> no user intervention.
So first invalidate homing flags as the user may have moved the Idler or Selector accidentally.

Beware: we may run into issues when FINDA or FSensor do not work correctly. Selector may rely on the presumed filament position and actually cut it accidentally when trying to rehome.
It is yet to be seen if something like this can actually happen.

MMU-191
2022-11-15 17:42:12 +01:00
D.R.racer 299a31b765 Generate exactly 1 userInput event when button pressed (and held)
This PR is a different solution to what @gudnimg found in PR#233 / PFW-1404.

The benefit of this approach is the fact, that the button press event is generated when the button is pressed and not after it has been released.

The downside is obvious:
CPUFLASH: +28B
RAM: +1B
2022-11-15 07:19:20 +01: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 4f1a301e0e Force fix formatting 2022-09-22 12:16:41 +02:00
D.R.racer 0fa8a3c278 Refactor original solution from @leptun
- rename stall*guard to StallGuard (match name with the vendor)
- separate TMC2130 module from EEPROM (they do not need to know about each other at all)
- separate SGTHRS settings from motion - moved to globals like all other "global" parameters
- improved EEPROM storage for SGTHRS
2022-09-22 12:16:41 +02:00
vintagepc fdb2058d2b Fix test build 2022-08-11 10:26:42 +02:00
D.R.racer ad0b26c5ec Fix unit tests 2022-08-11 10:26:42 +02:00
D.R.racer 5dffd32025 Introduce Idler::PartiallyDisengage
This is to solve a potential problem while feeding to printer's drive gears - while disengaging the Idler, the Pulley was still rotating to avoid grinding the filament (printer is pulling it).
Other filaments could have moved a bit when the Idler's bearings ran over them while the Pulley was still rotating slowly -> the filament could have been moved into the Selector's path causing trouble (especially when not used in the print).
Therefore, the Idler disengages partially now - moves into an intermediate position between the slots.
Then, the Pulley is completely stopped and after that the Idler does a full disengage like before.
2022-08-02 07:28:10 +02:00
D.R.racer 4964e9a781 Fixup unit tests due to new homing behavior 2022-08-02 07:16:54 +02:00
D.R.racer 3c3e625f39 Unit test ErrDisengageIdler: make sure it never sets error while disengaging 2022-07-20 16:23:43 +02:00
D.R.racer 4e44447762 Change the unit tests to follow the new spec 2022-07-20 16:23:43 +02:00
D.R.racer 40e9e5df7c Fix unit tests 2022-06-20 17:03:40 +02:00
D.R.racer bc298ab114 Add unit test for empty event queue 2022-06-20 17:03:40 +02:00
D.R.racer d80a58cfdb Fix unit tests 2022-06-20 17:03:40 +02:00
D.R.racer 2874dd3bc9 Make sure the selector never moves if FINDA is pressed
It looks we have some kind of leak when filament sensor state is not completely coherent with FINDA state.
This is yet to be discovered and fixed with some unit tests.
2022-06-20 14:20:31 +02:00
D.R.racer cecb659564 Reject LoadFilament if filament state > AtPulley
If the MMU receives a command LoadFilament with a slot number SL we reject
the command to avoid moving the selector (effectively cutting the piece of filament present in FINDA).

That includes the scenario when the selector is standing at the very same slot SL, because the filament could be held by the printer (i.e. loaded in the nozzle).

There is one special case though - same slot AND filament load state == InSelector (it MUST NOT be anywhere farther)
2022-06-20 13:53:35 +02:00
D.R.racer b4f9924013 Improve robustness of unit tests 2022-06-14 07:31:51 +02:00
D.R.racer fbb46e5951 Distinguish fast and slow feed stage
Originally, only FeedingToBondtech was reported to the printer.
With PR#173 we have this operation separated into a fast and a slow stage (for MK3S with the chimney).
It looks like the printer could benefit from knowing if the MMU is still pushing fast
or when it entered the slow stage (to prevent ramming hard the Bondtech gears)

Along with this new state being reported, we also introduce a new ErrorCode::FSENSOR_TOO_EARLY
which basically means that the fsensor triggered in the fast feeding stage.
2022-05-23 07:41:54 +02:00
D.R.racer e99e7441e1 Add unit tests for unlimited load 2022-05-13 12:54:23 +02:00
D.R.racer f428075a4d Make LoadFilament retract even when stopped with a button
+ fix unrelated unit test of unload to finda which got broken in PR#160
2022-05-11 08:20:41 +02:00
D.R.racer 9c1204dad9 Rename idle_mode to application 2022-05-10 20:03:16 +02:00
D.R.racer 047c76870c Move idle_mode out from logic subdir 2022-05-10 20:03:16 +02:00
D.R.racer c3739eaaef Make unlimited LoadFilament as default 2022-05-10 20:03:16 +02:00
D.R.racer ff1a89d369 Detect successful end of logic::command + start idle countdown
This commit looks horribly complex, but the main idea is to have each of the logic::commands
report their terminal OK state in the same way. That allow for leveraging this very moment
to initiate the idle timeout.

Additionally, I wanted to hide the logic of idle mode detection, which resulted in moving the
top level logic from main.cpp into logic/idle_mode.cpp and a set of additional files to compile
in unit tests.
2022-05-10 20:03:16 +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
D.R.racer 13c12aac7f Repeated unload
Set default nr. of repeated unloads to 1
+ introduce a unit test for repeated unloads
2022-05-10 19:58:09 +02:00
Yuri D'Elia fbb5843158 Guard critical sections in modules::motion
While motion queuing is safe, code that relies on the current block
needs to run with the isr disabled.

Protect AbortPlannedMoves and CurPosition from isr' interference by
using a RAII guard.
2022-05-02 12:33:37 +02:00
D.R.racer ca86797a9c Invalidate currentSlot while homing
makes calls to Slot() consistent and reliable
2022-02-21 18:38:04 +01:00
D.R.racer 8e8a17c34e Fix unit test UnloadFilament 2022-02-17 08:21:15 +01:00
D.R.racer b685ec4aff Fix waiting for homing of Selector after UnloadFilament 2022-02-17 08:21:15 +01:00
D.R.racer c95c6677b1 Add more unit tests for homing + fix the homing
It is a carpet-bombing-commit again, but solving the problem correctly required such an approach.
2022-02-17 08:21:15 +01:00
D.R.racer bcba966a0e Fix repeated re-homing + add more unit tests for that scenario 2022-02-17 08:21:15 +01:00
D.R.racer 18891dbeaf Add ClearButtons into unit tests 2022-02-17 08:21:15 +01:00
D.R.racer 7fbd3c9c7e Fix homing error recovery + add homing unit tests 2022-02-17 08:21:15 +01:00
D.R.racer 4d9d310f00 Fix unit tests 2022-02-17 08:21:15 +01:00
D.R.racer f9addb0d7a WIP: homing on both ends of axes
The principle has been implemented, but the TMC is not providing
the right data for some reason - homing doesn't work at all right now.

Also, after solving the physical homing, unit tests must be updated.
2022-02-17 08:21:15 +01:00