Skip to content

Commit

Permalink
Fixed #63 - Widget for last M117 Message
Browse files Browse the repository at this point in the history
  • Loading branch information
sco01 committed Oct 4, 2019
1 parent ee4baa1 commit c225579
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
18 changes: 16 additions & 2 deletions octoprint_dashboard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class DashboardPlugin(octoprint.plugin.SettingsPlugin,
octoprint.plugin.TemplatePlugin,
octoprint.plugin.EventHandlerPlugin):

printer_message = ""
extruded_filament = 0.0
extruded_filament_arr = []
extruder_mode = ""
Expand Down Expand Up @@ -50,7 +51,8 @@ def send_notifications(self):
cpuTemp=str(self.cpu_temp),
extrudedFilament=str( round( (sum(self.extruded_filament_arr) + self.extruded_filament) / 1000, 2) ),
layerTimes=str(self.layer_times),
layerLabels=str(self.layer_labels)))
layerLabels=str(self.layer_labels),
printerMessage =str(self.printer_message)))

def on_event(self, event, payload):
if event == "DisplayLayerProgress_layerChanged" or event == "DisplayLayerProgress_fanspeedChanged":
Expand Down Expand Up @@ -98,7 +100,8 @@ def get_settings_defaults(self):
hideHotend=False,
showFullscreen=True,
showFilament=True,
showLayerGraph=False
showLayerGraph=False,
showPrinterMessage=False
)

def get_template_configs(self):
Expand Down Expand Up @@ -134,14 +137,24 @@ def get_update_information(self):
def process_gcode(self, comm_instance, phase, cmd, cmd_type, gcode, *args, **kwargs):
if not gcode:
return

elif gcode == "M117":
if not cmd.startswith("M117 INDICATOR-Layer"):
self.printer_message = cmd.strip("M117 ")
self._logger.info("*********** Message: " + self.printer_message)
else: return

elif gcode in ("M82", "G90"):
self.extruder_mode = "absolute"

elif gcode in ("M83", "G91"):
self.extruder_mode = "relative"

elif gcode in ("G92"): #Extruder Reset
if self.extruder_mode == "absolute":
self.extruded_filament_arr.append(self.extruded_filament)
else: return

elif gcode in ("G0", "G1"):
CmdDict = dict ((x,float(y)) for d,x,y in (re.split('([A-Z])', i) for i in cmd.upper().split()))
if "E" in CmdDict:
Expand All @@ -151,6 +164,7 @@ def process_gcode(self, comm_instance, phase, cmd, cmd_type, gcode, *args, **kwa
elif self.extruder_mode == "relative":
self.extruded_filament += e
else: return

else:
return

Expand Down
2 changes: 2 additions & 0 deletions octoprint_dashboard/static/js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ $(function () {
self.getEta = ko.observable();
self.embedUrl = ko.observable("");
self.extrudedFilament = ko.observable(0.00);
self.printerMessage = ko.observable("");

//Dashboard backend vars
self.cpuPercent = ko.observable(0);
Expand Down Expand Up @@ -253,6 +254,7 @@ $(function () {
if (data.virtualMemPercent) { self.virtualMemPercent(data.virtualMemPercent); }
if (data.diskUsagePercent) { self.diskUsagePercent(data.diskUsagePercent); }
if (data.cpuTemp) { self.cpuTemp(data.cpuTemp); }
if (data.printerMessage) { self.printerMessage(data.printerMessage); }
if (data.extrudedFilament) { self.extrudedFilament(data.extrudedFilament); }
if (data.layerTimes && data.layerLabels) { self.renderChart(data.layerTimes, data.layerLabels); }
}
Expand Down
5 changes: 5 additions & 0 deletions octoprint_dashboard/templates/dashboard_settings.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
<input type="checkbox" data-bind="checked: settings.plugins.dashboard.showFan">
</label>
</div>
<div >
<label class="checkbox">{{ _('Show Printer Message (M117)') }}
<input type="checkbox" data-bind="checked: settings.plugins.dashboard.showPrinterMessage">
</label>
</div>
<div >
<label class="checkbox">{{ _('Show Progress Gauge') }}
<input type="checkbox" data-bind="checked: settings.plugins.dashboard.showProgress">
Expand Down
5 changes: 5 additions & 0 deletions octoprint_dashboard/templates/dashboard_tab.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@
</div>
</div>

<!-- Printer Message-->
<div class="dashboardGridItem" data-bind="visible: printerStateModel.isPrinting() && settingsViewModel.settings.plugins.dashboard.showPrinterMessage()">
<span class="dashboardSmall" id="printerMessage" data-bind="attr: { title: 'M117 Printer message' }, html: printerMessage()"></span>
</div>


<!-- Progress Circle-->
<div class="progressContainer" data-bind="visible: settingsViewModel.settings.plugins.dashboard.gaugetype() == 'circle', DashboardContextMenu: jobMenu">
Expand Down

0 comments on commit c225579

Please sign in to comment.