Disable pin port (NONE option)

In an X library, there are pins that can be used or maybe not.

Is there any way to disable the use of the pin?
for example if instead of using input-port I use input-number and I set a value -1. But I’m not sure if it’s the best.
Maybe the port pin should have a NONE option.

Nulls are a billion dollar mistake :slight_smile: XOD don’t want to repeat it.

In the particular case you describe, you can try using D255 as a special value which means nothing. Arduino defines a NOT_A_PIN macro in C++ which is 255 behind the scenes. If it will be convenient we can consider adding a similar not-a-pin literal to XOD.

the concrete example is a library that has a CS pin, a ENABLE pin and an INT.
Sometimes it is not necessary to use them, because the program does not require it, and it leaves me pins that I can not use. I thought that a none would put a -1, and so could avoid losing a pin.

Here is another example, the EN pin sometimes does not need to be used, but it removes an arduino pin.

ps: In an arduino library I saw that it uses -1 to not define that pin and thus leave it free for another use.

If instead of using input-port I use input-number I solve the problem. But I found that NONE = -1 better in input-port, I do not know if it would be possible

I see. D255 gets converted to uint8_t equal to 255 in C++ and if a function takes int8_t or uint8_t as an argument, 255 and -1 are the same values.

In other words, in C++:

uint8_t x = 255;
int8_t y = -1;
assert(x == y); // true, passes

Ok, I understand better
This library has the RESET and EOC pins, but they are not always used.

If I make a library, I would like to be able to decide if those pins were used or not in the patch, without having to edit it or make another node without the pin.

Yes, in this case, you can make a node which has EOC and RST port inputs. Bind the D255 value to them by default. The D255 will mean “not used”. It will be indistinguishable from -1 for the Adafruit’s C++ library.

P.S> Thanks for trying to help with the sensor breakout node! :heart:

1 Like

for having a fixed idea or for reading fast I missed this, sorry. :man_facepalming:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.