led row value b attr

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

Inlets

frac32 v0

frac32 v1

frac32 v2

frac32 v3

frac32 v4

frac32 v5

frac32 v6

frac32 v7

bool32.rising redraw

int32 row

bool32.risingfalling mute

Outlets

None

Attributes

objref LEDmaster

spinner row

combo mode0

combo mode1

combo mode2

combo mode3

combo mode4

combo mode5

combo mode6

combo mode7

Declaration
uint16_t offset;
int16_t nb;

int8_t in[8];
int8_t prev[8];
bool mode[8];
uint8_t row;
int8_t fb;
uint8_t prerow;
uint8_t count;
int8_t v;

bool doit;
bool update;
bool trig;
bool mtrig;
Init
#define BARS_ONE_L 0x03
#define BARS_ONE_R 0x04
#define BARS_TWO 0x05
#define BARS_NONE 0x06

mode[0] = attr_mode0;
mode[1] = attr_mode1;
mode[2] = attr_mode2;
mode[3] = attr_mode3;
mode[4] = attr_mode4;
mode[5] = attr_mode5;
mode[6] = attr_mode6;
mode[7] = attr_mode7;
Control Rate
if (!inlet_mute && !mtrig) {
  mtrig = 1;
  update = 1;
  count = 0;
}
if (inlet_mute)
  mtrig = 0;
if (!inlet_mute) {
  in[0] = inlet_v0 >> 20;
  in[1] = inlet_v1 >> 20;
  in[2] = inlet_v2 >> 20;
  in[3] = inlet_v3 >> 20;
  in[4] = inlet_v4 >> 20;
  in[5] = inlet_v5 >> 20;
  in[6] = inlet_v6 >> 20;
  in[7] = inlet_v7 >> 20;

  row = (inlet_row + attr_row) % 4;

  if (inlet_redraw && !trig) {
    trig = 1;
    update = 1;
    count = 0;
  }
  if (!inlet_redraw)
    trig = 0;
  if (row != prerow) {
    prerow = row;
    update = 1;
    count = 0;
  }

  offset = attr_LEDmaster.array[count + 308] + (row * 77);
  v = in[count];

  if ((v != prev[count]) || update) {
    prev[count] = v;
    if (!mode[count]) {
      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);
      if (v == 64) {
        attr_LEDmaster.array[4 + offset] = 60;
        attr_LEDmaster.array[3 + offset] = 62;
      }
      if (v > 64) {
        attr_LEDmaster.array[3 + offset] = 62;
        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;
      }
      if (v < 64) {
        attr_LEDmaster.array[4 + offset] = 60;
        nb = 8 - (((v + 6) << 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.LOCKED) {
    attr_LEDmaster.ROW = row + 1;
    doit = 0;
  }
  count++;
  count = count % 8;
  if (!count)
    update = 0;
}

Privacy

© 2024 Zrna Research