Skip to content

Commit

Permalink
Merge branch '0.7.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
cp2004 committed Mar 18, 2021
2 parents ab6cd3e + 9c4fc19 commit 76216b4
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 21 deletions.
14 changes: 7 additions & 7 deletions docs/configuration/printing-effects.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
8 changes: 8 additions & 0 deletions docs/documentation/m150-intercept.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

84 changes: 82 additions & 2 deletions docs/documentation/rest-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}


Expand Down
2 changes: 1 addition & 1 deletion docs/guides/setup-guide-1/wiring-your-leds.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 10 additions & 9 deletions octoprint_ws281x_led_status/effects/standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions octoprint_ws281x_led_status/static/js/ws281x_led_status.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 76216b4

Please sign in to comment.