Gauge¶
The gauge element displays a handle inside a circular dial.
Configure¶
Warning
Ensure the graphics library is included and initialised according to the configuration procedure.
Gauge myGauge(&myGraphics);
The constructor Gauge()
creates a gauge and sets the link to the graphics myGraphics
.
1 2 3 4 |
|
The required parameters are
-
The first line sets the x-y coordinates of the centre and the radius of the dial;
-
The second line sets the minimum, maximum and unit for the values.
The optional parameters are
-
The third line sets the number of divisions on the dial, default is
0
; -
The fourth line specifies the colour for the value.
Note
For monochrome and colour e-paper screens, ensure the selected colours are supported.
Use¶
myGauge.draw(value);
draw()
sends the new value.
Optionally,
1 2 |
|
- The optional second line contains the text displayed close to the bottom on the dial.
Example¶
This is the core of the code from example Graphics_Gauge.ino
.
void displayGauge()
{
myScreen.setOrientation(myOrientation);
myScreen.clear();
uint16_t x, y, dx, dy;
int32_t value = 128;
x = myScreen.screenSizeX();
y = myScreen.screenSizeY();
dx = x / 5;
dy = y / 5;
myScreen.selectFont(fontMedium);
myScreen.gText(0, 0, "Gauge");
Gauge myGauge(&myGraphics);
uint16_t dz = min(x, y) / 2 - 20;
myGauge.dDefine(x / 2, y / 2, dz, // x0 y0 radius
0, 255, 1, // valueMin valueMax unit
0, 8, // memory grid
myColours.black, // back colour
myColours.white, // front colour
myColours.grey, // grid colour
myColours.white, // value colour
myColours.grey, // min colour
myColours.grey); // max colour
myScreen.flushFast();
for (uint16_t count = 127; count > 0; count--)
{
value = cos32x100(count * 200);
myGauge.draw(value);
myScreen.flushFast();
}
}