led cell value b

Author:
License: GPL
Github: rbrt/push/led cell value b.axo

Inlets

bool32.risingfalling mute

frac32 in

bool32 mode

bool32.rising redraw

Outlets

None

Attributes

combo mode

spinner row

spinner column

objref LEDmaster

Declaration
int8_t v;
int8_t prev;
int8_t fb;
int16_t nb;
uint16_t offset;
uint8_t row;
bool doit;
bool trig;
bool mtrig;
bool update;
Init
#define BARS_ONE_L 0x03
#define BARS_ONE_R 0x04
#define BARS_TWO 0x05
#define BARS_NONE 0x06

offset = attr_LEDmaster.array[308 + attr_column] + (attr_row * 77);
Control Rate
if (!inlet_mute && !mtrig) {
  mtrig = 1;
  update = 1;
}
if (inlet_mute)
  mtrig = 0;

if (!inlet_mute) {
  if (inlet_redraw && !trig) {
    trig = 1;
    update = 1;
  }
  if (!inlet_redraw)
    trig = 0;
  row = attr_row;
  v = inlet_in >> 20;
  if (((v != prev) || update) && !attr_LEDmaster.LOCKED) {
    prev = v;
    update = 0;
    if (!(attr_mode || inlet_mode)) {
      if (v <= 0)
        v = 0;
      memset(attr_LEDmaster.array + offset, BARS_NONE, 8);
      nb = ((v + 1) << 4) >> 7;
      fb = nb >> 1;
      memset(attr_LEDmaster.array + offset, BARS_TWO, fb);
      if (nb % 2)
        attr_LEDmaster.array[fb + offset] = BARS_ONE_L;
    } else {
      v = (v >> 1) + 64;
      memset(attr_LEDmaster.array + offset, BARS_NONE, 8);
      attr_LEDmaster.array[4 + offset] = BARS_ONE_L;
      if (v > 64) {
        nb = (((v + 1) << 4) >> 7) - 8;
        fb = nb >> 1;
        memset(attr_LEDmaster.array + offset + 4, BARS_TWO, fb);
        if (nb % 2)
          attr_LEDmaster.array[fb + 4 + offset] = BARS_ONE_L;
      } else {
        nb = 8 - (((v + 1) << 4) >> 7);
        fb = nb >> 1;
        memset(attr_LEDmaster.array + offset + (4 - fb), BARS_TWO, fb);
        if (nb % 2)
          attr_LEDmaster.array[offset + 3 - fb] = BARS_ONE_R;
      }
    }
    doit = 1;
  }
  if (doit && !attr_LEDmaster.ROW) {
    attr_LEDmaster.ROW = row + 1;
    doit = 0;
  }
}

Privacy

© 2024 Zrna Research