Skip to content

Commit

Permalink
play nice with effects that may interrupt progress
Browse files Browse the repository at this point in the history
  • Loading branch information
EricHigdon committed Jun 13, 2020
1 parent 9440b14 commit da6cdb7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions octoprint_rgb_status/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,19 @@ def on_event(self, event, payload):
self.run_disconnected_effect()

def on_print_progress(self, storage, path, progress):
if progress == 100 and hasattr(self, '_effect') and self._effect.is_alive():
if progress == 100 and hasattr(self, '_effect') and self._effect.is_alive() and self._effect.name != 'Progress':
self._logger.info('Progress was set to 100, but the idle effect was already running. Ignoring progress update')
return
if self.strip is not None and self._settings.get_boolean(['show_progress']):
self._logger.info('Updating Progress LEDs: ' + str(progress))
if hasattr(self, '_queue'):
if self._effect.name != 'Progress':
self.run_effect(
progress_effect,
hex_to_rgb(self._settings.get(['progress_base_color'])),
progress=progress,
progress_color=hex_to_rgb(self._settings.get(['progress_color'])),
)
elif hasattr(self, '_queue'):
self._queue.put(progress)
elif self.strip is None:
self._logger.error('Error setting progress: The strip object does not exist. Did it fail to initialize?')
Expand Down
2 changes: 1 addition & 1 deletion octoprint_rgb_status/basic_effects.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def run_effect(effect, lock, queue, settings, color, delay, shutdown_event, reve
message = queue.get()
if message == 'KILL':
break
else:
elif 'progress' in kwargs:
kwargs['progress'] = int(message)
effect(strip, color, queue, delay, reverse=reverse, **kwargs)
finally:
Expand Down

0 comments on commit da6cdb7

Please sign in to comment.