Skip to content

Commit 8c5daf8

Browse files
committed
Add confirmations to ensure that we've actually run out of filament due to cheap switches.
Add first of many segfault attempted fixes.
1 parent 9a883df commit 8c5daf8

File tree

5 files changed

+41
-73
lines changed

5 files changed

+41
-73
lines changed

CODE_OF_CONDUCT.md

Lines changed: 0 additions & 46 deletions
This file was deleted.

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
# OctoPrint-FilamentReloaded
1+
# OctoPrint-FilamentSensor-ng
2+
3+
I made this because [Octoprint-Filament-Reloaded](https://github.com/kontakt/Octoprint-Filament-Reloaded) would segfault and I wanted more options.
24

35
[OctoPrint](http://octoprint.org/) plugin that integrates with a filament sensor hooked up to a Raspberry Pi GPIO pin and allows the filament spool to be changed during a print if the filament runs out.
46

57
Future developments are planned to include multiple filament sensors and pop-ups.
68

9+
Initial work based on the [Octoprint-Filament-Reloaded](https://github.com/kontakt/Octoprint-Filament-Reloaded) plugin by kontakt.
710
Initial work based on the [Octoprint-Filament](https://github.com/MoonshineSG/Octoprint-Filament) plugin by MoonshineSG.
811

912
## Required sensor
@@ -22,8 +25,7 @@ This plugin is using the GPIO.BOARD numbering scheme, the pin being used needs t
2225

2326
## Installation
2427

25-
* Install via the bundled [Plugin Manager](https://github.com/foosel/OctoPrint/wiki/Plugin:-Plugin-Manager).
26-
* Manually using this URL: https://github.com/kontakt/Octoprint-Filament-Reloaded/archive/master.zip
28+
* Manually using this URL: https://github.com/Red-M/Octoprint-Filament-Sensor-ng/archive/master.zip
2729

2830
## Configuration
2931

octoprint_filamentreload/__init__.py renamed to octoprint_filamentsensorng/__init__.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from time import sleep
88

99

10-
class FilamentReloadedPlugin(octoprint.plugin.StartupPlugin,
10+
class filamentsensorngPlugin(octoprint.plugin.StartupPlugin,
1111
octoprint.plugin.EventHandlerPlugin,
1212
octoprint.plugin.TemplatePlugin,
1313
octoprint.plugin.SettingsPlugin):
@@ -34,6 +34,10 @@ def switch(self):
3434
def mode(self):
3535
return int(self._settings.get(["mode"]))
3636

37+
@property
38+
def confirmations(self):
39+
return int(self._settings.get(["confirmations"]))
40+
3741
@property
3842
def no_filament_gcode(self):
3943
return str(self._settings.get(["no_filament_gcode"])).splitlines()
@@ -57,7 +61,7 @@ def _setup_sensor(self):
5761
self._logger.info("Pin not configured, won't work unless configured!")
5862

5963
def on_after_startup(self):
60-
self._logger.info("Filament Sensor Reloaded started")
64+
self._logger.info("FilamentSensor-ng started")
6165
self._setup_sensor()
6266

6367
def get_settings_defaults(self):
@@ -66,6 +70,7 @@ def get_settings_defaults(self):
6670
bounce = 250, # Debounce 250ms
6771
switch = 0, # Normally Open
6872
mode = 0, # Board Mode
73+
confirmations=0,# Confirm that we're actually out of filament
6974
no_filament_gcode = '',
7075
pause_print = True,
7176
)
@@ -95,13 +100,13 @@ def on_event(self, event, payload):
95100
Events.PRINT_RESUMED
96101
):
97102
self._logger.info("%s: Enabling filament sensor." % (event))
98-
if self.sensor_enabled():
99-
GPIO.remove_event_detect(self.pin)
100-
GPIO.add_event_detect(
101-
self.pin, GPIO.BOTH,
102-
callback=self.sensor_callback,
103-
bouncetime=self.bounce
104-
)
103+
# if self.sensor_enabled():
104+
# GPIO.remove_event_detect(self.pin)
105+
# GPIO.add_event_detect(
106+
# self.pin, GPIO.BOTH,
107+
# callback=self.sensor_callback,
108+
# bouncetime=self.bounce
109+
# )
105110
# Disable sensor
106111
elif event in (
107112
Events.PRINT_DONE,

octoprint_filamentreload/templates/filamentreload_settings.jinja2 renamed to octoprint_filamentsensorng/templates/filamentsensorng_settings.jinja2

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,27 @@
33
<div class="control-group">
44
<label class="control-label">{{ _('Pin:') }}</label>
55
<div class="controls" data-toggle="tooltip" title="{{ _('Which Raspberry Pi GPIO pin your switch is attached to (-1 disables the plugin)') }}">
6-
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: settings.plugins.filamentreload.pin">
6+
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: settings.plugins.filamentsensorng.pin">
77
</div>
88
</div>
99
<div class="control-group">
1010
<label class="control-label">{{ _('Debounce Time:') }}</label>
1111
<div class="controls" data-toggle="tooltip" title="{{ _('When a sensor state change happens, wait for this amount of time to wait for the signal to stabilize.') }}">
12-
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: settings.plugins.filamentreload.bounce">
12+
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: settings.plugins.filamentsensorng.bounce">
13+
<span class="add-on">ms</span>
14+
</div>
15+
</div>
16+
<div class="control-group">
17+
<label class="control-label">{{ _('Debounce Time:') }}</label>
18+
<div class="controls" data-toggle="tooltip" title="{{ _('When a sensor state change happens, wait for this amount of continous reads of the sensor not having filament to trigger.') }}">
19+
<input type="number" step="any" min="0" class="input-mini text-right" data-bind="value: settings.plugins.filamentsensorng.confirmations">
1320
<span class="add-on">ms</span>
1421
</div>
1522
</div>
1623
<div class="control-group">
1724
<label class="control-label">{{ _('Switch Type:') }}</label>
1825
<div class="controls" data-toggle="tooltip" title="{{ _('Whether the sensor should trip when the switch goes HIGH or LOW, Normally Open is LOW when filament is present, and Normally Closed is HIGH when filament is present.') }}">
19-
<select class="select-mini" data-bind="value: settings.plugins.filamentreload.switch">
26+
<select class="select-mini" data-bind="value: settings.plugins.filamentsensorng.switch">
2027
<option value=0>{{ _('Normally Open') }}</option>
2128
<option value=1>{{ _('Normally Closed') }}</option>
2229
</select>
@@ -25,7 +32,7 @@
2532
<div class="control-group">
2633
<label class="control-label">{{ _('Board Pin Mode:') }}</label>
2734
<div class="controls" data-toggle="tooltip" title="{{ _('RPi pins numbered in Board mode or BCM mode?') }}">
28-
<select class="select-mini" data-bind="value: settings.plugins.filamentreload.mode">
35+
<select class="select-mini" data-bind="value: settings.plugins.filamentsensorng.mode">
2936
<option value=0>{{ _('Board Mode') }}</option>
3037
<option value=1>{{ _('BCM Mode') }}</option>
3138
</select>
@@ -34,13 +41,13 @@
3441
<div class="control-group">
3542
<label class="control-label">{{ _('Out of filament GCODE:') }}</label>
3643
<div class="controls">
37-
<textarea rows="4" class="block" data-bind="value: settings.plugins.filamentreload.no_filament_gcode"></textarea>
44+
<textarea rows="4" class="block" data-bind="value: settings.plugins.filamentsensorng.no_filament_gcode"></textarea>
3845
</div>
3946
</div>
4047
<div class="control-group">
4148
<div class="controls" data-toggle="tooltip" title="{{ _('Beware that for some printers, pausing is incompatible with M600 (Filament change pause) as both will move the print head and it can resume at a different position as it paused.') }}">
4249
<label class="checkbox">
43-
<input type="checkbox" data-bind="checked: settings.plugins.filamentreload.pause_print"> {{ _('Pause print when out of filament') }}
50+
<input type="checkbox" data-bind="checked: settings.plugins.filamentsensorng.pause_print"> {{ _('Pause print when out of filament') }}
4451
</label>
4552
</div>
4653
</div>

setup.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@
44
### Do not forget to adjust the following variables to your own plugin.
55

66
# The plugin's identifier, has to be unique
7-
plugin_identifier = "filamentreload"
7+
plugin_identifier = "filamentsensorng"
88

99
# The plugin's python package, should be "octoprint_<plugin identifier>", has to be unique
10-
plugin_package = "octoprint_filamentreload"
10+
plugin_package = "octoprint_filamentsensorng"
1111

1212
# The plugin's human readable name. Can be overwritten within OctoPrint's internal data via __plugin_name__ in the
1313
# plugin module
14-
plugin_name = "Octoprint-FilamentReload"
14+
plugin_name = "Octoprint-FilamentSensor-ng"
1515

1616
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
17-
plugin_version = "1.0.1"
17+
plugin_version = "1.0.0"
1818

1919
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
2020
# module
21-
plugin_description = """A revamped and rewritten filament monitor that pauses the print when your filament runs out"""
21+
plugin_description = """A filament monitor that pauses the print when your filament runs out and lets you restart it."""
2222

2323
# The plugin's author. Can be overwritten within OctoPrint's internal data via __plugin_author__ in the plugin module
24-
plugin_author = "Connor Huffine"
24+
plugin_author = "Connor Huffine, Red_M"
2525

2626
# The plugin's author's mail address.
27-
plugin_author_email = "[email protected]"
27+
plugin_author_email = "[email protected], [email protected]"
2828

2929
# The plugin's homepage URL. Can be overwritten within OctoPrint's internal data via __plugin_url__ in the plugin module
30-
plugin_url = "https://github.com/kontakt/Octoprint-Filament-Reloaded"
30+
plugin_url = "https://github.com/Red-M/Octoprint-Filament-Reloaded"
3131

3232
# The plugin's license. Can be overwritten within OctoPrint's internal data via __plugin_license__ in the plugin module
33-
plugin_license = "AGPLv3"
33+
plugin_license = "GPLv3"
3434

3535
# Any additional requirements besides OctoPrint should be listed here
3636
plugin_requires = ['RPi.GPIO']

0 commit comments

Comments
 (0)