From 0fe3e6ec0926fb658b947c284d4a908c850a1cdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20K=C3=B6llmann?= Date: Mon, 14 May 2018 19:22:05 +0200 Subject: [PATCH 1/4] Minor code formatting improvements --- octoprint_navbartemp/__init__.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/octoprint_navbartemp/__init__.py b/octoprint_navbartemp/__init__.py index df3c29b..157ee45 100644 --- a/octoprint_navbartemp/__init__.py +++ b/octoprint_navbartemp/__init__.py @@ -40,17 +40,17 @@ def on_after_startup(self): elif match.group(1) == 'BCM2709': self._logger.debug("Pi 2") self.isRaspi = True - elif match.group(1) == 'BCM2835': - self._logger.debug("Pi 3") - self.isRaspi = True + elif match.group(1) == 'BCM2835': + self._logger.debug("Pi 3") + self.isRaspi = True if self.isRaspi and self.displayRaspiTemp: self._logger.debug("Let's start RepeatedTimer!") self.startTimer(30.0) - elif self.debugMode: - self.isRaspi = True - if self.displayRaspiTemp: - self.startTimer(5.0) + elif self.debugMode: + self.isRaspi = True + if self.displayRaspiTemp: + self.startTimer(5.0) self._logger.debug("is Raspberry Pi? - %s" % self.isRaspi) From ed05d7c28f05c52a2bd535bcdb294b1d6aa68afd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20K=C3=B6llmann?= Date: Mon, 14 May 2018 19:24:40 +0200 Subject: [PATCH 2/4] Added options to configure the displayname of the temperatures --- octoprint_navbartemp/__init__.py | 13 ++++++++++++- octoprint_navbartemp/static/js/navbartemp.js | 14 ++++++++++++-- .../templates/navbartemp_settings_raspi.jinja2 | 18 ++++++++++++++++++ 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/octoprint_navbartemp/__init__.py b/octoprint_navbartemp/__init__.py index 157ee45..9fc895e 100644 --- a/octoprint_navbartemp/__init__.py +++ b/octoprint_navbartemp/__init__.py @@ -19,6 +19,9 @@ def __init__(self): self.isRaspi = False self.debugMode = False # to simulate temp on Win/Mac self.displayRaspiTemp = True + self.bedTempDisplayName = "Bed:" + self.hotendTempDisplayName = "Hotend:" + self.raspiTempDisplayName = "Raspi:" self._checkTempTimer = None def on_after_startup(self): @@ -86,12 +89,20 @@ def randrange_float(start, stop, step): ##~~ SettingsPlugin def get_settings_defaults(self): - return dict(displayRaspiTemp = self.displayRaspiTemp) + return dict(displayRaspiTemp = self.displayRaspiTemp, displayNames = dict( + bed = self.bedTempDisplayName, + hotend = self.hotendTempDisplayName, + raspi = self.raspiTempDisplayName + ) + ) def on_settings_save(self, data): octoprint.plugin.SettingsPlugin.on_settings_save(self, data) self.displayRaspiTemp = self._settings.get(["displayRaspiTemp"]) + self.bedTempDisplayName = self._settings.get(["displayNames.bedTempDisplayName"]) + self.hotendTempDisplayName = self._settings.get(["displayNames.hotendTempDisplayName"]) + self.raspiTempDisplayName = self._settings.get(["displayNames.raspiTempDisplayName"]) if self.displayRaspiTemp: interval = 5.0 if self.debugMode else 30.0 diff --git a/octoprint_navbartemp/static/js/navbartemp.js b/octoprint_navbartemp/static/js/navbartemp.js index 0eb8712..e31cbd3 100644 --- a/octoprint_navbartemp/static/js/navbartemp.js +++ b/octoprint_navbartemp/static/js/navbartemp.js @@ -8,7 +8,17 @@ $(function() { self.isRaspi = ko.observable(false); self.formatBarTemperature = function(toolName, actual, target) { - var output = toolName + ": " + _.sprintf("%.1f°C", actual); + var displayName = ""; + + if (toolName == "Tool" || toolName == "End" || toolName == "Hotend" || toolName == "Hot End") { + displayName = self.settings.displayNames.hotend; + } else if (toolName == "Bett" || toolName == "Bed") { + displayName = self.settings.displayNames.bed; + } else { + displayName = toolName + ":"; + } + + var output = _.sprintf("%s %.1f°C", displayName, actual); if (target) { var sign = (target >= actual) ? " \u21D7 " : " \u21D8 "; @@ -34,7 +44,7 @@ $(function() { self.isRaspi(true); } - self.raspiTemp(_.sprintf("Raspi: %.1f°C", data.raspitemp)); + self.raspiTemp(_.sprintf("%s %.1f°C", self.settings.displayNames.raspi, data.raspitemp)); }; } diff --git a/octoprint_navbartemp/templates/navbartemp_settings_raspi.jinja2 b/octoprint_navbartemp/templates/navbartemp_settings_raspi.jinja2 index 4a07de9..e2a9d49 100644 --- a/octoprint_navbartemp/templates/navbartemp_settings_raspi.jinja2 +++ b/octoprint_navbartemp/templates/navbartemp_settings_raspi.jinja2 @@ -1,6 +1,18 @@

