Hello, welcome back and listen, we'll see how to work with event flux using our Simms's artist Apeace.
I'm going to make a copy of our last project over here.
The last project was the message Kyuss.
I'll copy this.
And paste over here.
And then I call this 45.
Events, flags.
It's karpin.
And we are here, this is forty five.
Going to expand it.
And then over here.
So may not see.
So less so this project we've made copies of previous project, we have SEMAFO stuff, Taimur stuff,
as well as our work stuff, we're going to.
Delete the QR code, the code for the Q we have in our task functions in our last project, we saw how
to send data using cues.
So I'm going to delete this.
Q sent and then the print message associated with a Q from a blue task and then the Q send was being
done from our red alert task.
I'm going to delete that as well so we can use our task functions.
We simply have four tasks and they all have the same priority.
So let's go to our documentation and see how we would work with event flags.
So this is all documentation.
I'm going to click event flux over here to see what we have.
OK, so event flags.
This flag has an attribute structure as well.
So just like our task semaphore and the rest, we have to define the attribute structure for events,
flag the see the functions we have.
We have always event for like new.
And this takes the attributes point to a segment discrete and initializes an event flag and we have
one to set the event flag, one to clear the event flag to get to, to delete.
OK, so let's declare the attribute structure for events like we're going to use just one member of
this structure, which is the name.
So we're going to.
First of all, declare an ad for the event of like we shall create, we call this lesse.
We call this event like we created a variable of type who has events like we call indescribable events
like Alyda, once that is done, we're going to create a structure and attribute structure over here.
We call in this event flug year.
And this is of type of event like attribute structure.
And then we're using just the name field.
We set in the name over here to event floods.
Once that is done, we're going to create a new event flag and the function is always events, flags,
new, and it takes the attributes as argument to come over here.
Once we've initialized our volcano, we create a new event flag and then.
The handle returned or the ID is going to be stored in our I.T. variable over here.
OK.
So that is it, so next, we agreed to make use of our events like so.
We agreed to let one of.
Our task.
So we're going to let one of our tasks, this task is going to set a particular event flag and then
we're going to wait for this particular event flag in another task.
So the red flag we're going to set, we going to set the flag over here.
The flag is a hexadecimal code.
So we're going to set zero zero one.
And then we expect or we wait for this in the blue led task force over here in the red ality task,
I'll see events flag.
And then I'll call the.
Sorry about that.
The always flux sets and then I passed the idea of the events flag and the flag over here.
OK, so the flag is the actual one.
Right, so now I'm going to come to our plurality's task and wait for this flag.
So I'm going to call the U.S. flag wait function over here.
So the first argument is the events like the second argument is the flag and then.
This one here, this the documents indicate whether we want to wait for any of the flags or the single
flag, you see any of the flag and over here wait forever.
Remember, we can combine flags.
We saw events, bits and event groups.
We can combine combine them over here.
We see any of them.
OK, let me show you what I mean when we go to the documentation.
And we go to always like, wait.
It explains further, it tells us flaks, meaning we can wait for multiple flags, specify.
The second argument specifies the flags to wait for.
And then specifies the flex option.
Options here.
Specifies the flux option.
So over here, we are specifying a single flag to wait for zero zero one and then over here, the options
we see in wait for any dysfunction function, always flag wait suspends the execution of the currently
running thread onto any or all event flag specified in the parameter flags onto any or all specified
in flags in the event object specified by parameter F ID.
Which is the idea for the event flag is set, so over here we are saying wait for any of the flags and
we know we have a single one, so that is fine.
If we had multiple ones, we could still say wait for any or wait for all.
So over here, the options.
Yeah, we can see always like wait any wait for any of the flights, this the default always flags wait
or waits for all of the flags.
And we have always flags, no clear do not clear flags which have been specified.
OK, so we've seen anyone any over here and over here wouldn't have any significance or you wouldn't
have any effect at all because we have a single flag we're dealing with.
OK, so once we receive this flag, we want to print out a message when a print this is blue to ask.
OK, let's build and see what we have.
I'll click over here to build.
It's building.
It's still in.
It's finished building.
Click here to run.
Right, click runners, ASTM 30 to.
And then.
Select forty five events like.
If you stop running, no.
I computer's running slow now.
OK, click OK over here.
And it's running.
OK, it's finished downloading onto the board.
Let's see where is real, Tim?
I'm going to clear this.
And of course, this where we have this is blue task, so the events flag is being received.
How do we know indeed this is the events flag making this.
Bring this.
I'm going to comment out the bits where we set the event flag and then we just wait for this event to
flag without setting it.
So I'm going to put a comment here.
And then do it again.
And just so you know, you see we have this arrest line here, meaning we are receiving data.
We are building after that, we're going to click here to download onto the board and we expect the
Erich's line to stop blinking and we expect this to stop moving.
OK.
It's done building, so I'm going to click here to run.
It's downloaded onto the board.
It's downloaded, it's done now, as you can see, we're no longer receiving any data.
There's no our line blinking here.
And this is this is stuck.
If I clear it, it is stuck if I press reset on my board.
Nothing happens, right?
OK.
So that is it.
I see, yes, nothing is supposed to happen in this one, we're not printing system initialise, so
we don't expect to see that.
So this is how events, flags work.
This is just an overview.
Of course, we've not we've not gone deeply into this systems, ARTUS, but I've just shown you how
easy it is to just go to the documentation and take the functions and then apply them so it will be
up to you to go and build more complex stuff and use the the much more complex variations of these APIs
by just visiting the documentation and making use of them.
But this all there is also you have a nice day.