Skip to content

Commit f18ec07

Browse files
2 parents c6635b3 + 102e5e9 commit f18ec07

4 files changed

Lines changed: 138 additions & 93 deletions

File tree

README.md

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ classDiagram
101101
+value()
102102
+high()
103103
+low()
104+
+on()
105+
+off()
104106
+toggle()
105107
}
106108
@@ -112,53 +114,65 @@ classDiagram
112114
}
113115
114116
class Audio_Notification {
115-
-__debug: bool
116-
+__init__(pin: int, debug: bool)
117-
+warning_on()
118-
+warning_off()
119-
+beep(freq: int, duration: int)
117+
- __debug: bool
118+
- __last_toggle_time: floot
119+
- __pin: int
120+
+ Audio_Notification(pin, debug=False)
121+
+ warning_on()
122+
+ warning_off()
123+
+ beep(freq=1000, duration=500)
120124
}
121125
PWM <|-- Audio_Notification : Inheritance
122126
123127
class Led_Light {
124-
-__debug: bool
125-
-__pin: int
126-
-__flashing: bool
127-
+__init__(pin: int, flashing: bool, debug: bool)
128-
+on()
129-
+off()
130-
+toggle()
131-
+flash(duration: int)
132-
+on_for(duration: int)
133-
+led_light_state: int
128+
- __debug: bool
129+
- __pin: int
130+
- __flashing: int
131+
- __last_toggle_time: float
132+
+ Led_Light(pin, flashing=False, debug=False)
133+
+ on()
134+
+ off()
135+
+ toggle()
136+
+ flash()
137+
+ led_light_state
138+
+ led_light_state(value)
134139
}
135140
Pin <|-- Led_Light : Inheritance
136141
137142
class Pedestrian_Button {
138-
-__debug: bool
139-
-__pin: int
140-
-__last_pressed: int
141-
-__pedestrian_waiting: bool
142-
+__init__(pin: int, debug: bool)
143-
+callback(pin: Pin)
144-
+button_state
145-
+reset
143+
- __pin: int
144+
- __debug: bool
145+
- __last_pressed: int
146+
- __pedestrian_waiting: bool
147+
+ Pedestrian_Button(pin, debug)
148+
+ button_state : bool
149+
+ button_state(value)
150+
+ callback(pin)
146151
}
147152
Pin <|-- Pedestrian_Button : Inheritance
148153
149154
class Controller {
150-
-__object: Led_Light
151-
-__object: Led_Light
152-
-__object: Led_Light
153-
-__object: Led_Light
154-
-__object: Led_Light
155-
-__object: Pedestrian_Button
156-
-__object: Audio_Notification
155+
- __Ped_Red: Class Led_Light
156+
- __Ped_Green: Class Led_Light
157+
- __Car_Red: Class Led_Light
158+
- __Car_Amber: Class Led_Light
159+
- __Car_Green: Class Led_Light
160+
- __Buzzer: Class Audio_Notification
161+
- __Button: Class Pedestrian_Button
162+
- bool __debug
163+
- str state
164+
- float last_state_change
165+
+ Controller(ped_red, ped_green, car_red, car_amber, car_green, button, buzzer, debug)
166+
+ walk()
167+
+ walk_warning()
168+
+ idle()
169+
+ change()
170+
+ update()
157171
}
158172
159-
Led_Light --> Controller : Composition
160-
Audio_Notification --> Controller : Composition
161-
Pedestrian_Button --> Controller : Composition
173+
Led_Light --> Controller : Association
174+
Audio_Notification --> Controller : Association
175+
Pedestrian_Button --> Controller : Association
162176
163177
```
164178

tutorials/Lecture1.md

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -119,36 +119,40 @@ classDiagram
119119
}
120120
121121
class Audio_Notification {
122-
-__debug: bool
123-
+__init__(pin: int, debug: bool)
124-
+warning_on()
125-
+warning_off()
126-
+beep(freq: int, duration: int)
122+
- __debug: bool
123+
- __last_toggle_time: floot
124+
- __pin: int
125+
+ Audio_Notification(pin, debug=False)
126+
+ warning_on()
127+
+ warning_off()
128+
+ beep(freq=1000, duration=500)
127129
}
128130
PWM <|-- Audio_Notification : Inheritance
129131
130132
class Led_Light {
131-
-__debug: bool
132-
-__pin: int
133-
-__flashing: bool
134-
+__init__(pin: int, flashing: bool, debug: bool)
135-
+on()
136-
+off()
137-
+high()
138-
+Low
139-
+toggle()
133+
- __debug: bool
134+
- __pin: int
135+
- __flashing: int
136+
- __last_toggle_time: float
137+
+ Led_Light(pin, flashing=False, debug=False)
138+
+ on()
139+
+ off()
140+
+ toggle()
141+
+ flash()
142+
+ led_light_state
143+
+ led_light_state(value)
140144
}
141145
Pin <|-- Led_Light : Inheritance
142146
143147
class Pedestrian_Button {
144-
-__debug: bool
145-
-__pin: int
146-
-__last_pressed: int
147-
-__pedestrian_waiting: bool
148-
+__init__(pin: int, debug: bool)
149-
+callback(pin: Pin)
150-
+button_state
151-
+reset
148+
- __pin: int
149+
- __debug: bool
150+
- __last_pressed: int
151+
- __pedestrian_waiting: bool
152+
+ Pedestrian_Button(pin, debug)
153+
+ button_state : bool
154+
+ button_state(value)
155+
+ callback(pin)
152156
}
153157
Pin <|-- Pedestrian_Button : Inheritance
154158

tutorials/Lecture4.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,26 @@
77

88
The `Pedestrian_Button` extends the `machine.Pin` to provide a debounced, interrupt-driven interface for a pedestrian button, with optional debug output.
99

10+
### UML
11+
12+
```mermaid
13+
classDiagram
14+
class Pin
15+
16+
class Pedestrian_Button {
17+
- __pin: int
18+
- __debug: bool
19+
- __last_pressed: int
20+
- __pedestrian_waiting: bool
21+
+ Pedestrian_Button(pin, debug)
22+
+ button_state : bool
23+
+ button_state(value)
24+
+ callback(pin)
25+
}
26+
27+
Pin <|-- Pedestrian_Button
28+
```
29+
1030
### Constructor
1131

1232
```python

