EGUI

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

EGUI

3,138 Views
dporada
Contributor III

Hi,

 

I trying to use the EGUI libraries and I am not sure how to get a function that I need.  I want something like a status indicator that would have text in text in a colored box and when I get an external signal, I want the text and background color to change showing that I have an input.

 

Should this be done as a label or a  button?  It looks like to show different colors, I need to use the full declaration of the object, but this also requires me to specify a bitmap for the background.

 

Does anyone have any example code showing how to display text on a background color and change the color?

 

Thanks,

 

Don

Labels (1)
0 Kudos
20 Replies

1,412 Views
Gargy
NXP Employee
NXP Employee

Hi,

if you want to only change the text then use the D4D_LABEL. If you want to chge the colors of label then use your own color scheme for this one label, that you can placed in RAM and change the colors in colors scheme and the Invalidate the label object.

 

And also if you use the full declaration macro and you don't want to use any bitmap or additional functions jsut fill the item as NULL.

0 Kudos

1,412 Views
livno
Contributor I

I'm using external keypad to manage button object to change color and text. I used following code to change color (focus and kill focus)  and it works, but I had to make one fake button, because seems to me that one button has to be focused. If not please let me know how I can make all of them unfocused at boot. Also I try to change text on the button, but button just shortly flicker and do not change text. I can change text in label object but not in button. Please can you help me with this, so I can continue my project. Now I'm stuck.

   if(Button1)
   {
   D4D_SCREEN* pScreen = D4D_GetActiveScreen();   // Get active screen
   D4D_FocusSet(pScreen, &scrMain_btnStop1);    // Focus selected object in given screen
   D4D_SetText(&scrMain_btnStop1, testText);  // DO NOT WORK

   D4D_SetText(&scrX_axis_lblValue, "DOWN"); // WORKS OK
   ToggleButton = 0;
   }

   if(!repeatedKey)
  {
  D4D_SCREEN* pScreen = D4D_GetActiveScreen();    // Get active screen
  D4D_FocusSet(pScreen, &scrMain_btnFake);     // Focus fake button to unfocus btnStop1

  D4D_SetText(&scrX_axis_lblValue, "UP"); // WORKS OK
  ToggleButton = 0;
  }

 

Regards,

Harry

0 Kudos

1,412 Views
Gargy
NXP Employee
NXP Employee

Hi,

first of all - Why do you need chnge the focus manually by function D4D_FocusSet ? I think much better way is keep manage eGUI change focus automatically and also colors.

 

And to answer question regarding setting text of button I need to know declaration of scrMain_btnStop1 and testText.

 

If you interested how to manage key inputs and generate autorepeat for keys just let know and I'm able to put here some simple test code.

 

Gargy

 

 

0 Kudos

1,412 Views
livno
Contributor I

 

Hi,

I've try both declaration (regular and INRAM):

D4D_DECLARE_TXT_RBUTTON_INRAM(scrMain_btnStop1, "MENU1", 10, 160, 100, 45, 12, FONT_TIMES_TAHOMA11, ScrMain_OnClickBtnStop1)
D4D_DECLARE_TXT_RBUTTON(scrMain_btnStop1, "MENU2", 130, 160, 100, 45, 12, FONT_TIMES_TAHOMA11, ScrMain_OnClickBtnStop1)
but they did not work. I use D4D_FocusSet because it was only way for me to plug it in my interrupt to do something when I press key on the keypad. Again I'm not using touchscreen bur 6x4 keypad and I'm monitoring their state in my interrupt routine. Maybe that is not really the best way to do it. It will be wery nice if you can provide sample code how to manage keypad and change color and text.

Thanks,

Harry

0 Kudos

1,412 Views
Gargy
NXP Employee
NXP Employee

HI, the good news is that I see where is your problem with D4D_SetText function :smileyhappy:

 

You have placed the text in Flash!! Not in RAM, the right way how to do it is:

 

D4D_CHAR pBtn1Text[MaxLen] = "MENU2";

 

