Skip to content

Commit

Permalink
RC Release 1.29.0rc1
Browse files Browse the repository at this point in the history
- E #265 show next filament change layer
- B #257 fixing relative height movement
- B #210 reduce temperature resulution and fixing blinking of bed temperature
  • Loading branch information
OllisGit committed Jul 11, 2022
1 parent dbeb03d commit 8235a7b
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 32 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ You can receive the layer/height and other values via a GET-Call.
"changeFilamentTimeLeft": "32s",
"changeFilamentTimeLeftInSeconds": 32,
"estimatedChangedFilamentTime": "22:36",
"nextChangeFilamentLayer": 5
}
}

Expand Down Expand Up @@ -198,6 +199,7 @@ Plugin sends the following custom events to the eventbus like this:
'changeFilamentTimeLeft': '1m12s,
'changeFilamentTimeLeftInSeconds': 72,
'changeFilamentCount': 2,
'nextChangeFilamentLayer': 5,
'currentFilename': 'AE10_xyzCalibration_cube.gcode'
}
```
Expand Down
63 changes: 43 additions & 20 deletions octoprint_DisplayLayerProgress/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
# Match G1 Z149.370 F1000 or G0 F9000 X161.554 Y118.520 Z14.950 ##no comments
# mine: ^[^;](.*)( Z)([+]*[0-9]+[.]*[0-9]*)(.*)
# pr: ^G[0|1](.*)( Z)([+]*[0-9]+[.]*[0-9]*)(.*)
Z_HEIGHT_EXPRESSION = "^[^;]*G[0|1](.*)( Z)([+]*[0-9]+[.]*[0-9]*)(.*)"
Z_HEIGHT_EXPRESSION = "^[^;]*G[0|1](.*)( Z)([+]?[-]?[0-9]+[.]*[0-9]*)(.*)"
zHeightPattern = re.compile(Z_HEIGHT_EXPRESSION)

# Match G0 or G1 positive extrusion e.g. G1 X58.030 Y72.281 E0.1839 F2250
Expand Down Expand Up @@ -135,6 +135,7 @@
ETA_CHANGEFILAMENT_KEYWORD_EXPRESSION = "[estimated_changefilament_time]"
CHANGEFILAMENTTIME_LEFT_KEYWORD_EXPRESSION = "[changefilamenttime_left]"
CHANGEFILAMENT_COUNT_KEYWORD_EXPRESSION = "[changefilament_count]"
NEXT_CHANGEFILAMENT_LAYER_KEYWORD_EXPRESSION = "[nextchangefilament_layer]" # see https://github.com/OllisGit/OctoPrint-DisplayLayerProgress/issues/265
PRINTER_STATE_KEYWORD_EXPRESSION = "[printer_state]"
M73PROGRESS_KEYWORD_EXPRESSION = "[M73progress]" # see https://github.com/tpmullan/OctoPrint-DetailedProgress
CURRENT_FILENAME_KEYWORD_EXPRESSION = "[current_print_filename]" # see https://github.com/OllisGit/OctoPrint-DisplayLayerProgress/issues/214
Expand Down Expand Up @@ -302,10 +303,12 @@ def __init__(self):
self._totalHeightFormatted = NOT_PRESENT
# self._totalHeightWithExtrusionFormatted = NOT_PRESENT
self._currentTemperatures = dict()
self._lastBedTemperatures = None

self._filamentChangeTimeLeftInSeconds = 0
self._filamentChangeTimeLeftFormatted = NOT_PRESENT
self._filamentChangeETAFormatted = NOT_PRESENT
self._nextM600Layer = 0

self._printerState = ""
self._lastPrinterState = ""
Expand Down Expand Up @@ -454,12 +457,6 @@ def queuingGCodeHook(self, comm_instance, phase, cmd, cmd_type, gcode, *args, **
if commandAsString.startswith(LAYER_MESSAGE_PREFIX):
# filter M117 indicator-command, not needed any more
return []

# movement type
if "G90" == gcode:
self._movementMode = MOVEMENT_ABSOLUTE
if "G91" == gcode:
self._movementMode = MOVEMENT_RELATIVE
return

# do the stuff in async-way
Expand All @@ -483,6 +480,12 @@ def sendingGCodeHookWorkerMethod(self, commandAsString):
# filter M117 indicator-command, not needed any more
return

# movement type/mode
if commandAsString.startswith("G90"):
self._movementMode = MOVEMENT_ABSOLUTE
if commandAsString.startswith("G91"):
self._movementMode = MOVEMENT_RELATIVE

# M600
if (commandAsString.startswith("M600")):
self._updateDisplay(UPDATE_DISPLAY_REASON_M600_OCCURRED)
Expand All @@ -499,6 +502,12 @@ def sendingGCodeHookWorkerMethod(self, commandAsString):

self._currentHeight = "%.2f" % self._currentHeightFloat
self._updateDisplay(UPDATE_DISPLAY_REASON_HEIGHT_CHANGED)
# G28 - home
if commandAsString.startswith("G28"):
self._currentHeightFloat = 0
self._currentHeight = "%.2f" % self._currentHeightFloat
self._updateDisplay(UPDATE_DISPLAY_REASON_HEIGHT_CHANGED)

# feedrate
matched = feedratePattern.match(commandAsString)
if matched:
Expand Down Expand Up @@ -649,6 +658,7 @@ def _resetCurrentValues(self):

self._currentPrinterDisplayMessagePattern = self._cachedSettings.getStringValue(SETTINGS_KEY_PRINTERDISPLAY_MESSAGEPATTERN)

self._lastBedTemperatures = None

def _resetTotalValues(self):
self._layerTotalCountWithoutOffset = NOT_PRESENT
Expand Down Expand Up @@ -737,6 +747,7 @@ def _readTemperatures(self):
if "bed" in temperaturesRead:
bedValues = temperaturesRead["bed"]
self._currentTemperatures["bed"] = bedValues
self._lastBedTemperatures = bedValues

pass

Expand Down Expand Up @@ -818,13 +829,11 @@ def _updateDisplay(self, updateReason):
# layerChanged event, then calculate the predicted filamentChange time
if (updateReason == UPDATE_DISPLAY_REASON_LAYER_CHANGED): #TODO only if it is included into message output pattern in settings-ui
currenLayerNumber = int(self._currentLayer)

if (len(self._m600LayerProcessingList) > 0):
self._nextM600Layer = self._m600LayerProcessingList[0]

if (self._nextM600Layer == currenLayerNumber):
self._m600LayerProcessingList.pop(0)
self._nextM600Layer == 0
else:
self._nextM600Layer = 0

Expand All @@ -843,7 +852,10 @@ def _updateDisplay(self, updateReason):

currentBedTemperature = ""
if ("bed" in self._currentTemperatures):
currentBedTemperature = str(self._currentTemperatures["bed"]["actual"])
currentBedTemperature = str(round(self._currentTemperatures["bed"]["actual"], 1))

if (currentBedTemperature == "" and self._lastBedTemperatures != None):
currentBedTemperature = str(round(self._lastBedTemperatures["actual"], 1))

currentTool0Temperature = ""
currentTool1Temperature = ""
Expand All @@ -855,22 +867,21 @@ def _updateDisplay(self, updateReason):
currentTool7Temperature = ""

if ("tool0" in self._currentTemperatures):
currentTool0Temperature = str(self._currentTemperatures["tool0"]["actual"])
currentTool0Temperature = str(round(self._currentTemperatures["tool0"]["actual"], 1))
if ("tool1" in self._currentTemperatures):
currentTool1Temperature = str(self._currentTemperatures["tool1"]["actual"])
currentTool1Temperature = str(round(self._currentTemperatures["tool1"]["actual"], 1))
if ("tool2" in self._currentTemperatures):
currentTool2Temperature = str(self._currentTemperatures["tool2"]["actual"])
currentTool2Temperature = str(round(self._currentTemperatures["tool2"]["actual"], 1))
if ("tool3" in self._currentTemperatures):
currentTool3Temperature = str(self._currentTemperatures["tool3"]["actual"])
currentTool3Temperature = str(round(self._currentTemperatures["tool3"]["actual"], 1))
if ("tool4" in self._currentTemperatures):
currentTool4Temperature = str(self._currentTemperatures["tool4"]["actual"])
currentTool4Temperature = str(round(self._currentTemperatures["tool4"]["actual"], 1))
if ("tool5" in self._currentTemperatures):
currentTool5Temperature = str(self._currentTemperatures["tool5"]["actual"])
currentTool5Temperature = str(round(self._currentTemperatures["tool5"]["actual"], 1))
if ("tool6" in self._currentTemperatures):
currentTool6Temperature = str(self._currentTemperatures["tool6"]["actual"])
currentTool6Temperature = str(round(self._currentTemperatures["tool6"]["actual"], 1))
if ("tool7" in self._currentTemperatures):
currentTool7Temperature = str(self._currentTemperatures["tool7"]["actual"])

currentTool7Temperature = str(round(self._currentTemperatures["tool7"]["actual"], 1))

currentValueDict = {
PROGRESS_KEYWORD_EXPRESSION: self._progress,
Expand All @@ -891,6 +902,7 @@ def _updateDisplay(self, updateReason):
ETA_CHANGEFILAMENT_KEYWORD_EXPRESSION: self._filamentChangeETAFormatted,
CHANGEFILAMENTTIME_LEFT_KEYWORD_EXPRESSION: self._filamentChangeTimeLeftFormatted,
CHANGEFILAMENT_COUNT_KEYWORD_EXPRESSION: str(len(self._m600LayerProcessingList)),
NEXT_CHANGEFILAMENT_LAYER_KEYWORD_EXPRESSION: str(self._calculateNextM600Layer()),
PRINTER_STATE_KEYWORD_EXPRESSION: self._printerState,
M73PROGRESS_KEYWORD_EXPRESSION: self._m73Progress,
CURRENT_FILENAME_KEYWORD_EXPRESSION: self._currentFilename,
Expand Down Expand Up @@ -1019,6 +1031,7 @@ def _updateDisplay(self, updateReason):
changeFilamentTimeLeft=self._filamentChangeTimeLeftFormatted,
changeFilamentTimeLeftInSeconds=self._filamentChangeTimeLeftInSeconds,
changeFilamentCount=len(self._m600LayerProcessingList),
nextChangeFilamentLayer=self._calculateNextM600Layer(),
currentFilename=self._currentFilename
)

Expand All @@ -1045,6 +1058,15 @@ def _updateDisplay(self, updateReason):

_lastSendEventBusData = dict()

def _calculateNextM600Layer(self):
nextM600LayerPlusOne = self._nextM600Layer
if nextM600LayerPlusOne == 0:
return 0
# plus one, because the M600 detection is in prev. layer.
# you want to change in layer 5 (cura-extension=5) then M600 command is in layer 4
nextM600LayerPlusOne = self._nextM600Layer + 1

return nextM600LayerPlusOne

def _calculateFeedrate(self, feedrate):
if feedrate == "-":
Expand Down Expand Up @@ -1317,7 +1339,8 @@ def get_displayLayerProgressValues(self):
"estimatedChangedFilamentTime": self._filamentChangeETAFormatted,
"changeFilamentTimeLeft": self._filamentChangeTimeLeftFormatted,
"changeFilamentTimeLeftInSeconds": self._filamentChangeTimeLeftInSeconds,
"changeFilamentCount": len(self._m600LayerProcessingList)
"changeFilamentCount": len(self._m600LayerProcessingList),
"nextChangeFilamentLayer": self._calculateNextM600Layer()
},
"currentFilename": self._currentFilename
})
Expand Down
24 changes: 14 additions & 10 deletions octoprint_DisplayLayerProgress/stringUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def one_xlat(match):
return rx.sub(one_xlat, text)

# see https://stackoverflow.com/questions/4048651/python-function-to-convert-seconds-into-minutes-hours-and-days/4048773
def secondsToText(secs, hideSeconds=False):
def secondsToText(secs, hideSeconds=False, withLeadingZeros=False):
result = ""
days = secs // 86400
hours = (secs - days * 86400) // 3600
Expand All @@ -75,13 +75,19 @@ def secondsToText(secs, hideSeconds=False):
result = "{}h".format(hours) + "{}m".format(minutes)
else:
result = "{}h".format(hours) + "{}m".format(minutes) + "{}s".format(seconds)
if (withLeadingZeros == True):
result = "0d" + result
elif (minutes > 0):
if (hideSeconds == True):
result = "{}m".format(minutes)
else:
result = "{}m".format(minutes) + "{}s".format(seconds)
if (withLeadingZeros == True):
result = "0d0h" + result
elif (seconds >= 0):
result = "{}s".format(seconds)
if (withLeadingZeros == True):
result = "0d0h0m" + result

# result = ("{}d".format(days) if days else "") + \
# ("{}h".format(hours) if hours else "") + \
Expand Down Expand Up @@ -144,8 +150,6 @@ def strfdelta(tdelta, fmt='{D:02}d {H:02}h {M:02}m {S:02}s', inputtype='timedelt
return f.format(fmt, **values)




import os
def getLastLinesFromFile(file_name, N):
# Create an empty list to keep the track of last N lines
Expand Down Expand Up @@ -192,13 +196,13 @@ def getLastLinesFromFile(file_name, N):


### TEST-ZONE
#day = 0
#hour = 0
#minute = 1
#second = 31

#seconds = day * 24 * 60 * 60 + hour * 60 * 60 + minute * 60 + second
#print(secondsToText(None, seconds) )
# day = 0
# hour = 0
# minute = 0
# second = 31
#
# seconds = day * 24 * 60 * 60 + hour * 60 * 60 + minute * 60 + second
# print(secondsToText(seconds, hideSeconds=False, withLeadingZeros=True) )

# import octoprint.util
# # gcode_line_as_str = "M117 Priming Filamentâ{¦"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
[last_layer_duration], [average_layer_duration], <br/>
[current_height], [total_height], <br/>
[feedrate], [feedrate_g0], [feedrate_g1], [fanspeed], <br/>
[changefilamenttime_left], [estimated_changefilament_time], [changefilament_count], <br/>
[changefilamenttime_left], [estimated_changefilament_time], [changefilament_count], [nextchangefilament_layer]<br/>
[printer_state], [current_print_filename]<br/>
[current_bed_temp], [current_tool0_temp] ... [current_tool7_temp]
</code>
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
plugin_name = "DisplayLayerProgress"

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "1.28.0"
plugin_version = "1.29.0rc1"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand Down

0 comments on commit 8235a7b

Please sign in to comment.