cancel
Showing results for 
Search instead for 
Did you mean: 

Dealing with some sensor transmitting data to gfx and show the data on the lcd screen

Z-YF
Associate III

I am working on the STM32N6570-DK board, and I have a question about demonstrating data on the lcd screen. You see, my project need to do multiple tasks, like collecting the data from the sensors and using the camera to do some AI model inference. Let's name it task A, and task B. I have already written these data-collecting functions in the main.c file, and in model.cpp, I wrote the Model::getcollecteddata() and Model::AIinference() function, and connect this model.cpp with main.c. However, I am wondering if I want to use the Model::tick to send the data to the presenter and use the lcd to show them, due to the fact that I already wrote two functions and the two functions mean s two tasks, in the Model::tick(), can I use the function below:

void Model::tick()
{
        tickCounter++;
        if((tickCounter%20)==0)
        {
                modelListener->collecteddatavalue(getcollecteddata());
                modelListener->AIinferencevalue(AIinference());
        }
}

What I really want to ask is when I use the touchgfx, the functions, like the getcollecteddata() and the AIinference(), will operate and get the data synchronously, so that I don't need to set a flag and set these functions to run orderly(like task A->task B->task C->taskA->...),right?(Since it is based on the threadx operating system)

And if they are not set to work like this, then where should I modify to make it work like it? And I want to know whether the flag idea can actually work.

1 ACCEPTED SOLUTION

Accepted Solutions

Your second is irelevant must be less as one tick. Default one tick is 1/60 s.

Then no 300ms isnt valid and require separate thread.

But ofcourse you can do this , but your GUI stop be responsive to events touch etc...

View solution in original post

5 REPLIES 5
MM..1
Chief III

You can IF one primary condition meet. Time for both func is shorter as one tick.

Z-YF
Associate III

Thanks, but if the AIinference function takes about 100ms, this function:

void Model::tick()
{
    tickCounter++;
    if((tickCounter%20)==0)
    {
        modelListener->collecteddatavalue(getcollecteddata());
        modelListener->AIinferencevalue(AIinference());
    }
}

can still work, right?(I mean that the tickCounter won't accumulate until both functions run successfully)

If it can't work like that, how should I change or modify the Model::tick()?

 

Z-YF
Associate III

Moreover, my real project has about 3 tasks, and the Model::tick() looks like this :

void Model::tick()
{
    tickCounter++;
    if((tickCounter%20)==0)
    {
        modelListener->collecteddatavalue(getcollecteddata());
        modelListener->AIinferencevalue(AIinference());

        modelListener->uploadToCloud(upload());

    }
}

I plan to update all the data once per second, and I can promise that the three tasks takes less than one second.(getcollecteddata() takes about 10ms, AIinference() takes about 300ms, upload() takes 50ms to 100ms)

Your second is irelevant must be less as one tick. Default one tick is 1/60 s.

Then no 300ms isnt valid and require separate thread.

But ofcourse you can do this , but your GUI stop be responsive to events touch etc...

Z-YF
Associate III

OK, I got it, seperate the AIinference task into several small pieces may work.

Thanks again for your time.  :)