No announcement yet.

Controlling cool gauge from 4DGL code

  • Filter
  • Time
  • Show
Clear All
new posts

  • Controlling cool gauge from 4DGL code

    I'm brand new to 4DGL and the PICASO, so go easy on me! Here's what I'm trying to do:
    I'm using a gen4-uLCD-24PT and I'm trying to display an engine's RPM on a cool gauge object using ViSi (not ViSiGenie).
    Click image for larger version

Name:	CoolGauge.png
Views:	289
Size:	19.2 KB
ID:	59120
    The actual engine RPMs run from 0 - about 4500, but because of the small screen size we're using, I couldn't have the gauge go from 0 - 5000, the digits looked way to crammed in there. So I'm having to display the RPMs in thousands of RPMs (i.e. a real engine RPM of 3250 should set the needle's position to 3.25). I want the digit field at the bottom of the gauge to display the raw number (i.e a real RPM of 3250 should display 3250, not 3.25). How do I go about doing this?

    I'm trying to find and read through the documentation for the cool gauge, and from what I've found, I'm making the following assumptions (obviously correct me if I'm wrong!):
    - I think that when I inserted a cool gauge into my project, that Workshop automatically generated a bunch of image frames for the gauge with the needle at various positions?
    - I think I need to access those images via img_SetWord(hndl, iRevButton, IMAGE_INDEX,FRAME_NUMBER) where "FRAME_NUMBER" is the correct image based on my actual value?

    Assuming that's right, how do I calculate what frame number corresponds to my raw value? I don't know enough yet to know how many frames were generated.
    How do I set the text value to my raw value separately from the RPM / 1000 value that needs to be set for the needle?

    If my assumptions are wrong, I'd appreciate knowing how to do this!

    If it matters, these are the properties of the cool gauge object
    Name RPMGauge
    Alias Coolgauge1
    Arc.Color 0xFFEFE0
    Arc.Opacity 200
    Arc.StartAngle 135
    Arc.StopAngle 405
    Threshold.Center 25
    Threshold.Color 0xFFD0AF
    Threshold.EndValue 100
    Threshold.Opacity 200
    Threshold.Span 25
    Threshold.StartAngle 135
    Threshold.StartValue 0
    Threshold.SweepAngle 270
    Threshold.ThresholdKind Angle
    Arc.Width 0.03
    CircleEndValue 360
    CircleStartValue 0
    DialText RPM
    Digit.Alignment Right
    Digit.BackGroundColor 0xFFEFE0
    Digit.BackGroundOpacity 30
    Digit.Color WHITE
    Digit.Visible Yes
    DivisionColor WHITE
    DivisionCount 5
    DivisionWidth 2
    EqualDimensions Yes
    Font.Color WHITE
    Font.Effects []
    Font.Name Tahoma
    Font.Size 14
    Font.Style []
    Height 167
    Innercircle.Color BLACK
    Gloss.Color clWhite
    Gloss.Opacity 72
    Innercircle.Opacity 200
    Left 28
    Logarithmic No
    LogarithmicBase 10
    MaximumValue 5
    MinimumValue 0
    Needle.Color WHITE
    Needle.InnerCenterColor WHITE
    Needle.InnerCenterColorTo 0xFFD0AF
    Needle.InnerCenterOpacity 255
    Needle.OuterCenterColor 0xFFD0AF
    Needle.OuterCenterColorTo WHITE
    Needle.OuterCenterOpacity 255
    Needle.ShineColor 0xFFEFE0
    Needle.ShineColorTo 0xD0D0D0
    OuterCircle.Color 0xFFD0AF
    OuterCircle.Opacity 100
    OuterCircle.Width 0.03
    OuterRim.Color 0x908070
    OuterRim.Opacity 255
    OuterRim.Width 2
    ShowValues Yes
    SubDivisionColor WHITE
    SubDivisionCount 1
    SubDivisionWidth 2
    TextRendering ClearType
    Top 0
    ValueFont.Color WHITE
    ValueFont.Effects []
    ValueFont.Name Tahoma
    ValueFont.Size 11
    ValueFont.Style []
    ValueFormat 0
    Width 167
    OnChanged ''

  • #2
    You could set ValueFormat to 0.000, but to me that looks a bit odd, as you get a '.' in there. Of course since you mentioned that the display is too small to see the difference between a ',' and a '.' that mighn't matter.

    If you really want the ',' you can temporarily change the windows number format to use a ',' as the decimal separator.

    You could also lower the font size of the 'Value Font'.

    You could also change the gauge to be RPM x 10 and use a ValueFormat of 0.0


    • #3
      Thanks, it turned out I missed the "Value Font" parameter, which helped greatly. Between changing that, and rearranging a couple things on my screen, I was able to set the minimum value to 0, and the maximum value to 5000 and got something that looks pretty decent as shown below. Now I can just set the raw RPM value on the gauge and both the needle and LED area display the correct value.
      Click image for larger version

Name:	CoolGauge5000.png
Views:	207
Size:	24.5 KB
ID:	59133
      I guess the only issue I have with this current approach, is that it created 5001 frames, which Workshop warned me it would use up over 200MB. I'm not too worried about file sizes, I'm using a 4GB sim card, and there's still quite a bit of space available on the drive. Unless having this many images will impact performance? So far I haven't noticed any issues...


      • #4
        There won't be any issues, the 200MB message is more about a simple sanity check as some people accidentally set up huge files without understanding why.

        In your case it is valid and expected