Skip to content

Commit 7dd77bf

Browse files
improve UML
1 parent 3d14cdf commit 7dd77bf

6 files changed

Lines changed: 182 additions & 90 deletions

File tree

README.md

Lines changed: 46 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,64 @@ 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+
- bool __debug
118+
- float _last_toggle_time
119+
+ Audio_Notification(pin, debug=False)
120+
+ warning_on()
121+
+ warning_off()
122+
+ beep(freq=1000, duration=500)
120123
}
121124
PWM <|-- Audio_Notification : Inheritance
122125
123126
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
127+
- bool __debug
128+
- int __pin
129+
- bool __flashing
130+
- float __last_toggle_time
131+
+ Led_Light(pin, flashing=False, debug=False)
132+
+ on()
133+
+ off()
134+
+ toggle()
135+
+ flash()
136+
+ led_light_state
137+
+ led_light_state(value)
134138
}
135139
Pin <|-- Led_Light : Inheritance
136140
137141
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
142+
- int __pin
143+
- bool __debug
144+
- int __last_pressed
145+
- bool __pedestrian_waiting
146+
+ Pedestrian_Button(pin, debug)
147+
+ button_state : bool
148+
+ button_state(value)
149+
+ callback(pin)
146150
}
147151
Pin <|-- Pedestrian_Button : Inheritance
148152
149153
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
154+
- Led_Light __Ped_Red
155+
- Led_Light __Ped_Green
156+
- Led_Light __Car_Red
157+
- Led_Light __Car_Amber
158+
- Led_Light __Car_Green
159+
- Audio_Notification __Buzzer
160+
- Pedestrian_Button __Button
161+
- bool __debug
162+
- str state
163+
- float last_state_change
164+
+ Controller(ped_red, ped_green, car_red, car_amber, car_green, button, buzzer, debug)
165+
+ walk()
166+
+ walk_warning()
167+
+ idle()
168+
+ change()
169+
+ update()
157170
}
158171
159-
Led_Light --> Controller : Composition
160-
Audio_Notification --> Controller : Composition
161-
Pedestrian_Button --> Controller : Composition
172+
Led_Light --> Controller : Association
173+
Audio_Notification --> Controller : Association
174+
Pedestrian_Button --> Controller : Association
162175
163176
```
164177

tutorials/Lecture1.md

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -97,36 +97,39 @@ classDiagram
9797
}
9898
9999
class Audio_Notification {
100-
-__debug: bool
101-
+__init__(pin: int, debug: bool)
102-
+warning_on()
103-
+warning_off()
104-
+beep(freq: int, duration: int)
100+
- bool __debug
101+
- float _last_toggle_time
102+
+ Audio_Notification(pin, debug=False)
103+
+ warning_on()
104+
+ warning_off()
105+
+ beep(freq=1000, duration=500)
105106
}
106107
PWM <|-- Audio_Notification : Inheritance
107108
108109
class Led_Light {
109-
-__debug: bool
110-
-__pin: int
111-
-__flashing: bool
112-
+__init__(pin: int, flashing: bool, debug: bool)
113-
+on()
114-
+off()
115-
+high()
116-
+Low
117-
+toggle()
110+
- bool __debug
111+
- int __pin
112+
- bool __flashing
113+
- float __last_toggle_time
114+
+ Led_Light(pin, flashing=False, debug=False)
115+
+ on()
116+
+ off()
117+
+ toggle()
118+
+ flash()
119+
+ led_light_state
120+
+ led_light_state(value)
118121
}
119122
Pin <|-- Led_Light : Inheritance
120123
121124
class Pedestrian_Button {
122-
-__debug: bool
123-
-__pin: int
124-
-__last_pressed: int
125-
-__pedestrian_waiting: bool
126-
+__init__(pin: int, debug: bool)
127-
+callback(pin: Pin)
128-
+button_state
129-
+reset
125+
- int __pin
126+
- bool __debug
127+
- int __last_pressed
128+
- bool __pedestrian_waiting
129+
+ Pedestrian_Button(pin, debug)
130+
+ button_state : bool
131+
+ button_state(value)
132+
+ callback(pin)
130133
}
131134
Pin <|-- Pedestrian_Button : Inheritance
132135

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` class extends the `machine.Pin` class 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+
- int __pin
18+
- bool __debug
19+
- int __last_pressed
20+
- bool __pedestrian_waiting
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/Lecture5.md

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

88
The `Audio_Notification` class extends the `machine.PWM` class to provide an interface for controlling a piezo buzzer or speaker, with optional debug output. It supports warning beeps and custom tones.
99

10+
### UML
11+
12+
```mermaid
13+
classDiagram
14+
class PWM
15+
16+
class Audio_Notification {
17+
- bool __debug
18+
- float _last_toggle_time
19+
+ Audio_Notification(pin, debug=False)
20+
+ warning_on()
21+
+ warning_off()
22+
+ beep(freq=1000, duration=500)
23+
}
24+
25+
PWM <|-- Audio_Notification
26+
```
27+
1028
### Constructor
1129

1230
```python

tutorials/Lecture6.md

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -86,53 +86,59 @@ classDiagram
8686
}
8787
8888
class Audio_Notification {
89-
-__debug: bool
90-
+__init__(pin: int, debug: bool)
91-
+warning_on()
92-
+warning_off()
93-
+beep(freq: int, duration: int)
89+
- bool __debug
90+
- float _last_toggle_time
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+
- bool __debug
100+
- int __pin
101+
- bool __flashing
102+
- float __last_toggle_time
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+
- int __pin
115+
- bool __debug
116+
- int __last_pressed
117+
- bool __pedestrian_waiting
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+
- Led_Light __Ped_Red
127+
- Led_Light __Ped_Green
128+
- Led_Light __Car_Red
129+
- Led_Light __Car_Amber
130+
- Led_Light __Car_Green
131+
- Audio_Notification __Buzzer
132+
- Pedestrian_Button __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
138144
Led_Light --> Controller: Association

tutorials/Lecture7.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,38 @@ Key concepts:
5959

6060
The `Controller` class manages the state machine for a pedestrian crossing system, coordinating LEDs, buzzer, and button input. It handles the sequence of traffic and pedestrian signals based on button presses and timing.
6161

62+
### UML
63+
64+
```mermaid
65+
classDiagram
66+
class Led_Light
67+
class Pedestrian_Button
68+
class Audio_Notification
69+
70+
class Controller {
71+
- Led_Light __Ped_Red
72+
- Led_Light __Ped_Green
73+
- Led_Light __Car_Red
74+
- Led_Light __Car_Amber
75+
- Led_Light __Car_Green
76+
- Audio_Notification __Buzzer
77+
- Pedestrian_Button __Button
78+
- bool __debug
79+
- str state
80+
- float last_state_change
81+
+ Controller(ped_red, ped_green, car_red, car_amber, car_green, button, buzzer, debug)
82+
+ walk()
83+
+ walk_warning()
84+
+ idle()
85+
+ change()
86+
+ update()
87+
}
88+
89+
Led_Light --> Controller : Association
90+
Audio_Notification --> Controller : Association
91+
Pedestrian_Button --> Controller : Association
92+
```
93+
6294
### Constructor
6395

6496
```python

0 commit comments

Comments
 (0)