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)
| 585 | return sensors |
| 586 | |
| 587 | def 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 | |
| 604 | def handle_buzzer(regObj): |
no test coverage detected