D4D_DECLARE_TXT_RBUTTON(scrMain_btnStop1, pBtn1Text, 130, 160, 100, 45, 12, FONT_TIMES_TAHOMA11, ScrMain_OnClickBtnStop1)

 

By tihs way you create the text array in RAM and the application will works.

 

And regarding the colors - they should be changed automatically by status of object , just set your colors in color scheme.

 

For example the default colors scheme you can setup in d4d_usr_cfg.h file:

/******************************************************************************
* General object colors
******************************************************************************/

// standard normal color fore
#define D4D_COLOR_FORE_NORM  D4D_COLOR_YELLOW
// standard normal color background
#define D4D_COLOR_BCKG_NORM  D4D_COLOR_LIGHT_GREY

// standard disabled color fore
#define D4D_COLOR_FORE_DISABLED D4D_COLOR_WHITE
// standard disabled color background
#define D4D_COLOR_BCKG_DISABLED D4D_COLOR_LIGHT_GREY

// standard focus color fore
#define D4D_COLOR_FORE_FOCUS D4D_COLOR_ORANGE
// standard focus color background
#define D4D_COLOR_BCKG_FOCUS D4D_COLOR_WHITE

// standard capturing color fore
#define D4D_COLOR_FORE_CAPTURE D4D_COLOR_BRIGHT_RED
// standard capturing color background
#define D4D_COLOR_BCKG_CAPTURE D4D_COLOR_WHITE

Enjoy

Gargy

0 Kudos

1,412 Views
livno
Contributor I

Hi Gargy,

I made my button stuff working, but now need to connect them with my external keypad. I have my code to scan keypad (4x5 keys) and tried to see key change in eGUI, but no success. Please can you provide sample code for keypad.

Regards,

Harry

0 Kudos

1,412 Views
Gargy
NXP Employee
NXP Employee

Hi,

 I never do it, but it sounds easy Smiley Happy

 

1.just create table of all buttons on screen (array of pointer to buttons) to simplify  whole code.

2. if you detect press down event on your HW keyboard, then call function void D4D_FocusSet(D4D_SCREEN* pScreen, D4D_OBJECT_PTR pObject) to redraw button as focused

3. and send message to button to simulate that ENTER key has been pushed (or screen touched on button area)

D4D_MESSAGE MyMsg;MyMsg.pObject = arrayButtons[pressedButton];MyMsg.pScreen = pScreenButton;MyMsg.nMsgId = D4D_MSG_KEYDOWN;MyMsg.prm.key = D4D_KEY_SCANCODE_ENTER;D4D_SendMessage(&MyMsg);

 

4. when the key will be released send the same message just for KEYUP

 

That should work

 

Gargy

0 Kudos

1,412 Views
livno
Contributor I

Hi Petr,

The best I could do to make my keypad working is :

 

D4D_CHAR Menu1_text[] = "Menu item 1";

D4D_CHAR Menu2_text[] = "Menu item 2";

static void SreenMenu_OnClicked(D4D_OBJECT* pThis, D4D_MENU_INDEX ix);

static void ScrMain_OnClickButton11(D4D_OBJECT* pThis);

static void ScrMain_OnClickButton22(D4D_OBJECT* pThis);

D4D_DECLARE_TXT_RBUTTON(scrMain_Button11, Button11_text, 10, 220, 100, 45, 12, FONT_TIMES_TAHOMA11, ScrMain_OnClickButton11)

D4D_DECLARE_TXT_RBUTTON(scrMain_Button22, Button22_text, 130, 220, 100, 45, 12, FONT_TIMES_TAHOMA11, ScrMain_OnClickButton22)

D4D_DECLARE_STD_MENU_AUTOSIZE_BEGIN(scr_Menu_Menu, MenuTitle_text , FONT_TIMES_TAHOMA11, 0, 0, 480, 282,\

FONT_TIMES_TAHOMA11, FONT_TIMES_TAHOMA11, NULL, SreenMenu_OnClicked)

D4D_DECLARE_MENU_ITEM(Menu1_text, NULL)

D4D_DECLARE_MENU_ITEM(Menu2_text, NULL)