Configuration for Raspberry Pi

+
+ +
+ +
+
+
+ +
+ +
+
@@ -9,4 +21,10 @@
+
+ +
+ +
+
\ No newline at end of file From 1579f58baf6dcc6e5d5b655686b9f6f4e5dee380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20K=C3=B6llmann?= Date: Mon, 14 May 2018 19:25:38 +0200 Subject: [PATCH 3/4] Renamed settings template and changed the behaviour to always be rendered --- octoprint_navbartemp/__init__.py | 9 +-- ...aspi.jinja2 => navbartemp_settings.jinja2} | 58 +++++++++---------- 2 files changed, 32 insertions(+), 35 deletions(-) rename octoprint_navbartemp/templates/{navbartemp_settings_raspi.jinja2 => navbartemp_settings.jinja2} (98%) diff --git a/octoprint_navbartemp/__init__.py b/octoprint_navbartemp/__init__.py index 9fc895e..a1136e5 100644 --- a/octoprint_navbartemp/__init__.py +++ b/octoprint_navbartemp/__init__.py @@ -117,12 +117,9 @@ def on_settings_save(self, data): ##~~ TemplatePlugin API def get_template_configs(self): - if self.isRaspi: - return [ - dict(type="settings", template="navbartemp_settings_raspi.jinja2") - ] - else: - return [] + return [ + dict(type="settings", template="navbartemp_settings.jinja2") + ] ##~~ AssetPlugin API def get_assets(self): diff --git a/octoprint_navbartemp/templates/navbartemp_settings_raspi.jinja2 b/octoprint_navbartemp/templates/navbartemp_settings.jinja2 similarity index 98% rename from octoprint_navbartemp/templates/navbartemp_settings_raspi.jinja2 rename to octoprint_navbartemp/templates/navbartemp_settings.jinja2 index e2a9d49..31b5475 100644 --- a/octoprint_navbartemp/templates/navbartemp_settings_raspi.jinja2 +++ b/octoprint_navbartemp/templates/navbartemp_settings.jinja2 @@ -1,30 +1,30 @@ -

Configuration for Raspberry Pi

- -
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
+

Configuration for Raspberry Pi

+ + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
\ No newline at end of file From 53f12c18518432c5e3e954794686fa23b23beb32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20K=C3=B6llmann?= Date: Mon, 14 May 2018 19:49:40 +0200 Subject: [PATCH 4/4] Changed title of configuration template --- octoprint_navbartemp/templates/navbartemp_settings.jinja2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/octoprint_navbartemp/templates/navbartemp_settings.jinja2 b/octoprint_navbartemp/templates/navbartemp_settings.jinja2 index 31b5475..f17579f 100644 --- a/octoprint_navbartemp/templates/navbartemp_settings.jinja2 +++ b/octoprint_navbartemp/templates/navbartemp_settings.jinja2 @@ -1,4 +1,4 @@ -

Configuration for Raspberry Pi

+

Configuration