| @@ 105-123 (lines=19) @@ | ||
| 102 | else: |
|
| 103 | return str(RPiGPIO.input(int(pin))).lower() in LOW_LEVEL |
|
| 104 | ||
| 105 | def set_output(self, pin, value, log_output=True): |
|
| 106 | parsed_pin = doorpi.DoorPi().parse_string("!"+str(pin)+"!") |
|
| 107 | if parsed_pin != "!"+str(pin)+"!": |
|
| 108 | pin = parsed_pin |
|
| 109 | ||
| 110 | pin = int(pin) |
|
| 111 | value = str(value).lower() in HIGH_LEVEL |
|
| 112 | if self._polarity is 1: |
|
| 113 | value = not value |
|
| 114 | log_output = str(log_output).lower() in HIGH_LEVEL |
|
| 115 | ||
| 116 | if pin not in self._OutputPins: |
|
| 117 | return False |
|
| 118 | if log_output: |
|
| 119 | logger.debug("out(pin = %s, value = %s, log_output = %s)", pin, value, log_output) |
|
| 120 | ||
| 121 | RPiGPIO.output(pin, value) |
|
| 122 | self._OutputStatus[pin] = value |
|
| 123 | return True |
|
| 124 | ||
| @@ 77-92 (lines=16) @@ | ||
| 74 | else: |
|
| 75 | return str(p.digital_read(int(pin))).lower() in LOW_LEVEL |
|
| 76 | ||
| 77 | def set_output(self, pin, value, log_output = True): |
|
| 78 | parsed_pin = doorpi.DoorPi().parse_string("!"+str(pin)+"!") |
|
| 79 | if parsed_pin != "!"+str(pin)+"!": |
|
| 80 | pin = parsed_pin |
|
| 81 | ||
| 82 | pin = int(pin) |
|
| 83 | value = str(value).lower() in HIGH_LEVEL |
|
| 84 | if self._polarity is 1: value = not value |
|
| 85 | log_output = str(log_output).lower() in HIGH_LEVEL |
|
| 86 | ||
| 87 | if not pin in self._OutputPins: return False |
|
| 88 | if log_output: logger.debug("out(pin = %s, value = %s, log_output = %s)", pin, value, log_output) |
|
| 89 | ||
| 90 | p.digital_write(pin, value) |
|
| 91 | self._OutputStatus[pin] = value |
|
| 92 | return True |
|
| 93 | ||
| @@ 103-116 (lines=14) @@ | ||
| 100 | self.__write_file(file, value) |
|
| 101 | os.chmod(file, 0o666) |
|
| 102 | ||
| 103 | def set_output(self, pin, value, log_output = True): |
|
| 104 | parsed_pin = doorpi.DoorPi().parse_string("!"+str(pin)+"!") |
|
| 105 | if parsed_pin != "!"+str(pin)+"!": |
|
| 106 | pin = parsed_pin |
|
| 107 | ||
| 108 | value = str(value).lower() in HIGH_LEVEL |
|
| 109 | log_output = str(log_output).lower() in HIGH_LEVEL |
|
| 110 | ||
| 111 | if pin not in self._OutputPins: return False |
|
| 112 | written_value = self.__write_file(os.path.join(self.__base_path_output, pin), value) |
|
| 113 | if log_output: logger.debug("out(pin = %s, value = %s, log_output = %s)", pin, written_value, log_output) |
|
| 114 | ||
| 115 | self._OutputStatus[pin] = value |
|
| 116 | return True |
|
| 117 | ||
| 118 | def on_modified(self, event): |
|
| 119 | if 'FileModifiedEvent' not in str(event): return |
|
| @@ 48-61 (lines=14) @@ | ||
| 45 | else: |
|
| 46 | return str(0).lower() in LOW_LEVEL |
|
| 47 | ||
| 48 | def set_output(self, pin, value, log_output = True): |
|
| 49 | parsed_pin = doorpi.DoorPi().parse_string("!"+str(pin)+"!") |
|
| 50 | if parsed_pin != "!"+str(pin)+"!": |
|
| 51 | pin = parsed_pin |
|
| 52 | ||
| 53 | value = str(value).lower() in HIGH_LEVEL |
|
| 54 | if self._polarity is 1: value = not value |
|
| 55 | log_output = str(log_output).lower() in HIGH_LEVEL |
|
| 56 | ||
| 57 | if pin not in self._OutputPins: return False |
|
| 58 | if log_output: logger.debug("out(pin = %s, value = %s, log_output = %s)", pin, value, log_output) |
|
| 59 | ||
| 60 | self._OutputStatus[pin] = value |
|
| 61 | return True |
|
| 62 | ||