{"action":"created","issue":{"url":"https://api.github.com/repos/MarlinFirmware/Marlin/issues/2820","labels_url":"https://api.github.com/repos/MarlinFirmware/Marlin/issues/2820/labels{/name}","comments_url":"https://api.github.com/repos/MarlinFirmware/Marlin/issues/2820/comments","events_url":"https://api.github.com/repos/MarlinFirmware/Marlin/issues/2820/events","html_url":"https://github.com/MarlinFirmware/Marlin/pull/2820","id":120187942,"number":2820,"title":"Check probes only when deployed","user":{"login":"Wackerbarth","id":505323,"avatar_url":"https://avatars.githubusercontent.com/u/505323?v=3","gravatar_id":"","url":"https://api.github.com/users/Wackerbarth","html_url":"https://github.com/Wackerbarth","followers_url":"https://api.github.com/users/Wackerbarth/followers","following_url":"https://api.github.com/users/Wackerbarth/following{/other_user}","gists_url":"https://api.github.com/users/Wackerbarth/gists{/gist_id}","starred_url":"https://api.github.com/users/Wackerbarth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wackerbarth/subscriptions","organizations_url":"https://api.github.com/users/Wackerbarth/orgs","repos_url":"https://api.github.com/users/Wackerbarth/repos","events_url":"https://api.github.com/users/Wackerbarth/events{/privacy}","received_events_url":"https://api.github.com/users/Wackerbarth/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/MarlinFirmware/Marlin/labels/PR%20Bug%20Fix","name":"PR Bug Fix","color":"60D060"},{"url":"https://api.github.com/repos/MarlinFirmware/Marlin/labels/PR%20Needs%20update","name":"PR Needs update","color":"e11d21"},{"url":"https://api.github.com/repos/MarlinFirmware/Marlin/labels/RCBugFIX","name":"RCBugFIX","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-12-03T14:51:10Z","updated_at":"2016-01-31T02:57:02Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/MarlinFirmware/Marlin/pulls/2820","html_url":"https://github.com/MarlinFirmware/Marlin/pull/2820","diff_url":"https://github.com/MarlinFirmware/Marlin/pull/2820.diff","patch_url":"https://github.com/MarlinFirmware/Marlin/pull/2820.patch"},"body":"Aim: Test probes in update_endstops only when activated\r\n\r\nChanges:\r\nConfigurations\r\n Add define for FIX_MOUNTED_PROBE to handle the situation where formerly ENDSTOPS_ONLY_FOR_HOMING had to be set to lower the nozzle below Z_PROBE_OFFSET_FROM_EXTRUDER without a endstop hit message.\r\n Add define for Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN to indicate the common situation, that we have a probe but it is connected to an endstop pin\r\n Add some comments\r\n Shift some entries to have related thins together.\r\n\r\nConditionals.h\r\n We have a probe (HAS_Z_MIN_PROBE) if one of the pins is defined and one of the probes is defined.\r\n\r\nSanityCheck.h\r\n Add some tests if the probe is connected and if we have defined a probe.\r\n\r\nstepper.cpp\r\n Changes to test the probe only when it is deployed (z_probe_is_active).\r\n Test update_endstops() when the probe is deployed.\r\n\r\nMarlinMain.cpp\r\n a. set and reset z_probe_is_active in deploy_z_probe(), stow_z_probe() and dock_sled()\r\n b. set and reset z_probe_is_active in the case a z-servo is moved to a defined position. The only remaining unhandled servo move is in M280 where we do not end in a defined position. If you want to handle a probe use M401/402\r\n c. skip deploying/stowing when already deployed/stowed in the dedicated deploy/stow functions.\r\n d. Handle the new FIX_MOUNTED_PROBE in parallel to a servo driven probe/endstop.\r\n\r\n To do: In an other PR. handle all probes in deploy/stow_z_probe.\r\n Sort out SERVO_LEVELING vs. HAS_SERVO_ENDSTOPS."},"comment":{"url":"https://api.github.com/repos/MarlinFirmware/Marlin/issues/comments/177366217","html_url":"https://github.com/MarlinFirmware/Marlin/pull/2820#issuecomment-177366217","issue_url":"https://api.github.com/repos/MarlinFirmware/Marlin/issues/2820","id":177366217,"user":{"login":"thinkyhead","id":698003,"avatar_url":"https://avatars.githubusercontent.com/u/698003?v=3","gravatar_id":"","url":"https://api.github.com/users/thinkyhead","html_url":"https://github.com/thinkyhead","followers_url":"https://api.github.com/users/thinkyhead/followers","following_url":"https://api.github.com/users/thinkyhead/following{/other_user}","gists_url":"https://api.github.com/users/thinkyhead/gists{/gist_id}","starred_url":"https://api.github.com/users/thinkyhead/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thinkyhead/subscriptions","organizations_url":"https://api.github.com/users/thinkyhead/orgs","repos_url":"https://api.github.com/users/thinkyhead/repos","events_url":"https://api.github.com/users/thinkyhead/events{/privacy}","received_events_url":"https://api.github.com/users/thinkyhead/received_events","type":"User","site_admin":false},"created_at":"2016-01-31T02:57:02Z","updated_at":"2016-01-31T02:57:02Z","body":"Ok, I finally read through all of MarlinFirmware/MarlinDev#285 and I believe I get the gist of the proposed solution. The code should be this way generally, forever-more. If a probe is not deployed, it should not be checked. As an add-on, you might want to disable the probe in-between probing points, even if it is still deployed.\r\n\r\nIn that conversation you and @Roxy-3DPrintBoard also discussed whether to run the general before/after-probing GCode script in the `stow()` / `deploy()` routines. The conclusions:\r\n- The current script options are intended for the initial `deploy` and final `stow` of things like allen key and sled probes, so you wouldn't want to use them with every individual probe (as with the \"E\" option).\r\n- And anyway, you can't currently run GCode from within a GCode handler. You can only add it to the end of the queue. The GCode processor needs a hook to allow such chicanery. [Basically moving most of `process_next_command()` into a new `process_command(char *commandStr)` function that can be called from anyplace, and implementing a concise `process_more_commands(char *manyCommandsStr)` function that runs delimited commands immediately. Also, to allow multi-threaded argument-handling, the global `current_command` pointer would need to be replaced with a pointer argument to the command handlers. Another thread on this may exist someplace…?]\r\n\r\nAnyway, next I will take a closer look at the commits to see that I fully understand the solutions.\r\n\r\nIn the longer run, it's good to be looking now at the endstop problem as a whole in a comprehensive way and getting a bird's-eye view. There are two facets of the problem: (1) updating the endstop states, and (2) responding to the endstop states. Within that there is the question of how to relate probes and endstop switches. Maybe we make a general `switches.cpp` interface first, then make `endstops.cpp` and `probes.cpp` as special cases. Or perhaps the current lean-but-distributed approach is still good.\r\n\r\nIn any case, the most \"programmerly\" way to approach the problem up-front is to write up a flow-chart or step-by-step list describing the behavior that we want to see realized for each potential configuration.\r\n\r\nNext to that, write down the current endstop and probe behavior for each configuration (by having testers use the debug options for homing and leveling or by running the source code in your head).\r\n\r\nWe ultimately want to know every function that is called, at what time, in what order, and with what parameters. With the \"endstop machinery\" isolated, it should be much easier to consolidate. And the same with probing and leveling. These functions can definitely all be generalized into instances of \"special commands that do info gathering\" and \"special commands that apply gathered info.\" It's worth taking a look at the current single-probe GCodes and thinking of ways to take a GCode-based approach to these kinds of processes."}}