Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
STM with Timeout
Es ist nach dem Start ein Timeout von 3 Sekunden zu implementieren, sodass die LED1 entweder nach drücken der Taste oder nach 3 Sekunden automatisch auf gelöscht wird.
Sie können folgende Codeteile für Integration in die STM-Klasse verwenden:
Timeout Function
Timeout to;
bool _timeout;
void flip() {
_timeout = true;
}
bool CheckTimeOut() {
if( _timeout ){
_timeout=false;
return true;
}
return false;
}
State Function
void ST_Ein(){
// entry
to.attach(&flip, 3.0); // Timeout von 3 Sekunden starten
// do
while(true) {
led1 = 1;
if(CheckFlag() || CheckTimeOut()) {
state = ST_AUS;
to.detach(); // Timeout abstellen
// exit
return;
}
}
}