D4D_DECLARE_MENU_END(scr_Menu_Menu)

D4D_DECLARE_STD_SCREEN_BEGIN(screen_menu, ScreenMenu_)

D4D_DECLARE_SCREEN_OBJECT(scr_Menu_Menu)

D4D_DECLARE_SCREEN_OBJECT(scrMain_Button11)

D4D_DECLARE_SCREEN_OBJECT(scrMain_Button22)

D4D_DECLARE_SCREEN_END()

 

static void SreenMenu_OnClicked(D4D_OBJECT* pThis, D4D_MENU_INDEX ix)

{

D4D_UNUSED(pThis);

switch(ix)

{

case 0:

D4D_SetText(&scrMain_Button44, "OOOO"); // Change text

break;

case 1:

D4D_SetText(&scrMain_Button44, "SSSS"); // Change text

break;

default:

break;

}

}

//Button Stop OnClick CallBack

static void ScrMain_OnClickButton11(D4D_OBJECT* pThis)

{

D4D_SetText(&scrMain_Button44, "Text1");

}

static void ScrMain_OnClickButton22(D4D_OBJECT* pThis)

{

D4D_SetText(&scrMain_Button44, "Text2");

}

static void ScreenMenu_OnActivate()

{

D4D_CaptureKeys(&scr_Menu_Menu);

}

 

static void ScreenMenu_OnMain()

{

if(ToggleButton)

{

if(Button1)

{

D4D_KeysChanged(D4D_KEY_UP); // This change key and assign action

d4d_msg.nMsgId = D4D_MSG_TOUCHED; // Change button color

d4d_msg.pObject = (D4D_OBJECT*) &scrMain_Button11; // Select button

D4D_SendMessage(&d4d_msg); // Send message to the object

ToggleButton = 0;

}

else if(Button2)

{

D4D_KeysChanged(D4D_KEY_DOWN);

d4d_msg.nMsgId = D4D_MSG_TOUCHED; // Button action

d4d_msg.pObject = (D4D_OBJECT*) &scrMain_Button22; // Select object

D4D_SendMessage(&d4d_msg); // Send message to the object

ToggleButton = 0;

}

}

if(!repeatedKey)

{

D4D_KeysChanged(0); // Get ready for next key change

ToggleButton = 0;

}

}

 

My problem now is that function

static void SreenMenu_OnClicked(D4D_OBJECT* pThis, D4D_MENU_INDEX ix)

does not do anything, and functions

static void ScrMain_OnClickButton11(D4D_OBJECT* pThis)

static void ScrMain_OnClickButton22(D4D_OBJECT* pThis)

respond just after I pressed the same button twice.

Also is there any way to update menu items text "Menu1_text" in real time (from my host). If not, then what will be the best way to make menu like screen which menu items names can be updated from host, be able to scroll and select them. I was thiniking of labels array, but not sure if it is going to work. Takes me to much time to experiment with all this stuff, but there is not sample code anywhere. Please can you help me to solve those problems, and if you have any comment (suggestion) for my code above reply it to me.

Thanks,

Harry

0 Kudos

1,412 Views
Gargy
NXP Employee
NXP Employee

Hi,

 the "issue" with double click on button is easy to solve - As I see you are using D4D_DECLARE_TXT_RBUTTON and this macro is using standard flags D4D_BTN_F_DEFAULT and this can be configure in d4d_usr_cfg.h file and the double click is standard behavior - first select and second time do action. But if you want to switch to single touch behaviour then you have add to flags one more: D4D_OBJECT_F_FASTTOUCH - that's all.

 

 

Regarding runtime changing of item texts in menu - Yes it possible ( I never tested it :-)), but the good idea is create items by strings in RAM. But what you do next is :

* Change all strings that you need to change

* then invalidate the object to force eGUI to redraw it.

void D4D_InvalidateObject(D4D_OBJECT_PTR pObject, Byte bComplete)

 

That's all - piece of cake Smiley Happy

 

 

And what you want to do with this piece of code :

