Skip to content

Commit 16b4ea5

Browse files
committed
Added init
1 parent 8ae7c5d commit 16b4ea5

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

external_samples/rev_touch_sensor.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
from component import Component, PortType
1+
from component import Component, PortType, InvalidPortException
22
from collections.abc import Callable
33

44
class RevTouchSensor(Component):
5-
def __init__(self):
5+
def __init__(self, ports : list[tuple[PortType, int]]):
66
self.is_pressed = None
7-
7+
portType, port = ports[0]
8+
if portType != PortType.SMART_IO_PORT:
9+
raise InvalidPortException
10+
self.port = port
811
# Required methods
912
def get_manufacturer(self) -> str:
1013
return "REV Robotics"
@@ -19,6 +22,8 @@ def get_version(self) -> tuple[int, int, str]:
1922
def stop(self) -> None:
2023
pass
2124
def reset(self) -> None:
25+
self.pressed_callback = None
26+
self.released_callback = None
2227
pass
2328
def get_connection_port_type(self) -> list[PortType]:
2429
return [PortType.SMART_IO_PORT]

0 commit comments

Comments
 (0)