boneIO 0.6.3.dev1__py3-none-any.whl → 0.6.3.dev2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {boneIO-0.6.3.dev1.dist-info → boneIO-0.6.3.dev2.dist-info}/METADATA +1 -1
- {boneIO-0.6.3.dev1.dist-info → boneIO-0.6.3.dev2.dist-info}/RECORD +10 -10
- boneio/helper/click_timer.py +11 -15
- boneio/helper/gpio.py +19 -1
- boneio/input/gpio.py +49 -32
- boneio/schema/schema.yaml +1 -1
- boneio/version.py +1 -1
- {boneIO-0.6.3.dev1.dist-info → boneIO-0.6.3.dev2.dist-info}/WHEEL +0 -0
- {boneIO-0.6.3.dev1.dist-info → boneIO-0.6.3.dev2.dist-info}/entry_points.txt +0 -0
- {boneIO-0.6.3.dev1.dist-info → boneIO-0.6.3.dev2.dist-info}/licenses/LICENSE +0 -0
|
@@ -13,12 +13,12 @@ boneio/example_config/output32x5A.yaml,sha256=G2Pb6qL8mXs6MliIM1roAanPag9ozRe3Mc
|
|
|
13
13
|
boneio/fonts/danube__.ttf,sha256=KBRPUcGvmroCjrWC8zK4MulUb9lV8R0lXkOY7lNnQWc,19372
|
|
14
14
|
boneio/helper/__init__.py,sha256=r-9dubCtDlrs_HFF2OGPQEPmw1XREgb4qQF6I486Li4,2039
|
|
15
15
|
boneio/helper/async_updater.py,sha256=BVh5mXFxgaZqoekjQbQSCTssfyVIdCQ80LCJny-rOo4,985
|
|
16
|
-
boneio/helper/click_timer.py,sha256=
|
|
16
|
+
boneio/helper/click_timer.py,sha256=dVYdX3VNpAEKHCIqWs3u0PCJLSPIGr0K2kMffc_kGdc,1138
|
|
17
17
|
boneio/helper/config.py,sha256=tOYbr6Axf-91eHyCgRNuIkSC7nrAFO0XVqImajpPpZI,2277
|
|
18
18
|
boneio/helper/events.py,sha256=EHYJy507RF1LikWQ2s4r990JRvR9rO4z7FkaJqt1Mrk,7494
|
|
19
19
|
boneio/helper/exceptions.py,sha256=vyYSUojwB7OttOPUjbxeHFM7C_o5ZQmRUcZ_vYpxYYI,717
|
|
20
20
|
boneio/helper/filter.py,sha256=UcjifjaC5wHDW2He7wmwCX2IjSSeLVhXyhrXHeT8RmA,885
|
|
21
|
-
boneio/helper/gpio.py,sha256=
|
|
21
|
+
boneio/helper/gpio.py,sha256=sxvkYtKVt5alGoXFBRzG8ONEo112fsKsX-zK2C-_YKg,3249
|
|
22
22
|
boneio/helper/ha_discovery.py,sha256=s80gwx1Fik2_vtq-6kqabUqPx4KwwZUt4G1Oy6RgGgU,6278
|
|
23
23
|
boneio/helper/loader.py,sha256=dKlk42tI7RkyI_FmX6CneN3FIGnHQ55c20sfn11B_bk,13547
|
|
24
24
|
boneio/helper/logger.py,sha256=zyF_Vk3o2eSHuXypJhNzK99eZgkWDWybuB5KcJgurDs,1801
|
|
@@ -35,7 +35,7 @@ boneio/helper/timeperiod.py,sha256=xpg9oe30Z5WiLDQPq3EBKKScejOnN47NhcpeFvDd3bY,5
|
|
|
35
35
|
boneio/helper/util.py,sha256=QfSoT3H3WnOQAKO5bFRIBCy62HT5NMa9Ek-FmfTW_rw,508
|
|
36
36
|
boneio/helper/yaml_util.py,sha256=gAX7hCaHUlPgkhGCIQ4zjv0Vj9JmLzQsSyF51ZmSb9g,11304
|
|
37
37
|
boneio/input/__init__.py,sha256=u9wuehuC_TNizL4tyn7EygZW5LaTFjSnFaZeZr3zZ1U,99
|
|
38
|
-
boneio/input/gpio.py,sha256=
|
|
38
|
+
boneio/input/gpio.py,sha256=vldjzyi-gFqRJUw6Jucj56XXbVQxriLpZtWDcRnFQz0,3440
|
|
39
39
|
boneio/manager.py,sha256=ZldVPnmQ_IRu3ldj7p2HR0-tobNeRjRf2pBM3V3qm-E,20922
|
|
40
40
|
boneio/modbus.py,sha256=eA_sGnmdcIneXX75ZcXOI223-UkKN1UYmWFqiJBAhJo,4176
|
|
41
41
|
boneio/mqtt_client.py,sha256=NYvok8y_g8iRXDopVojzcDGVnDJEFqHBEYhOGy8m7T8,8331
|
|
@@ -52,7 +52,7 @@ boneio/schema/actions_switch.yaml,sha256=sdqhwz0LrcfaiAN3-RfAR_xApxo5dh9RxXQubuK
|
|
|
52
52
|
boneio/schema/filters.yaml,sha256=WopX1SmCZsSZXNiGccLoi7uMCsUpdbs0eVfsAjmbay4,286
|
|
53
53
|
boneio/schema/filters_adc.yaml,sha256=3e0ts92MoFKOnfGOOn6WYIHxu0-tnZe9OjAjN9m7hiI,304
|
|
54
54
|
boneio/schema/id.yaml,sha256=vHI_6dxkJwoiGp5ien_pPpyaWA1F06eirTgfWMyWa1E,75
|
|
55
|
-
boneio/schema/schema.yaml,sha256=
|
|
55
|
+
boneio/schema/schema.yaml,sha256=47FIR47bF6VemVJ_prE3D-d0leXlKFhZXuJYGfc9Rds,12988
|
|
56
56
|
boneio/schema/temp_unit.yaml,sha256=m32VGz9RTW92Lz08l9n6RftkcVNZquOGPPr5mc3eZVc,65
|
|
57
57
|
boneio/schema/update_interval.yaml,sha256=L_YLddAZdybcdO-T57Qhlv1GaWIVDwhvH-GadD1oOIo,133
|
|
58
58
|
boneio/sensor/__init__.py,sha256=VjFBEQQv_U0T2ENkzefuBdzmqNvBTEv4M-gQKScc8o0,431
|
|
@@ -69,9 +69,9 @@ boneio/sensor/temp/__init__.py,sha256=OViqBb7DwVn_aFIy6V0iqkSUDjsDNLQ5sOS_4frYdw
|
|
|
69
69
|
boneio/sensor/temp/dallas.py,sha256=xrvd1LNBh1fRcjz_yd_9S29Lv26ItVtLCmhZgVQWJos,2485
|
|
70
70
|
boneio/sensor/temp/lm75.py,sha256=-mpOv78429plRPBp9s09Ljz1x2Bdxuagalqz40vlAKE,243
|
|
71
71
|
boneio/sensor/temp/mcp9808.py,sha256=yAh5yJzZLGTqa39xV4fyqsruj7oy3niOZAUV2W6eyCM,271
|
|
72
|
-
boneio/version.py,sha256=
|
|
73
|
-
boneIO-0.6.3.
|
|
74
|
-
boneIO-0.6.3.
|
|
75
|
-
boneIO-0.6.3.
|
|
76
|
-
boneIO-0.6.3.
|
|
77
|
-
boneIO-0.6.3.
|
|
72
|
+
boneio/version.py,sha256=lELkUhPyqz9wrO0Yfi4xgdYwqNB6En4AmL1Or73si50,42
|
|
73
|
+
boneIO-0.6.3.dev2.dist-info/entry_points.txt,sha256=Igl1SMDEWwMg144bwRz28UOCb80hdxomC99QJ3u6qC0,46
|
|
74
|
+
boneIO-0.6.3.dev2.dist-info/WHEEL,sha256=B19PGBCYhWaz2p_UjAoRVh767nYQfk14Sn4TpIZ-nfU,87
|
|
75
|
+
boneIO-0.6.3.dev2.dist-info/METADATA,sha256=zJ01oNSWDqEAVffzyM8MNdNnwToTq9A-Zvle3K69ES0,1699
|
|
76
|
+
boneIO-0.6.3.dev2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
77
|
+
boneIO-0.6.3.dev2.dist-info/RECORD,,
|
boneio/helper/click_timer.py
CHANGED
|
@@ -1,37 +1,33 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
import asyncio
|
|
3
|
-
from boneio.helper.
|
|
4
|
-
|
|
3
|
+
from boneio.helper.timeperiod import TimePeriod
|
|
4
|
+
import time
|
|
5
5
|
|
|
6
6
|
class ClickTimer:
|
|
7
7
|
"""Represent async call later function with variable to check if timing is ON."""
|
|
8
8
|
|
|
9
|
-
def __init__(self, delay:
|
|
9
|
+
def __init__(self, delay: TimePeriod, action) -> None:
|
|
10
10
|
"""Initialize Click timer."""
|
|
11
11
|
self._loop = asyncio.get_running_loop()
|
|
12
12
|
self._remove_listener = None
|
|
13
|
-
self._delay = delay
|
|
13
|
+
self._delay: float = delay.total_in_seconds
|
|
14
14
|
self._action = action
|
|
15
15
|
|
|
16
16
|
def is_waiting(self) -> bool:
|
|
17
17
|
"""If variable is set then timer is ON, if None is Off."""
|
|
18
18
|
return self._remove_listener is not None
|
|
19
19
|
|
|
20
|
-
def action(self, x: float) -> None:
|
|
21
|
-
"""Reset Call later variable and call action."""
|
|
22
|
-
self.reset()
|
|
23
|
-
self._action(x)
|
|
24
|
-
|
|
25
20
|
def reset(self) -> None:
|
|
26
21
|
"""Uninitialize variable remove_listener."""
|
|
27
22
|
if self._remove_listener:
|
|
28
|
-
self._remove_listener()
|
|
23
|
+
self._remove_listener.cancel()
|
|
29
24
|
self._remove_listener = None
|
|
30
25
|
|
|
26
|
+
async def _start_async_timer(self) -> None:
|
|
27
|
+
await asyncio.sleep(self._delay)
|
|
28
|
+
self._remove_listener = None
|
|
29
|
+
self._action(time.time())
|
|
30
|
+
|
|
31
31
|
def start_timer(self) -> None:
|
|
32
32
|
"""Start timer."""
|
|
33
|
-
self._remove_listener =
|
|
34
|
-
loop=self._loop,
|
|
35
|
-
action=self.action,
|
|
36
|
-
delay=self._delay,
|
|
37
|
-
)
|
|
33
|
+
self._remove_listener = self._loop.create_task(self._start_async_timer())
|
boneio/helper/gpio.py
CHANGED
|
@@ -80,6 +80,24 @@ def edge_detect(
|
|
|
80
80
|
GPIO.add_event_detect(gpio=pin, edge=edge, callback=callback, bouncetime=bounce)
|
|
81
81
|
except RuntimeError as err:
|
|
82
82
|
raise GPIOInputException(err)
|
|
83
|
+
|
|
84
|
+
def add_event_detect(
|
|
85
|
+
pin: str, edge: Gpio_Edges = FALLING
|
|
86
|
+
) -> None:
|
|
87
|
+
"""Add detection for RISING and FALLING events."""
|
|
88
|
+
try:
|
|
89
|
+
GPIO.add_event_detect(gpio=pin, edge=edge)
|
|
90
|
+
except RuntimeError as err:
|
|
91
|
+
raise GPIOInputException(err)
|
|
92
|
+
|
|
93
|
+
def add_event_callback(
|
|
94
|
+
pin: str, callback: Callable
|
|
95
|
+
) -> None:
|
|
96
|
+
"""Add detection for RISING and FALLING events."""
|
|
97
|
+
try:
|
|
98
|
+
GPIO.add_event_callback(gpio=pin,callback=callback)
|
|
99
|
+
except RuntimeError as err:
|
|
100
|
+
raise GPIOInputException(err)
|
|
83
101
|
|
|
84
102
|
|
|
85
103
|
class GpioBaseClass:
|
|
@@ -91,7 +109,7 @@ class GpioBaseClass:
|
|
|
91
109
|
"""Setup GPIO Input Button"""
|
|
92
110
|
self._pin = pin
|
|
93
111
|
gpio_mode = kwargs.get(GPIO_MODE, GPIO_STR)
|
|
94
|
-
self._bounce_time = kwargs.get("bounce_time", TimePeriod(milliseconds=
|
|
112
|
+
self._bounce_time = kwargs.get("bounce_time", TimePeriod(milliseconds=50))
|
|
95
113
|
self._loop = asyncio.get_running_loop()
|
|
96
114
|
self._press_callback = press_callback
|
|
97
115
|
setup_input(pin=self._pin, pull_mode=gpio_mode)
|
boneio/input/gpio.py
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
"""GPIOInputButton to receive signals."""
|
|
2
2
|
from __future__ import annotations
|
|
3
|
+
import time
|
|
3
4
|
import logging
|
|
4
|
-
import asyncio
|
|
5
5
|
from functools import partial
|
|
6
|
-
from boneio.const import DOUBLE, LONG, SINGLE, ClickTypes
|
|
6
|
+
from boneio.const import DOUBLE, LONG, SINGLE, ClickTypes, BOTH
|
|
7
7
|
from boneio.helper import GpioBaseClass, ClickTimer
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
from boneio.helper.gpio import add_event_callback, add_event_detect
|
|
9
|
+
from boneio.helper.timeperiod import TimePeriod
|
|
10
10
|
# TIMINGS FOR BUTTONS
|
|
11
11
|
|
|
12
|
-
DOUBLE_CLICK_DURATION_MS = 350
|
|
13
|
-
LONG_PRESS_DURATION_MS = 600
|
|
14
12
|
|
|
15
13
|
_LOGGER = logging.getLogger(__name__)
|
|
16
14
|
|
|
15
|
+
PERIOD_TO_WAIT_FOR_SECOND_PRESS_MS = 30
|
|
16
|
+
DOUBLE_CLICK_DURATION_MS = 250
|
|
17
|
+
LONG_PRESS_DURATION_MS = 500
|
|
17
18
|
|
|
18
19
|
class GpioInputButton(GpioBaseClass):
|
|
19
20
|
"""Represent Gpio input switch."""
|
|
@@ -22,52 +23,68 @@ class GpioInputButton(GpioBaseClass):
|
|
|
22
23
|
"""Setup GPIO Input Button"""
|
|
23
24
|
super().__init__(**kwargs)
|
|
24
25
|
self._state = self.is_pressed
|
|
25
|
-
|
|
26
|
+
self.button_pressed_time = 0.0
|
|
27
|
+
self._debounce_time: float = self._bounce_time.total_in_seconds
|
|
28
|
+
|
|
29
|
+
self._timer_single = ClickTimer(
|
|
30
|
+
delay=TimePeriod(milliseconds=PERIOD_TO_WAIT_FOR_SECOND_PRESS_MS),
|
|
31
|
+
action=lambda x: self.press_callback(click_type=SINGLE),
|
|
32
|
+
)
|
|
33
|
+
|
|
26
34
|
self._timer_double = ClickTimer(
|
|
27
|
-
delay=DOUBLE_CLICK_DURATION_MS,
|
|
35
|
+
delay=TimePeriod(milliseconds=DOUBLE_CLICK_DURATION_MS),
|
|
28
36
|
action=lambda x: self.double_click_press_callback(),
|
|
29
37
|
)
|
|
30
38
|
self._timer_long = ClickTimer(
|
|
31
|
-
delay=LONG_PRESS_DURATION_MS,
|
|
39
|
+
delay=TimePeriod(milliseconds=LONG_PRESS_DURATION_MS),
|
|
32
40
|
action=lambda x: self.press_callback(click_type=LONG),
|
|
33
41
|
)
|
|
34
42
|
self._double_click_ran = False
|
|
35
43
|
self._is_waiting_for_second_click = False
|
|
36
44
|
self._long_press_ran = False
|
|
37
|
-
asyncio.create_task(self._run())
|
|
38
45
|
|
|
39
|
-
|
|
40
|
-
self.
|
|
41
|
-
|
|
42
|
-
)
|
|
46
|
+
add_event_detect(pin=self._pin, edge=BOTH)
|
|
47
|
+
add_event_callback(pin=self._pin, callback=self.check_state)
|
|
48
|
+
_LOGGER.debug("Configured listening for input pin %s", self._pin)
|
|
43
49
|
|
|
44
50
|
def double_click_press_callback(self):
|
|
45
51
|
self._is_waiting_for_second_click = False
|
|
46
52
|
if not self._state and not self._timer_long.is_waiting():
|
|
47
53
|
self.press_callback(click_type=SINGLE)
|
|
48
54
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
self._timer_double.start_timer()
|
|
66
|
-
self._is_waiting_for_second_click = True
|
|
55
|
+
def check_state(self, channel) -> None:
|
|
56
|
+
self._state = self.is_pressed
|
|
57
|
+
time_now = time.time()
|
|
58
|
+
if self._state:
|
|
59
|
+
if time_now - self.button_pressed_time >= self._debounce_time:
|
|
60
|
+
self.button_pressed_time = time_now
|
|
61
|
+
self._timer_long.start_timer()
|
|
62
|
+
self._timer_single.reset()
|
|
63
|
+
if self._timer_double.is_waiting():
|
|
64
|
+
self._double_click_ran = True
|
|
65
|
+
self.press_callback(click_type=DOUBLE)
|
|
66
|
+
self._is_waiting_for_second_click = False
|
|
67
|
+
return
|
|
68
|
+
else:
|
|
69
|
+
self._timer_double.start_timer()
|
|
70
|
+
self._is_waiting_for_second_click = True
|
|
67
71
|
|
|
68
72
|
else:
|
|
69
73
|
if not self._is_waiting_for_second_click and not self._double_click_ran:
|
|
70
74
|
if self._timer_long.is_waiting():
|
|
71
75
|
self.press_callback(click_type=SINGLE)
|
|
76
|
+
elif self._is_waiting_for_second_click:
|
|
77
|
+
self._timer_single.start_timer()
|
|
72
78
|
self._timer_long.reset()
|
|
73
79
|
self._double_click_ran = False
|
|
80
|
+
|
|
81
|
+
def reset_all_timers(self) -> None:
|
|
82
|
+
self._timer_single.reset()
|
|
83
|
+
self._timer_double.reset()
|
|
84
|
+
self._timer_long.reset()
|
|
85
|
+
|
|
86
|
+
def press_callback(self, click_type: ClickTypes):
|
|
87
|
+
self.reset_all_timers()
|
|
88
|
+
self._loop.call_soon(
|
|
89
|
+
partial(self._press_callback, click_type, self._pin)
|
|
90
|
+
)
|
boneio/schema/schema.yaml
CHANGED
boneio/version.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
# flake8: noqa
|
|
2
|
-
__version__ = "0.6.
|
|
2
|
+
__version__ = "0.6.3_dev2"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|