File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,12 @@ ETCController::ETCController()
23
23
this ->state .cockpit = false ;
24
24
}));
25
25
this ->cockpitSwitchInterrupt .fall (callback ([this ]() {
26
- this ->checkStartConditions ();
26
+ this ->cockpitSwitchTicker .attach (callback ([this ]() {
27
+ if (!cockpitSwitchInterrupt.read ()) {
28
+ this ->checkStartConditions ();
29
+ }
30
+ this ->cockpitSwitchTicker .detach ();
31
+ }), 100ms);
27
32
this ->state .cockpit = true ;
28
33
}));
29
34
this ->reverseSwitchInterrupt .rise (callback ([this ]() { this ->switchForwardMotor (); }));
@@ -131,8 +136,10 @@ void ETCController::checkStartConditions() {
131
136
132
137
133
138
void ETCController::runRTDS () {
134
- this ->rtdsOutput .write (true );
135
- this ->rtdsTicker .attach (callback ([this ] {this ->stopRTDS ();}), 1000ms);
139
+ if (!this ->rtdsOutput .read ()) {
140
+ this ->rtdsOutput .write (true );
141
+ this ->rtdsTicker .attach (callback ([this ] {this ->stopRTDS ();}), 1000ms);
142
+ }
136
143
}
137
144
138
145
Original file line number Diff line number Diff line change @@ -77,6 +77,9 @@ class ETCController {
77
77
/* * Timer for the RTDS activation. */
78
78
Ticker rtdsTicker;
79
79
80
+ /* * Ticker for debouncing cockpit switch */
81
+ Ticker cockpitSwitchTicker;
82
+
80
83
/* * State of the ETC. */
81
84
ETCState state;
82
85
@@ -153,6 +156,10 @@ class ETCController {
153
156
*/
154
157
void checkStartConditions ();
155
158
159
+ /* *
160
+ * Wait and check again before allowing starting
161
+ */
162
+ void debounceCockpitSwitch ();
156
163
157
164
/* *
158
165
* Runs the RTDS buzzer for 3 seconds.
You can’t perform that action at this time.
0 commit comments