h. Dial Widget

<< Click to Display Table of Contents >>

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

h. Dial Widget

The Dial widget draws a rotary dial control which is used to display an analog value.  This section shows how to draw a dial widget with various parameters using the eve_dial() command.

 

 

Command Prototype

 

uint16_t eve_dial(int x, int y, int16_t r, int16_t options, int16_t val)

 

Parameters

Description

x

x-coordinate of dial center, in pixels

y

y-coordinate of dial center, in pixels

r

radius of dial, in pixels.

options

By default the dial is drawn with a 3D effect and the value of options is zero. Options OPT_FLAT removes the 3D effect and its value is 256

val

Specify the position of dial points by setting value between 0 and 65535 inclusive. 0 means that the dial points straight down, 0x4000 left, 0x8000 up, and0xc000 right.

 

 

Code

 

 

void setup()

{

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

 CleO.begin();

 

/* Start building a screen frame */

 CleO.Start();

 int x = 400, y = 240, radius = 75;

 uint16_t options = 0;

 uint16_t value1 = 24000;

 uint16_t value2 = 12000;

 uint16_t value3 = 48000;

 

/* Draw dials with various values */

 CleO.eve_dial(x, y - 160, radius, options, value1);

 CleO.eve_dial(x, y, radius, options, value2);

 CleO.eve_dial(x, y + 160, radius, options, value3);

 

/* Display completed screen frame */

 CleO.Show();

}

 

void loop()

{

}

 

 

Description

 

In the above code snippet, the Setup routine uses the eve_dial() command to draw three dial widgets. Dial widgets are drawn at (x,y) with radius r. By default, the dial is drawn with a 3D effect, and the value of options is zero. Option OPT_FLAT removes the 3D effect, and its value is 256. The position of the dial points is set by using the values between 0 and 65535 inclusive. 0 means that the dial points straight down, 0x4000 left, 0x8000 up, and0xc000 right.

 

Output

 

Here is the output displayed upon executing the code snippet -

 

Tutorials18-DialWidget.50