d4d_msg.nMsgId = D4D_MSG_TOUCHED; // Button actiond4d_msg.pObject = (D4D_OBJECT*) &scrMain_Button22; // Select objectD4D_SendMessage(&d4d_msg); // Send message to the object

 

You send a message that makes at least nothing Smiley Happy

 

So the last thing I don't understand what you mean that MENU object doesn't work Smiley Sad Please explain more in detail.

 

0 Kudos

1,412 Views
Victor125
Contributor I

Hi Gargy,

 

I have a screen with several labels.I need to change the color of one text label during execution depending of a state. I create my own scheme color and assigned to the label I want change color but I get a compiler error: 'Ilegal constant expression'. The code is:

 

D4D_DECLARE_CLR_SCHEME(d4d_clr_scheme_color, \
        D4D_COLOR_SCR_DESKTOP, D4D_COLOR_SCR_OUTLINE, D4D_COLOR_SCR_TITLEBAR, D4D_COLOR_SCR_TILTLETEXT, D4D_COLOR_SCR_EXIT_BTN_FORE, D4D_COLOR_SCR_EXIT_BTN_BCKG,\
        D4D_COLOR_BCKG_NORM_GREEN, D4D_COLOR_BCKG_DISABLED, D4D_COLOR_BCKG_FOCUS, D4D_COLOR_BCKG_CAPTURE,\
        D4D_COLOR_FORE_NORM, D4D_COLOR_FORE_DISABLED, D4D_COLOR_FORE_FOCUS, D4D_COLOR_FORE_CAPTURE,\
        D4D_COLOR_GAUG_HUB, D4D_COLOR_GAUG_POINTER,\
        D4D_COLOR_SLDR_BAR_BCKG, D4D_COLOR_SLDR_BAR_FORE, D4D_COLOR_SLDR_BAR_START, D4D_COLOR_SLDR_BAR_END,\
        D4D_COLOR_CHECKBOX_ICON_BCKG,\
        D4D_COLOR_GRAPH_GRID,\
        D4D_COLOR_PRGRS_BAR_BAR_BCKG, D4D_COLOR_PRGRS_BAR_BAR_FORE, D4D_COLOR_PRGRS_BAR_BAR_END\
        )
       
D4D_CLR_SCHEME *pSchemeColor = (D4D_CLR_SCHEME*)&d4d_clr_scheme_color;

 

D4D_DECLARE_LABEL_AUTOSIZE(scrTest_lblCarrera, scrTest_lblCarrera_str, 5, 50, (D4D_LBL_F_DEFAULT), pSchemeColor, FONT_ARIAL69, NULL, NULL) 

 

Can you help me? My idea is to change the standard background color of my scheme during execution so the label with this scheme will change the color.

 

Regards,

Victor

0 Kudos

1,412 Views
Gargy
NXP Employee
NXP Employee

Hi,

 I look on this issue and I think that this should be enough,(I just compile it, not test on Hardware):

D4D_DECLARE_CLR_SCHEME(d4d_clr_scheme_color, \
        D4D_COLOR_SCR_DESKTOP, D4D_COLOR_SCR_OUTLINE, D4D_COLOR_SCR_TITLEBAR, D4D_COLOR_SCR_TILTLETEXT, D4D_COLOR_SCR_EXIT_BTN_FORE, D4D_COLOR_SCR_EXIT_BTN_BCKG,\
        D4D_COLOR_BLACK, D4D_COLOR_BCKG_DISABLED, D4D_COLOR_BCKG_FOCUS, D4D_COLOR_BCKG_CAPTURE,\
        D4D_COLOR_FORE_NORM, D4D_COLOR_FORE_DISABLED, D4D_COLOR_FORE_FOCUS, D4D_COLOR_FORE_CAPTURE,\
        D4D_COLOR_GAUG_HUB, D4D_COLOR_GAUG_POINTER,\
        D4D_COLOR_SLDR_BAR_BCKG, D4D_COLOR_SLDR_BAR_FORE, D4D_COLOR_SLDR_BAR_START, D4D_COLOR_SLDR_BAR_END,\
        D4D_COLOR_CHECKBOX_ICON_BCKG,\
        D4D_COLOR_GRAPH_GRID,\
        D4D_COLOR_PRGRS_BAR_BAR_BCKG, D4D_COLOR_PRGRS_BAR_BAR_FORE, D4D_COLOR_PRGRS_BAR_BAR_END\
        )

