eGUI - purpose of the 'pOnUsrMsg' argument in object declaration

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

eGUI - purpose of the 'pOnUsrMsg' argument in object declaration

Jump to solution
1,080 Views
Maciek
Contributor V

Hi,

what is the purpose of 'pOnUsrMsg' argument in object declaration macro ?

How a user message can be sent to an object ?

What does it mean (user guide comment on pOnUsrMsg): "This callback is called before this

message event is sent to the object itself" ?

Any 'design patterns' here ?

Regards

Maciek

Tags (2)
0 Kudos
1 Solution
690 Views
Gargy
NXP Employee
NXP Employee

Hi,

the eGUI handles all actions/events to objects through the messages. So and if you want to do some advanced techniques you can catch the event just before the object get it and do your own action. And after your own action you can decide if the object gets the message or if will be discarded.

The example:

You want catch the message that the object has been just redrawn and you want to add to object some own graphics:

1 declare object and for the parameter 'pOnUsrMsg', place name of your handle function with prototype:

Byte (*OnUsrMessage)(struct D4D_MESSAGE_S* pMsg)

2. Create the handle function:

Byte MyObject_OnUsrMessage(D4D_MESSAGE_S* pMsg)

{

     if(pMsg->msgId == D4D_MSG_DRAWDONE)

     {

          // Draw your own graphic

     }

     return D4D_MSG_NOSKIP; // Message won't be discarded

}

Gargy

View solution in original post

0 Kudos
6 Replies
691 Views
Gargy
NXP Employee
NXP Employee

Hi,

the eGUI handles all actions/events to objects through the messages. So and if you want to do some advanced techniques you can catch the event just before the object get it and do your own action. And after your own action you can decide if the object gets the message or if will be discarded.

The example:

You want catch the message that the object has been just redrawn and you want to add to object some own graphics:

1 declare object and for the parameter 'pOnUsrMsg', place name of your handle function with prototype:

Byte (*OnUsrMessage)(struct D4D_MESSAGE_S* pMsg)

2. Create the handle function:

Byte MyObject_OnUsrMessage(D4D_MESSAGE_S* pMsg)

{

     if(pMsg->msgId == D4D_MSG_DRAWDONE)

     {

          // Draw your own graphic

     }

     return D4D_MSG_NOSKIP; // Message won't be discarded

}

Gargy

0 Kudos
690 Views
Maciek
Contributor V

Ok. Above is clear. Thanks.

What is the preferred/right way of accessing objects (changing color, text, dimensions) - by a user of the library, from another MQX task ? For example I want to change the button property (color) in response to the CAN message received...

CAN message is received by another task.

Regards

Maciek

0 Kudos
690 Views
Gargy
NXP Employee
NXP Employee

Hi,

good question.

With colours this is easy because the eGUI is running on colour schemes so you need do for your button own colour scheme in RAM.

In other task you can changed this colour normally (if you do this from more task the MUTEX will be fine), and then you can call the D4D_InvalidateObject function, and it depends on color what you change, you will use parameter for full redraw or just content.

Gargy

690 Views
Maciek
Contributor V

Hi,

I have two questions:

1) Is the 'D4D_InvalidateObject' function thread-safe ?

Let's say I'm changing object parameter from a few threads concurrently. Should I protect (with the mutex for example) only the parts that change parameter (and next use D4D_InvalidateObject outside the protected block) ?

Or, should I protect the parts with parameter change AND the 'D4D_InvalidateObject' function (everything inside protected block) ?

2) I'm not sure what is the meaning of bComplete parameter in D4D_InvalidateObject. I suppose 1 means that the object is fully redrawn (for example all the button with background, text, boarders etc. is redrawn). Am I right ? What is the meaning of 0 ?

Thanks

Maciek

ps. is there any chance to obtain the new User Guide (for 3.0) before official release ?

0 Kudos
690 Views
Gargy
NXP Employee
NXP Employee

Hi,

1. The 'D4D_InvalidateObject' function is thread-safe. Don't worry to use it.

2. bComplete parameter when is set force the complete redraw of the object, if it clear then the object redraw just only content (no frame, no background, no titles redraw).

The documentation at the moment is not available, I'm so sorry (is in publication process).

Gargy

0 Kudos
690 Views
elisamejia
Contributor III

Hi,

Can I change the color scheme of a screen after creating it?

I'm trying to disable an entire screen once I open another one. Can I change the colors of the previous screen so it is obvious that it is disabled?

Regards,

Elisa

0 Kudos