MCPcopy Create free account
hub / github.com/DexterInd/GoPiGo3 / handle_eye_color

Function handle_eye_color

Software/Scratch/GoPiGo3Scratch.py:767–792  ·  view source on GitHub ↗

set the color of one or both eyes, and open the eye

(regObj)

Source from the content-addressed store, hash-verified

765
766
767def handle_eye_color(regObj):
768 '''
769 set the color of one or both eyes, and open the eye
770 '''
771 if regObj.group(EYE_COLOR_STRING_GROUP):
772 r,g,b=eye_colors[regObj.group(EYE_COLOR_STRING_GROUP)]
773
774 if regObj.group(EYE_COLOR_R_GROUP):
775 r = int(regObj.group(EYE_COLOR_R_GROUP))
776 if regObj.group(EYE_COLOR_G_GROUP):
777 g = int(regObj.group(EYE_COLOR_G_GROUP))
778 if regObj.group(EYE_COLOR_B_GROUP):
779 b = int(regObj.group(EYE_COLOR_B_GROUP))
780 if regObj.group(EYE_COLOR_HTML_GROUP):
781 color = regObj.group(EYE_COLOR_HTML_GROUP)
782 r,g,b = tuple(int(color[i:i+2], 16) for i in (1, 3 ,5))
783 try:
784 if regObj.group(EYE_COLOR_LEFT_GROUP)==None:
785 gpg.set_right_eye_color((r,g,b))
786 gpg.open_right_eye()
787 if regObj.group(EYE_COLOR_RIGHT_GROUP)==None:
788 gpg.set_left_eye_color((r,g,b))
789 gpg.open_left_eye()
790 except Exception as e:
791 print("handle_eye_color".format(e))
792 return None
793
794
795def handle_eyes(regObj):

Callers 1

handle_GoPiGo3_msgFunction · 0.85

Calls 4

set_right_eye_colorMethod · 0.80
open_right_eyeMethod · 0.80
set_left_eye_colorMethod · 0.80
open_left_eyeMethod · 0.80

Tested by

no test coverage detected