✨ Support for heated chamber fw capabilities

Chamber temperatures reported via M105 will only be parsed if the
fw reports chamber capabilities (through Cap:CHAMBER_TEMPERATURE:1) or
the currently selected printer profile has a heated chamber configured.
This is to avoid incompatibility issues with firmware variants that
might already use the C parameter for something else (which might be the
case since we don't have a reliable well defined standard that people
need to adhere to...)

Chamber temperature commands M141 and M191 will only be allowed to be
sent if the selected printer profile has a heated chamber configured.
This mirrors the behaviour for the bed temperature commands M140 and
M190 and heated bed configuration.

Display of chamber data in the graph will only happen if the printer
profile has a heated chamber configured.

Implements one workflow behind #321
This commit is contained in:
Gina Häußge committed 2019-03-18 16:51:12 +01:00
1 parent b2637eb06a
commit 8d3befb01f
17 files changed
+580 -32

No files matched your search

+73 -5
View File
@@ -211,7 +211,71 @@ def printerBedState():
if not printerProfileManager.get_current_or_default()["heatedBed"]:
return make_response("Printer does not have a heated bed", 409)
data = _get_temperature_data(_delete_tools)
data = _get_temperature_data(_keep_bed)
if isinstance(data, Response):
return data
else:
return jsonify(data)
##~~ Heated chamber
@api.route("/printer/chamber", methods=["POST"])
@restricted_access
def printerChamberCommand():
if not printer.is_operational():
return make_response("Printer is not operational", 409)
if not printerProfileManager.get_current_or_default()["heatedChamber"]:
return make_response("Printer does not have a heated chamber", 409)
valid_commands = {
"target": ["target"],
"offset": ["offset"]
}
command, data, response = get_json_command_from_request(request, valid_commands)
if response is not None:
return response
tags = {"source:api", "api:printer.chamber"}
##~~ temperature
if command == "target":
target = data["target"]
# make sure the target is a number
if not isinstance(target, (int, long, float)):
return make_response("Not a number: %r" % target, 400)
# perform the actual temperature command
printer.set_temperature("chamber", target, tags=tags)
##~~ temperature offset
elif command == "offset":
offset = data["offset"]
# make sure the offset is valid
if not isinstance(offset, (int, long, float)):
return make_response("Not a number: %r" % offset, 400)
if not -50 <= offset <= 50:
return make_response("Offset not in range [-50, 50]: %f" % offset, 400)
# set the offsets
printer.set_temperature_offset({"chamber": offset})
return NO_CONTENT
@api.route("/printer/chamber", methods=["GET"])
def printerChamberState():
if not printer.is_operational():
return make_response("Printer is not operational", 409)
if not printerProfileManager.get_current_or_default()["heatedChamber"]:
return make_response("Printer does not have a heated chamber", 409)
data = _get_temperature_data(_keep_chamber)
if isinstance(data, Response):
return data
else:
@@ -412,12 +476,16 @@ def _get_temperature_data(preprocessor):
return preprocessor(tempData)
def _delete_tools(x):
return _delete_from_data(x, lambda k: k.startswith("tool"))
def _keep_tools(x):
return _delete_from_data(x, lambda k: not k.startswith("tool"))
def _delete_bed(x):
return _delete_from_data(x, lambda k: k == "bed")
def _keep_bed(x):
return _delete_from_data(x, lambda k: k != "bed")
def _keep_chamber(x):
return _delete_from_data(x, lambda k: k != "chamber")
def _delete_from_data(x, key_matcher):