Skip to content

Commit

Permalink
✨ Add torch toggle @ command
Browse files Browse the repository at this point in the history
See #184
  • Loading branch information
cp2004 committed Mar 13, 2022
1 parent b40d421 commit e2d41df
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/documentation/host-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ The plugin reacts to some different @ commands, listed below:
| `@WS TORCH` | Activates the torch mode, for timer mode |
| `@WS TORCH_ON` | Turn torch on, for toggle mode |
| `@WS TORCH_OFF` | Turn torch off, for toggle mode |
| `@WS TORCH_TOGGLE` | Toggle torch on/off, for toggle mode |

These commands can be used in g-code scripts, or in custom controls in apps - see here for [instructions for OctoRemote](https://github.com/cp2004/OctoPrint-WS281x\_LED\_Status/issues/6#issuecomment-668110507), or the guide on how to create a [timelapse flash in OctoLapse](../guides/octolapse-flash.md) which also uses @ commands.

Expand Down
7 changes: 7 additions & 0 deletions octoprint_ws281x_led_status/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,13 @@ def process_at_command(
["effects", "torch", "toggle"]
):
self.deactivate_torch()
elif params == AtCommands.TORCH_TOGGLE and self._settings.get_boolean(
["effects", "torch", "toggle"]
):
if self.torch_on:
self.deactivate_torch()
else:
self.activate_torch()
elif params[0:6] == AtCommands.CUSTOM:
self.custom_triggers.on_at_command(params[7:]) # Strip off "CUSTOM"

Expand Down
1 change: 1 addition & 0 deletions octoprint_ws281x_led_status/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class AtCommands:
TORCH = "TORCH"
TORCH_ON = "TORCH_ON"
TORCH_OFF = "TORCH_OFF"
TORCH_TOGGLE = "TORCH_TOGGLE"

CUSTOM = "CUSTOM"

Expand Down

0 comments on commit e2d41df

Please sign in to comment.