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

Function handle_buzzer

Software/Scratch/GoPiGo3Scratch.py:604–617  ·  view source on GitHub ↗

if a port is not provided assume AD1

(regObj)

Source from the content-addressed store, hash-verified

602
603
604def handle_buzzer(regObj):
605 '''
606 if a port is not provided assume AD1
607 '''
608 sensors = {}
609 port = "AD2" if regObj.group(SENSOR_BUZZER_PORT2_GROUP) else "AD1"
610 try:
611 power = float(regObj.group(SENSOR_BUZZER_POWER_GROUP))
612 except:
613 power = 100 if regObj.group(SENSOR_BUZZER_POWER_GROUP)=="on" else 0
614 Buzzer = get_sensor_instance(port, easysensors.Buzzer)
615 if Buzzer:
616 Buzzer.sound(power)
617 return {"{}: Buzzer".format(port):power}
618
619
620def handle_distance(regObj):

Callers 1

Calls 2

get_sensor_instanceFunction · 0.85
soundMethod · 0.45

Tested by

no test coverage detected