Skip to content

Comments

Prelim M150 functionality#79

Open
JohnTRoth wants to merge 6 commits intoEricHigdon:mainfrom
JohnTRoth:main
Open

Prelim M150 functionality#79
JohnTRoth wants to merge 6 commits intoEricHigdon:mainfrom
JohnTRoth:main

Conversation

@JohnTRoth
Copy link

Support M150 (Issue #14)

JohnTRoth added 6 commits July 8, 2020 19:21
Created handler for M150, supporting R, G/U, B, P, and I parameters
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
@JohnTRoth
Copy link
Author

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)
D - Delay
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

No known bugs, but plenty of room for improvement.

}
}

def HandleM150(self, comm_instance, phase, cmd, cmd_type, gcode, *args, **kwargs):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s just add the brightness and index parameters to the existing solid_color function.

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']}})
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loop is unnecessary. Just set the color of the led at index.

Repository owner deleted a comment from cp2004 Feb 4, 2021
@EricHigdon
Copy link
Owner

@JohnTRoth Apologies, I left several comments on the code above and just realized that I never finalized my review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants