1.5k views
in GUI Development by

Hi,

I meet a troube for show value by HEX format in my project, the result is strange as my meaning. I explain as follows.

I create a "Views::Text" and use a "Method" to assign a HEX format string. I test by "Prototyper(F5)" and result is normal.

But if I test on real machine then result is abnormal, the OSD is always keep show "0000" after I adjusted value. (Value of OSD is no any change. but real value is changed by "trace")

I don't know why the result is difference, has any limitation for this request? I made a simple sample as following link. 

http://ask.embedded-wizard.de/?qa=blob&qa_blobid=6143071893042238013

In this sample, you can press plus/minus key for add/dec value and value change by HEX format. But due you have not real machine, so you will always get normal result.

Could you help me to analysis this trouble? And have other ways for show value by HEX format?

PS: My developing platform is "Panasonic.PH1sLD3_Linux_OpenGL.RGBA8888", Version of Embeddid Wizard is 6.10.

 

1 Answer

0 votes
by
 
Best answer

Hi Steward,

thank you for your question and the good preparation of the sample. I think your question addresses two aspects:

1.) How to convert a decimal value into a string with hexadecimal digits?

The following code snippet contains the implementation of a method DecValue2HexString( int32 aValue, int32 aNumberOfDigits):

var string str  = "";
var string sign = "";
var int32  num  = aValue;

/* take care on negative values */
if ( num < 0 )
{
  sign = "-";
  num = -num;
}

/* limit given number of digits */
if (( aNoOfDigits <= 0 ) || ( aNoOfDigits > 8 ))
  aNoOfDigits = 1;

/* convert one digit after the other */
while (( num > 0 ) || ( aNoOfDigits > 0 ))
{
  var int8 digit = (int8)( num % 16 );

  /* convert digit into character '0'-'9' or 'A'-'F' */
  if ( digit < 10 )
    str = (char)((int8)'0' + digit ) + str;
  else
    str = (char)((int8)'A' + digit - 10 ) + str;

  /* process next digit */
  num = num / 16;
  aNoOfDigits = aNoOfDigits - 1;
}

/* add sign and return result */
return sign + str;

2. Why do you receive only '0000' on the target?

Probably you read your values from a data class (device class) which is accessed as autoobject. If you do not have a variable that refers to the autoobject all the time, it will be deleted by the Garbage Collector and re-created when you access it next time. For more details, please have a look to the article 'Data stored in an autoobject get lost'.

 

by
I understood and result is well in my project.

Many thanks.

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

...