233 views
in GUI Development by
Hi..May you help me in solarDemo example in momentary power ,how can show negetive data on power panel? for example "var SimPower= --3600 " and " MaxValue=4800 " and " MinValue= -- 4800 " .in this case the neddle just locate on "0" Value Text for each negetive value of  "  SimPower " !!!!! .......Please HELP

1 Answer

0 votes
by

Hi Bastin,

the class 'PowerPanel' was implemented to show only positive values, because solar modules usually only produce energy...

Nevertheless, you can adapt the implementation in order to show also a value range that include negative values:

  • Open the class 'DataPlotter'
  • Open the method 'OnSetMinValue' within the Code Editor and remove the limitation that ensures that 'value' is greater than 0.
  • Open the method 'OnSetMaxValue' within the Code Editor and remove the limitation that ensures that 'value' is greater than 0.
  • Open the method 'DrawSamples' within the Code Editor and change the implementation of drawing the samples: 
/* draw all samples of the last sequence */
for ( x = 0; x <  SamplesPerUpdate; x = x + 1 )
{
  /* draw data of channel */
  y = Bounds.h - borderY;

  if ( MaxValue > MinValue )
    y =  y - (( SampleStorage[ x ] - MinValue ) * ( Bounds.h - 2 * borderY ) / ( MaxValue - MinValue ));

  DrawPenLine( PenColor, Bounds.w - deltaX * ( SamplesPerUpdate - x ) - 10, LastValue, y );
  LastValue = y;
}

Now you can use the data plotter with your desired value range and just add your samples. Please note, that the scale that is shown within the power panel needs to be adapted to your value range.

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

...