Displays a number value at the SegM8 module or several modules linked in a daisy chain.
display-number
@/display-number
Displays a number value at the SegM8 module or several modules linked in a daisy chain.
DEV@/segm8-device
The SegM8 device.
VALnumber
A value to display.
POSnumber
In a daisy chain, the ordinal segM8 module number from which the value display begins. The module numbering in a daisy chain starts from 0, from left module to right.
Wnumber
The width of the displayed value in segM8 modules. The dot "." character of the floating-point value does not occupy the entire segM8 module.
DIGnumber
The number of SegM8 modules used to display digits after the dot. If it is set to 0, the value is displayed as an integer.
RDXnumber
The radix for an integer value. It can be 10 or 16. If the RDX is 16 the value is displayed in the hexadecimal format including the characters A, b, C, d, E, F;
LZboolean
The "leading zeroes" flag. If it is true adds zeroes to the beginning of the displayed value until it is W-sized.
Aboolean
The "align" flag. Aligns the displayed value to the left if true and to the right if false.
UPDpulse
Triggers a new display of the value.
DONEpulse
Pulses when the display of the value is done.
DEV'@/segm8-device
The SegM8 device.
To use the node in your project you should have the amperka/segm8 library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.
C++ implementation
struct State {
};
{{ GENERATED_CODE }}
void evaluate(Context ctx) {
auto chain = getValue<input_DEV>(ctx);
auto num = getValue<input_VAL>(ctx);
auto position = getValue<input_POS>(ctx);
auto width = getValue<input_W>(ctx);
auto precission = getValue<input_DIG>(ctx);
auto radix = getValue<input_RDX>(ctx);
auto leadzeros = getValue<input_LZ>(ctx);
auto toleft = getValue<input_A>(ctx);
if (isSettingUp())
emitValue<output_DEVU0027>(ctx, chain);
if(isInputDirty<input_UPD>(ctx)) {
for(uint8_t i = 0; i < width; i++) chain->writeSegments( 0, position + i); // clear field, put spaces
if(precission == 0) { // it is integer, not float
if(radix == 10) {
chain->display((int32_t)num, position, width, (toleft ? SEGM8_ALIGN_LEFT : 0) | (leadzeros ? SEGM8_PAD_ZEROS : 0));
} else if(radix == 16) {
chain->display((uint32_t)num, position, width, (toleft ? SEGM8_ALIGN_LEFT : 0) | (leadzeros ? SEGM8_PAD_ZEROS : 0) | SEGM8_RADIX_16);
} else { // other radixes not supported - error
chain->display("ERROR", position, width, SEGM8_ALIGN_LEFT);
}
} else { // it is float
chain->display((double)num, position, width, precission, (toleft ? SEGM8_ALIGN_LEFT : 0) | (leadzeros ? SEGM8_PAD_ZEROS : 0));
}
emitValue<output_DONE>(ctx, true);
}
}