Skip to content

Commit e2d41df

Browse files
committed
✨ Add torch toggle @ command
See #184
1 parent b40d421 commit e2d41df

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

docs/documentation/host-commands.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The plugin reacts to some different @ commands, listed below:
1818
| `@WS TORCH` | Activates the torch mode, for timer mode |
1919
| `@WS TORCH_ON` | Turn torch on, for toggle mode |
2020
| `@WS TORCH_OFF` | Turn torch off, for toggle mode |
21+
| `@WS TORCH_TOGGLE` | Toggle torch on/off, for toggle mode |
2122

2223
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.
2324

octoprint_ws281x_led_status/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,13 @@ def process_at_command(
706706
["effects", "torch", "toggle"]
707707
):
708708
self.deactivate_torch()
709+
elif params == AtCommands.TORCH_TOGGLE and self._settings.get_boolean(
710+
["effects", "torch", "toggle"]
711+
):
712+
if self.torch_on:
713+
self.deactivate_torch()
714+
else:
715+
self.activate_torch()
709716
elif params[0:6] == AtCommands.CUSTOM:
710717
self.custom_triggers.on_at_command(params[7:]) # Strip off "CUSTOM"
711718

octoprint_ws281x_led_status/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class AtCommands:
4444
TORCH = "TORCH"
4545
TORCH_ON = "TORCH_ON"
4646
TORCH_OFF = "TORCH_OFF"
47+
TORCH_TOGGLE = "TORCH_TOGGLE"
4748

4849
CUSTOM = "CUSTOM"
4950

0 commit comments

Comments
 (0)