D4D_CHAR *scrTest_lblCarrera_str;

D4D_DECLARE_LABEL_AUTOSIZE(scrTest_lblCarrera, " ", 5, 50, (D4D_LBL_F_DEFAULT), (D4D_CLR_SCHEME*)&d4d_clr_scheme_color, 0, NULL, NULL)

 

Petr

0 Kudos

1,412 Views
Toe
Contributor IV

Gargy, I don't think your solution will do what he's trying to do.  Color schemes and objects are both declared const, so changing the scheme dynamically or setting the object to a new scheme will crash the task or application.  At least that is what I experienced.

 

So I'm in a similar situation where I want to change the color of multiple status lables or buttons depending on different events.  The way I found to do it for now is to remvoe the const in the D4D_DECLARE_CLR_SCHEME macro.  This lets me create a scheme that I can change as I want.

 

Is there a better way to do this?  Doing it like this takes about 50 bytes of ram for each scheme.

0 Kudos

1,412 Views
Victor125
Contributor I

 

Hi Toe and Gargy,

 

I finally declare a D4D_DECLARE_CLR_SCHEME_IN_RAM macro and it works perfect. I use the standard macro for controls that I don't nedd change the color and RAM macro for controls I need.

 

Regards,

Victor

 

 

0 Kudos

1,412 Views
james07
Contributor I

Excuse me you all, i´m in the same trouble as you were, and i don´t even know what should i do. You said that to change the color of the label you had to create a color scheme IN RAM? How did you do that? Could you help me? Victor? Gargy?Anyone?

Thiago

0 Kudos

1,412 Views
Gargy
NXP Employee
NXP Employee

Hi all,

D4D_DECLARE_CLR_SCHEME_IN_RAMis good idea, and it's missing in eGUI. Thanks for inspiration.

I added it into next offiacial release.

 

Gargy

0 Kudos

1,412 Views
livno
Contributor I

Hi Petr,

I've made everything work pretty good. Is there any possibilyty to have nicier (higher resolution) fonts. In some labels I use big font and they are very coarse. I was thinking to mage bigger font then scale it down, but scale factor is integer. Any advice.

Thanks,

Harry

0 Kudos

1,412 Views
Gargy
NXP Employee
NXP Employee

Hi,

 the solution is simply, just create a new font data by Freescale eGUI converter utility and use it. You can prepare any font what you need. The utility is available on www.freescale.com/egui

 

Gargy

0 Kudos

1,412 Views
vaderlost
Contributor II

Greetings all,

I'm working on the Tower-LCD kit, and using eGUI to develop a user interface.

I need to create a Text Editor object that implements:

-navigation.
-edition. ( delete/add text in any position )
-partial char/word underlining.

I think D4D_CONSOLE object may be a very good start point to create a the text editor object that extends console capabilities.

I'm was studying eGui documentation and source code and I feel able to modify them to add functionality but:

There is someone who has already done something similar?

Thanks,

0 Kudos

1,412 Views
Gargy
NXP Employee
NXP Employee

Hi,

 D4D_CONSOLE it could be example how to handle eGUI messages and how to basicly do new D4D_OBJECT. But the object that you dscribe will be most difficult ever in eGUI :smileyhappy:

 

Because there are feew points that you have to keep in mind:

- the console is strictly oriented to lines with defined count of characters on line !!

- it can be modified just only be code!!

- and if you want to change properties of individual words you will have to create for each word own STRING structure with all properties and do own drawings or any other way.

 

So good luck

0 Kudos

1,412 Views
vaderlost
Contributor II

Hi Petr

Thanks for answer

 

I'll work on it,

is likely to bother you with more questions.

 

best regards

0 Kudos