Build a node for Void Setup?

Im horrible at C code how would i go about building a node that will inject a piece of code in to Void Setup?

any tutorials?

thanks

XOD is very different than IDE in this regard. There are no global variables, and there is no separate Setup function. All nodes are “executed” during initialization with none of the input pins “dirty” or pulses active. If you have code you want to execute only on startup, your node can test:

if (isSettingUp())

While a few nodes use this, many nodes that have initialization code also have data that needs initialized and stored, so rather than checking for isSettingUp(), they check to see if the data has been initialized (or if it needs changed, perhaps indicating re-initialization is needed).

Most of the documentation that is available can be found here: https://xod.io/docs. For specifics like this, it might be easier just to look at existing nodes to see how they did it (but finding which nodes have examples that apply to you can be difficult). I found the isSettingUp() function while looking at other nodes or I would not know about it. It would be nice if there was better documentation listing functions like this that are available (and maybe list some sample built-in nodes that could be referenced for sample usage of each function).

I was able to raise my PWM to 32khz by modifying the clock by using this bit of code.

Basically clicked show code, copy pasted into Arduino IDE and it actually worked, which surprised me lol.

but it would be nice if i could make a node that would make clock selectable and change the pwm but i believe it can only work in this particular part of the code.

//----------------------------------------------------------------------------
// Entry point
//----------------------------------------------------------------------------
void setup() {
// FIXME: looks like there is a rounding bug. Waiting for 100ms fights it
delay(100);

////////////////////////////////////////////////////////////////////////////////
TCCR2B = TCCR2B & B11111000 | B00000001; // last 3 digits determine PWM Freq
TCCR4B = TCCR4B & B11111000 | B00000001;
////////////////////////////////////////////////////////////////////////////////

#if defined(XOD_DEBUG) || defined(XOD_SIMULATION)
XOD_DEBUG_SERIAL.begin(115200);
XOD_DEBUG_SERIAL.setTimeout(10);
#endif
XOD_TRACE_FLN("\n\nProgram started");

xod::g_isSettingUp = true;
xod::runTransaction();
xod::g_isSettingUp = false;

}

void loop() {
xod::runTransaction();