tutorials/Lecture6.md

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ Association in Object-Oriented Programming (OOP) describes the relationship betw
6464
- It represents a "uses-a" or "knows-a" relationship.
6565
- The lifetime of associated objects is independent—neither object controls the lifecycle of the other.
6666

67-
6867
```mermaid
6968
classDiagram
7069
class Pin {
@@ -86,58 +85,66 @@ classDiagram
8685
}
8786
8887
class Audio_Notification {
89-
-__debug: bool
90-
+__init__(pin: int, debug: bool)
91-
+warning_on()
92-
+warning_off()
93-
+beep(freq: int, duration: int)
88+
- __debug: bool
89+
- __last_toggle_time: floot
90+
- __pin: int
91+
+ Audio_Notification(pin, debug=False)
92+
+ warning_on()
93+
+ warning_off()
94+
+ beep(freq=1000, duration=500)
9495
}
9596
PWM <|-- Audio_Notification : Inheritance
9697
9798
class Led_Light {
98-
-__debug: bool
99-
-__pin: int
100-
-__flashing: bool
101-
+__init__(pin: int, flashing: bool, debug: bool)
102-
+on()
103-
+off()
104-
+high()
105-
+Low
106-
+toggle()
99+
- __debug: bool
100+
- __pin: int
101+
- __flashing: int
102+
- __last_toggle_time: float
103+
+ Led_Light(pin, flashing=False, debug=False)
104+
+ on()
105+
+ off()
106+
+ toggle()
107+
+ flash()
108+
+ led_light_state
109+
+ led_light_state(value)
107110
}
108111
Pin <|-- Led_Light : Inheritance
109112
110113
class Pedestrian_Button {
111-
-__debug: bool
112-
-__pin: int
113-
-__last_pressed: int
114-
-__pedestrian_waiting: bool
115-
+__init__(pin: int, debug: bool)
116-
+callback(pin: Pin)
117-
+button_state
118-
+reset
114+
- __pin: int
115+
- __debug: bool
116+
- __last_pressed: int
117+
- __pedestrian_waiting: bool
118+
+ Pedestrian_Button(pin, debug)
119+
+ button_state : bool
120+
+ button_state(value)
121+
+ callback(pin)
119122
}
120123
Pin <|-- Pedestrian_Button : Inheritance
121124
122125
class Controller {
123-
-self.__Ped_Red = ped_red
124-
-self.__Ped_Green = ped_green
125-
-self.__Car_Red = car_red
126-
-self.__Car_Amber = car_amber
127-
-self.__Car_Green = car_green
128-
-self.__Buzzer = buzzer
129-
-self.__Button = button
130-
-self.__debug = debug
131-
+update()
132-
+walk_on()
133-
+walk_off()
134-
+walk_warning()
135-
+change()
126+
- __Ped_Red: Class Led_Light
127+
- __Ped_Green: Class Led_Light
128+
- __Car_Red: Class Led_Light
129+
- __Car_Amber: Class Led_Light
130+
- __Car_Green: Class Led_Light
131+
- __Buzzer: Class Audio_Notification
132+
- __Button: Class Pedestrian_Button
133+
- bool __debug
134+
- str state
135+
- float last_state_change
136+
+ Controller(ped_red, ped_green, car_red, car_amber, car_green, button, buzzer, debug)
137+
+ walk()
138+
+ walk_warning()
139+
+ idle()
140+
+ change()
141+
+ update()
136142
}
137143
138-
Led_Light --> Controller: Association
144+
Led_Light --> Controller : Association
145+
Audio_Notification --> Controller : Association
139146
Pedestrian_Button --> Controller : Association
140-
Audio_Notification --> Controller: Association
147+
141148
```
142149

143150
### Setup differnet states of the controller using association

0 commit comments

Comments
 (0)