Skip to content

Commit 835bf31

Browse files
committed
Add debug option.
1 parent f53f689 commit 835bf31

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

octoprint_filamentsensorng/__init__.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ def mode(self):
4040
def confirmations(self):
4141
return int(self._settings.get(["confirmations"]))
4242

43+
@property
44+
def debug_mode(self):
45+
return int(self._settings.get(["debug_mode"]))
46+
4347
@property
4448
def no_filament_gcode(self):
4549
return str(self._settings.get(["no_filament_gcode"])).splitlines()
@@ -76,6 +80,10 @@ def get_settings_defaults(self):
7680
'no_filament_gcode':'',
7781
'pause_print':True,
7882
})
83+
84+
def debug_only_output(self, string):
85+
if self.debug_mode():
86+
self._logger.info(string)
7987

8088
def on_settings_save(self, data):
8189
octoprint.plugin.SettingsPlugin.on_settings_save(self, data)
@@ -128,10 +136,10 @@ def check_status(self):
128136

129137
def sensor_callback(self, _):
130138
sleep(self.poll_time/1000)
131-
#self._logger.info('Pin: '+str(GPIO.input(self.pin)))
139+
self.debug_only_output('Pin: '+str(GPIO.input(self.pin)))
132140
if self.no_filament():
133141
self.filamentsensorngPlugin_confirmations_tracking+=1
134-
self._logger.info('Confirmations: '+str(self.filamentsensorngPlugin_confirmations_tracking))
142+
self.debug_only_output('Confirmations: '+str(self.filamentsensorngPlugin_confirmations_tracking))
135143
if self.confirmations<=self.filamentsensorngPlugin_confirmations_tracking:
136144
self._logger.info("Out of filament!")
137145
if self.pause_print:
@@ -162,7 +170,7 @@ def get_update_information(self):
162170
)
163171

164172
__plugin_name__ = "Filament Sensor NG"
165-
__plugin_version__ = "1.0.0"
173+
__plugin_version__ = "1.0.1"
166174

167175
def __plugin_load__():
168176
global __plugin_implementation__

octoprint_filamentsensorng/templates/filamentsensorng_settings.jinja2

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@
4343
<textarea rows="4" class="block" data-bind="value: settings.plugins.filamentsensorng.no_filament_gcode"></textarea>
4444
</div>
4545
</div>
46+
<div class="control-group">
47+
<label class="control-label">{{ _('Debug Output:') }}</label>
48+
<div class="controls" data-toggle="tooltip" title="{{ _('Debug information out to the terminal/log.') }}">
49+
<select class="select-mini" data-bind="value: settings.plugins.filamentsensorng.debug_mode">
50+
<option value=0>{{ _('Off') }}</option>
51+
<option value=1>{{ _('On') }}</option>
52+
</select>
53+
</div>
54+
</div>
4655
<div class="control-group">
4756
<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.') }}">
4857
<label class="checkbox">

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
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.0"
17+
plugin_version = "1.0.1"
1818

1919
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
2020
# module

0 commit comments

Comments
 (0)