BRT Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome to the Bridgetek Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ Bridgetek Support

Please refer to our website for detailed information on all our products - Bridgetek - Bridging Technology

Author Topic: Simple way to draw meter  (Read 6950 times)

vdc

  • Newbie
  • *
  • Posts: 32
    • View Profile
Simple way to draw meter
« on: February 03, 2023, 04:25:24 PM »

Hi all,

Is there any simple way to draw a meter? I look at the DemoMeterDemo application and try to understand but this give me a really hard time to follow the code.

I tried with drawing two circle to get the  meter circle. But I have no idea how to get color changed when moving let say arrow.

Let say at 50%, the first half circle is green and the other half is red. I tried with the EDGE_STRIP but it just cover all the other half. Is there any better way to display this?

Thank you so much,

Quote
SCISSOR_XY(300,780)
SCISSOR_SIZE(200,120)
CLEAR_COLOR_RGB(0xff,0xff,0xff)
CLEAR(1, 1, 1)
POINT_SIZE(1600)
BEGIN(POINTS)
VERTEX2F(6400, 14400)
COLOR_RGB(0xFF,0xFF,0xFF)
POINT_SIZE(800)
VERTEX2F(6400, 14400)
END()



Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 733
    • View Profile
Re: Simple way to draw meter
« Reply #1 on: February 17, 2023, 03:33:30 PM »

Hi,

Is it an arc gauge style which you wish to draw?

Best Regards,
BRT Community

Logged

Rudolph

  • Sr. Member
  • ****
  • Posts: 389
    • View Profile
Re: Simple way to draw meter
« Reply #2 on: February 18, 2023, 01:56:38 PM »

A simple way to draw a meter could be to use cmd_gauge with OPT_NOBACK and OPT_NOTICKS on a fancier background image.

What I have done a couple of times now in projects which is even simpler is to use two rectangles on top of each other for a frame and then use a third rectangle within the frame, not as fancy but very efficient.
And you can round the edges of rectangles with the line width.
The result is more like a battery indicator.
It could be combined with changing the color, lines on top to form segments, numbers on the side and/or a number below/on top to show the current value.
I displayed values for temperature, voltage, torgue and rotational speed next to each other.
Funtionality was the goal, not so much eye-candy.
Logged

vdc

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: Simple way to draw meter
« Reply #3 on: February 20, 2023, 01:13:04 AM »

Something like the attached image.
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 733
    • View Profile
Re: Simple way to draw meter
« Reply #4 on: February 20, 2023, 04:54:11 PM »

Hi,

There are a few ways to do this, which can be
- entirely with EVE display objects (including the gauge background and the pointer)
- entirely via loading images (e.g. have a series of bitmap cells with the gauge at different positions)
- or a combination of these (e.g. image as the gauge background and use EVE shapes for the pointer)

One suggested way would be to use an image as the background of the gauge, and then to have a second bitmap of just the pointer and then rotate the pointer image.

You can also make the background using EVE shapes.

We can make a couple of small examples of these for you and post them here.

Best Regards, BRT Community




Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 733
    • View Profile
Re: Simple way to draw meter
« Reply #5 on: February 21, 2023, 01:33:04 PM »

Hi,

Here is one small example of using some gradients along with a gauge widget.

Here is the code and a short description attached,

Code: [Select]
CLEAR_COLOR_RGB(255, 255, 255)
CLEAR(1, 1, 1)

// *** Draw the invisible circles to make the ARC in the stencil buffer ***
COLOR_MASK(0, 0, 0, 1) // Disable writes of R, G and B to the screen
STENCIL_OP(INCR, INCR) // Set the stencil to increment

COLOR_RGB(0, 0, 255)
BEGIN(POINTS)
POINT_SIZE(1600) // Draw an outer circle defining the outside of the arc
VERTEX2II(200, 200)
COLOR_RGB(0, 255, 0)
POINT_SIZE(800) // Draw an inner circle defining the inside of the arc
VERTEX2II(200, 200)
END()

// *** Draw the gradient arc ***
COLOR_MASK(1, 1, 1, 1) // Enable writes to the colors again
STENCIL_OP(KEEP, KEEP) // Stop the stencil INCR
STENCIL_FUNC(EQUAL, 1, 255) // Only draw where the stencil buffer is =1 which is our arc
SCISSOR_SIZE(100, 100) // Constrain drawing to one half of the arc
SCISSOR_XY(100, 100)
CMD_GRADIENT(200, 150, 0xFFFF00, 100, 200, 0xFF0000) // Draw a gradient from red to yellow
SCISSOR_SIZE(100, 100) // Constrain drawing to the other half of the arc
SCISSOR_XY(200, 100)
CMD_GRADIENT(200, 150, 0xFFFF00, 300, 199, 0x00AA00) // Draw a gradient from yellow to green

// *** Return the stencil and scissor to normal***
STENCIL_FUNC(ALWAYS, 1, 255)
SCISSOR_SIZE(800, 480)
SCISSOR_XY(0, 0)

// *** Draw a gauge with no background or tickmarks ***
COLOR_RGB(0, 0, 0)
CMD_GAUGE(200, 200, 107, OPT_NOBACK | OPT_NOTICKS, 4, 8, 32, 100)

Best Regards, BRT Community
Logged

vdc

  • Newbie
  • *
  • Posts: 32
    • View Profile
Re: Simple way to draw meter
« Reply #6 on: February 22, 2023, 01:34:21 AM »

Thank you so much. This help me alot.
Logged