aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2019-01-08 11:34:09 -0500
committerKevin O'Connor <kevin@koconnor.net>2019-01-08 11:34:09 -0500
commit33f5b5f2858b344a118c6a219487cccec759e024 (patch)
tree29ef514a03593a0f27223c7afcf66e5d8c6b26be
parent857e7ed5f1a725e1342359b6c071586a3d495702 (diff)
downloadkutter-33f5b5f2858b344a118c6a219487cccec759e024.tar.gz
kutter-33f5b5f2858b344a118c6a219487cccec759e024.tar.xz
kutter-33f5b5f2858b344a118c6a219487cccec759e024.zip
docs: Update Code_Overview.md with removal of printer_state() callback
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--docs/Code_Overview.md32
1 files changed, 21 insertions, 11 deletions
diff --git a/docs/Code_Overview.md b/docs/Code_Overview.md
index 2b5fa621..5266fd1e 100644
--- a/docs/Code_Overview.md
+++ b/docs/Code_Overview.md
@@ -262,16 +262,26 @@ The following may also be useful:
will have been instantiated. The "gcode" and "pins" modules will
always be available, but for other modules it is a good idea to
defer the lookup.
-* Define a `printer_state()` method if the code needs to be called
- during printer setup and/or shutdown. This method is called twice
- during setup (with "connect" and then "ready") and may also be
- called at run-time (with "shutdown" or "disconnect"). It is common
- to perform "printer object" lookup during the "connect" and "ready"
- phases.
+* Register event handlers using the `printer.register_event_handler()`
+ method if the code needs to be called during "events" raised by
+ other printer objects. Each event name is a string, and by
+ convention it is the name of the main source module that raises the
+ event along with a short name for the action that is occurring (eg,
+ "klippy:connect"). The parameters passed to each event handler are
+ specific to the given event (as are exception handling and execution
+ context). Two common startup events are:
+ * klippy:connect - This event is generated after all printer objects
+ are instantiated. It is commonly used to lookup other printer
+ objects, to verify config settings, and to perform an initial
+ "handshake" with printer hardware.
+ * klippy:ready - This event is generated after all connect handlers
+ have completed successfully. It indicates the printer is
+ transitioning to a state ready to handle normal operations. Do not
+ raise an error in this callback.
* If there is an error in the user's config, be sure to raise it
- during the `load_config()` or `printer_state("connect")` phases. Use
- either `raise config.error("my error")` or `raise
- printer.config_error("my error")` to report the error.
+ during the `load_config()` or "connect event" phases. Use either
+ `raise config.error("my error")` or `raise printer.config_error("my
+ error")` to report the error.
* Use the "pins" module to configure a pin on a micro-controller. This
is typically done with something similar to
`printer.lookup_object("pins").setup_pin("pwm",
@@ -286,8 +296,8 @@ The following may also be useful:
printer object returned from the `load_config()` function. This is
important as otherwise the RESTART command may not perform as
expected. Also, for similar reasons, if any external files (or
- sockets) are opened then be sure to close them from the
- `printer_state("disconnect")` callback.
+ sockets) are opened then be sure to register a "klippy:disconnect"
+ event handler and close them from that callback.
* Avoid accessing the internal member variables (or calling methods
that start with an underscore) of other printer objects. Observing
this convention makes it easier to manage future changes.