docs: Update Code_Overview.md with information on get_status()

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2021-11-16 19:15:20 -05:00
parent 34f58f2816
commit 779793c746
1 changed files with 11 additions and 0 deletions

View File

@ -286,6 +286,17 @@ The following may also be useful:
`printer.lookup_object("pins").setup_pin("pwm",
config.get("my_pin"))`. The returned object can then be commanded at
run-time.
* If the printer object defines a `get_status()` method then the
module can export [status information](Status_Reference.md) via
[macros](Command_Templates.md) and via the
[API Server](API_Server.md). The `get_status()` method must return a
Python dictionary with keys that are strings and values that are
integers, floats, strings, lists, dictionaries, True, False, or
None. Tuples (and named tuples) may also be used (these appear as
lists when accessed via the API Server). Lists and dictionaries that
are exported must be treated as "immutable" - if their contents
change then a new object must be returned from `get_status()`,
otherwise the API Server will not detect those changes.
* If the module needs access to system timing or external file
descriptors then use `printer.get_reactor()` to obtain access to the
global "event reactor" class. This reactor class allows one to