Skip to content

Commit 2858717

Browse files
committed
Add periodic method
1 parent 388dd1e commit 2858717

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

external_samples/component.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ def get_version(self) -> tuple[int, int, str]:
3939
def stop(self) -> None:
4040
pass
4141

42-
# any reset required (if any) after it has stopped before it can be used
42+
# any reset required (if any) at the beginning of each opmode
43+
# This might remove any registered callbacks
4344
@abstractmethod
4445
def reset(self) -> None:
4546
pass
@@ -48,4 +49,9 @@ def reset(self) -> None:
4849
# of the PortType enumeration
4950
@abstractmethod
5051
def get_connection_port_type(self) -> list[PortType]:
52+
pass
53+
54+
# This is called periodically when an opmode is running
55+
@abstractmethod
56+
def periodic(self) -> None:
5157
pass

external_samples/rev_touch_sensor.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ def reset(self) -> None:
1919
pass
2020
def get_connection_port_type(self) -> list[PortType]:
2121
return [PortType.SMART_IO_PORT]
22+
def periodic(self) -> None:
23+
# This would poll the hardware and see if it needs to fire any events
24+
pass
2225

2326
# Methods
2427
def is_pressed(self) -> bool:

0 commit comments

Comments
 (0)