diff --git a/docs/configuration/printing-effects.md b/docs/configuration/printing-effects.md index 85d31d3..fce7464 100644 --- a/docs/configuration/printing-effects.md +++ b/docs/configuration/printing-effects.md @@ -35,13 +35,13 @@ All the standard effects available, with fancy visualisations! Sets all LEDs to one colour, forever. -![](../.gitbook/assets/solid_colour%20%283%29.gif) +![](../.gitbook/assets/solid_colour%20%284%29.gif) ### Colour Wipe Wipes colour across the strip pixel by pixel, then clears it pixel by pixel. -![](../.gitbook/assets/color_wipe%20%282%29.gif) +![](../.gitbook/assets/color_wipe%20%284%29.gif) ### Colour Wipe V2 @@ -53,13 +53,13 @@ Wipes colour pixel by pixel, as above, but to clear it turns around and heads ba Fades brightness up and down. Looks better in real life than the visualisation below! -![](../.gitbook/assets/pulse%20%281%29.gif) +![](../.gitbook/assets/pulse%20%283%29%20%281%29.gif) ### Bounce Sends a pulse of light bouncing from one side of your strip to the other. -![](../.gitbook/assets/bounce%20%283%29.gif) +![](../.gitbook/assets/bounce%20%282%29%20%281%29.gif) ### Solo Bounce @@ -71,13 +71,13 @@ Sends just a single pixel from one side to the other, bouncing about. Cycles all the LEDs through the rainbow together. -![](../.gitbook/assets/rainbow%20%281%29.gif) +![](../.gitbook/assets/rainbow%20%282%29%20%281%29.gif) ### Rainbow Cycle Rainbow that cycles across the strip, so a full rainbow is across the whole strip at once. -![](../.gitbook/assets/rainbow_cycle%20%283%29.gif) +![](../.gitbook/assets/rainbow_cycle%20%282%29%20%281%29.gif) ### Crossover @@ -89,7 +89,7 @@ Two pixels bouncing in opposite directions, crossing over in the middle. Sets all LEDs to a random colour, then changes a random pixel, to a new random colour -![](../.gitbook/assets/random%20%281%29.gif) +![](../.gitbook/assets/random%20%283%29%20%281%29.gif) ### Bouncy Balls diff --git a/docs/documentation/m150-intercept.md b/docs/documentation/m150-intercept.md index 89f3aa6..0a33214 100644 --- a/docs/documentation/m150-intercept.md +++ b/docs/documentation/m150-intercept.md @@ -31,3 +31,11 @@ M150 W100 # Sets to white, at 100 intensity M150 R255 P200 # Sets LEDs to red, at 200 brightness ``` +## What does the W parameter do? + +On a standard RGB WS281x strip, the W parameter sets an equal value of R, G and B on the LEDs. + +If you have an RGBW strip and enable the 'Use dedicated white' setting, the W parameter will control the white LEDs only. + +Sending any of R, G or B with the command takes priority over the W. + diff --git a/docs/documentation/rest-api.md b/docs/documentation/rest-api.md index 1a2a00e..2de2b37 100644 --- a/docs/documentation/rest-api.md +++ b/docs/documentation/rest-api.md @@ -6,8 +6,88 @@ description: >- # REST API -{% hint style="danger" %} -The API of the plugin is currently undocumented and **it will change in version 0.7.0 of this plugin.** From that point onwards I will aim to have a stable, documented API. +The plugin implements a [SimpleAPI as provided by OctoPrint](https://docs.octoprint.org/en/devel/plugins/mixins.html#simpleapiplugin), which enables external access to the plugin's functionality. + +It has a single endpoint, supporting a get request and posting a command. + +{% api-method method="get" host="http://octopi.local" path="/api/plugin/ws281x\_led\_status" %} +{% api-method-summary %} +SimpleAPI Get +{% endapi-method-summary %} + +{% api-method-description %} +Get current state of the plugin, which includes the light status and the torch status. +{% endapi-method-description %} + +{% api-method-spec %} +{% api-method-request %} +{% api-method-headers %} +{% api-method-parameter name="X-Api-Key" type="string" required=true %} +A valid OctoPrint API key. +{% endapi-method-parameter %} +{% endapi-method-headers %} +{% endapi-method-request %} + +{% api-method-response %} +{% api-method-response-example httpCode=200 %} +{% api-method-response-example-description %} +Details of the plugin's current state +{% endapi-method-response-example-description %} + +```javascript +{ + "lights_on": false, + "torch_on": false +} +``` +{% endapi-method-response-example %} +{% endapi-method-response %} +{% endapi-method-spec %} +{% endapi-method %} + +{% api-method method="post" host="http://octopi.local" path="/api/plugin/ws281x\_led\_status" %} +{% api-method-summary %} +SimpleAPI Command +{% endapi-method-summary %} + +{% api-method-description %} +Send commands to the plugin, to make it do something. +{% endapi-method-description %} + +{% api-method-spec %} +{% api-method-request %} +{% api-method-headers %} +{% api-method-parameter name="X-Api-Key" type="string" required=true %} +A valid OctoPrint API key +{% endapi-method-parameter %} +{% endapi-method-headers %} + +{% api-method-body-parameters %} +{% api-method-parameter name="command" type="string" required=true %} +The command to be sent to the plugin. See commands below. +{% endapi-method-parameter %} +{% endapi-method-body-parameters %} +{% endapi-method-request %} + +{% api-method-response %} +{% api-method-response-example httpCode=200 %} +{% api-method-response-example-description %} + +{% endapi-method-response-example-description %} + +```javascript +{ + "lights_on": false, + "torch_on": false +} +``` +{% endapi-method-response-example %} +{% endapi-method-response %} +{% endapi-method-spec %} +{% endapi-method %} + +{% hint style="info" %} +See also the [SimpleApi docs](https://docs.octoprint.org/en/devel/plugins/mixins.html#octoprint.plugin.SimpleApiPlugin) for details about how the request should be structured. {% endhint %} diff --git a/docs/guides/setup-guide-1/wiring-your-leds.md b/docs/guides/setup-guide-1/wiring-your-leds.md index 9fe9c78..4d57f6e 100644 --- a/docs/guides/setup-guide-1/wiring-your-leds.md +++ b/docs/guides/setup-guide-1/wiring-your-leds.md @@ -39,7 +39,7 @@ Wiring is as follows: Make sure you have a common ground between the power supply and Pi. {% endhint %} -![Wiring with no shifter](../../.gitbook/assets/wiring_no_shift%20%282%29.png) +![Wiring with no shifter](../../.gitbook/assets/wiring_no_shift%20%283%29%20%281%29.png) ### Level Shifting Chip diff --git a/octoprint_ws281x_led_status/effects/standard.py b/octoprint_ws281x_led_status/effects/standard.py index 38428e4..0514f7b 100644 --- a/octoprint_ws281x_led_status/effects/standard.py +++ b/octoprint_ws281x_led_status/effects/standard.py @@ -65,16 +65,17 @@ def set_pixel(pixel, pixel_color): def simple_pulse(strip, queue, color, delay, brightness_manager, *args, **kwargs): + max_brightness = brightness_manager.max_brightness + solid_color( + strip=strip, + queue=queue, + color=color, + brightness_manager=brightness_manager, + wait=False, + ) + while True: - max_brightness = brightness_manager.max_brightness brightness_manager.set_brightness(1) - solid_color( - strip=strip, - queue=queue, - color=color, - brightness_manager=brightness_manager, - wait=False, - ) for direction in DIRECTIONS: for b in ( @@ -208,7 +209,7 @@ def blink(strip, queue, color, delay, brightness_manager, *args, **kwargs): brightness_manager=brightness_manager, wait=False, ) - for _ms in range(int(delay / 2)): + for _ms in range(int(delay) // 2): if not q_poll_milli_sleep(2, queue): # We do it this way so we can check the q more often, as for blink # delay may be high. Otherwise the effect may end up blocking the diff --git a/octoprint_ws281x_led_status/static/js/ws281x_led_status.js b/octoprint_ws281x_led_status/static/js/ws281x_led_status.js index d654cb2..e7c69ef 100644 --- a/octoprint_ws281x_led_status/static/js/ws281x_led_status.js +++ b/octoprint_ws281x_led_status/static/js/ws281x_led_status.js @@ -4,7 +4,7 @@ * Copyright (c) Charlie Powell 2020-2021 - released under the terms of the AGPLv3 License */ -const ko = window.ko; +let ko = window.ko; $(function () { function ws281xLedStatusNavbarViewModel(parameters) { @@ -155,7 +155,9 @@ $(function () { }; self.sendTestCommand = function (color) { - OctoPrint.simpleApiCommand("ws281x_led_status", "test_led", { color } ); + OctoPrint.simpleApiCommand("ws281x_led_status", "test_led", { + color, + }); }; self.advancedStripOpen = ko.observable(false);