diff --git a/README.md b/README.md index 6d683bb..ee89b04 100644 --- a/README.md +++ b/README.md @@ -76,31 +76,24 @@ chmod +x ~/.octoprint/plugins/OctoPrint-Enclosure/extras/GetTemperature1820.py Note that DS18B20 sensors will not provide information regarding humidity of the enclosure. -**wiringPi** +**Filament sensor:** -To use raspberry pi GPIO without needing to run octoprint as root this plugin uses [wiringPi](http://wiringpi.com) +You have the hability to add a filament sensor to the enclosure, it will automatically pause the print if you run out of filament, I can be any type of filament that gives a signal normally open, and it should connect to ground (active low) when detected the end of filament. I'm using the following sensor: -You must install wiringPi using: +http://www.thingiverse.com/thing:1698397 +**GPIO** -``` -git clone git://git.drogon.net/wiringPi -cd wiringPi -git pull origin -cd wiringPi -./build -``` - -If by any change the git page is offline you can follow *Plan B* on wiringPi website. - +This release uses RPi.GPIO to control IO of raspberry pi, it should install and work automatically. If it doesn't please update your octoprint with the latest release of octopi. ## Configuration Default plugin configuration uses: Pin 4 connected to Temperature Sensor -Pin 14 connected to the relay that controls the fan -Pin 15 connected to the relay that controls the light -Pin 18 connected to the relay that controls the heater +Pin 23 connected to the relay that controls the fan +Pin 18 connected to the relay that controls the light +Pin 17 connected to the relay that controls the heater +Pin 24 connected to the fillament sensor Those settings are configurable, as well the location of the python scripts to read temperature and humidity. diff --git a/octoprint_enclosure/__init__.py b/octoprint_enclosure/__init__.py index f26781a..76fa3f2 100644 --- a/octoprint_enclosure/__init__.py +++ b/octoprint_enclosure/__init__.py @@ -122,18 +122,18 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, self.heater.write(False) def startFilamentDetection(self): - if not GPIO.input(self.PIN_FILAMENT): + if not GPIO.input(self.filamentSensor.pinNumber): self._logger.info("Started printing with no filament.") self._printer.toggle_pause_print() - else: - try: - GPIO.remove_event_detect(self.filamentSensor.pinNumber) - except: - pass - if self.self.filamentSensor.pinNumber != -1: - GPIO.add_event_detect(self.filamentSensor.pinNumber, GPIO.FALLING, callback=self.handleFilamentDetection, bouncetime=200) + try: + GPIO.remove_event_detect(self.filamentSensor.pinNumber) + except: + pass + if self.filamentSensor.pinNumber != -1: + self._logger.info("Started filament detection.") + GPIO.add_event_detect(self.filamentSensor.pinNumber, GPIO.FALLING, callback=self.handleFilamentDetection, bouncetime=200) - def handleFilamentDetection(self): + def handleFilamentDetection(self,channel): if self._printer.is_printing(): self._logger.info("Detected end of filament.") self._printer.toggle_pause_print() @@ -203,12 +203,7 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, #~~ SettingsPlugin mixin def on_settings_save(self, data): octoprint.plugin.SettingsPlugin.on_settings_save(self, data) - self.io1.configureGPIO() - self.io2.configureGPIO() - self.io3.configureGPIO() - self.io4.configureGPIO() - self.heater.configureGPIO() - self.filamentSensor.configureGPIO() + self.startGPIO() def get_settings_defaults(self): return dict( @@ -217,8 +212,8 @@ class EnclosurePlugin(octoprint.plugin.StartupPlugin, heaterActiveLow=True, dhtPin=4, filamentSensorPin=24, - filamentSensorEnable=False, - dhtModel=22, + filamentSensorEnable=True, + dhtModel=2302, io1Pin=18, io2Pin=23, io3Pin=22,