countX

cyclic up counter with external count-up control
Author: Johannes Taelman edit by Remco van der Most
License: BSD
Github: sss/logic/countX.axo

Inlets

bool32.rising trigger

int32 start

int32 step

int32.positive MaxCount

Outlets

bool32 c

int32 output

Declaration
int ntrig;
int rtrig;
int32_t count;
Init
count = 0;
ntrig = 0;
rtrig = 0;
Control Rate
int c = 0;
if ((inlet_trig > 0) && !ntrig) {
  int Max = inlet_MaxCount;
  count += inlet_step;
  if (count >= Max) {
    count -= Max;
    c = 1;
  }
  ntrig = 1;
} else if (!(inlet_trig > 0))
  ntrig = 0;
outlet_o = count + inlet_start;
outlet_c = c;

Privacy

© 2024 Zrna Research