Commit 4d586b80 authored by Guillaume Seguin's avatar Guillaume Seguin

Rework temperature report parsing

This change is based on an IRC discussion with @Triffid_Hunder, @Sound and
reifsnyder, where we figured out that the best way to report multiple extruders
temperature would simply to add more information to the M105 line in the form of
T0:a/b T1:a/b... The "T:" part should still report the active extruder tool by
default, or obey the T gcode parameter).
This change also simplifies the parsing by using a generic regexp.
parent 198601a5
...@@ -49,11 +49,11 @@ import pronsole ...@@ -49,11 +49,11 @@ import pronsole
from pronsole import dosify, wxSetting, HiddenSetting, StringSetting, SpinSetting, FloatSpinSetting, BooleanSetting from pronsole import dosify, wxSetting, HiddenSetting, StringSetting, SpinSetting, FloatSpinSetting, BooleanSetting
from printrun import gcoder from printrun import gcoder
def parse_temperature_report(report, key): tempreport_exp = re.compile("([TB]\d*):([-+]?\d*\.?\d*)\/?([-+]?\d*\.?\d*)")
if key in report:
return float(filter(lambda x: x.startswith(key), report.split())[0].split(":")[1].split("/")[0]) def parse_temperature_report(report):
else: matches = tempreport_exp.findall(report)
return -1.0 return dict((m[0], (m[1], m[2])) for m in matches)
def format_time(timestamp): def format_time(timestamp):
return datetime.datetime.fromtimestamp(timestamp).strftime("%H:%M:%S") return datetime.datetime.fromtimestamp(timestamp).strftime("%H:%M:%S")
...@@ -1136,10 +1136,18 @@ class PronterWindow(MainWindow, pronsole.pronsole): ...@@ -1136,10 +1136,18 @@ class PronterWindow(MainWindow, pronsole.pronsole):
def update_tempdisplay(self): def update_tempdisplay(self):
try: try:
hotend_temp = parse_temperature_report(self.tempreport, "T:") # FIXME : we don't use setpoints here, we should probably exploit them
temps = parse_temperature_report(self.tempreport)
if "T0" in temps:
hotend_temp = float(temps["T0"][0])
else:
hotend_temp = float(temps["T"][0]) if "T" in temps else -1.0
wx.CallAfter(self.graph.SetExtruder0Temperature, hotend_temp) wx.CallAfter(self.graph.SetExtruder0Temperature, hotend_temp)
if self.display_gauges: wx.CallAfter(self.hottgauge.SetValue, hotend_temp) if self.display_gauges: wx.CallAfter(self.hottgauge.SetValue, hotend_temp)
bed_temp = parse_temperature_report(self.tempreport, "B:") if "T1" in temps:
hotend_temp = float(temps["T1"][0])
wx.CallAfter(self.graph.SetExtruder1Temperature, hotend_temp)
bed_temp = float(temps["B"][0]) if "B" in temps else -1.0
wx.CallAfter(self.graph.SetBedTemperature, bed_temp) wx.CallAfter(self.graph.SetBedTemperature, bed_temp)
if self.display_gauges: wx.CallAfter(self.bedtgauge.SetValue, bed_temp) if self.display_gauges: wx.CallAfter(self.bedtgauge.SetValue, bed_temp)
except: except:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment