Announcement

Collapse
No announcement yet.

How to change gauge position

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to change gauge position

    Please give a newbe some advice 😀
    I have tried the code below on a uLCD-35DT. It works as intended, a gauge with a needle moving back anf forth.

    My question: The gauge is placed in the top left corner. How to position the gauge in different position, like Left=100, Right = 200?

    Thank you!

    Code:
    #platform "uLCD-35DT"
    #inherit "4DGL_16bitColours.fnc"
    
    var state;
    var Gauge1Ram[10];
    
    #DATA
    word Gauge1Info
    // Scale parameters
    90, // Range scale outer edge radius
    70, // Range scale inner edge radius
    20, // Number of partitions of marker ticks
    2, // Number of minor ticks before next major tick (0 to disable)
    17, // Length for major ticks radiating from scale outer edge
    5, // Length for minor ticks radiating from scale outer edge
    10, // Length for major ticks radiating from scale inner edge
    2, // Length for minor ticks radiating from scale inner edge
    1, // Tick width
    0xFFFF, // Tick color
    270, // Starting angle for range scale second ring section
    337, // Starting angle for range scale third ring section
    0xDF, // Range scale first ring section color
    0x3BF, // Range scale second ring section color
    0xF800, // Range scale third ring section color
    0, // Range scale section incremental step size
    10, // Total number of marker scale labels
    FONT1, // Marker scale label font style
    0xFFFF, // Marker scale label text color
    15, // Marker scale label offset distance (relative to range scale midpoint)
    0, /* Labels */ // Pointer to label strings (Default is numeric is set to zero (0))
    (0 + 0 + 0 + 0), // Gauge Options
    2, // Caption
    0xFFFF, // Caption text color
    -26, // Caption horizontal offset from rotation centre
    56, // Caption vertical offset from rotation centre
    Gauge1Caption, // Caption text pointer
    
    // Gauge parameters common to needle
    10, // Top-Left X-position
    10, // Top-Left Y-position
    235, // Width
    197, // Height
    128, // Rotation centre X-position
    125, // Rotation centre Y-position
    GRAY, // Background color (required for erasing needle path)
    135, // Starting angle
    405, // Ending angle
    0, // Minimum value
    100, // Maximum value
    
    // Needle parameters
    60, // Needle length
    NEEDLE_F_TRIANGLE, // Needle style options
    0, // Needle offset distance from center
    6, // Needle width (Half value of overall needle thickness)
    30, // Needle tail length (Applicable only for double triangle style)
    0xFFFF, // Needle color
    6, // Needle Hub radius
    0xFFFF, // Needle Hub color
    2, // Needle Pin radius
    0xF800 // Needle Pin color
    byte Gauge1Caption "Pressure\0"
    #END
    
    func main()
    gfx_ScreenMode(LANDSCAPE);
    
    repeat
    for (state:= 0; state < 100; state += 1)
    gfx_AngularMeter(state, Gauge1Ram, Gauge1Info);
    pause(20);
    next
    for (state:= 100; state > 0; state -= 1)
    gfx_AngularMeter(state, Gauge1Ram, Gauge1Info);
    pause(20);
    next
    forever
    
    endfunc

  • #2
    Not sure where you got the code from, but it sure highlights why it is much easier to use the GUI to generate the parameters.

    Change line 39 and 43 to reflect changes in the x position, and lines 40 and 44 to reflect changes in the y Position
    Mark

    Comment


    • #3
      ESPsupport thanks! I did not realize that I had to change in 2+2 places to change the position (not very logical).
      The code is from the Diabolo16 Internal functions pdf (page 187). The code in main() is my own.

      Comment


      • #4
        Once you find you need to offset the needle from the centre of the gauge it is very logical. If your couldn't do that you wouldn't be able to do many many useful things with the gauge
        Mark

        Comment

        Working...
        X