@@ -18,7 +18,8 @@ def initialize(self):
18
18
if GPIO .VERSION < "0.6" : # Need at least 0.6 for edge detection
19
19
raise Exception ("RPi.GPIO must be greater than 0.6" )
20
20
GPIO .setwarnings (False ) # Disable GPIO warnings
21
- self .filamentsensorngPlugin_confirmations_tracking = 0
21
+ self .confirmations_tracking = 0
22
+ self .turn_off_tracking = False
22
23
23
24
@property
24
25
def pin (self ):
@@ -126,7 +127,7 @@ def on_event(self, event, payload):
126
127
Events .ERROR
127
128
):
128
129
self ._logger .info ("%s: Disabling filament sensor." % (event ))
129
- GPIO . remove_event_detect ( self .pin )
130
+ self .turn_off_tracking = True
130
131
131
132
@octoprint .plugin .BlueprintPlugin .route ("/status" , methods = ["GET" ])
132
133
def check_status (self ):
@@ -139,19 +140,21 @@ def sensor_callback(self, _):
139
140
sleep (self .poll_time / 1000 )
140
141
self .debug_only_output ('Pin: ' + str (GPIO .input (self .pin )))
141
142
if self .no_filament ():
142
- self .filamentsensorngPlugin_confirmations_tracking += 1
143
- self .debug_only_output ('Confirmations: ' + str (self .filamentsensorngPlugin_confirmations_tracking ))
144
- if self .confirmations <= self .filamentsensorngPlugin_confirmations_tracking :
143
+ self .confirmations_tracking += 1
144
+ self .debug_only_output ('Confirmations: ' + str (self .confirmations_tracking ))
145
+ if self .confirmations <= self .confirmations_tracking :
145
146
self ._logger .info ("Out of filament!" )
146
147
if self .pause_print :
147
148
self ._logger .info ("Pausing print." )
148
149
self ._printer .pause_print ()
150
+ self .turn_off_tracking = False
151
+ GPIO .remove_event_detect (self .pin )
149
152
if self .no_filament_gcode :
150
153
self ._logger .info ("Sending out of filament GCODE" )
151
154
self ._printer .commands (self .no_filament_gcode )
152
- self .filamentsensorngPlugin_confirmations_tracking = 0
155
+ self .confirmations_tracking = 0
153
156
else :
154
- self .filamentsensorngPlugin_confirmations_tracking = 0
157
+ self .confirmations_tracking = 0
155
158
156
159
def get_update_information (self ):
157
160
return dict (
0 commit comments