Files
2026-09-11 16:55:54 +08:00

37 lines
1.1 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""diwatch — 统一 DI 输入监听库,适配 SE5 / SE9。
对外主要 API:
from diwatch import DIChannel, EventBackend, SysfsBackend, make_in1_backend
# IN1(自动选后端)
ch = DIChannel("IN1", backend=make_in1_backend(), active_low=True)
ch.on_press = lambda ts: print("有电", ts)
ch.on_release = lambda ts: print("断电", ts)
ch.run()
# IN2(sysfs 轮询)
ch2 = DIChannel("IN2",
backend=SysfsBackend("/sys/bus/platform/devices/gpio-in-2/gpio_status"),
active_low=False)
ch2.on_change = lambda old, new, ts: print(f"{old}->{new}", ts)
ch2.run(duration=10)
"""
from .core import DIChannel, fmt_dur, now_str
from .backends import (
EventBackend, SysfsBackend, make_backend,
make_in1_backend, find_status_file,
)
from .devicetree import derive_gpio
__all__ = [
"DIChannel", "fmt_dur", "now_str",
"EventBackend", "SysfsBackend", "make_backend",
"make_in1_backend", "find_status_file", "derive_gpio",
]
__version__ = "1.1.0"