... | @@ -35,7 +35,6 @@ Here we define three possible events: `EV_1`, `EV_2` and `EV_3`. |
... | @@ -35,7 +35,6 @@ Here we define three possible events: `EV_1`, `EV_2` and `EV_3`. |
|
```cpp
|
|
```cpp
|
|
#pragma once
|
|
#pragma once
|
|
|
|
|
|
#include "Common.h"
|
|
|
|
#include "events/EventHandler.h"
|
|
#include "events/EventHandler.h"
|
|
|
|
|
|
enum ExampleEvents : uint8_t
|
|
enum ExampleEvents : uint8_t
|
... | @@ -101,7 +100,7 @@ int main() |
... | @@ -101,7 +100,7 @@ int main() |
|
evh.postEvent(Event{EV_2});
|
|
evh.postEvent(Event{EV_2});
|
|
Thread::sleep(100);
|
|
Thread::sleep(100);
|
|
|
|
|
|
evh.postEvent(Event{EV_3});
|
|
evh.postEvent(Event{EV_3}); // event not handled by MyEventHandler
|
|
Thread::sleep(100);
|
|
Thread::sleep(100);
|
|
|
|
|
|
evh.stop(); // it posts an EV_EMPTY to wake up the thread
|
|
evh.stop(); // it posts an EV_EMPTY to wake up the thread
|
... | @@ -117,15 +116,9 @@ int main() |
... | @@ -117,15 +116,9 @@ int main() |
|
Remember to add the `test-myeventhandler.cpp` to `sbs.conf` and to specify all the needed includes.
|
|
Remember to add the `test-myeventhandler.cpp` to `sbs.conf` and to specify all the needed includes.
|
|
After you run the example you should see the following output:
|
|
After you run the example you should see the following output:
|
|
```sh
|
|
```sh
|
|
Starting Kernel... Ok
|
|
|
|
Miosix v2.11 (stm32f407vg_stm32f4discovery, Oct 28 2020 11:21:38, gcc 9.2.0-mp3.1)
|
|
|
|
Mounting MountpointFs as / ... Ok
|
|
|
|
Mounting DevFs as /dev ... Ok
|
|
|
|
Mounting Fat32Fs as /sd ... Failed
|
|
|
|
Available heap 90688 out of 131072 Bytes
|
|
|
|
0.13> Received EV_1
|
|
0.13> Received EV_1
|
|
0.23> Received EV_2
|
|
0.23> Received EV_2
|
|
0.33> Invalid event
|
|
0.33> Invalid event
|
|
0.43> Invalid event
|
|
0.43> Invalid event
|
|
```
|
|
```
|
|
The last "Invalid event" is due to the `EV_EMPTY` posted by the `stop()` method. |
|
The last "Invalid event" is due to the `EV_EMPTY` posted by the `stop()` method of the EventHandler object. |
|
\ No newline at end of file |
|
\ No newline at end of file |