Hello, I’m trying to do something in C ++, I’ve copied parts from other nodes but I can not eliminate the error, if I try to solve it every time I have more.
The idea is to do a botton with debounce all in one, yes … the node is combined, but I want to learn something from C ++
I appreciate your help
struct State {
};
{{ GENERATED_CODE }}
void evaluate(Context ctx) {
if (!isInputDirty<input_UPD>(ctx))
return;
const uint8_t port = getValue<input_PORT>(ctx);
if (!isValidDigitalPort(port)) {
emitValue<output_ERR>(ctx, 1);
return;
::pinMode(port, INPUT);
}
State* state = getState(ctx); //error: conversion from 'xod::____button_mod::State*' to non-scalar type 'xod::____button_mod::
//State' requested State state = getState(ctx);
// ^
bool x = getValue<input_PORT>(ctx); // read digital port; is correct?
if (x != state->state) { //error: base operand of '->' has non-pointer type 'xod::____button_mod::
//State' if (x != state->state) {
// ^
state->state = x; //base operand of '->' has non-pointer type 'xod::____button_mod::State'
// state->state = x;
// ^
TimeMs dt = getValue<input_Ts>(ctx) * 1000;
setTimeout(ctx, dt);
}
if (isTimedOut(ctx)) {
::pinMode(port, INPUT);
emitValue<output_SIG>(ctx, ::digitalRead(!port));
emitValue<output_DONE>(ctx, 1);
}
}