Commit Graph

59 Commits (3988a9aff099c2fdc83f3f4983b3de262a60ed6a)

Author SHA1 Message Date
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 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 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 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 e99e7441e1 Add unit tests for unlimited load 2022-05-13 12:54:23 +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 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 18891dbeaf Add ClearButtons into 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 b36e6b99a1 Add Pulley as a Movable module
This PR brings the following improvements:
- unifies the error handling of TMC and Homing/Stallguard errors on all motorized modules (Idler, Selector, Pulley)
- now we distinguish between Homing and TMC errors + we have a separate handling of these two kinds into CommandBase unified for all motorized modules
- adds unit tests to verify the function
- fixes SetFINDAStateAndDebounce (didn't obey the press parameter before)
2022-02-17 08:21:15 +01:00
D.R.racer 6973dbff13 Introduce intelligent homing if Idler and Selector
Both movable components now perform homing sequences transparently
whenever the logic layer invalidates the homingValid flag.
That reflects the fact, that the user may have moved the Idler or Selector
while trying to resolve a HW issue with un/loading filament.

Basic rules:
- Idler gets rehomed immediately and then moves into the target slot position
- Selector rehomes once it is possible - i.e. when filament load state
  is AtPulley - then it immediately and spontanneously executes the homing
  sequence and then returns to the desired state

Motivation:
- resolve startup issues (EEPROM says we have filament, but FINDA is not triggered)
- resolve accidental moves of Idler and/or Selector while
  digging out stuck filament from the unit
2021-11-25 13:04:22 +01:00
D.R.racer 6f982e2505 Cleanup compiler warnings 2021-11-17 08:48:59 +01:00
D.R.racer 515119edc8 Test ToolChange error recovery by button 0 and 1 2021-11-17 08:48:59 +01:00
D.R.racer 7fe9d7f329 Finish UnloadFilament unit test - error state resolved by user + checks 2021-11-17 08:48:59 +01:00
D.R.racer c2325b687a Unittests: set buttons more consistently 2021-11-17 08:48:59 +01:00
D.R.racer 872b2206ed Cleanup error recovery of LoadFilament
+ cover all paths with unit tests
2021-11-17 08:48:59 +01:00
D.R.racer 96397ec16b Improve error handling of ToolChange state machines
... and fix an edge case in LoadFilament
2021-11-17 08:48:59 +01:00
D.R.racer 9438253106 Avoid trying to unload filament when not loaded
however, it looks like the EEPROM is not updated correctly, needs more testing
2021-10-21 15:16:29 +02:00
D.R.racer ee247246ee Fix unit tests
- fix homing procedure for Idler and Selector
  (homing now ends with a move to the Parking position)
- fix unit tests' startup conditions with regard to necessary
  homing of Idler and Selector

TODO: still test_cut_filament fails for minor reasons
2021-10-21 07:55:41 +02:00
D.R.racer e1af08b3d5 Fix unit tests
That includes:
- introduce pulley slow feedrate and fsensor-to-nozzle distance
  in config necessary for slowly feeding the filament from fsensor into the nozzle.
  (the constant is subject to extraction into some other config as it has to be used in the printer as well).
- update FeedToBondtech accordingly to perform a gentle push into the nozzle
  after fsensor detects the filament + update its unit tests.
- slight cleanup of LoadFilament + fix its unit tests
- add FeedingToNozzle progress code, as it might be interesting
  to inform the printer about this task in the future
- revert non-clean changes from RetractFromFinda - it should not disengage the idler
- revert incorrect + fix ToolChange
- clean-up UnloadFilament
2021-10-12 18:11:05 +02:00
3d-gussner abf875bda0 After Load Filament is compeleted the slot LED should be off 2021-10-12 18:11:05 +02:00
D.R.racer c26cc30185 Add finer filament loaded states and improve unit tests
We need to know better where the filament is, a simple "filament loaded true/false"
does not correspond to the reality.
2021-10-12 18:11:05 +02:00
D.R.racer 5af0125672 LoadFilament should not set filament loaded (surprisingly)
because of the change of semantics of LoadFilament operation.
LoadFilament pushes the filament into FINDA and then retracts it back just to keep the
filament ready to be grabbed by the idler and pulley and loaded into the printer's nozzle.

So the selector is not blocked by the filament -> filament NOT loaded
2021-10-12 18:11:05 +02:00
D.R.racer 5cf4a496e3 Introduce checking for enabled/disabled Pulley axis in unit tests 2021-10-12 18:11:05 +02:00
D.R.racer 6426295e32 Change the semantics of load filament
Load filament performs feed to FINDA and retract:
- engage idler
- feed normal to FINDA with config::feedToFinda distance until FINDA triggers
- retract normal and as soon FINDA un-triggers move back to PTFE config::cuttingEdgeToFindaMidpoint
- disengage the idler

That implied introducing another substate machine - RetractFromFinda, which does the opposite
of FeedToFinda while also checking for the FINDA switching off while retracting filament.

Still, ToolChange and CutFilament need fixing with this change
2021-10-12 18:11:05 +02:00
D.R.racer 74629f0103 Fix reporting progress of running commands
The problem was the error state while running a command - we never used the RUNNING error state.
2021-09-02 08:35:56 +02:00
3d-gussner 12cf25511a Fix unit test: load_filament 2021-08-31 06:59:29 +02:00
D.R.racer 06c46b20a6 Turn off green LED after load/unload finished successfully
MMU-65
2021-08-30 17:34:46 +02:00
D.R.racer e0ea47595f Add unit tests for logic state machines reusal
as it will work in the real FW
2021-08-12 10:30:40 +02:00
D.R.racer 9ba116e06e Handle slot indices out of range correctly at top level
Besides Unload Filament, which only operates on active slot, all other
top level state machines check the validity of the command's parameter.
If the parameter is out of range for available slots, they return
ErrorCode::INVALID_TOOL now.
2021-08-12 10:30:40 +02:00
D.R.racer 2f5dff6c5b Introduce short namespace aliases
especially for modules
2021-08-04 11:03:56 +02:00
D.R.racer 8694c53033 Fixes after rebase onto main 2021-08-02 10:52:18 +02:00
D.R.racer aa5995368d Update to latest main + fix unit tests
... in relation to the newly introduced stepping in physical units rather than in steps
2021-08-02 10:52:18 +02:00
D.R.racer 751ee46450 Add bit masks for error codes for the TMC drivers
+ add common error handling for idler and selector
+ improve error handling in command_base
+ rename ERR1xxxx errors to ERRxxxx (remove the '1')
2021-08-02 07:45:45 +02:00
D.R.racer df2c1ba7fe Add prototype of unified handling of HW errors in the logic layer 2021-08-02 07:45:45 +02:00
D.R.racer f5df642eb5 Improve error codes
- Distinguish among FINDA on/off failuje
- The same applies to newly introduced Filament sensor errors
- Add TMC init error
- Add a communication error ID - to be used on the printer
2021-08-02 07:45:45 +02:00
Yuri D'Elia 787c73ecff Merge remote-tracking branch 'upstream/main' into motion_wip 2021-07-12 10:25:06 +02:00
Alan Dragomirecký cf5b1c3955 Do not use hard-to-read relative paths in CMake 2021-07-12 09:09:21 +02:00