string_muxer

String selector with value display
Author: Berend Klein Haneveld
License:
Github: hohum/disp/string_muxer.axo

Inlets

int32 value

int32 index

Outlets

charptr32 text

Attributes

table a1

table a2

table a3

table a4

table a5

table a6

table a7

table a8

table a9

table a10

Declaration
const int offset = 8;
char c[64];
int pvalue = -1;
int pindex = -1;
Init
strcpy(&c[0], "attr_a1           ");
pvalue = -1;
pindex = -1;
Control Rate
int index = inlet_index;
int value = inlet_value;

if (index != pindex) {
  if (index == 0) {
    strcpy(&c[0], "attr_a1          ");
  } else if (index == 1) {
    strcpy(&c[0], "attr_a2          ");
  } else if (index == 2) {
    strcpy(&c[0], "attr_a3          ");
  } else if (index == 3) {
    strcpy(&c[0], "attr_a4          ");
  } else if (index == 4) {
    strcpy(&c[0], "attr_a5          ");
  } else if (index == 5) {
    strcpy(&c[0], "attr_a6          ");
  } else if (index == 6) {
    strcpy(&c[0], "attr_a7          ");
  } else if (index == 7) {
    strcpy(&c[0], "attr_a8          ");
  } else if (index == 8) {
    strcpy(&c[0], "attr_a9          ");
  } else if (index == 9) {
    strcpy(&c[0], "attr_a10          ");
  }
  pindex = index;
}

if (value != pvalue) {
  int i = value;
  int i0 = i / 10;
  c[offset + 2] = '0' + i - 10 * i0;
  i = i0;
  i0 = i / 10;
  c[offset + 1] = '0' + i - 10 * i0;
  i = i0;
  i0 = i / 10;
  c[offset + 0] = '0' + i - 10 * i0;
  // Make sure there is a space between text and value
  c[offset - 1] = ' ';
  pvalue = value;
}

outlet_text = &c[0];

Privacy

© 2024 Zrna Research