singen

bradzilla84/singen/singen

SinGen Arduino is the arduino library that generates sine signals using the PWM outputs 3,5,6,9,10 and 11.
singen
@/singen
SinGen Arduino is the arduino library that generates sine signals using the PWM outputs 3,5,6,9,10 and 11.
SLport
Pin PWM Low
SHport
Pin PWM High
HZnumber
Frequency
INITpulse
Starts the Gen on first pulse. and updates on each pulse.
singen
SL
SH
HZ
INIT
Done
Donepulse
Update Complete and output to pins
To use the node in your project you should have the bradzilla84/singen library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

#pragma XOD require "https://github.com/Bradzilla84/SinGen"

// Include C++ library:
{{#global}}
#include "SinGen.h"
{{/global}}


struct State {
    uint8_t mem[sizeof(SinGen)];
};

// Define our custom type as a pointer on the class instance.
using Type = SinGen*;

{{ GENERATED_CODE }}

void evaluate(Context ctx) {

    // It should be evaluated only once on the first (setup) transaction
    if (isSettingUp()){
    auto state = getState(ctx);
    auto Sin = new (state->mem) SinGen(getValue<input_SL>(ctx), getValue<input_SH>(ctx), getValue<input_HZ>(ctx));
    Sin->init();
        return;
    }

    // The node responds only if there is an input pulse
    if (!isInputDirty<input_INIT>(ctx)){
        return;}

    auto state = getState(ctx);
    auto Sin = reinterpret_cast<SinGen*>(state->mem);
    Sin->run();

    emitValue<output_Done>(ctx, 1);
}