695 views
in Embedded Wizard Studio by

Hello team,

char aaa[20] = "asdasdasdasdasdasd";
 ApplicationDeviceClass__UpdateDISPLAYDATE(DeviceObject,(XInt32)aaa);  

       if i want to display on screen, display(asdasdasdasdasdasd),   i try to change XInt32 or XChar , etc,It can't be shown here ,why?

       or in the embedded wizard,Does this Text need to be changed  ?

      Thank for your help

 

Best regards,

Tonny

1 Answer

0 votes
by

Hello Tonny,

I assume you want to transfer a string from your C code into your GUI application. Correct?

In this case let me refer to the chapter Be careful when exchanging strings - it describes the different aspects and provides some examples.

Does this answer your question?

Best regards,

Manfred

by
Hello Manfred,

       Can you give me an example?I think if I had an example, I would soon understand .

   Thank you very much.

Best regards,

Tonny
by
Hello Tonny,

can you please explain what you want to do? Which data do you have? And what do you want to display?

Then it will be easier to give you an adequate example.

Best regards,

Manfred.
by

Hello Manfred,

         now,I received a set of data in the project ,for example:( DateDisplay[64])

        and i want to display the DateDisplay[64]  on the screen.Can use Text display?

int DeviceDriver_ProcessData(void)
{
        for(int i = 0; i < 64; i++)
        {                
          if(i%16 == 0)
                {
                        
                  PRINTF("\r\n");
                }
        PRINTF("%02x  ",DateDisplay[i]);

        }
        
        ApplicationDeviceClass__UpdateDISPLAYDATE(DeviceObject,(XChar)DateDisplay);  
}

Thank you very much!

Best regards,

Tonny

by

Hi Tonny,

in principle there are two possibilities to transfer the data from the Device Driver written in C to you GUI application.

1.) You can format the string in C based on your received data and transfer the string to your TextView.

  • Within your C code, create a C-string (an array of character) and format the string according your needs, e.g. with sprintf().
  • Use the function EwNewStringAnsi() to create a proper string object before passing it to the Update() method of the Device Class.
  • Transfer the string to the Device Class, e.g. ApplicationDeviceClass__UpdateText( device, string );

2.) Alternatively, you can store the array of data within your Device Driver and read the data array within your Device Class in order to update your GUI component (e.g. by displaying the values or by creating a string for a TextView).

For this purpose please have a look to the chapter Exchange array contents section "Case 3: Access all array elements". There you will find an example.

This approach is more flexible, as you can decide within your GUI application how to process the data - e.g. you can format a string for a TextView or you can use the integer values to show them in some widgets.

I hope this helps...

Best regards,

Manfred

by

Hello  Manfred,

       For the first method,in the embedded wizard,Is that right ?

First:

Then:

And:

        for(int i = 0; i < 64; i++)
        {                
          if(i%16 == 0)
                {      
                  PRINTF("\r\n");
                }
        PRINTF("%02x  ",DateDisplay[i]);
        }
        ApplicationDeviceClass__UpdateDISPLAYDATE(DeviceObject,(XInt32)EwNewStringAnsi(DateDisplay)); 

My goal is to show in screen :(00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14

                                                 15 16 17 18 19 20 21 21 22 23 24 25 26 27 28 29

                                                 ...

                                                 ...                                                                             )

But I'm showing a very strange number,Where is the problem, please?

Thank you very much,

Best regards,

Tonny

by

Hello Tonny,

please make the following steps:

  • Open your Device Class and add a new Property from the Gallery folder Device.
  • Rename it to HexDataText and set the Type of the Property to string.
  • Rename the Update method to UpdateHexDataText and set the type of parameter to string.

  • Open your GUI component and add a Text View that will display the hex data. Configure the Text View according your design.
  • Add a Property Observer from the Gallery folder Device (rename it if you want) and set the Property Outlet to the previously created HexDataText Property. As a result, each time the text changes within the Device Class, the slot method onEvent() will be called.

  • Open the slot method onEvent() and write the string from the Device Class to the corresponding Property of the TextView:
TextView.String = Device.HexDataText;
  • Open your Device Driver C code with an editor and implement the DeviceDriver_ProcessData() function:
  /* check for new data - prepare the string for the GUI only if new data are available */
  if ( YourTarget_NewDataAvailable() )
  {
    char buffer[ 256 ];   /* this is the C string */
    char* ptr = buffer;   /* pointer to format the C string */
    XString text;         /* Chora string to provide to the Device Class */
    for ( int i = 0; i < 64; i++ )
    {
      sprintf( ptr, "%02X ", i );
      ptr += 3;
      if ( i % 16 == 15 )
        sprintf( ptr++, "\n" );
    }
    /* just for debugging on the console */
    EwPrint( buffer );

    /* convert the C string to a Chora string */
    text = EwNewStringAnsi( buffer );

    /* inform the Device Class about the text */
    ApplicationDeviceClass__UpdateHexDataText( DeviceObject, text );
    needUpdate = 1;
  }

I hope this helps.

Best regards,

Manfred.

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...