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

Function handle_led

Software/Scratch/GoPiGo3Scratch.py:587–601  ·  view source on GitHub ↗

if a port is not provided assume AD1 if power is not a valid float, check for the word "on" and go full power otherwise turn led off on any other word

(regObj)

Source from the content-addressed store, hash-verified

585 return sensors
586
587def handle_led(regObj):
588 '''
589 if a port is not provided assume AD1
590 if power is not a valid float, check for the word "on" and go full power
591 otherwise turn led off on any other word
592 '''
593 port = "AD2" if regObj.group(SENSOR_LED_PORT2_GROUP) else "AD1"
594 try:
595 power = float(regObj.group(SENSOR_LED_POWER_GROUP))
596 except:
597 power = 100 if regObj.group(SENSOR_LED_POWER_GROUP)=="on" else 0
598 Led = get_sensor_instance(port, easysensors.Led)
599 if Led:
600 Led.light_on(power)
601 return {"{}: LED".format(port):power}
602
603
604def handle_buzzer(regObj):

Callers 1

Calls 2

get_sensor_instanceFunction · 0.85
light_onMethod · 0.80

Tested by

no test coverage detected