You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorials/Lecture4.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,13 +5,13 @@
5
5
-[Class Overview](#class-overview)
6
6
-[Create Files](#create-files)
7
7
-[Imports and Constructor](#imports-and-constructor)
8
-
-[Implement an Interupt](#implement-an-interupt)
8
+
-[Implement an Interrupt](#implement-an-interrupt)
9
9
-[Getter and Setter](#getter-and-setter)
10
-
-[Create a Callback Method for the Interupt Trigger](#create-a-callback-method-for-the-interupt-trigger)
10
+
-[Create a Callback Method for the Interrupt Trigger](#create-a-callback-method-for-the-interrupt-trigger)
11
11
12
12
## Class Overview
13
13
14
-
The Pedestrian_Button class extends the machine.Pin class to provide a debounced button interface specifically designed for pedestrian crossing systems. It uses interrupt-based detection and software debouncing to reliably capture button presses. It also provides optional debug output.
14
+
The Pedestrian_Button class extends the Pin class to provide a debounced button interface specifically designed for pedestrian crossing systems. It uses interrupt-based detection and software debouncing to reliably capture button presses. It also provides optional debug output.
15
15
16
16
## Create Files
17
17
@@ -20,7 +20,7 @@ The Pedestrian_Button class extends the machine.Pin class to provide a debounced
20
20
21
21
## Imports and Constructor
22
22
23
-
In your `pedestrian_button.py` include your imports, define the class and configure the initialiser with the paramters pin and debug. Add the required parameters to store time and hold state when the button has been pressed.
23
+
In your `pedestrian_button.py` include your imports, define the class and configure the initialiser with the parameters pin and debug. Add the required parameters to store time and hold state if the button has been pressed.
24
24
25
25
```python
26
26
from machine import Pin
@@ -41,7 +41,7 @@ class Pedestrian_Button(Pin):
41
41
) # Set up interrupt on rising edge
42
42
```
43
43
44
-
## Implement an Interupt
44
+
## Implement an Interrupt
45
45
46
46
An interrupt is a signal to the processor that an event needs immediate attention. Instead of constantly checking (polling) if something has happened, interrupts allow the system to be notified immediately when an event occurs.
47
47
@@ -62,7 +62,7 @@ class Pedestrian_Button(Pin):
62
62
63
63
## Getter and Setter
64
64
65
-
Our system has a design requirement that the button state is stored until the walk lights have been displayed. So because we are not setting or getting the current state of the button as we did with the LED_Light Class, we will use an Adhoc method that updates the `__pedestrian_waiting` attribute.
65
+
Our system has a design requirement that the button state is stored until the walk lights have been displayed. So, because we are not setting or getting the current state of the button as we did with the LED_Light Class, we will use an ad hoc method that updates the `__pedestrian_waiting` attribute.
66
66
67
67
- If `button_state()` is called with no arguments, it returns the current state (getter).
68
68
- If `button_state(bool)` is called with a boolean argument, it sets the state (setter).
@@ -86,9 +86,9 @@ Our system has a design requirement that the button state is stored until the wa
86
86
)
87
87
```
88
88
89
-
## Create a Callback Method for the Interupt Trigger
89
+
## Create a Callback Method for the Interrupt Trigger
90
90
91
-
This `clallback()` was configured in the attributes and will be executed in response to an interupt call.
91
+
This `callback()` was configured in the attributes and will be executed in response to an interrupt call.
92
92
93
93
```python
94
94
defcallback(self, pin):
@@ -100,4 +100,4 @@ This `clallback()` was configured in the attributes and will be executed in resp
100
100
self.__pedestrian_waiting =True
101
101
ifself.__debug:
102
102
print(f"Button pressed on Pin {self.__pin} at {current_time}ms")
0 commit comments