mirror of
https://github.com/xodio/xod.git
synced 2026-03-15 05:06:59 +01:00
fix(rt/c++): workaround pin names and global macros collision
Closes #650
This commit is contained in:
@@ -15,14 +15,10 @@ State* getState(NodeId nid) {
|
||||
return reinterpret_cast<State*>(storages[nid]);
|
||||
}
|
||||
|
||||
namespace Inputs {
|
||||
{{#each inputs}}
|
||||
using {{ pinKey }} = InputDescriptor<{{ type }}, offsetof(Storage, input_{{ pinKey }})>;
|
||||
{{/each}}
|
||||
}
|
||||
{{#each inputs}}
|
||||
using input_{{ pinKey }} = InputDescriptor<{{ type }}, offsetof(Storage, input_{{ pinKey }})>;
|
||||
{{/each}}
|
||||
|
||||
namespace Outputs {
|
||||
{{#each outputs}}
|
||||
using {{ pinKey }} = OutputDescriptor<{{ type }}, offsetof(Storage, output_{{ pinKey }}), {{@index}}>;
|
||||
{{/each}}
|
||||
}
|
||||
{{#each outputs}}
|
||||
using output_{{ pinKey }} = OutputDescriptor<{{ type }}, offsetof(Storage, output_{{ pinKey }}), {{@index}}>;
|
||||
{{/each}}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace _program {
|
||||
{ }, // state
|
||||
{{#each inputs }}
|
||||
{{#exists nodeId }}
|
||||
{ NodeId({{ nodeId }}), {{ patch/owner }}__{{ patch/libName }}__{{ patch/patchName }}::Outputs::{{ fromPinKey }}::KEY }, // input_{{ pinKey }}
|
||||
{ NodeId({{ nodeId }}), {{ patch/owner }}__{{ patch/libName }}__{{ patch/patchName }}::output_{{ fromPinKey }}::KEY }, // input_{{ pinKey }}
|
||||
{{else }}
|
||||
{ NO_NODE, 0 }, // input_{{ pinKey }}
|
||||
{{/exists }}
|
||||
|
||||
10
packages/xod-arduino/test/fixtures/implList.cpp
vendored
10
packages/xod-arduino/test/fixtures/implList.cpp
vendored
@@ -27,14 +27,10 @@ State* getState(NodeId nid) {
|
||||
return reinterpret_cast<State*>(storages[nid]);
|
||||
}
|
||||
|
||||
namespace Inputs {
|
||||
using IN1 = InputDescriptor<Number, offsetof(Storage, input_IN1)>;
|
||||
using IN2 = InputDescriptor<Number, offsetof(Storage, input_IN2)>;
|
||||
}
|
||||
using input_IN1 = InputDescriptor<Number, offsetof(Storage, input_IN1)>;
|
||||
using input_IN2 = InputDescriptor<Number, offsetof(Storage, input_IN2)>;
|
||||
|
||||
namespace Outputs {
|
||||
using OUT = OutputDescriptor<Number, offsetof(Storage, output_OUT), 0>;
|
||||
}
|
||||
using output_OUT = OutputDescriptor<Number, offsetof(Storage, output_OUT), 0>;
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
/* Native implementation goes here */
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace _program {
|
||||
NodeId links_1_OUT[] = { NO_NODE };
|
||||
xod__math__multiply::Storage storage_1 = {
|
||||
{ }, // state
|
||||
{ NodeId(0), xod__math__multiply::Outputs::OUT::KEY }, // input_IN1
|
||||
{ NodeId(0), xod__math__multiply::output_OUT::KEY }, // input_IN1
|
||||
{ NO_NODE, 0 }, // input_IN2
|
||||
{ 0, links_1_OUT } // output_OUT
|
||||
};
|
||||
|
||||
@@ -932,22 +932,18 @@ State* getState(NodeId nid) {
|
||||
return reinterpret_cast<State*>(storages[nid]);
|
||||
}
|
||||
|
||||
namespace Inputs {
|
||||
using IVAL = InputDescriptor<Number, offsetof(Storage, input_IVAL)>;
|
||||
using RST = InputDescriptor<Logic, offsetof(Storage, input_RST)>;
|
||||
}
|
||||
using input_IVAL = InputDescriptor<Number, offsetof(Storage, input_IVAL)>;
|
||||
using input_RST = InputDescriptor<Logic, offsetof(Storage, input_RST)>;
|
||||
|
||||
namespace Outputs {
|
||||
using TICK = OutputDescriptor<Logic, offsetof(Storage, output_TICK), 0>;
|
||||
}
|
||||
using output_TICK = OutputDescriptor<Logic, offsetof(Storage, output_TICK), 0>;
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
State* state = getState(nid);
|
||||
TimeMs tNow = transactionTime();
|
||||
TimeMs dt = getValue<Inputs::IVAL>(nid) * 1000;
|
||||
TimeMs dt = getValue<input_IVAL>(nid) * 1000;
|
||||
TimeMs tNext = tNow + dt;
|
||||
|
||||
if (isInputDirty<Inputs::RST>(nid)) {
|
||||
if (isInputDirty<input_RST>(nid)) {
|
||||
if (dt == 0) {
|
||||
state->nextTrig = 0;
|
||||
clearTimeout(nid);
|
||||
@@ -957,7 +953,7 @@ void evaluate(NodeId nid) {
|
||||
}
|
||||
} else {
|
||||
// It was a scheduled tick
|
||||
emitValue<Outputs::TICK>(nid, 1);
|
||||
emitValue<output_TICK>(nid, 1);
|
||||
state->nextTrig = tNext;
|
||||
setTimeout(nid, dt);
|
||||
}
|
||||
@@ -984,17 +980,12 @@ State* getState(NodeId nid) {
|
||||
return reinterpret_cast<State*>(storages[nid]);
|
||||
}
|
||||
|
||||
namespace Inputs {
|
||||
using PORT = InputDescriptor<Number, offsetof(Storage, input_PORT)>;
|
||||
using SIG = InputDescriptor<Logic, offsetof(Storage, input_SIG)>;
|
||||
}
|
||||
|
||||
namespace Outputs {
|
||||
}
|
||||
using input_PORT = InputDescriptor<Number, offsetof(Storage, input_PORT)>;
|
||||
using input_SIG = InputDescriptor<Logic, offsetof(Storage, input_SIG)>;
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
State* state = getState(nid);
|
||||
const int port = (int)getValue<Inputs::PORT>(nid);
|
||||
const int port = (int)getValue<input_PORT>(nid);
|
||||
if (port != state->configuredPort) {
|
||||
::pinMode(port, OUTPUT);
|
||||
// Store configured port so to avoid repeating `pinMode` call if just
|
||||
@@ -1002,7 +993,7 @@ void evaluate(NodeId nid) {
|
||||
state->configuredPort = port;
|
||||
}
|
||||
|
||||
const bool val = getValue<Inputs::SIG>(nid);
|
||||
const bool val = getValue<input_SIG>(nid);
|
||||
::digitalWrite(port, val);
|
||||
}
|
||||
|
||||
@@ -1029,22 +1020,18 @@ State* getState(NodeId nid) {
|
||||
return reinterpret_cast<State*>(storages[nid]);
|
||||
}
|
||||
|
||||
namespace Inputs {
|
||||
using SET = InputDescriptor<Logic, offsetof(Storage, input_SET)>;
|
||||
using TGL = InputDescriptor<Logic, offsetof(Storage, input_TGL)>;
|
||||
using RST = InputDescriptor<Logic, offsetof(Storage, input_RST)>;
|
||||
}
|
||||
using input_SET = InputDescriptor<Logic, offsetof(Storage, input_SET)>;
|
||||
using input_TGL = InputDescriptor<Logic, offsetof(Storage, input_TGL)>;
|
||||
using input_RST = InputDescriptor<Logic, offsetof(Storage, input_RST)>;
|
||||
|
||||
namespace Outputs {
|
||||
using MEM = OutputDescriptor<Logic, offsetof(Storage, output_MEM), 0>;
|
||||
}
|
||||
using output_MEM = OutputDescriptor<Logic, offsetof(Storage, output_MEM), 0>;
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
State* state = getState(nid);
|
||||
bool newState = state->state;
|
||||
if (isInputDirty<Inputs::TGL>(nid)) {
|
||||
if (isInputDirty<input_TGL>(nid)) {
|
||||
newState = !state->state;
|
||||
} else if (isInputDirty<Inputs::SET>(nid)) {
|
||||
} else if (isInputDirty<input_SET>(nid)) {
|
||||
newState = true;
|
||||
} else {
|
||||
newState = false;
|
||||
@@ -1054,7 +1041,7 @@ void evaluate(NodeId nid) {
|
||||
return;
|
||||
|
||||
state->state = newState;
|
||||
emitValue<Outputs::MEM>(nid, newState);
|
||||
emitValue<output_MEM>(nid, newState);
|
||||
}
|
||||
|
||||
} // namespace xod__core__flip_flop
|
||||
@@ -1075,15 +1062,10 @@ State* getState(NodeId nid) {
|
||||
return reinterpret_cast<State*>(storages[nid]);
|
||||
}
|
||||
|
||||
namespace Inputs {
|
||||
}
|
||||
|
||||
namespace Outputs {
|
||||
using VAL = OutputDescriptor<Number, offsetof(Storage, output_VAL), 0>;
|
||||
}
|
||||
using output_VAL = OutputDescriptor<Number, offsetof(Storage, output_VAL), 0>;
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
reemitValue<Outputs::VAL>(nid);
|
||||
reemitValue<output_VAL>(nid);
|
||||
}
|
||||
|
||||
} // namespace xod__core__constant_number
|
||||
@@ -1103,22 +1085,22 @@ namespace _program {
|
||||
NodeId links_0_TICK[] = { 2, NO_NODE };
|
||||
xod__core__clock::Storage storage_0 = {
|
||||
{ }, // state
|
||||
{ NodeId(3), xod__core__constant_number::Outputs::VAL::KEY }, // input_IVAL
|
||||
{ NodeId(3), xod__core__constant_number::output_VAL::KEY }, // input_IVAL
|
||||
{ NO_NODE, 0 }, // input_RST
|
||||
{ false, links_0_TICK } // output_TICK
|
||||
};
|
||||
|
||||
xod__core__digital_output::Storage storage_1 = {
|
||||
{ }, // state
|
||||
{ NodeId(4), xod__core__constant_number::Outputs::VAL::KEY }, // input_PORT
|
||||
{ NodeId(2), xod__core__flip_flop::Outputs::MEM::KEY }, // input_SIG
|
||||
{ NodeId(4), xod__core__constant_number::output_VAL::KEY }, // input_PORT
|
||||
{ NodeId(2), xod__core__flip_flop::output_MEM::KEY }, // input_SIG
|
||||
};
|
||||
|
||||
NodeId links_2_MEM[] = { 1, NO_NODE };
|
||||
xod__core__flip_flop::Storage storage_2 = {
|
||||
{ }, // state
|
||||
{ NO_NODE, 0 }, // input_SET
|
||||
{ NodeId(0), xod__core__clock::Outputs::TICK::KEY }, // input_TGL
|
||||
{ NodeId(0), xod__core__clock::output_TICK::KEY }, // input_TGL
|
||||
{ NO_NODE, 0 }, // input_RST
|
||||
{ false, links_2_MEM } // output_MEM
|
||||
};
|
||||
|
||||
@@ -930,16 +930,12 @@ State* getState(NodeId nid) {
|
||||
return reinterpret_cast<State*>(storages[nid]);
|
||||
}
|
||||
|
||||
namespace Inputs {
|
||||
using UPD = InputDescriptor<Logic, offsetof(Storage, input_UPD)>;
|
||||
}
|
||||
using input_UPD = InputDescriptor<Logic, offsetof(Storage, input_UPD)>;
|
||||
|
||||
namespace Outputs {
|
||||
using TIME = OutputDescriptor<Number, offsetof(Storage, output_TIME), 0>;
|
||||
}
|
||||
using output_TIME = OutputDescriptor<Number, offsetof(Storage, output_TIME), 0>;
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
emitValue<Outputs::TIME>(nid, millis() / 1000.f);
|
||||
emitValue<output_TIME>(nid, millis() / 1000.f);
|
||||
}
|
||||
|
||||
} // namespace xod__core__system_time
|
||||
@@ -976,19 +972,14 @@ State* getState(NodeId nid) {
|
||||
return reinterpret_cast<State*>(storages[nid]);
|
||||
}
|
||||
|
||||
namespace Inputs {
|
||||
using RS = InputDescriptor<Number, offsetof(Storage, input_RS)>;
|
||||
using EN = InputDescriptor<Number, offsetof(Storage, input_EN)>;
|
||||
using D4 = InputDescriptor<Number, offsetof(Storage, input_D4)>;
|
||||
using D5 = InputDescriptor<Number, offsetof(Storage, input_D5)>;
|
||||
using D6 = InputDescriptor<Number, offsetof(Storage, input_D6)>;
|
||||
using D7 = InputDescriptor<Number, offsetof(Storage, input_D7)>;
|
||||
using L1 = InputDescriptor<XString, offsetof(Storage, input_L1)>;
|
||||
using L2 = InputDescriptor<XString, offsetof(Storage, input_L2)>;
|
||||
}
|
||||
|
||||
namespace Outputs {
|
||||
}
|
||||
using input_RS = InputDescriptor<Number, offsetof(Storage, input_RS)>;
|
||||
using input_EN = InputDescriptor<Number, offsetof(Storage, input_EN)>;
|
||||
using input_D4 = InputDescriptor<Number, offsetof(Storage, input_D4)>;
|
||||
using input_D5 = InputDescriptor<Number, offsetof(Storage, input_D5)>;
|
||||
using input_D6 = InputDescriptor<Number, offsetof(Storage, input_D6)>;
|
||||
using input_D7 = InputDescriptor<Number, offsetof(Storage, input_D7)>;
|
||||
using input_L1 = InputDescriptor<XString, offsetof(Storage, input_L1)>;
|
||||
using input_L2 = InputDescriptor<XString, offsetof(Storage, input_L2)>;
|
||||
|
||||
void printLine(LiquidCrystal* lcd, uint8_t lineIndex, XString str) {
|
||||
if (!str)
|
||||
@@ -1004,18 +995,18 @@ void evaluate(NodeId nid) {
|
||||
auto lcd = state->lcd;
|
||||
if (!state->lcd) {
|
||||
state->lcd = lcd = new LiquidCrystal(
|
||||
(int)getValue<Inputs::RS>(nid),
|
||||
(int)getValue<Inputs::EN>(nid),
|
||||
(int)getValue<Inputs::D4>(nid),
|
||||
(int)getValue<Inputs::D5>(nid),
|
||||
(int)getValue<Inputs::D6>(nid),
|
||||
(int)getValue<Inputs::D7>(nid));
|
||||
(int)getValue<input_RS>(nid),
|
||||
(int)getValue<input_EN>(nid),
|
||||
(int)getValue<input_D4>(nid),
|
||||
(int)getValue<input_D5>(nid),
|
||||
(int)getValue<input_D6>(nid),
|
||||
(int)getValue<input_D7>(nid));
|
||||
|
||||
lcd->begin(16, 2);
|
||||
}
|
||||
|
||||
printLine(lcd, 0, getValue<Inputs::L1>(nid));
|
||||
printLine(lcd, 1, getValue<Inputs::L2>(nid));
|
||||
printLine(lcd, 0, getValue<input_L1>(nid));
|
||||
printLine(lcd, 1, getValue<input_L2>(nid));
|
||||
}
|
||||
|
||||
} // namespace xod__common_hardware__text_lcd_16x2
|
||||
@@ -1038,20 +1029,16 @@ State* getState(NodeId nid) {
|
||||
return reinterpret_cast<State*>(storages[nid]);
|
||||
}
|
||||
|
||||
namespace Inputs {
|
||||
using IN = InputDescriptor<Number, offsetof(Storage, input_IN)>;
|
||||
}
|
||||
using input_IN = InputDescriptor<Number, offsetof(Storage, input_IN)>;
|
||||
|
||||
namespace Outputs {
|
||||
using OUT = OutputDescriptor<XString, offsetof(Storage, output_OUT), 0>;
|
||||
}
|
||||
using output_OUT = OutputDescriptor<XString, offsetof(Storage, output_OUT), 0>;
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
char str[16];
|
||||
auto num = getValue<Inputs::IN>(nid);
|
||||
auto num = getValue<input_IN>(nid);
|
||||
dtostrf(num, 0, 2, str);
|
||||
auto xstr = ::xod::List<char>::fromPlainArray(str, strlen(str));
|
||||
emitValue<Outputs::OUT>(nid, xstr);
|
||||
emitValue<output_OUT>(nid, xstr);
|
||||
}
|
||||
|
||||
} // namespace xod__core__cast_number_to_string
|
||||
@@ -1073,15 +1060,10 @@ State* getState(NodeId nid) {
|
||||
return reinterpret_cast<State*>(storages[nid]);
|
||||
}
|
||||
|
||||
namespace Inputs {
|
||||
}
|
||||
|
||||
namespace Outputs {
|
||||
using TICK = OutputDescriptor<Logic, offsetof(Storage, output_TICK), 0>;
|
||||
}
|
||||
using output_TICK = OutputDescriptor<Logic, offsetof(Storage, output_TICK), 0>;
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
emitValue<Outputs::TICK>(nid, 1);
|
||||
emitValue<output_TICK>(nid, 1);
|
||||
setTimeout(nid, 0);
|
||||
}
|
||||
|
||||
@@ -1103,15 +1085,10 @@ State* getState(NodeId nid) {
|
||||
return reinterpret_cast<State*>(storages[nid]);
|
||||
}
|
||||
|
||||
namespace Inputs {
|
||||
}
|
||||
|
||||
namespace Outputs {
|
||||
using VAL = OutputDescriptor<Number, offsetof(Storage, output_VAL), 0>;
|
||||
}
|
||||
using output_VAL = OutputDescriptor<Number, offsetof(Storage, output_VAL), 0>;
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
reemitValue<Outputs::VAL>(nid);
|
||||
reemitValue<output_VAL>(nid);
|
||||
}
|
||||
|
||||
} // namespace xod__core__constant_number
|
||||
@@ -1132,15 +1109,10 @@ State* getState(NodeId nid) {
|
||||
return reinterpret_cast<State*>(storages[nid]);
|
||||
}
|
||||
|
||||
namespace Inputs {
|
||||
}
|
||||
|
||||
namespace Outputs {
|
||||
using VAL = OutputDescriptor<XString, offsetof(Storage, output_VAL), 0>;
|
||||
}
|
||||
using output_VAL = OutputDescriptor<XString, offsetof(Storage, output_VAL), 0>;
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
reemitValue<Outputs::VAL>(nid);
|
||||
reemitValue<output_VAL>(nid);
|
||||
}
|
||||
|
||||
} // namespace xod__core__constant_string
|
||||
@@ -1160,26 +1132,26 @@ namespace _program {
|
||||
NodeId links_0_TIME[] = { 2, NO_NODE };
|
||||
xod__core__system_time::Storage storage_0 = {
|
||||
{ }, // state
|
||||
{ NodeId(3), xod__core__continuously::Outputs::TICK::KEY }, // input_UPD
|
||||
{ NodeId(3), xod__core__continuously::output_TICK::KEY }, // input_UPD
|
||||
{ 0, links_0_TIME } // output_TIME
|
||||
};
|
||||
|
||||
xod__common_hardware__text_lcd_16x2::Storage storage_1 = {
|
||||
{ }, // state
|
||||
{ NodeId(9), xod__core__constant_number::Outputs::VAL::KEY }, // input_RS
|
||||
{ NodeId(8), xod__core__constant_number::Outputs::VAL::KEY }, // input_EN
|
||||
{ NodeId(4), xod__core__constant_number::Outputs::VAL::KEY }, // input_D4
|
||||
{ NodeId(7), xod__core__constant_number::Outputs::VAL::KEY }, // input_D5
|
||||
{ NodeId(6), xod__core__constant_number::Outputs::VAL::KEY }, // input_D6
|
||||
{ NodeId(10), xod__core__constant_number::Outputs::VAL::KEY }, // input_D7
|
||||
{ NodeId(2), xod__core__cast_number_to_string::Outputs::OUT::KEY }, // input_L1
|
||||
{ NodeId(5), xod__core__constant_string::Outputs::VAL::KEY }, // input_L2
|
||||
{ NodeId(9), xod__core__constant_number::output_VAL::KEY }, // input_RS
|
||||
{ NodeId(8), xod__core__constant_number::output_VAL::KEY }, // input_EN
|
||||
{ NodeId(4), xod__core__constant_number::output_VAL::KEY }, // input_D4
|
||||
{ NodeId(7), xod__core__constant_number::output_VAL::KEY }, // input_D5
|
||||
{ NodeId(6), xod__core__constant_number::output_VAL::KEY }, // input_D6
|
||||
{ NodeId(10), xod__core__constant_number::output_VAL::KEY }, // input_D7
|
||||
{ NodeId(2), xod__core__cast_number_to_string::output_OUT::KEY }, // input_L1
|
||||
{ NodeId(5), xod__core__constant_string::output_VAL::KEY }, // input_L2
|
||||
};
|
||||
|
||||
NodeId links_2_OUT[] = { 1, NO_NODE };
|
||||
xod__core__cast_number_to_string::Storage storage_2 = {
|
||||
{ }, // state
|
||||
{ NodeId(0), xod__core__system_time::Outputs::TIME::KEY }, // input_IN
|
||||
{ NodeId(0), xod__core__system_time::output_TIME::KEY }, // input_IN
|
||||
{ ::xod::List<char>::empty(), links_2_OUT } // output_OUT
|
||||
};
|
||||
|
||||
|
||||
@@ -12,11 +12,11 @@ struct State {
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
State* state = getState(nid);
|
||||
auto port = (int)getValue<Inputs::PORT>(nid);
|
||||
auto port = (int)getValue<input_PORT>(nid);
|
||||
if (port != state->configuredPort) {
|
||||
state->servo.attach(port);
|
||||
state->configuredPort = port;
|
||||
}
|
||||
|
||||
state->servo.write(getValue<Inputs::VAL>(nid) * 180);
|
||||
state->servo.write(getValue<input_VAL>(nid) * 180);
|
||||
}
|
||||
|
||||
@@ -23,16 +23,16 @@ void evaluate(NodeId nid) {
|
||||
auto lcd = state->lcd;
|
||||
if (!state->lcd) {
|
||||
state->lcd = lcd = new LiquidCrystal(
|
||||
(int)getValue<Inputs::RS>(nid),
|
||||
(int)getValue<Inputs::EN>(nid),
|
||||
(int)getValue<Inputs::D4>(nid),
|
||||
(int)getValue<Inputs::D5>(nid),
|
||||
(int)getValue<Inputs::D6>(nid),
|
||||
(int)getValue<Inputs::D7>(nid));
|
||||
(int)getValue<input_RS>(nid),
|
||||
(int)getValue<input_EN>(nid),
|
||||
(int)getValue<input_D4>(nid),
|
||||
(int)getValue<input_D5>(nid),
|
||||
(int)getValue<input_D6>(nid),
|
||||
(int)getValue<input_D7>(nid));
|
||||
|
||||
lcd->begin(16, 2);
|
||||
}
|
||||
|
||||
printLine(lcd, 0, getValue<Inputs::L1>(nid));
|
||||
printLine(lcd, 1, getValue<Inputs::L2>(nid));
|
||||
printLine(lcd, 0, getValue<input_L1>(nid));
|
||||
printLine(lcd, 1, getValue<input_L2>(nid));
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
auto x = getValue<Inputs::X>(nid);
|
||||
emitValue<Outputs::ABSX>(nid, abs(x));
|
||||
auto x = getValue<input_X>(nid);
|
||||
emitValue<output_ABSX>(nid, abs(x));
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
auto x = getValue<Inputs::X>(nid);
|
||||
auto y = getValue<Inputs::Y>(nid);
|
||||
emitValue<Outputs::SUM>(nid, x + y);
|
||||
auto x = getValue<input_X>(nid);
|
||||
auto y = getValue<input_Y>(nid);
|
||||
emitValue<output_SUM>(nid, x + y);
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
if (!isInputDirty<Inputs::UPD>(nid))
|
||||
if (!isInputDirty<input_UPD>(nid))
|
||||
return;
|
||||
|
||||
State* state = getState(nid);
|
||||
const int port = (int)getValue<Inputs::PORT>(nid);
|
||||
const int port = (int)getValue<input_PORT>(nid);
|
||||
if (port != state->configuredPort) {
|
||||
::pinMode(port, INPUT);
|
||||
// Store configured port so to avoid repeating `pinMode` on
|
||||
@@ -17,5 +17,5 @@ void evaluate(NodeId nid) {
|
||||
state->configuredPort = port;
|
||||
}
|
||||
|
||||
emitValue<Outputs::VAL>(nid, ::analogRead(port) / 1023.);
|
||||
emitValue<output_VAL>(nid, ::analogRead(port) / 1023.);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
auto a = getValue<Inputs::A>(nid);
|
||||
auto b = getValue<Inputs::B>(nid);
|
||||
emitValue<Outputs::AND>(nid, a && b);
|
||||
auto a = getValue<input_A>(nid);
|
||||
auto b = getValue<input_B>(nid);
|
||||
emitValue<output_AND>(nid, a && b);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
bool p1 = isInputDirty<Inputs::P1>(nid);
|
||||
bool p2 = isInputDirty<Inputs::P2>(nid);
|
||||
bool p1 = isInputDirty<input_P1>(nid);
|
||||
bool p2 = isInputDirty<input_P2>(nid);
|
||||
if (p1 || p2)
|
||||
emitValue<Outputs::ANY>(nid, true);
|
||||
emitValue<output_ANY>(nid, true);
|
||||
}
|
||||
|
||||
@@ -4,5 +4,5 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
emitValue<Outputs::BOOT>(nid, 1);
|
||||
emitValue<output_BOOT>(nid, 1);
|
||||
}
|
||||
|
||||
@@ -5,14 +5,14 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
if (!isInputDirty<Inputs::UPD>(nid))
|
||||
if (!isInputDirty<input_UPD>(nid))
|
||||
return;
|
||||
|
||||
State* state = getState(nid);
|
||||
auto newValue = getValue<Inputs::NEW>(nid);
|
||||
auto newValue = getValue<input_NEW>(nid);
|
||||
if (newValue == state->value)
|
||||
return;
|
||||
|
||||
state->value = newValue;
|
||||
emitValue<Outputs::MEM>(nid, newValue);
|
||||
emitValue<output_MEM>(nid, newValue);
|
||||
}
|
||||
|
||||
@@ -4,5 +4,5 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
emitValue<Outputs::OUT>(nid, getValue<Inputs::IN>(nid) ? 1.0 : 0.0);
|
||||
emitValue<output_OUT>(nid, getValue<Inputs::IN>(nid) ? 1.0 : 0.0);
|
||||
}
|
||||
|
||||
@@ -6,10 +6,10 @@ struct State {
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
State* state = getState(nid);
|
||||
auto newValue = getValue<Inputs::IN>(nid);
|
||||
auto newValue = getValue<input_IN>(nid);
|
||||
|
||||
if (newValue == true && state->state == false)
|
||||
emitValue<Outputs::OUT>(nid, 1);
|
||||
emitValue<output_OUT>(nid, 1);
|
||||
|
||||
state->state = newValue;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
auto x = getValue<Inputs::IN>(nid);
|
||||
auto x = getValue<input_IN>(nid);
|
||||
auto xstr = x
|
||||
? ::xod::List<char>::fromPlainArray("true", 4)
|
||||
: ::xod::List<char>::fromPlainArray("false", 5);
|
||||
emitValue<Outputs::OUT>(nid, xstr);
|
||||
emitValue<output_OUT>(nid, xstr);
|
||||
}
|
||||
|
||||
@@ -4,5 +4,5 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
emitValue<Outputs::OUT>(nid, getValue<Inputs::IN>(nid) != 0.0);
|
||||
emitValue<output_OUT>(nid, getValue<Inputs::IN>(nid) != 0.0);
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ struct State {
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
char str[16];
|
||||
auto num = getValue<Inputs::IN>(nid);
|
||||
auto num = getValue<input_IN>(nid);
|
||||
dtostrf(num, 0, 2, str);
|
||||
auto xstr = ::xod::List<char>::fromPlainArray(str, strlen(str));
|
||||
emitValue<Outputs::OUT>(nid, xstr);
|
||||
emitValue<output_OUT>(nid, xstr);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
auto x = getValue<Inputs::X>(nid);
|
||||
emitValue<Outputs::CEIL>(nid, ceil(x));
|
||||
auto x = getValue<input_X>(nid);
|
||||
emitValue<output_CEIL>(nid, ceil(x));
|
||||
}
|
||||
|
||||
@@ -7,10 +7,10 @@ struct State {
|
||||
void evaluate(NodeId nid) {
|
||||
State* state = getState(nid);
|
||||
TimeMs tNow = transactionTime();
|
||||
TimeMs dt = getValue<Inputs::IVAL>(nid) * 1000;
|
||||
TimeMs dt = getValue<input_IVAL>(nid) * 1000;
|
||||
TimeMs tNext = tNow + dt;
|
||||
|
||||
if (isInputDirty<Inputs::RST>(nid)) {
|
||||
if (isInputDirty<input_RST>(nid)) {
|
||||
if (dt == 0) {
|
||||
state->nextTrig = 0;
|
||||
clearTimeout(nid);
|
||||
@@ -20,7 +20,7 @@ void evaluate(NodeId nid) {
|
||||
}
|
||||
} else {
|
||||
// It was a scheduled tick
|
||||
emitValue<Outputs::TICK>(nid, 1);
|
||||
emitValue<output_TICK>(nid, 1);
|
||||
state->nextTrig = tNext;
|
||||
setTimeout(nid, dt);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
auto head = getValue<Inputs::HEAD>(nid);
|
||||
auto tail = getValue<Inputs::TAIL>(nid);
|
||||
emitValue<Outputs::STR>(nid, head->concat(tail));
|
||||
auto head = getValue<input_HEAD>(nid);
|
||||
auto tail = getValue<input_TAIL>(nid);
|
||||
emitValue<output_STR>(nid, head->concat(tail));
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
if (!isInputDirty<Inputs::DUMP>(nid))
|
||||
if (!isInputDirty<input_DUMP>(nid))
|
||||
return;
|
||||
|
||||
State* state = getState(nid);
|
||||
@@ -13,7 +13,7 @@ void evaluate(NodeId nid) {
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
auto line = getValue<Inputs::LINE>(nid);
|
||||
auto line = getValue<input_LINE>(nid);
|
||||
if (line) {
|
||||
for (auto it = line->iterate(); it; ++it)
|
||||
Serial.write((char)*it);
|
||||
|
||||
@@ -4,5 +4,5 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
reemitValue<Outputs::VAL>(nid);
|
||||
reemitValue<output_VAL>(nid);
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@ struct State {};
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
reemitValue<Outputs::VAL>(nid);
|
||||
reemitValue<output_VAL>(nid);
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@ struct State {};
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
reemitValue<Outputs::VAL>(nid);
|
||||
reemitValue<output_VAL>(nid);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
auto x = getValue<Inputs::X>(nid);
|
||||
auto minX = getValue<Inputs::MIN>(nid);
|
||||
auto maxX = getValue<Inputs::MAX>(nid);
|
||||
emitValue<Outputs::XC>(nid, x < minX ? minX : (x > maxX ? maxX : x));
|
||||
auto x = getValue<input_X>(nid);
|
||||
auto minX = getValue<input_MIN>(nid);
|
||||
auto maxX = getValue<input_MAX>(nid);
|
||||
emitValue<output_XC>(nid, x < minX ? minX : (x > maxX ? maxX : x));
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
emitValue<Outputs::TICK>(nid, 1);
|
||||
emitValue<output_TICK>(nid, 1);
|
||||
setTimeout(nid, 0);
|
||||
}
|
||||
|
||||
@@ -4,14 +4,14 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
TimeMs dt = getValue<Inputs::T>(nid) * 1000;
|
||||
TimeMs dt = getValue<input_T>(nid) * 1000;
|
||||
|
||||
if (isInputDirty<Inputs::RST>(nid)) {
|
||||
if (isInputDirty<input_RST>(nid)) {
|
||||
clearTimeout(nid);
|
||||
} else if (isInputDirty<Inputs::SET>(nid)) {
|
||||
} else if (isInputDirty<input_SET>(nid)) {
|
||||
setTimeout(nid, dt);
|
||||
} else {
|
||||
// It was a scheduled evaluation
|
||||
emitValue<Outputs::DONE>(nid, true);
|
||||
emitValue<output_DONE>(nid, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,11 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
if (!isInputDirty<Inputs::UPD>(nid))
|
||||
if (!isInputDirty<input_UPD>(nid))
|
||||
return;
|
||||
|
||||
State* state = getState(nid);
|
||||
const int port = (int)getValue<Inputs::PORT>(nid);
|
||||
const int port = (int)getValue<input_PORT>(nid);
|
||||
if (port != state->configuredPort) {
|
||||
::pinMode(port, INPUT);
|
||||
// Store configured port so to avoid repeating `pinMode` on
|
||||
@@ -17,5 +17,5 @@ void evaluate(NodeId nid) {
|
||||
state->configuredPort = port;
|
||||
}
|
||||
|
||||
emitValue<Outputs::SIG>(nid, ::digitalRead(port));
|
||||
emitValue<output_SIG>(nid, ::digitalRead(port));
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ struct State {
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
State* state = getState(nid);
|
||||
const int port = (int)getValue<Inputs::PORT>(nid);
|
||||
const int port = (int)getValue<input_PORT>(nid);
|
||||
if (port != state->configuredPort) {
|
||||
::pinMode(port, OUTPUT);
|
||||
// Store configured port so to avoid repeating `pinMode` call if just
|
||||
@@ -14,6 +14,6 @@ void evaluate(NodeId nid) {
|
||||
state->configuredPort = port;
|
||||
}
|
||||
|
||||
const bool val = getValue<Inputs::SIG>(nid);
|
||||
const bool val = getValue<input_SIG>(nid);
|
||||
::digitalWrite(port, val);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
auto x = getValue<Inputs::X>(nid);
|
||||
auto y = getValue<Inputs::Y>(nid);
|
||||
emitValue<Outputs::FRAC>(nid, x / y);
|
||||
auto x = getValue<input_X>(nid);
|
||||
auto y = getValue<input_Y>(nid);
|
||||
emitValue<output_FRAC>(nid, x / y);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
auto lhs = getValue<Inputs::LHS>(nid);
|
||||
auto rhs = getValue<Inputs::RHS>(nid);
|
||||
emitValue<Outputs::EQ>(nid, lhs == rhs);
|
||||
auto lhs = getValue<input_LHS>(nid);
|
||||
auto rhs = getValue<input_RHS>(nid);
|
||||
emitValue<output_EQ>(nid, lhs == rhs);
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ struct State {
|
||||
void evaluate(NodeId nid) {
|
||||
State* state = getState(nid);
|
||||
bool newState = state->state;
|
||||
if (isInputDirty<Inputs::TGL>(nid)) {
|
||||
if (isInputDirty<input_TGL>(nid)) {
|
||||
newState = !state->state;
|
||||
} else if (isInputDirty<Inputs::SET>(nid)) {
|
||||
} else if (isInputDirty<input_SET>(nid)) {
|
||||
newState = true;
|
||||
} else {
|
||||
newState = false;
|
||||
@@ -19,5 +19,5 @@ void evaluate(NodeId nid) {
|
||||
return;
|
||||
|
||||
state->state = newState;
|
||||
emitValue<Outputs::MEM>(nid, newState);
|
||||
emitValue<output_MEM>(nid, newState);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
auto x = getValue<Inputs::X>(nid);
|
||||
emitValue<Outputs::FLR>(nid, floor(x));
|
||||
auto x = getValue<input_X>(nid);
|
||||
emitValue<output_FLR>(nid, floor(x));
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ struct State {
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
char str[16];
|
||||
auto num = getValue<Inputs::NUM>(nid);
|
||||
auto dig = getValue<Inputs::DIG>(nid);
|
||||
auto num = getValue<input_NUM>(nid);
|
||||
auto dig = getValue<input_DIG>(nid);
|
||||
dtostrf(num, 0, dig, str);
|
||||
auto xstr = ::xod::List<char>::fromPlainArray(str, strlen(str));
|
||||
emitValue<Outputs::STR>(nid, xstr);
|
||||
emitValue<output_STR>(nid, xstr);
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
if (!isInputDirty<Inputs::TRIG>(nid))
|
||||
if (!isInputDirty<input_TRIG>(nid))
|
||||
return;
|
||||
|
||||
if (getValue<Inputs::GATE>(nid)) {
|
||||
emitValue<Outputs::T>(nid, 1);
|
||||
if (getValue<input_GATE>(nid)) {
|
||||
emitValue<output_T>(nid, 1);
|
||||
} else {
|
||||
emitValue<Outputs::F>(nid, 1);
|
||||
emitValue<output_F>(nid, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
auto lhs = getValue<Inputs::LHS>(nid);
|
||||
auto rhs = getValue<Inputs::RHS>(nid);
|
||||
emitValue<Outputs::GT>(nid, lhs > rhs);
|
||||
auto lhs = getValue<input_LHS>(nid);
|
||||
auto rhs = getValue<input_RHS>(nid);
|
||||
emitValue<output_GT>(nid, lhs > rhs);
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
auto cond = getValue<Inputs::COND>(nid);
|
||||
auto trueVal = getValue<Inputs::T>(nid);
|
||||
auto falseVal = getValue<Inputs::F>(nid);
|
||||
emitValue<Outputs::R>(nid, cond ? trueVal : falseVal);
|
||||
auto cond = getValue<input_COND>(nid);
|
||||
auto trueVal = getValue<input_T>(nid);
|
||||
auto falseVal = getValue<input_F>(nid);
|
||||
emitValue<output_R>(nid, cond ? trueVal : falseVal);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ struct State {};
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
auto lhs = getValue<Inputs::LHS>(nid);
|
||||
auto rhs = getValue<Inputs::RHS>(nid);
|
||||
emitValue<Outputs::LT>(nid, lhs < rhs);
|
||||
auto lhs = getValue<input_LHS>(nid);
|
||||
auto rhs = getValue<input_RHS>(nid);
|
||||
emitValue<output_LT>(nid, lhs < rhs);
|
||||
}
|
||||
|
||||
@@ -4,12 +4,12 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
auto x = getValue<Inputs::X>(nid);
|
||||
auto sMin = getValue<Inputs::Smin>(nid);
|
||||
auto sMax = getValue<Inputs::Smax>(nid);
|
||||
auto tMin = getValue<Inputs::Tmin>(nid);
|
||||
auto tMax = getValue<Inputs::Tmax>(nid);
|
||||
auto x = getValue<input_X>(nid);
|
||||
auto sMin = getValue<input_Smin>(nid);
|
||||
auto sMax = getValue<input_Smax>(nid);
|
||||
auto tMin = getValue<input_Tmin>(nid);
|
||||
auto tMax = getValue<input_Tmax>(nid);
|
||||
auto k = (x - sMin) / (sMax - sMin);
|
||||
auto xm = tMin + k * (tMax - tMin);
|
||||
emitValue<Outputs::Xm>(nid, xm);
|
||||
emitValue<output_Xm>(nid, xm);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
auto x = getValue<Inputs::X>(nid);
|
||||
auto y = getValue<Inputs::Y>(nid);
|
||||
emitValue<Outputs::PROD>(nid, x * y);
|
||||
auto x = getValue<input_X>(nid);
|
||||
auto y = getValue<input_Y>(nid);
|
||||
emitValue<output_PROD>(nid, x * y);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
auto a = getValue<Inputs::A>(nid);
|
||||
auto b = getValue<Inputs::B>(nid);
|
||||
emitValue<Outputs::NAND>(nid, !(a && b));
|
||||
auto a = getValue<input_A>(nid);
|
||||
auto b = getValue<input_B>(nid);
|
||||
emitValue<output_NAND>(nid, !(a && b));
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
auto a = getValue<Inputs::A>(nid);
|
||||
auto b = getValue<Inputs::B>(nid);
|
||||
emitValue<Outputs::NOR>(nid, !(a || b));
|
||||
auto a = getValue<input_A>(nid);
|
||||
auto b = getValue<input_B>(nid);
|
||||
emitValue<output_NOR>(nid, !(a || b));
|
||||
}
|
||||
|
||||
@@ -4,6 +4,6 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
auto x = getValue<Inputs::X>(nid);
|
||||
emitValue<Outputs::NOTX>(nid, !x);
|
||||
auto x = getValue<input_X>(nid);
|
||||
emitValue<output_NOTX>(nid, !x);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
auto a = getValue<Inputs::A>(nid);
|
||||
auto b = getValue<Inputs::B>(nid);
|
||||
emitValue<Outputs::OR>(nid, a || b);
|
||||
auto a = getValue<input_A>(nid);
|
||||
auto b = getValue<input_B>(nid);
|
||||
emitValue<output_OR>(nid, a || b);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ struct State {
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
State* state = getState(nid);
|
||||
const int port = (int)getValue<Inputs::PORT>(nid);
|
||||
const int port = (int)getValue<input_PORT>(nid);
|
||||
if (port != state->configuredPort) {
|
||||
::pinMode(port, OUTPUT);
|
||||
// Store configured port so to avoid repeating `pinMode` call if just
|
||||
@@ -14,7 +14,7 @@ void evaluate(NodeId nid) {
|
||||
state->configuredPort = port;
|
||||
}
|
||||
|
||||
auto duty = getValue<Inputs::DUTY>(nid);
|
||||
auto duty = getValue<input_DUTY>(nid);
|
||||
duty = duty > 1 ? 1 : (duty < 0 ? 0 : duty);
|
||||
|
||||
uint8_t val = (uint8_t)(duty * 255.0);
|
||||
|
||||
@@ -4,6 +4,6 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
auto x = getValue<Inputs::X>(nid);
|
||||
emitValue<Outputs::RND>(nid, round(x));
|
||||
auto x = getValue<input_X>(nid);
|
||||
emitValue<output_RND>(nid, round(x));
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
auto x = getValue<Inputs::X>(nid);
|
||||
auto y = getValue<Inputs::Y>(nid);
|
||||
emitValue<Outputs::DIFF>(nid, x - y);
|
||||
auto x = getValue<input_X>(nid);
|
||||
auto y = getValue<input_Y>(nid);
|
||||
emitValue<output_DIFF>(nid, x - y);
|
||||
}
|
||||
|
||||
@@ -4,5 +4,5 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
emitValue<Outputs::TIME>(nid, millis() / 1000.f);
|
||||
emitValue<output_TIME>(nid, millis() / 1000.f);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ struct State {
|
||||
{{ GENERATED_CODE }}
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
auto a = getValue<Inputs::A>(nid);
|
||||
auto b = getValue<Inputs::B>(nid);
|
||||
emitValue<Outputs::XOR>(nid, a != b);
|
||||
auto a = getValue<input_A>(nid);
|
||||
auto b = getValue<input_B>(nid);
|
||||
emitValue<output_XOR>(nid, a != b);
|
||||
}
|
||||
|
||||
@@ -932,24 +932,20 @@ State* getState(NodeId nid) {
|
||||
return reinterpret_cast<State*>(storages[nid]);
|
||||
}
|
||||
|
||||
namespace Inputs {
|
||||
using GATE = InputDescriptor<Logic, offsetof(Storage, input_GATE)>;
|
||||
using TRIG = InputDescriptor<Logic, offsetof(Storage, input_TRIG)>;
|
||||
}
|
||||
using input_GATE = InputDescriptor<Logic, offsetof(Storage, input_GATE)>;
|
||||
using input_TRIG = InputDescriptor<Logic, offsetof(Storage, input_TRIG)>;
|
||||
|
||||
namespace Outputs {
|
||||
using T = OutputDescriptor<Logic, offsetof(Storage, output_T), 0>;
|
||||
using F = OutputDescriptor<Logic, offsetof(Storage, output_F), 1>;
|
||||
}
|
||||
using output_T = OutputDescriptor<Logic, offsetof(Storage, output_T), 0>;
|
||||
using output_F = OutputDescriptor<Logic, offsetof(Storage, output_F), 1>;
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
if (!isInputDirty<Inputs::TRIG>(nid))
|
||||
if (!isInputDirty<input_TRIG>(nid))
|
||||
return;
|
||||
|
||||
if (getValue<Inputs::GATE>(nid)) {
|
||||
emitValue<Outputs::T>(nid, 1);
|
||||
if (getValue<input_GATE>(nid)) {
|
||||
emitValue<output_T>(nid, 1);
|
||||
} else {
|
||||
emitValue<Outputs::F>(nid, 1);
|
||||
emitValue<output_F>(nid, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -975,21 +971,17 @@ State* getState(NodeId nid) {
|
||||
return reinterpret_cast<State*>(storages[nid]);
|
||||
}
|
||||
|
||||
namespace Inputs {
|
||||
using PORT = InputDescriptor<Number, offsetof(Storage, input_PORT)>;
|
||||
using UPD = InputDescriptor<Logic, offsetof(Storage, input_UPD)>;
|
||||
}
|
||||
using input_PORT = InputDescriptor<Number, offsetof(Storage, input_PORT)>;
|
||||
using input_UPD = InputDescriptor<Logic, offsetof(Storage, input_UPD)>;
|
||||
|
||||
namespace Outputs {
|
||||
using SIG = OutputDescriptor<Logic, offsetof(Storage, output_SIG), 0>;
|
||||
}
|
||||
using output_SIG = OutputDescriptor<Logic, offsetof(Storage, output_SIG), 0>;
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
if (!isInputDirty<Inputs::UPD>(nid))
|
||||
if (!isInputDirty<input_UPD>(nid))
|
||||
return;
|
||||
|
||||
State* state = getState(nid);
|
||||
const int port = (int)getValue<Inputs::PORT>(nid);
|
||||
const int port = (int)getValue<input_PORT>(nid);
|
||||
if (port != state->configuredPort) {
|
||||
::pinMode(port, INPUT);
|
||||
// Store configured port so to avoid repeating `pinMode` on
|
||||
@@ -997,7 +989,7 @@ void evaluate(NodeId nid) {
|
||||
state->configuredPort = port;
|
||||
}
|
||||
|
||||
emitValue<Outputs::SIG>(nid, ::digitalRead(port));
|
||||
emitValue<output_SIG>(nid, ::digitalRead(port));
|
||||
}
|
||||
|
||||
} // namespace xod__core__digital_input
|
||||
@@ -1023,22 +1015,18 @@ State* getState(NodeId nid) {
|
||||
return reinterpret_cast<State*>(storages[nid]);
|
||||
}
|
||||
|
||||
namespace Inputs {
|
||||
using SET = InputDescriptor<Logic, offsetof(Storage, input_SET)>;
|
||||
using TGL = InputDescriptor<Logic, offsetof(Storage, input_TGL)>;
|
||||
using RST = InputDescriptor<Logic, offsetof(Storage, input_RST)>;
|
||||
}
|
||||
using input_SET = InputDescriptor<Logic, offsetof(Storage, input_SET)>;
|
||||
using input_TGL = InputDescriptor<Logic, offsetof(Storage, input_TGL)>;
|
||||
using input_RST = InputDescriptor<Logic, offsetof(Storage, input_RST)>;
|
||||
|
||||
namespace Outputs {
|
||||
using MEM = OutputDescriptor<Logic, offsetof(Storage, output_MEM), 0>;
|
||||
}
|
||||
using output_MEM = OutputDescriptor<Logic, offsetof(Storage, output_MEM), 0>;
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
State* state = getState(nid);
|
||||
bool newState = state->state;
|
||||
if (isInputDirty<Inputs::TGL>(nid)) {
|
||||
if (isInputDirty<input_TGL>(nid)) {
|
||||
newState = !state->state;
|
||||
} else if (isInputDirty<Inputs::SET>(nid)) {
|
||||
} else if (isInputDirty<input_SET>(nid)) {
|
||||
newState = true;
|
||||
} else {
|
||||
newState = false;
|
||||
@@ -1048,7 +1036,7 @@ void evaluate(NodeId nid) {
|
||||
return;
|
||||
|
||||
state->state = newState;
|
||||
emitValue<Outputs::MEM>(nid, newState);
|
||||
emitValue<output_MEM>(nid, newState);
|
||||
}
|
||||
|
||||
} // namespace xod__core__flip_flop
|
||||
@@ -1072,17 +1060,12 @@ State* getState(NodeId nid) {
|
||||
return reinterpret_cast<State*>(storages[nid]);
|
||||
}
|
||||
|
||||
namespace Inputs {
|
||||
using PORT = InputDescriptor<Number, offsetof(Storage, input_PORT)>;
|
||||
using SIG = InputDescriptor<Logic, offsetof(Storage, input_SIG)>;
|
||||
}
|
||||
|
||||
namespace Outputs {
|
||||
}
|
||||
using input_PORT = InputDescriptor<Number, offsetof(Storage, input_PORT)>;
|
||||
using input_SIG = InputDescriptor<Logic, offsetof(Storage, input_SIG)>;
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
State* state = getState(nid);
|
||||
const int port = (int)getValue<Inputs::PORT>(nid);
|
||||
const int port = (int)getValue<input_PORT>(nid);
|
||||
if (port != state->configuredPort) {
|
||||
::pinMode(port, OUTPUT);
|
||||
// Store configured port so to avoid repeating `pinMode` call if just
|
||||
@@ -1090,7 +1073,7 @@ void evaluate(NodeId nid) {
|
||||
state->configuredPort = port;
|
||||
}
|
||||
|
||||
const bool val = getValue<Inputs::SIG>(nid);
|
||||
const bool val = getValue<input_SIG>(nid);
|
||||
::digitalWrite(port, val);
|
||||
}
|
||||
|
||||
@@ -1113,15 +1096,10 @@ State* getState(NodeId nid) {
|
||||
return reinterpret_cast<State*>(storages[nid]);
|
||||
}
|
||||
|
||||
namespace Inputs {
|
||||
}
|
||||
|
||||
namespace Outputs {
|
||||
using TICK = OutputDescriptor<Logic, offsetof(Storage, output_TICK), 0>;
|
||||
}
|
||||
using output_TICK = OutputDescriptor<Logic, offsetof(Storage, output_TICK), 0>;
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
emitValue<Outputs::TICK>(nid, 1);
|
||||
emitValue<output_TICK>(nid, 1);
|
||||
setTimeout(nid, 0);
|
||||
}
|
||||
|
||||
@@ -1143,15 +1121,10 @@ State* getState(NodeId nid) {
|
||||
return reinterpret_cast<State*>(storages[nid]);
|
||||
}
|
||||
|
||||
namespace Inputs {
|
||||
}
|
||||
|
||||
namespace Outputs {
|
||||
using VAL = OutputDescriptor<Number, offsetof(Storage, output_VAL), 0>;
|
||||
}
|
||||
using output_VAL = OutputDescriptor<Number, offsetof(Storage, output_VAL), 0>;
|
||||
|
||||
void evaluate(NodeId nid) {
|
||||
reemitValue<Outputs::VAL>(nid);
|
||||
reemitValue<output_VAL>(nid);
|
||||
}
|
||||
|
||||
} // namespace xod__core__constant_number
|
||||
@@ -1172,8 +1145,8 @@ namespace _program {
|
||||
NodeId links_0_F[] = { 2, NO_NODE };
|
||||
xod__core__gate::Storage storage_0 = {
|
||||
{ }, // state
|
||||
{ NodeId(1), xod__core__digital_input::Outputs::SIG::KEY }, // input_GATE
|
||||
{ NodeId(9), xod__core__continuously::Outputs::TICK::KEY }, // input_TRIG
|
||||
{ NodeId(1), xod__core__digital_input::output_SIG::KEY }, // input_GATE
|
||||
{ NodeId(9), xod__core__continuously::output_TICK::KEY }, // input_TRIG
|
||||
{ false, links_0_T }, // output_T
|
||||
{ false, links_0_F } // output_F
|
||||
};
|
||||
@@ -1181,17 +1154,17 @@ namespace _program {
|
||||
NodeId links_1_SIG[] = { 0, NO_NODE };
|
||||
xod__core__digital_input::Storage storage_1 = {
|
||||
{ }, // state
|
||||
{ NodeId(6), xod__core__constant_number::Outputs::VAL::KEY }, // input_PORT
|
||||
{ NodeId(9), xod__core__continuously::Outputs::TICK::KEY }, // input_UPD
|
||||
{ NodeId(6), xod__core__constant_number::output_VAL::KEY }, // input_PORT
|
||||
{ NodeId(9), xod__core__continuously::output_TICK::KEY }, // input_UPD
|
||||
{ false, links_1_SIG } // output_SIG
|
||||
};
|
||||
|
||||
NodeId links_2_MEM[] = { 5, NO_NODE };
|
||||
xod__core__flip_flop::Storage storage_2 = {
|
||||
{ }, // state
|
||||
{ NodeId(3), xod__core__gate::Outputs::F::KEY }, // input_SET
|
||||
{ NodeId(3), xod__core__gate::output_F::KEY }, // input_SET
|
||||
{ NO_NODE, 0 }, // input_TGL
|
||||
{ NodeId(0), xod__core__gate::Outputs::F::KEY }, // input_RST
|
||||
{ NodeId(0), xod__core__gate::output_F::KEY }, // input_RST
|
||||
{ false, links_2_MEM } // output_MEM
|
||||
};
|
||||
|
||||
@@ -1199,8 +1172,8 @@ namespace _program {
|
||||
NodeId links_3_F[] = { 2, NO_NODE };
|
||||
xod__core__gate::Storage storage_3 = {
|
||||
{ }, // state
|
||||
{ NodeId(4), xod__core__digital_input::Outputs::SIG::KEY }, // input_GATE
|
||||
{ NodeId(9), xod__core__continuously::Outputs::TICK::KEY }, // input_TRIG
|
||||
{ NodeId(4), xod__core__digital_input::output_SIG::KEY }, // input_GATE
|
||||
{ NodeId(9), xod__core__continuously::output_TICK::KEY }, // input_TRIG
|
||||
{ false, links_3_T }, // output_T
|
||||
{ false, links_3_F } // output_F
|
||||
};
|
||||
@@ -1208,15 +1181,15 @@ namespace _program {
|
||||
NodeId links_4_SIG[] = { 3, NO_NODE };
|
||||
xod__core__digital_input::Storage storage_4 = {
|
||||
{ }, // state
|
||||
{ NodeId(7), xod__core__constant_number::Outputs::VAL::KEY }, // input_PORT
|
||||
{ NodeId(9), xod__core__continuously::Outputs::TICK::KEY }, // input_UPD
|
||||
{ NodeId(7), xod__core__constant_number::output_VAL::KEY }, // input_PORT
|
||||
{ NodeId(9), xod__core__continuously::output_TICK::KEY }, // input_UPD
|
||||
{ false, links_4_SIG } // output_SIG
|
||||
};
|
||||
|
||||
xod__core__digital_output::Storage storage_5 = {
|
||||
{ }, // state
|
||||
{ NodeId(8), xod__core__constant_number::Outputs::VAL::KEY }, // input_PORT
|
||||
{ NodeId(2), xod__core__flip_flop::Outputs::MEM::KEY }, // input_SIG
|
||||
{ NodeId(8), xod__core__constant_number::output_VAL::KEY }, // input_PORT
|
||||
{ NodeId(2), xod__core__flip_flop::output_MEM::KEY }, // input_SIG
|
||||
};
|
||||
|
||||
NodeId links_6_VAL[] = { 1, NO_NODE };
|
||||
|
||||
Reference in New Issue
Block a user