eGUI: How to draw a line ?

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

eGUI: How to draw a line ?

Jump to solution
1,968 Views
robroz
Contributor III

Hi,

I'm trying to draw straight line on eGUI screen, but I can't see it...

Have tried two line thickness settings and both lines are not visible :

What am I doing wrong ? Any working example?

Thanks in advance,

Bulek.

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

Hello,

there could be three reasons why you can't see the line on the screen:

1: you are drawing same color as is background

2: you wrongly used coordinations, there is used system of drawing from last draw point. So the function is LineTo(...). For example good example how to draw triangle with points A,B,C - (ax,ay), (bx,by) and (cx,cy).

D4D_MoveToXY(ax, ay);

D4D_LineToXY(bx, by, D4D_LINE_THIN, D4D_COLOR_RED);

D4D_LineToXY(cx, cy, D4D_LINE_THIN, D4D_COLOR_RED);

D4D_LineToXY(ax, ay, D4D_LINE_THIN, D4D_COLOR_RED);

3: You are draw on place that will be redraw by any object/screen by eGUI automatically. For example one way how to draw on screen additional graphics after eGUI redraw the screen.To the ScreenOnMessage function add code like this:

// Screen on message function called with each internal massage for this screen

static Byte ScreenMain_OnObjectMsg(D4D_MESSAGE* pMsg)

{

     // check that this is message for the screen (not for object - NULL pointer) and the message is draw done

  if((pMsg->pObject == NULL) && (pMsg->nMsgId == D4D_MSG_DRAWDONE))

  {

    // When the screen content is drawed - just draw the triangle

     D4D_MoveToXY(ax, ay);

     D4D_LineToXY(bx, by, D4D_LINE_THIN, D4D_COLOR_RED);

     D4D_LineToXY(cx, cy, D4D_LINE_THIN, D4D_COLOR_RED);

     D4D_LineToXY(ax, ay, D4D_LINE_THIN, D4D_COLOR_RED);

  }

  return D4D_MSG_NOSKIP;

}

Best regards

Petr

View solution in original post

0 Kudos
12 Replies
1,564 Views
simona-marinela
Contributor I

Hello!

I also tried to draw a simple line with the eGUI, but I got into lots of expression syntax error and messages about identifier 'D4D_MoveToXY(unsigned short, unsigned short) was originally declared as '__regabi void (unsigned short, unsigned short)'.

This is part of my screen_hello_world.c :

#include "main.h"

#include "pictures.h"

#include "d4d.h"

D4D_COOR ax = 150, ay = 200;

D4D_COOR bx = 300, by = 400;

D4D_COLOR clr = D4D_COLOR_RED;

// Declaration of example Label

D4D_DECLARE_STD_LABEL_AUTOSIZE(lbl_HelloWorld, "Hello World", 70, 50, FONT_8x14_BIG)

// mutam logical cursor

D4D_MoveToXY( ax, ay );

// desenam linia - de la logical cursor la ppt (pointer to point)

D4D_LineToXY( bx, by, D4D_LINE_THICK, clr);

// Standard screen declaration with 3 objects

//D4D_DECLARE_STD_SCREEN_BEGIN(screen_HelloWorld, ScreenHelloWorld_)

D4D_DECLARE_SCREEN_BEGIN(screen_HelloWorld, ScreenHelloWorld_, 0, 0, 319, 239, "MyHelloWorld", FONT_8x14_BIG, NULL, D4D_SCR_F_BCKG | D4D_SCR_F_TITLEBAR, NULL)

  D4D_DECLARE_SCREEN_OBJECT(lbl_HelloWorld)       

D4D_DECLARE_SCREEN_END()

