It is currently Sun May 19, 2013 5:30 am


All times are UTC - 7 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Changing the Display of a Readout Based on Its Value
PostPosted: Wed Feb 21, 2007 11:52 am 

Joined: Wed Aug 02, 2006 4:50 pm
Posts: 281
Location: Colorado
I had a recent discussion about changing the number of decimal points to display on a readout (from readouts.dsn) based on its value and thought it might be of general interest.

Of course, formatting of strings can be done in code or simulation and then sent out for display. But what if your code is just sending a value and you want the readout to automatically adjust?

The readouts have animations that let you easily set the number of decimal digits to display. You then have to "tickle" the value to have the new setting apply. The tricky part about this problem is that we want to change whenever we receive a new value -- and we'll be "tickling" that same value. That is, we want to ignore the values we send.

Anyway, here is some Control code that can be used to listen to the float value and then change the number of decimal points displayed:
Code:
WHEN 1_readout_float ==
  // Turn on caching so we only update once
  SET altiaCacheOutput = 1
  IF 1_readout_routing == 0
    // This float change isn't from our "tickle," so process it
    IF 1_readout_float >= 10 AND 1_readout_decimal_pts != 0
      // No decimals for values over 10
      SET 1_readout_decimal_pts = 0
      SET 1_readout_float = 1_readout_float
      SET 1_readout_routing = 1
    ENDIF
    ELSEIF 1_readout_float < 10 AND 1_readout_decimal_pts != 1
      // 1 decimal for values under 10
      SET 1_readout_decimal_pts = 1
      SET 1_readout_float = 1_readout_float
      SET 1_readout_routing = 1
    ENDIF
  ENDIF
  ELSE
    SET 1_readout_routing = 0
  ENDIF
  SET altiaCacheOutput = 0
END


In order for this control code to work as expected, be sure to set the "Number Sytle" property in the readout's properties dialog to "Decimal." This allows the "1_readout_decimal_pts" animation to drive the number of decimal places for the readout.

_________________
Altia.com - User Interface Design Tools and GUI Software


Top
Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net