c. Gauge Widget

<< Click to Display Table of Contents >>

Navigation:  Tutorials > Tutorial 18 - Built-In FT81x Widgets >

c. Gauge Widget

A Gauge widget depicts the value of a specified attribute or a count of features as a percentage of a target value.  This section shows how to draw the Gauge widget with various parameters using the eve_gauge() command.

 

 

Command Prototype

 

uint16_t eve_gauge(int x, int y, int16_t r, int16_t options, int16_t major, int16_t minor, int16_t val, int16_t range)

 

Parameters

Description

x

X-coordinate of gauge center, in pixels

y

Y-coordinate of gauge center, in pixels

r

Radius of the gauge, in pixels

options

By default the gauge dial is drawn with a 3D effect and the value of options is zero. OPT_FLAT removes the 3D effect. With option OPT_NOBACK, the background is not drawn. With option OPT_NOTICKS, the tick marks are not drawn. With option OPT_NOPOINTER, the pointer is not drawn.

major

Number of major subdivisions on the dial, 1-10

minor

Number of minor subdivisions on the dial, 1-10

val

Gauge indicated value, between 0 and range, inclusive

range

Maximum value

 

 

Code

 

 

void setup()

{

/* Initialize CleO - needs to be done only once */

 CleO.begin();

 

/* Start building a screen frame */

 CleO.Start();

 int x = 160, y = 240;

 uint16_t r = 40, major = 4, minior = 3;

 uint16_t options = 0;

 uint16_t value1 = 24000;

 uint16_t value2 = 12000;

 uint16_t value3 = 48000;

 uint16_t range = 65535;

 

/* Draw gauge with various values */

 CleO.eve_gauge(x, y - 100, r, options, major, minior, value1, range);

 CleO.eve_gauge(x, y, r, options, major, minior, value2, range);

 CleO.eve_gauge(x, y + 100, r, options, major, minior, value3, range);

 

/* Display completed screen frame */

 CleO.Show();

}

 

void loop()

{

}

 

 

Description

 

In the above code snippet, the eve_gauge() command is used to draw three gauge widgets. Gauge widgets are drawn at (x,y) with radius r. By default, the gauge dial is drawn with a 3D effect, and the value of options is set as zero. The options parameter refers to any of the following -

 

 

OPT_FLAT                removes the 3D effect

OPT_NOBACK        background is not drawn

OPT_NOTICKS        tick marks are not drawn

OPT_NOPOINTER        pointer is not drawn.

 

 

Output

 

Here is the output displayed upon executing the code snippet -

 

GaugeWidget