and these are the first errors appeared in Console ( I didn't paste the hole output as there are many "syntax error"s after these ones

C:/Freescale/CW_MCU_v10.2/MCU/ColdFire_Tools/Command_Line_Tools/mwccmcf|Compiler|Error

(D:\CWWorkspace\JM128EGUI\App\screen_hello_world.c|29|22|1|684|1)

=D4D_MoveToXY( ax, ay ); 

>identifier 'D4D_MoveToXY(unsigned short, unsigned short)' redeclared as

>'__regabi int (...)'

(D:\CWWorkspace\JM128EGUI\Freescale_Embedded_Gui\common_files\d4d.h|152|41|1|5638|1)

=void D4D_MoveToXY(D4D_COOR x, D4D_COOR y); 

>identifier 'D4D_MoveToXY(unsigned short, unsigned short)' was originally

>declared as '__regabi void (unsigned short, unsigned short)'

(D:\CWWorkspace\JM128EGUI\App\screen_hello_world.c|36|1|6|920|24)

= extern const D4D_OBJECT * const screen_HelloWorld_objects[]; static vo

>expression syntax error

C:/Freescale/CW_MCU_v10.2/MCU/ColdFire_Tools/Command_Line_Tools/mwccmcf|Compiler|Error

(D:\CWWorkspace\JM128EGUI\App\screen_hello_world.c|36|32|6|920|24)

=st screen_HelloWorld_objects[]; static void ScreenHelloWorld_OnInit(); static void ScreenHelloWorld_On

>expression syntax error

If you could help me understand, it would be great!

Thanks,

Simona

0 Kudos
1,564 Views
LuisCasado
NXP Employee
NXP Employee

Hi Simona,

You can't call a function D4D_MoveToXY( ax, ay ); at that code point.

You could call the function D4D_LCD_Line, defined in d4d_low.c All the drawing functions are in d4d_low.c , but you must call them inside a function body.

Luis

0 Kudos
1,564 Views
simona-marinela
Contributor I

Thank you!

It's basic C, I don't know how I didn't realize that I was outside a function body  :-). I think I'm not used with this type of code ( never worked on hardware before ).

Anyway, my fault.

0 Kudos
1,564 Views
Monica
Senior Contributor III

Robroz :smileyhappy:

Please tell us how was the example working! We'd like to know, was it useful?

Regards,

Monica.

0 Kudos
1,565 Views
Gargy
NXP Employee
NXP Employee

Hello,

there could be three reasons why you can't see the line on the screen:

1: you are drawing same color as is background

2: you wrongly used coordinations, there is used system of drawing from last draw point. So the function is LineTo(...). For example good example how to draw triangle with points A,B,C - (ax,ay), (bx,by) and (cx,cy).

D4D_MoveToXY(ax, ay);

D4D_LineToXY(bx, by, D4D_LINE_THIN, D4D_COLOR_RED);

D4D_LineToXY(cx, cy, D4D_LINE_THIN, D4D_COLOR_RED);

D4D_LineToXY(ax, ay, D4D_LINE_THIN, D4D_COLOR_RED);

3: You are draw on place that will be redraw by any object/screen by eGUI automatically. For example one way how to draw on screen additional graphics after eGUI redraw the screen.To the ScreenOnMessage function add code like this:

// Screen on message function called with each internal massage for this screen

static Byte ScreenMain_OnObjectMsg(D4D_MESSAGE* pMsg)

{

     // check that this is message for the screen (not for object - NULL pointer) and the message is draw done

  if((pMsg->pObject == NULL) && (pMsg->nMsgId == D4D_MSG_DRAWDONE))

  {

    // When the screen content is drawed - just draw the triangle

     D4D_MoveToXY(ax, ay);

     D4D_LineToXY(bx, by, D4D_LINE_THIN, D4D_COLOR_RED);

     D4D_LineToXY(cx, cy, D4D_LINE_THIN, D4D_COLOR_RED);

     D4D_LineToXY(ax, ay, D4D_LINE_THIN, D4D_COLOR_RED);

  }

  return D4D_MSG_NOSKIP;

}

Best regards

Petr

0 Kudos
1,564 Views
robroz
Contributor III

Hi,

thanks for advice...

Hmm, something is wrong - I've setup breakpoint in that drawing part and it never gets in... I've set breakpoint on if clause and it seems that all messages are only for objects, never object is null...

in d4d_screen.c :

for(i=0; pScreen->pObjects[i] != NULL; i++)
{
pObj = (D4D_OBJECT*) pScreen->pObjects[i];
if(!(pObj->flags->bits.bVisible))
continue;
d4d_msg.pObject = pObj;


and it seems that pObj never gets to NULL!!!


Am I wrong ?


I've added after for loop that message is sent once again with null pObject and it works for now... Do I have some outdated version of eGUI ?


Regards,

Rob.

0 Kudos
1,564 Views
Gargy
NXP Employee
NXP Employee

Hi Rob,

this points on any older version of eGUI, in current version (close to release) is handled children object also and the loop looks differently.

In these thread you can find one latest snapshot of eGUI 3.0:

https://community.freescale.com/message/323071#323071

By the way, if in the message the pObject pointer is NULL, then the message is targeted just only to screen!

Petr

0 Kudos
1,564 Views
robroz
Contributor III

Hi,

thanks for response. If I understand right, it's highly recommended to switch to prerelease V3.0 of eGUI? What are your experiences on potential migrating problems for v3.0?

Thanks in advance,

regards,

Bul.

0 Kudos
1,564 Views
Gargy
NXP Employee
NXP Employee

Hi,

I really recommended to migrate, in 3.0 is big amount of new features and the object could for example use bevels to make softer visual appearance, object could be compounded from other objects (group box etc), multilanguage, unicode etc.

The effort what you have to do for migration is not so big, there is only few non compatibility in object declaration in general.

Just switch the source codes (also in your project - there is a new files).

Check the includes paths in project - now is needed just one to root D4D folder.
And go through the compilation errors (and check the new declarations in eGUI headers).

Let us know how hard was this :-)

Petr

0 Kudos
1,564 Views
robroz
Contributor III

Hi,

thanks for response... Will do this as soon as possible...

Do you also have any kind of "prerelase" documentation or at least a list of novelties in v3.0 ?

Any kind of even non-complete documentation will be of great help...

I'm particularly after "multilanguage" and Unicode support...

Thanks in advance,

regards,

Bul.

0 Kudos
1,564 Views
Gargy
NXP Employee
NXP Employee

Hello, at the moment I working on switch complete API of eGUI description into DOXYGEN comment direct in code , give me some time to finish it.

The DRM116 document is little bit out date.

Petr

0 Kudos
1,564 Views
robroz
Contributor III

Hi,

please post even partial and not finished documents as you work on it... Something is much better than nothing :-)...

Thanks in advance,

regards,

Bul.

0 Kudos