Customvaluegauge
Subpage of Gauges
Custom expression gauge
You are not allowed to change the symbol to show like normally, but you have to write your own expression in 'C-style'. Do not worry if you are not familiar with the C programming language, this help provides all the information you need.
Right-click on the gauge and click on Change gauge text and format menu to open the editor.
You can set the following values of the gauge:
- the title of the gauge (e.g. Custom expressions)
- the size and the position of the title (The color is determined by the theme, it can not be changed here)
- the size and color of the expression
- and perhaps you can set the expression
If you know the printf("format",...) function you may go to examples (But it is recommended to go through the next section quickly because not all the formatters supported by printf are supported by the gauge!)
The expression editor
The expression editor provides so-called code-completition. It means you do not have to know the exact name of a symbol,
if you type min. 3 characters, the editor will show a list filled with the symbols that start with the letters you have typed in.
If you press Ctrl-Space you will see the list of all available symbols.
In the editor you must use the following format:
"format", arg1, ..., argnOn the gauge a sequence of data formatted as the format argument specifies will be displayed.
After the format parameter, at least as many additional arguments as specified in format is expected.
Important: the format parameter must be between quotes!
argn may be a constant value (e.g. 2000) or a symbol (e.g. rpm) or an expression
expression is a combination of constant values, symbols, operators and functions (e.g. 1.5 * lambda, lambda / lambdatarget, sin(0.5 * pi))
The format argument tells what to display and how to display, it is a string that contains the text to be written out.
It can optionally contain embedded format tags that are substituted by the values specified in subsequent argument(s) and formatted as requested.
The number of arguments following the format parameters should at least be as much as the number of format tags.
The format tags follow this prototype:
%[flags][width][.precision][length]specifier
specifier | meaning | example |
---|---|---|
c | Character | a |
i or d | Signed integer | -42 |
f | Decimal floating point | 3.1415 |
o | Unsigned octal | 777 |
u | Unsigned decimal integer | 12345 |
x | Unsigned hexadecimal integer | 4f |
X | Unsigned hexadecimal integer (capital letters) | FFA |
% | Display % | % |
The tag can also contain flags, width, .precision and modifiers sub-specifiers, which are optional and follow these specifications:
flags | meaning |
---|---|
- | Left-justify within the given field width; Right justification is the default (see width sub-specifier). |
+ | Forces to precede the result with a plus or minus sign (+ or -) even for positive numbers. By default, only negative numbers are preceded with a - sign. |
0 | Left-pads the number with zeroes (0) instead of spaces, where padding is specified (see width sub-specifier). |
width | meaning |
---|---|
(number) | Left-justify within the given field width; Right justification is the default (see width sub-specifier). |
+ | Minimum number of characters to be printed. If the value to be printed is shorter than this number, the result is padded with blank spaces. The value is not truncated even if the result is larger. |
precision | meaning |
---|---|
.number | description
.number For integer specifiers (d, i, o, u, x, X): precision specifies the minimum number of digits to be written. If the value to be written is shorter than this number, the result is padded with leading zeros. The value is not truncated even if the result is longer. A precision of 0 means that no character is written for the value 0. For f specifier: this is the number of digits to be printed after the decimal point. For c type: it has no effect. When no precision is specified, the default is 1. If the period is specified without an explicit value for precision, 0 is assumed. |
length | meaning |
---|---|
h | The argument is interpreted as a short int or unsigned short int (only applies to integer specifiers: i, d, o, u, x and X). |
l | The argument is interpreted as a long int or unsigned long int for integer specifiers (i, d, o, u, x and X), and as a wide character for specifier c |
L | The argument is interpreted as a long double (only applies to floating point specifier f) |
Only these formatters are supported!
The backslash (\) character is an 'escaper' character. You need escaping if you want display quote ("), new-line or backslash on the gauge.
Write this | To get |
---|---|
\\ | \ |
\" | " |
\n | (linebreak) |
Only these characters can be escaped!
Examples
Input | A possible output | Remarks |
---|---|---|
"GPS Date: %d-%02d-%02d", gpsDateY + 2000, gpsDateM, gpsDateD | GPS Date: 2011-04-01 | - |
"GPS Date: %d-%d-%d", gpsDateY, gpsDateM, gpsDateD | GPS Date: 11-4-1 | - |
"RPM = %d", rpm | RPM = 2676 | RPM is integer |
"Lambda = %.01f", lambda | Lambda = 1.0 | We need the fraction too |
"Lambda = %.02f", lambda | Lambda = 1.04 | We need bigger precision |
"Lambda is equal\nto lambdatarget?\n%d", lambda == lambdatarget | Lambda is equal to lambdatarget? 0 | If equal it displays 1, otherwise 0 |
"lambdadiff = %.2f", lambda - lambdatarget | lambdadiff = -0.05 | - |
"egoCorr VE = %.2f", (veCurr * egoCorrection * lambda) / (lambdatarget * 100) | egoCorr VE = 124.55 | - |