Conversation
Created handler for M150, supporting R, G/U, B, P, and I parameters
Add files via upload
Added fully functional M150, supporting the following: R - Red value (0-255) G or U - Green value (0-255) B - Blue value (0-255) P - Brightness (0-255) I - LED Index (1 to # of LED's) When used in combination with Effect 9 (Solid With Brightness), specifying this will control the color/brightness of only the specified LED. Leaving this parameter out (or using a value of -1) will result in controlling all LED's E - Effect (0-9) The effect to display. Leaving out this parameter defaults to Effect 9 (Solid With Brightness) to maintain compatibility with the official M150 code. Effects are one of: 0 = Theater Chase 1 = Solid Color 2 = Rainbow Cycle 3 = Rainbow 4 = Color Wipe 5 = Pulse 6 = Knight Rider 7 = Plasma 8 = Theater Chase Rainbow 9 = Color With Brightness
Add files via upload
Included Delay parameter ('D')
|
Added fully functional M150, supporting the following: Effects are one of: No known bugs, but plenty of room for improvement. |
| } | ||
| } | ||
|
|
||
| def HandleM150(self, comm_instance, phase, cmd, cmd_type, gcode, *args, **kwargs): |
There was a problem hiding this comment.
Use lower_snake_case for method names.
| strip.setPixelColorRGB(p, *color) | ||
| strip.show() | ||
|
|
||
| def solid_with_brightness(strip, color, queue, delay=10, iterations=1, reverse=False, brightness=255, index=-1): |
There was a problem hiding this comment.
Let’s just add the brightness and index parameters to the existing solid_color function.
octoprint_rgb_status/__init__.py
Outdated
| index=parameters['i'] | ||
| ) | ||
| elif hasattr(self, '_queue'): | ||
| json_str = json.JSONEncoder().encode({'data':{'r': parameters['r'],'g': parameters['g'],'b': parameters['b'],'brightness': parameters['p'],'index': parameters['i']}}) |
There was a problem hiding this comment.
Why not use json.dumps() to parallel loads() on line 19 of basic_effects.py?
| for p in range(strip.numPixels()): | ||
| strip.setPixelColorRGB(p, *color) | ||
| else: | ||
| for p in range(strip.numPixels()): |
There was a problem hiding this comment.
This loop is unnecessary. Just set the color of the led at index.
|
@JohnTRoth Apologies, I left several comments on the code above and just realized that I never finalized my review. |
Support M150 (Issue #14)