script2

script with 2 inputs and 2 outputs, running in a separate thread, you must define "void setup(void){}" and "void loop(void)"
Author: Johannes Taelman
License: BSD
Github: script/script2.axo

Inlets

frac32 in1

frac32 in2

Outlets

frac32 out1

frac32 out2

Attributes

text script

Declaration
int32_t in1, in2;
int32_t out1, out2;
attr_script msg_t ThreadX2() {
  setup();
  while (!chThdShouldTerminate()) {
    loop();
    chThdSleepMilliseconds(1);
  }
  chThdExit((msg_t)0);
}
static msg_t ThreadX(void *arg) { ((attr_parent *)arg)->ThreadX2(); }
WORKING_AREA(waThreadX, 1024);
Thread *Thd;
Init
in1 = 0;
in2 = 0;
out1 = 0;
out2 = 0;
Thd = chThdCreateStatic(waThreadX, sizeof(waThreadX), NORMALPRIO, ThreadX,
                        (void *)this);
Control Rate
outlet_out1__ = this->out1;
outlet_out2__ = this->out2;
this->in1 = inlet_in1__;
this->in2 = inlet_in2__;
Dispose
chThdTerminate(Thd);
chThdWait(Thd);

Privacy

© 2024 Zrna Research