From da1c17e88e79298971544083a88c74583fd7b321 Mon Sep 17 00:00:00 2001 From: Vitor de Miranda Henrique Date: Wed, 7 Mar 2018 09:35:24 -0600 Subject: [PATCH 01/27] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 059eac5..dc362bf 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_package = "octoprint_enclosure" plugin_name = "OctoPrint-Enclosure" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "3.51" +plugin_version = "4.00" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module From 854e513aec0b221c67e57645fef9ad1ee5d81b22 Mon Sep 17 00:00:00 2001 From: Vitor de Miranda Henrique Date: Thu, 8 Mar 2018 08:36:59 -0600 Subject: [PATCH 02/27] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index dc362bf..64c601a 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_package = "octoprint_enclosure" plugin_name = "OctoPrint-Enclosure" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "4.00" +plugin_version = "4.01" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module From ae9066af98a3d3ba764469ab6ed96398bdbacd30 Mon Sep 17 00:00:00 2001 From: Vitor de Miranda Henrique Date: Thu, 8 Mar 2018 12:04:20 -0600 Subject: [PATCH 03/27] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 60a0921..712d2d3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +# BEFORE OPENING AN ISSUE + +Check the [troubleshooting guide](https://github.com/vitormhenrique/OctoPrint-Enclosure/wiki/Troubleshooting-Guide). Issues with no log, no print screen will be closed until the necessary documentation is available. + # OctoPrint-Enclosure **Control pretty much everything that you might want to do on your raspberry pi / octoprint / enclosure** @@ -20,8 +24,6 @@ Here is a list of possibilities: Find the plugin useful? Buy me a coffee [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/VitorHenrique/2) -Having problems with the plugin? check the [troubleshooting guide](https://github.com/vitormhenrique/OctoPrint-Enclosure/wiki/Troubleshooting-Guide) - Check pictures on thingiverse: http://www.thingiverse.com/thing:2245493 **Software** From 3f7f45f0e66127b925dc2fcbda03d81bf7343761 Mon Sep 17 00:00:00 2001 From: Vitor de Miranda Henrique Date: Thu, 8 Mar 2018 12:04:49 -0600 Subject: [PATCH 04/27] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 712d2d3..5805245 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# BEFORE OPENING AN ISSUE +# Before opening an issue... Check the [troubleshooting guide](https://github.com/vitormhenrique/OctoPrint-Enclosure/wiki/Troubleshooting-Guide). Issues with no log, no print screen will be closed until the necessary documentation is available. From 0ea6194f7b7c036538d21314ca7200d833388916 Mon Sep 17 00:00:00 2001 From: Vitor de Miranda Henrique Date: Thu, 8 Mar 2018 12:21:41 -0600 Subject: [PATCH 05/27] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 64c601a..c715956 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_package = "octoprint_enclosure" plugin_name = "OctoPrint-Enclosure" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "4.01" +plugin_version = "4.02" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module From bb8128df3edc58c190969c11e95dbc4e7a8689b7 Mon Sep 17 00:00:00 2001 From: Vitor de Miranda Henrique Date: Thu, 8 Mar 2018 16:53:18 -0600 Subject: [PATCH 06/27] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 5805245..6dbf64c 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ Check the [troubleshooting guide](https://github.com/vitormhenrique/OctoPrint-Enclosure/wiki/Troubleshooting-Guide). Issues with no log, no print screen will be closed until the necessary documentation is available. +Also, be aware that upgrading from versions lower than 4.00 will **DELETE** all settings. More information on [release notes](https://github.com/vitormhenrique/OctoPrint-Enclosure/releases/tag/4.00) + # OctoPrint-Enclosure **Control pretty much everything that you might want to do on your raspberry pi / octoprint / enclosure** From 485dcc67d7227d40c2d82da3a08677c59d48053e Mon Sep 17 00:00:00 2001 From: Vitor de Miranda Henrique Date: Mon, 12 Mar 2018 00:47:56 -0500 Subject: [PATCH 07/27] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index c715956..9bd7310 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_package = "octoprint_enclosure" plugin_name = "OctoPrint-Enclosure" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "4.02" +plugin_version = "4.04" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module From 102879af2f0d4201c7257d8b20f56607500f8911 Mon Sep 17 00:00:00 2001 From: Vitor de Miranda Henrique Date: Fri, 16 Mar 2018 15:25:33 -0500 Subject: [PATCH 08/27] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6dbf64c..b06bb89 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ +Find the plugin useful? Buy me a coffee +[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/VitorHenrique/2) + # Before opening an issue... -Check the [troubleshooting guide](https://github.com/vitormhenrique/OctoPrint-Enclosure/wiki/Troubleshooting-Guide). Issues with no log, no print screen will be closed until the necessary documentation is available. +Check the [troubleshooting guide](https://github.com/vitormhenrique/OctoPrint-Enclosure/wiki/Troubleshooting-Guide). Issues with no log, no print screen *will be closed* until the necessary documentation is available. Also, be aware that upgrading from versions lower than 4.00 will **DELETE** all settings. More information on [release notes](https://github.com/vitormhenrique/OctoPrint-Enclosure/releases/tag/4.00) @@ -23,9 +26,6 @@ Here is a list of possibilities: * Notifications using IFTTT when events happen (temperature trigger / print events / etc) * Add sub-menus on navbar to quick access outputs and temperature sensors -Find the plugin useful? Buy me a coffee -[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/VitorHenrique/2) - Check pictures on thingiverse: http://www.thingiverse.com/thing:2245493 **Software** From d32e54fba3acd89c3aa9c274d6854a825a93af7f Mon Sep 17 00:00:00 2001 From: Roy Hooper Date: Fri, 16 Mar 2018 22:49:47 -0400 Subject: [PATCH 09/27] make instructions a little easier for those that are forgetful --- README.md | 7 ++++++- octoprint_enclosure/templates/enclosure_settings.jinja2 | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b06bb89..8eb51a6 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,11 @@ Start by adding the following line to /boot/config.txt
dtoverlay=w1-gpio
+After rebooting, you can check if the OneWire device was found properly with +
dmesg | grep w1-gpip
+You should see something like +
[    3.030368] w1-gpio onewire@0: gpio pin 4, external pullup pin -1, parasitic power 0
+ You should be able to test your sensor by rebooting your system with sudo reboot. When the Pi is back up and you're logged in again, type the commands you see below into a terminal window. When you are in the 'devices' directory, the directory starting '28-' may have a different name, so cd to the name of whatever directory is there.
sudo modprobe w1-gpio
@@ -77,7 +82,7 @@ cat w1_slave
The response will either have YES or NO at the end of the first line. If it is yes, then the temperature will be at the end of the second line, in 1/000 degrees C. -Copy the serial number, you will need to configure the plugin +Copy the serial number, you will need to configure the plugin. Note that for the serial number includes the 28-, for example 28-0000069834ff. * For the SI7021, BME280 and TMP102 sensors diff --git a/octoprint_enclosure/templates/enclosure_settings.jinja2 b/octoprint_enclosure/templates/enclosure_settings.jinja2 index 1be738a..7b7fa4f 100644 --- a/octoprint_enclosure/templates/enclosure_settings.jinja2 +++ b/octoprint_enclosure/templates/enclosure_settings.jinja2 @@ -500,7 +500,7 @@
DS18B20 serial value, needs to be used to have support for multiple sensors, read documentation on github page - for more information + for more information. The serial is typically in the form of 28-0123456789ab.
From ee8b0588c068e3dc194a0267d8993e7c4a752c01 Mon Sep 17 00:00:00 2001 From: Vitor de Miranda Henrique Date: Thu, 12 Apr 2018 12:29:03 -0500 Subject: [PATCH 10/27] Update README.md --- README.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 8eb51a6..7c37718 100644 --- a/README.md +++ b/README.md @@ -115,11 +115,11 @@ You can use relays / mosfets to control you lights, heater, lockers etc... If yo * Relay -The relays module that I used can be found [here](https://www.amazon.com/gp/product/B0057OC6D8?psc=1&redirect=true&ref_=oh_aui_search_detailpage). Those relays are active low, that means that they will turn on when you put LOW on the output of your pin. In order to not fry your Raspberry Pi pay attention on your wiring connection: remove the jumper link and connect 3.3v to VCC, 5V to JD-VCC and Ground to GND. +The relays module that I used couple [SainSmart 2-Channel Relay Module](https://www.amazon.com/gp/product/B0057OC6D8?ie=UTF8&tag=3dpstuff-20&camp=1789&linkCode=xm2&creativeASIN=B0057OC6D8). Those relays are active low, that means that they will turn on when you put LOW on the output of your pin. In order to not fry your Raspberry Pi pay attention on your wiring connection: remove the jumper link and connect 3.3v to VCC, 5V to JD-VCC and Ground to GND. * Heater -For heating my enclosure I got a $15 lasko inside my enclosure. I opened it and added a relay to the mains wire. If you’re uncomfortable soldering or dealing with high voltage, please check out the [PowerSwitch Tail II](http://www.powerswitchtail.com/Pages/default.aspx) . The PowerSwitch Tail II is fully enclosed, making it a lot safer. +For heating my enclosure I got a $15 lasko inside my enclosure. I opened it and added a relay to the mains wire. If you’re uncomfortable soldering or dealing with high voltage, please check out the [PowerSwitch Tail II](http://www.powerswitchtail.com/) . The PowerSwitch Tail II is fully enclosed, making it a lot safer. **CAUTION: VOLTAGE ON MAINS WIRE CAN KILL YOU, ONLY ATTEMPT TO DO THIS IF YOU KNOW WHAT YOU ARE DOING, AND DO AT YOUR OWN RISK** @@ -127,7 +127,7 @@ For heating my enclosure I got a $15 lasko inside my enclosure. I opened it and * Cooler -You can get a [5V small fan](https://www.amazon.com/gp/product/B003FO0LG6/ref=oh_aui_search_detailpage?ie=UTF8&psc=1) and control it over a relay. +You can get a [USB Mini Desktop Fan](https://www.amazon.com/gp/product/B00WM7TRTY?ie=UTF8&tag=3dpstuff-20&camp=1789&linkCode=xm2&creativeASIN=B00WM7TRTY) and control it over a relay. * Filament sensor @@ -189,8 +189,8 @@ You can do this by changing the config.yaml file as instructed on [octoprint doc You just need to add the following section: -``` -appearance: + +
appearance:
   components:
     order:
       tab:
@@ -198,9 +198,7 @@ appearance:
       - control
       - gcodeviewer
       - terminal
-      - plugin_enclosure
-      - timelapse
-```
+      - plugin_enclosure
 
 
      

From eafccfe41160d8ffcaa901026bcca0cdf4c97e66 Mon Sep 17 00:00:00 2001
From: Vitor de Miranda Henrique 
Date: Wed, 18 Apr 2018 01:02:01 -0500
Subject: [PATCH 11/27] fixed rowspan issue

---
 octoprint_enclosure/static/js/enclosure.js         | 5 +++++
 octoprint_enclosure/templates/enclosure_tab.jinja2 | 8 ++++----
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/octoprint_enclosure/static/js/enclosure.js b/octoprint_enclosure/static/js/enclosure.js
index 36c391a..31126bf 100644
--- a/octoprint_enclosure/static/js/enclosure.js
+++ b/octoprint_enclosure/static/js/enclosure.js
@@ -83,6 +83,11 @@ $(function () {
       });
     };
 
+    self.calculateRowSpan = function(index_id){
+      span = self.linkedTemperatureControl(index_id())().length
+      return span == 0 ? 1 : span;
+    };
+
     self.hasAnySensorWithHumidity = function(){
       return_value = false;
       self.rpi_inputs_temperature_sensors().forEach(function (sensor) {
diff --git a/octoprint_enclosure/templates/enclosure_tab.jinja2 b/octoprint_enclosure/templates/enclosure_tab.jinja2
index 323f998..809827c 100644
--- a/octoprint_enclosure/templates/enclosure_tab.jinja2
+++ b/octoprint_enclosure/templates/enclosure_tab.jinja2
@@ -20,8 +20,8 @@
 
             
             
-                
-                
+                
+                
                      
                     
                     °F
@@ -31,7 +31,7 @@
                     
                 
                 
-                
+                
                      
                     %
                 
@@ -39,7 +39,7 @@
 
                 
                 
-                N/A
+                N/A
                 
                 
 

From ffb7f8a6e93584c74d38aee354e1723c2e3fd252 Mon Sep 17 00:00:00 2001
From: Vitor de Miranda Henrique 
Date: Wed, 18 Apr 2018 09:00:55 -0500
Subject: [PATCH 12/27] Update enclosure_tab.jinja2

fix row span issue
---
 octoprint_enclosure/templates/enclosure_tab.jinja2 | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/octoprint_enclosure/templates/enclosure_tab.jinja2 b/octoprint_enclosure/templates/enclosure_tab.jinja2
index 809827c..ffc251c 100644
--- a/octoprint_enclosure/templates/enclosure_tab.jinja2
+++ b/octoprint_enclosure/templates/enclosure_tab.jinja2
@@ -20,8 +20,8 @@
 
             
             
-                
-                
+                
+                
                      
                     
                     °F
@@ -31,7 +31,7 @@
                     
                 
                 
-                
+                
                      
                     %
                 
@@ -39,7 +39,7 @@
 
                 
                 
-                N/A
+                N/A
                 
                 
 
@@ -286,4 +286,4 @@
     
 
 
-
\ No newline at end of file
+

From adab306d51264704ab955c00fc2231a848dbc973 Mon Sep 17 00:00:00 2001
From: Vitor de Miranda Henrique 
Date: Tue, 24 Apr 2018 08:27:38 -0700
Subject: [PATCH 13/27] Update setup.py

---
 setup.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index 9bd7310..2fba047 100644
--- a/setup.py
+++ b/setup.py
@@ -14,7 +14,7 @@ plugin_package = "octoprint_enclosure"
 plugin_name = "OctoPrint-Enclosure"
 
 # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
-plugin_version = "4.04"
+plugin_version = "4.05"
 
 # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
 # module

From 208d4d800cf0e19cf03b2f06d56fc9fb3aadb68b Mon Sep 17 00:00:00 2001
From: Vitor de Miranda Henrique 
Date: Tue, 24 Apr 2018 10:52:33 -0700
Subject: [PATCH 14/27] better hysteresis temperature control implementation

---
 octoprint_enclosure/__init__.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/octoprint_enclosure/__init__.py b/octoprint_enclosure/__init__.py
index 683d4d6..d4986d2 100644
--- a/octoprint_enclosure/__init__.py
+++ b/octoprint_enclosure/__init__.py
@@ -708,7 +708,9 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin,
                     linked_data = self.get_linked_temp_sensor_data(
                         linked_id)
 
-                    if str(temp_hum_control['temp_ctr_type']) == 'dehumidifier':
+                    control_type = str(temp_hum_control['temp_ctr_type'])
+
+                    if control_type == 'dehumidifier':
                         current_value = self.to_float(linked_data['humidity'])
                         temp_deadband = 0
                     else:
@@ -717,15 +719,15 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin,
 
                     if set_temperature - temp_deadband > current_value:
                         current_status = True
-                    elif set_temperature + temp_deadband < current_value:
+                    elif set_temperature < current_value:
                         current_status = False
                     else:
                         current_status = previous_status
 
-                    if str(temp_hum_control['temp_ctr_type']) == 'cooler' or str(temp_hum_control['temp_ctr_type']) == 'dehumidifier':
+                    if control_type == 'cooler' or control_type == 'dehumidifier':
                         current_status = not current_status
 
-                    if temp_hum_control['temp_ctr_type'] == 'heater' and max_temp > 0.0 and max_temp < current_value:
+                    if control_type == 'heater' and max_temp > 0.0 and max_temp < current_value:
                         if self._settings.get(["debug"]) is True:
                             self._logger.info(
                                 "Maximun temperature reached for temperature control %s", temp_hum_control['index_id'])

From a416dac362fd02f7ffb846da4500eb2a44e71573 Mon Sep 17 00:00:00 2001
From: Vitor de Miranda Henrique 
Date: Fri, 27 Apr 2018 00:51:55 -0500
Subject: [PATCH 15/27] fixed #130

---
 octoprint_enclosure/__init__.py               | 92 ++++++++++++-------
 octoprint_enclosure/static/js/enclosure.js    |  1 +
 .../templates/enclosure_tab.jinja2            |  6 ++
 3 files changed, 65 insertions(+), 34 deletions(-)

diff --git a/octoprint_enclosure/__init__.py b/octoprint_enclosure/__init__.py
index d4986d2..e499d67 100644
--- a/octoprint_enclosure/__init__.py
+++ b/octoprint_enclosure/__init__.py
@@ -36,6 +36,9 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin,
     temperature_sensor_data = []
     last_filament_end_detected = []
     print_complete = False
+    development_mode = False
+    dummy_value = 30.0
+    dummy_delta = 0.5
 
     def start_timer(self):
         """
@@ -321,11 +324,11 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin,
                 if temp is not None and hum is not None:
                     sensor_data.append(
                         dict(index_id=sensor['index_id'], temperature=temp, humidity=hum))
-            self.temperature_sensor_data = sensor_data
-            self.handle_temp_hum_control()
-            self.handle_temperature_events()
-            self.handle_pwm_linked_temperature()
-            self.update_ui()
+                    self.temperature_sensor_data = sensor_data
+                    self.handle_temp_hum_control()
+                    self.handle_temperature_events()
+                    self.handle_pwm_linked_temperature()
+                    self.update_ui()
         except Exception as ex:
             self.log_error(ex)
 
@@ -447,8 +450,10 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin,
                     regular_status.append(
                         dict(index_id=index, status=val, auto_startup=startup, auto_shutdown=shutdown))
                 if output['output_type'] == 'temp_hum_control':
+                    val = GPIO.input(pin) if not output['active_low'] else (
+                        not GPIO.input(pin))
                     temp_control_status.append(
-                        dict(index_id=index, auto_startup=startup, auto_shutdown=shutdown))
+                        dict(index_id=index, status=val, auto_startup=startup, auto_shutdown=shutdown))
                 if output['output_type'] == 'neopixel_indirect' or output['output_type'] == 'neopixel_direct':
                     val = output['neopixel_color']
                     neopixel_status.append(
@@ -486,27 +491,30 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin,
 
     def get_sensor_data(self, sensor):
         try:
-            if sensor['temp_sensor_type'] in ["11", "22", "2302"]:
-                self._logger.info("temp_sensor_type dht")
-                temp, hum = self.read_dht_temp(
-                    sensor['temp_sensor_type'], sensor['gpio_pin'])
-            elif sensor['temp_sensor_type'] == "18b20":
-                temp = self.read_18b20_temp(sensor['ds18b20_serial'])
-                hum = 0
-            elif sensor['temp_sensor_type'] == "bme280":
-                temp, hum = self.read_bme280_temp(
-                    sensor['temp_sensor_address'])
-            elif sensor['temp_sensor_type'] == "si7021":
-                temp, hum = self.read_si7021_temp(
-                    sensor['temp_sensor_address'])
-            elif sensor['temp_sensor_type'] == "tmp102":
-                temp = self.read_tmp102_temp(
-                    sensor['temp_sensor_address'])
-                hum = 0
+            if self.development_mode:
+                temp, hum = self.read_dummy_temp()
             else:
-                self._logger.info("temp_sensor_type no match")
-                temp = None
-                hum = None
+                if sensor['temp_sensor_type'] in ["11", "22", "2302"]:
+                    self._logger.info("temp_sensor_type dht")
+                    temp, hum = self.read_dht_temp(
+                        sensor['temp_sensor_type'], sensor['gpio_pin'])
+                elif sensor['temp_sensor_type'] == "18b20":
+                    temp = self.read_18b20_temp(sensor['ds18b20_serial'])
+                    hum = 0
+                elif sensor['temp_sensor_type'] == "bme280":
+                    temp, hum = self.read_bme280_temp(
+                        sensor['temp_sensor_address'])
+                elif sensor['temp_sensor_type'] == "si7021":
+                    temp, hum = self.read_si7021_temp(
+                        sensor['temp_sensor_address'])
+                elif sensor['temp_sensor_type'] == "tmp102":
+                    temp = self.read_tmp102_temp(
+                        sensor['temp_sensor_address'])
+                    hum = 0
+                else:
+                    self._logger.info("temp_sensor_type no match")
+                    temp = None
+                    hum = None
             if temp != -1 and hum != -1:
                 temp = round(self.to_float(
                     temp), 1) if not sensor['use_fahrenheit'] else round(self.to_float(temp) * 1.8 + 32, 1)
@@ -537,6 +545,17 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin,
                                        temperature_alarm['alarm_set_temp'])
                                 self.send_notification(msg)
 
+    def read_dummy_temp(self):
+        current_value = self.dummy_value
+        if current_value > 40 or current_value < 30:
+            self.dummy_delta = - self.dummy_delta
+
+        return_value = current_value + self.dummy_delta
+
+        self.dummy_value = return_value
+
+        return return_value, return_value
+
     def read_dht_temp(self, sensor, pin):
         try:
             script = os.path.dirname(
@@ -717,15 +736,20 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin,
                         current_value = self.to_float(
                             linked_data['temperature'])
 
-                    if set_temperature - temp_deadband > current_value:
-                        current_status = True
-                    elif set_temperature < current_value:
-                        current_status = False
-                    else:
-                        current_status = previous_status
-
                     if control_type == 'cooler' or control_type == 'dehumidifier':
-                        current_status = not current_status
+                        if current_value <= set_temperature and current_value >= (set_temperature - temp_deadband):
+                            current_status = previous_status
+                        elif current_value < set_temperature:
+                            current_status = False
+                        else:
+                            current_status = True
+                    else:
+                        if current_value <= set_temperature and current_value >= (set_temperature - temp_deadband):
+                            current_status = previous_status
+                        elif current_value > set_temperature:
+                            current_status = False
+                        else:
+                            current_status = True
 
                     if control_type == 'heater' and max_temp > 0.0 and max_temp < current_value:
                         if self._settings.get(["debug"]) is True:
diff --git a/octoprint_enclosure/static/js/enclosure.js b/octoprint_enclosure/static/js/enclosure.js
index 31126bf..fd8e75d 100644
--- a/octoprint_enclosure/static/js/enclosure.js
+++ b/octoprint_enclosure/static/js/enclosure.js
@@ -188,6 +188,7 @@ $(function () {
             return (output['index_id'] == item.index_id());
           }).pop();
           if (linked_output) {
+            linked_output.gpio_status(output['status'])
             linked_output.auto_shutdown(output['auto_shutdown'])
             linked_output.auto_startup(output['auto_startup'])
           }
diff --git a/octoprint_enclosure/templates/enclosure_tab.jinja2 b/octoprint_enclosure/templates/enclosure_tab.jinja2
index ffc251c..3b8b479 100644
--- a/octoprint_enclosure/templates/enclosure_tab.jinja2
+++ b/octoprint_enclosure/templates/enclosure_tab.jinja2
@@ -216,6 +216,12 @@
     
     Dehumidifier
     
+    
+    on
+    
+    
+    off
+    
 
 
 

From ab97240ca2dc5fe96a9161ac9b07e8b285e668c5 Mon Sep 17 00:00:00 2001
From: Vitor de Miranda Henrique 
Date: Fri, 27 Apr 2018 00:55:24 -0500
Subject: [PATCH 16/27] Update setup.py

---
 setup.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index 2fba047..d81ee29 100644
--- a/setup.py
+++ b/setup.py
@@ -14,7 +14,7 @@ plugin_package = "octoprint_enclosure"
 plugin_name = "OctoPrint-Enclosure"
 
 # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
-plugin_version = "4.05"
+plugin_version = "4.06"
 
 # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
 # module

From 396a0eed48a5813112c28dca0248c3386c6a1856 Mon Sep 17 00:00:00 2001
From: Vitor de Miranda Henrique 
Date: Sun, 29 Apr 2018 09:56:53 -0500
Subject: [PATCH 17/27] tmp102 number format fix

---
 octoprint_enclosure/tmp102.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/octoprint_enclosure/tmp102.py b/octoprint_enclosure/tmp102.py
index ce3f3d6..12ae68b 100644
--- a/octoprint_enclosure/tmp102.py
+++ b/octoprint_enclosure/tmp102.py
@@ -42,7 +42,7 @@ def main():
     # Divide by 16 to get value in celsius
     temp /= 16.0
 
-    print temp
+    print('{0:0.1f}'.format(temp))
 
 if __name__ == "__main__":
     main()

From 67387933c0affb8ae6317a2d83b6c3f8947149a6 Mon Sep 17 00:00:00 2001
From: Vitor de Miranda Henrique 
Date: Sun, 29 Apr 2018 10:03:57 -0500
Subject: [PATCH 18/27] Improved instructions

---
 README.md | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 7c37718..f7f5ef3 100644
--- a/README.md
+++ b/README.md
@@ -51,6 +51,8 @@ sudo apt-get update
 sudo apt-get install build-essential python-dev python-openssl
 sudo python setup.py install
+Note: All libraries need to be installed on raspberry pi system python not octoprint virtual environment. + You can test the library by using:
cd examples
@@ -97,9 +99,9 @@ Use the right arrow to select the button
 Select yes when it asks to reboot
 
-Install some packages: +Install some packages (on raspberry pi system python not octoprint virtual environment): -
sudo apt-get install i2c-tools python-pip
+
sudo apt-get install i2c-tools python-pip python-smbus
Find the address of the sensor: From 34ae72a38051d9c9c9c88d59845325ac0096eb2c Mon Sep 17 00:00:00 2001 From: Vitor de Miranda Henrique Date: Fri, 11 May 2018 16:07:18 -0500 Subject: [PATCH 19/27] fix filament detection time out --- octoprint_enclosure/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/octoprint_enclosure/__init__.py b/octoprint_enclosure/__init__.py index e499d67..9ff7b58 100644 --- a/octoprint_enclosure/__init__.py +++ b/octoprint_enclosure/__init__.py @@ -428,7 +428,8 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, task['thread'].cancel() self.event_queue.remove(task) if self._settings.get(["debug"]) is True: - self._logger.info("Queue id stoped and removed from list...") + self._logger.info( + "Queue id stoped and removed from list...") self._logger.info("Old queue list: %s", old_list) self._logger.info("New queue list: %s", self.event_queue) @@ -910,11 +911,14 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, filament_sensor['filament_sensor_enabled']): last_detected_time = list(filter(lambda item: item['index_id'] == filament_sensor['index_id'], self.last_filament_end_detected)).pop()['time'] - if time.time() - last_detected_time > self._settings.get_int(["filament_sensor_timeout"]): + time_now = time.time() + time_difference = self.to_int(time_now - last_detected_time) + time_out_value = self.to_int(filament_sensor['filament_sensor_timeout']) + if time_difference > time_out_value: self._logger.info("Detected end of filament.") for item in self.last_filament_end_detected: if item['index_id'] == filament_sensor['index_id']: - item['time'] = time.time() + item['time'] = time_now for line in self._settings.get(["filament_sensor_gcode"]).split('\n'): if line: self._printer.commands(line.strip().upper()) From c72c5bf1f2b9ea0e40392fa2603118ade4a81fd0 Mon Sep 17 00:00:00 2001 From: Vitor de Miranda Henrique Date: Fri, 11 May 2018 17:22:22 -0500 Subject: [PATCH 20/27] better sudo warning message --- octoprint_enclosure/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/octoprint_enclosure/__init__.py b/octoprint_enclosure/__init__.py index 9ff7b58..3a9db07 100644 --- a/octoprint_enclosure/__init__.py +++ b/octoprint_enclosure/__init__.py @@ -574,6 +574,7 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, temp, hum = stdout.split("|") return (self.to_float(temp.strip()), self.to_float(hum.strip())) except Exception as ex: + self._logger.info("Failed to excecute python scripts, try disabling use SUDO on advanced section of the plugin.") self.log_error(ex) return (0, 0) @@ -594,6 +595,7 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, temp, hum = stdout.split("|") return (self.to_float(temp.strip()), self.to_float(hum.strip())) except Exception as ex: + self._logger.info("Failed to excecute python scripts, try disabling use SUDO on advanced section of the plugin.") self.log_error(ex) return (0, 0) @@ -614,6 +616,7 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, temp, hum = stdout.split("|") return (self.to_float(temp.strip()), self.to_float(hum.strip())) except Exception as ex: + self._logger.info("Failed to excecute python scripts, try disabling use SUDO on advanced section of the plugin.") self.log_error(ex) return (0, 0) @@ -655,6 +658,7 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, self._logger.info("TMP102 result: %s", stdout) return self.to_float(stdout.strip()) except Exception as ex: + self._logger.info("Failed to excecute python scripts, try disabling use SUDO on advanced section.") self.log_error(ex) return 0 From 52b15b0992080fd2fe1c51e4e9e669058b54b56e Mon Sep 17 00:00:00 2001 From: Vitor de Miranda Henrique Date: Fri, 11 May 2018 17:27:28 -0500 Subject: [PATCH 21/27] bumping version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d81ee29..37a32d7 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_package = "octoprint_enclosure" plugin_name = "OctoPrint-Enclosure" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "4.06" +plugin_version = "4.07" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module From 3ac0d62a996a2e9681075db4ac958b9f1770cdb5 Mon Sep 17 00:00:00 2001 From: Vitor de Miranda Henrique Date: Fri, 11 May 2018 19:39:50 -0500 Subject: [PATCH 22/27] Improved PWM code --- octoprint_enclosure/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/octoprint_enclosure/__init__.py b/octoprint_enclosure/__init__.py index 3a9db07..15578fb 100644 --- a/octoprint_enclosure/__init__.py +++ b/octoprint_enclosure/__init__.py @@ -882,6 +882,7 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, GPIO.setup(pin, GPIO.OUT) pwm_instance = GPIO.PWM(pin, self.to_int( gpio_out_pwm['pwm_frequency'])) + pwm_instance.start(0) self.pwm_intances.append({pin: pwm_instance}) for gpio_out_neopixel in list(filter(lambda item: item['output_type'] == 'neopixel_direct', self.rpi_outputs)): pin = self.to_int(gpio_out_neopixel['gpio_pin']) @@ -1092,8 +1093,7 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, old_pwm_value = pwm['duty_cycle'] if 'duty_cycle' in pwm else -1 if not self.to_int(old_pwm_value) == self.to_int(pwm_value): pwm['duty_cycle'] = pwm_value - pwm_object.stop() - pwm_object.start(pwm_value) + pwm_object.ChangeDutyCycle(pwm_value) if self._settings.get(["debug"]) is True: self._logger.info( "Writing PWM on gpio: %s value %s", gpio, pwm_value) From b559843f92c90c4f0a211f269f16db1f274f0fd3 Mon Sep 17 00:00:00 2001 From: Vitor de Miranda Henrique Date: Fri, 11 May 2018 19:42:33 -0500 Subject: [PATCH 23/27] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 37a32d7..3b4e194 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ plugin_package = "octoprint_enclosure" plugin_name = "OctoPrint-Enclosure" # The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module -plugin_version = "4.07" +plugin_version = "4.08" # The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin # module From 6429487d5f5c4fab629fc1447a4c21f0a4efb406 Mon Sep 17 00:00:00 2001 From: Vitor de Miranda Henrique Date: Thu, 14 Jun 2018 18:05:12 -0500 Subject: [PATCH 24/27] fixes and improvements --- octoprint_enclosure/__init__.py | 136 ++++++++++++------ octoprint_enclosure/neopixel_direct.py | 3 +- octoprint_enclosure/static/js/enclosure.js | 31 ++-- .../templates/enclosure_settings.jinja2 | 33 ++++- 4 files changed, 139 insertions(+), 64 deletions(-) diff --git a/octoprint_enclosure/__init__.py b/octoprint_enclosure/__init__.py index 15578fb..a3853e9 100644 --- a/octoprint_enclosure/__init__.py +++ b/octoprint_enclosure/__init__.py @@ -117,20 +117,26 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, self.configure_gpio() self.update_ui() self.start_outpus_with_server() + self.handle_initial_gpio_control() self.start_timer() self.print_complete = False def get_settings_version(self): - return 4 + return 5 - def on_settings_migrate(self, target, current=None): - self._logger.warn("######### settings not compatible #########") - self._logger.warn("######### current settings version %s target settings version %s #########", - current, target) - self._settings.set(["rpi_outputs"], []) - self._settings.set(["rpi_inputs"], []) - self.rpi_outputs = self._settings.get(["rpi_outputs"]) - self.rpi_inputs = self._settings.get(["rpi_inputs"]) + def on_settings_migrate(self, target, current): + self._logger.warn("######### current settings version %s target settings version %s #########", current, target) + if current == 4 and target == 5: + self._logger.warn("######### migrating settings from v4 to v5 #########") + old_outputs = self._settings.get(["rpi_outputs"]) + for rpi_output in old_outputs: + rpi_output['shutdown_on_failed'] = False + self._settings.set(["rpi_outputs"], old_outputs) + else: + self._logger.warn("######### settings not compatible #########") + self._settings.set(["rpi_outputs"], []) + self._settings.set(["rpi_inputs"], []) + self.rpi_inputs = self._settings.get(["rpi_inputs"]) # ~~ Blueprintplugin mixin @octoprint.plugin.BlueprintPlugin.route("/setEnclosureTempHum", methods=["GET"]) @@ -302,7 +308,14 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, sudo_str = "" cmd = sudo_str + "python " + script + str(led_pin) + " " + str(led_count) + " " + str( - led_brightness) + " " + str(red) + " " + str(green) + " " + str(blue) + " " + str(address) + led_brightness) + " " + str(red) + " " + str(green) + " " + str(blue) + " " + + if neopixel_dirrect: + dma = self._settings.get(["neopixel_dma"]) or 10 + cmd = cmd + str(dma) + else: + cmd = cmd + str(address) + if self._settings.get(["debug"]) is True: if queue_id is not None: self._logger.info("Runing scheduled queue id %s", queue_id) @@ -496,7 +509,6 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, temp, hum = self.read_dummy_temp() else: if sensor['temp_sensor_type'] in ["11", "22", "2302"]: - self._logger.info("temp_sensor_type dht") temp, hum = self.read_dht_temp( sensor['temp_sensor_type'], sensor['gpio_pin']) elif sensor['temp_sensor_type'] == "18b20": @@ -799,7 +811,7 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, try: current_mode = GPIO.getmode() set_mode = GPIO.BOARD if self._settings.get( - ["useBoardPinNumber"]) else GPIO.BCM + ["use_board_pin_number"]) else GPIO.BCM if current_mode is None: outputs = list(filter(lambda item: item['output_type'] == 'regular' or item['output_type'] == 'pwm' or @@ -815,7 +827,7 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, elif current_mode != set_mode: GPIO.setmode(current_mode) tempstr = "BOARD" if current_mode == GPIO.BOARD else "BCM" - self._settings.set(["useBoardPinNumber"], + self._settings.set(["use_board_pin_number"], True if current_mode == GPIO.BOARD else False) warn_msg = "GPIO mode was configured before, GPIO mode will be forced to use: " + \ tempstr + " as pin numbers. Please update GPIO accordingly!" @@ -889,10 +901,20 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, self.clear_channel(pin) for rpi_input in list(filter(lambda item: item['input_type'] == 'gpio', self.rpi_inputs)): - pull_resistor = GPIO.PUD_UP if rpi_input['input_pull_resistor'] == 'input_pull_up' else GPIO.PUD_DOWN gpio_pin = self.to_int(rpi_input['gpio_pin']) + pull_resistor = GPIO.PUD_UP if rpi_input['input_pull_resistor'] == 'input_pull_up' else GPIO.PUD_DOWN GPIO.setup(gpio_pin, GPIO.IN, pull_resistor) edge = GPIO.RISING if rpi_input['edge'] == 'rise' else GPIO.FALLING + + inputs_same_gpio = list( + [r_inp for r_inp in self.rpi_inputs if self.to_int(r_inp['gpio_pin']) == gpio_pin]) + + if len(inputs_same_gpio) > 1: + GPIO.remove_event_detect(gpio_pin) + for other_input in inputs_same_gpio: + if other_input['edge'] is not edge: + edge = GPIO.BOTH + if rpi_input['action_type'] == 'output_control': self._logger.info( "Adding GPIO event detect on pin %s with edge: %s", gpio_pin, edge) @@ -980,39 +1002,50 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, self._logger.warn("Failed to stop task %s.", task) pass - def handle_gpio_control(self, channel): - try: - if self._settings.get(["debug"]) is True: - self._logger.info( - "GPIO event triggered on channel %s", channel) - rpi_input = [r_inp for r_inp in self.rpi_inputs if self.to_int( - r_inp['gpio_pin']) == self.to_int(channel)].pop() + def handle_initial_gpio_control(self): + for rpi_input in [r_inp for r_inp in self.rpi_inputs if r_inp['action_type'] == 'output_control']: gpio_pin = self.to_int(rpi_input['gpio_pin']) controlled_io = self.to_int(rpi_input['controlled_io']) if (rpi_input['edge'] == 'fall') ^ GPIO.input(gpio_pin): rpi_output = [r_out for r_out in self.rpi_outputs if self.to_int( r_out['index_id']) == controlled_io].pop() if rpi_output['output_type'] == 'regular': - if rpi_input['controlled_io_set_value'] == 'toggle': - val = GPIO.LOW if GPIO.input(self.to_int( - rpi_output['gpio_pin'])) == GPIO.HIGH else GPIO.HIGH - else: - val = GPIO.LOW if rpi_input['controlled_io_set_value'] == 'low' else GPIO.HIGH + val = GPIO.LOW if rpi_input['controlled_io_set_value'] == 'low' else GPIO.HIGH self.write_gpio(self.to_int( rpi_output['gpio_pin']), val) - for notification in self.notifications: - if notification['gpioAction']: - msg = "GPIO control action caused by input " + str(rpi_input['label']) + ". Setting GPIO" + str( - rpi_input['controlled_io']) + " to: " + str(rpi_input['controlled_io_set_value']) - self.send_notification(msg) - if rpi_output['output_type'] == 'gcode_output': - self.send_gcode_command(rpi_output['gcode']) - for notification in self.notifications: - if notification['gpioAction']: - msg = "GPIO control action caused by input " + \ - str(rpi_input['label']) + \ - ". Sending GCODE command" - self.send_notification(msg) + + def handle_gpio_control(self, channel): + try: + if self._settings.get(["debug"]) is True: + self._logger.info( + "GPIO event triggered on channel %s", channel) + for rpi_input in [r_inp for r_inp in self.rpi_inputs if self.to_int(r_inp['gpio_pin']) == self.to_int(channel)]: + gpio_pin = self.to_int(rpi_input['gpio_pin']) + controlled_io = self.to_int(rpi_input['controlled_io']) + if (rpi_input['edge'] == 'fall') ^ GPIO.input(gpio_pin): + rpi_output = [r_out for r_out in self.rpi_outputs if self.to_int( + r_out['index_id']) == controlled_io].pop() + if rpi_output['output_type'] == 'regular': + if rpi_input['controlled_io_set_value'] == 'toggle': + val = GPIO.LOW if GPIO.input(self.to_int( + rpi_output['gpio_pin'])) == GPIO.HIGH else GPIO.HIGH + else: + val = GPIO.LOW if rpi_input['controlled_io_set_value'] == 'low' else GPIO.HIGH + self.write_gpio(self.to_int( + rpi_output['gpio_pin']), val) + for notification in self.notifications: + if notification['gpioAction']: + msg = "GPIO control action caused by input " + str(rpi_input['label']) + ". Setting GPIO" + str( + rpi_input['controlled_io']) + " to: " + str(rpi_input['controlled_io_set_value']) + self.send_notification(msg) + if rpi_output['output_type'] == 'gcode_output': + self.send_gcode_command(rpi_output['gcode']) + for notification in self.notifications: + if notification['gpioAction']: + msg = "GPIO control action caused by input " + \ + str(rpi_input['label']) + \ + ". Sending GCODE command" + self.send_notification(msg) except Exception as ex: self.log_error(ex) pass @@ -1162,6 +1195,7 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, if event == Events.PRINT_STARTED: self.print_complete = False self.cancel_all_events_on_queue() + self.event_queue = [] self.start_filament_detection() for rpi_output in self.rpi_outputs: if rpi_output['auto_startup']: @@ -1199,6 +1233,19 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, elif event in (Events.PRINT_CANCELLED, Events.PRINT_FAILED): self.stop_filament_detection() self.cancel_all_events_on_queue() + self.event_queue = [] + for rpi_output in self.rpi_outputs: + if rpi_output['shutdown_on_failed']: + shutdown_time = rpi_output['shutdown_time'] + if rpi_output['output_type'] == 'pwm' and rpi_output['pwm_temperature_linked']: + rpi_output['duty_cycle'] = rpi_output['default_duty_cycle'] + if rpi_output['auto_shutdown'] and not self.is_hour(shutdown_time): + delay_seconds = self.to_float(shutdown_time) + self.schedule_auto_shutdown_outputs( + rpi_output, delay_seconds) + if rpi_output['output_type'] == 'temp_hum_control': + rpi_output['temp_ctr_set_value'] = 0 + self.run_tasks() if event == Events.PRINT_DONE: for notification in self.notifications: @@ -1228,7 +1275,7 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, shutdown_delay_seconds, rpi_output, value, sufix) if rpi_output['output_type'] == 'pwm' and rpi_output['pwm_temperature_linked']: self.schedule_pwm_duty_on_queue( - shutdown_delay_seconds, rpi_output, 0) + shutdown_delay_seconds, rpi_output, 0, sufix) if (rpi_output['output_type'] == 'neopixel_indirect' or rpi_output['output_type'] == 'neopixel_direct'): self.add_neopixel_output_to_queue( rpi_output, shutdown_delay_seconds, 0, 0, 0, sufix) @@ -1330,9 +1377,9 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, self.event_queue.append(dict(queue_id=queue_id, thread=thread)) - def schedule_pwm_duty_on_queue(self, delay_seconds, rpi_output, value): - queue_id = '{0!s}_{1!s}'.format( - rpi_output['index_id'], "pwm_linked_temp") + def schedule_pwm_duty_on_queue(self, delay_seconds, rpi_output, value, sufix): + queue_id = '{0!s}_{1!s}_{2!s}'.format( + rpi_output['index_id'], "pwm_linked_temp", sufix) thread = threading.Timer(delay_seconds, self.set_pwm_duty_cycle, args=[rpi_output, value, queue_id]) @@ -1415,10 +1462,11 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, "M82 ;Set extruder to Absolute Mode\n" + "G92 E0 ;Set Extruder to 0", use_sudo=True, + neopixel_dma=10, debug=False, gcode_control=False, debug_temperature_log=False, - useBoardPinNumber=False, + use_board_pin_number=False, notification_provider="disabled", notification_api_key="", notification_event_name="printer_event", diff --git a/octoprint_enclosure/neopixel_direct.py b/octoprint_enclosure/neopixel_direct.py index cb038b2..0096207 100644 --- a/octoprint_enclosure/neopixel_direct.py +++ b/octoprint_enclosure/neopixel_direct.py @@ -3,7 +3,6 @@ import sys import time LED_INVERT = False -LED_DMA = 5 LED_FREQ_HZ = 800000 if len(sys.argv) == 8: @@ -13,7 +12,7 @@ if len(sys.argv) == 8: red = int(sys.argv[4]) green = int(sys.argv[5]) blue = int(sys.argv[6]) - address = int(sys.argv[7], 16) + LED_DMA = int(sys.argv[7], 16) else: print("fail") sys.exit(1) diff --git a/octoprint_enclosure/static/js/enclosure.js b/octoprint_enclosure/static/js/enclosure.js index fd8e75d..da6cf56 100644 --- a/octoprint_enclosure/static/js/enclosure.js +++ b/octoprint_enclosure/static/js/enclosure.js @@ -43,13 +43,17 @@ $(function () { }); }); + self.use_sudo = ko.observable(); + self.gcode_control = ko.observable(); + self.neopixel_dma = ko.observable(); self.debug = ko.observable(); self.debug_temperature_log = ko.observable(); + self.use_board_pin_number = ko.observable(); self.filament_sensor_gcode = ko.observable(); self.notification_provider = ko.observable(); self.notification_event_name = ko.observable(); self.notification_api_key = ko.observable(); - self.notifications = ko.observable(); + self.notifications = ko.observableArray([]); self.humidityCapableSensor = function(sensor){ if (['11', '22', '2302', 'bme280', 'si7021'].indexOf(sensor) >= 0){ @@ -262,24 +266,28 @@ $(function () { return duty_cycle; } - self.bindSettings = function(){ + self.bindFromSettings = function(){ self.rpi_outputs(self.settingsViewModel.settings.plugins.enclosure.rpi_outputs()); self.rpi_inputs(self.settingsViewModel.settings.plugins.enclosure.rpi_inputs()); - self.debug(self.settingsViewModel.settings.plugins.enclosure.debug()) - self.debug_temperature_log(self.settingsViewModel.settings.plugins.enclosure.debug_temperature_log()) - self.filament_sensor_gcode(self.settingsViewModel.settings.plugins.enclosure.filament_sensor_gcode()) - self.notification_provider(self.settingsViewModel.settings.plugins.enclosure.notification_provider()) - self.notification_event_name(self.settingsViewModel.settings.plugins.enclosure.notification_event_name()) - self.notification_api_key(self.settingsViewModel.settings.plugins.enclosure.notification_api_key()) - self.notifications(self.settingsViewModel.settings.plugins.enclosure.notifications()) + self.use_sudo(self.settingsViewModel.settings.plugins.enclosure.use_sudo()); + self.gcode_control(self.settingsViewModel.settings.plugins.enclosure.gcode_control()); + self.neopixel_dma(self.settingsViewModel.settings.plugins.enclosure.neopixel_dma()); + self.debug(self.settingsViewModel.settings.plugins.enclosure.debug()); + self.debug_temperature_log(self.settingsViewModel.settings.plugins.enclosure.debug_temperature_log()); + self.use_board_pin_number(self.settingsViewModel.settings.plugins.enclosure.use_board_pin_number()); + self.filament_sensor_gcode(self.settingsViewModel.settings.plugins.enclosure.filament_sensor_gcode()); + self.notification_provider(self.settingsViewModel.settings.plugins.enclosure.notification_provider()); + self.notification_event_name(self.settingsViewModel.settings.plugins.enclosure.notification_event_name()); + self.notification_api_key(self.settingsViewModel.settings.plugins.enclosure.notification_api_key()); + self.notifications(self.settingsViewModel.settings.plugins.enclosure.notifications()); }; self.onBeforeBinding = function () { - self.bindSettings(); + self.bindFromSettings(); }; self.onSettingsBeforeSave = function() { - self.bindSettings(); + self.bindFromSettings(); }; self.onStartupComplete = function () { @@ -368,6 +376,7 @@ $(function () { controlled_io_set_value: ko.observable("Low"), startup_time: ko.observable(0), auto_shutdown: ko.observable(false), + shutdown_on_failed: ko.observable(false), shutdown_time: ko.observable(0), linked_temp_sensor: ko.observable(""), alarm_set_temp: ko.observable(0), diff --git a/octoprint_enclosure/templates/enclosure_settings.jinja2 b/octoprint_enclosure/templates/enclosure_settings.jinja2 index 7b7fa4f..6810866 100644 --- a/octoprint_enclosure/templates/enclosure_settings.jinja2 +++ b/octoprint_enclosure/templates/enclosure_settings.jinja2 @@ -204,6 +204,15 @@ +
+
+ + Choose if output should turn off automatomatically when print is canceled or fails +
+
+
@@ -294,13 +303,16 @@
+
- Default temperature / humidity that temperature control will be set when the print starts. + Default temperature / humidity that temperature control will be set when the print starts or the server starts.
+ +
@@ -714,6 +726,13 @@ github page
+
+ +
+ + DMA channel used on direct control of neopixel. +
+
- +