# Disable pin port (NONE option)

**URL:** <https://forum.xod.io/t/disable-pin-port-none-option/2243>\
**Category:** Uncategorized\
**Created:** [May 15, 2019, 1:24am UTC](https://forum.xod.io/t/disable-pin-port-none-option/2243 "2019-05-15T01:24:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![cesars](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@cesars](https://forum.xod.io/u/cesars)\
**Post date:** [May 15, 2019, 1:24am UTC](https://forum.xod.io/t/disable-pin-port-none-option/2243/1 "2019-05-15T01:24:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![nkrkv](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/nkrkv/32/8_2.png) [@nkrkv](https://forum.xod.io/u/nkrkv)\
**Post date:** [May 15, 2019, 3:54pm UTC](https://forum.xod.io/t/disable-pin-port-none-option/2243/2 "2019-05-15T15:54:32Z")

</div>

Nulls are a [billion dollar mistake](https://medium.com/@hinchman_amanda/null-pointer-references-the-billion-dollar-mistake-1e616534d485) 🙂 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.

---

<div class="post-metadata">

**Author:** ![cesars](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@cesars](https://forum.xod.io/u/cesars)\
**Post date:** [May 15, 2019, 4:17pm UTC](https://forum.xod.io/t/disable-pin-port-none-option/2243/3 "2019-05-15T16:17:34Z")

</div>

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.

 ![image](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/2X/4/462b0ced8040390f99b6329c9f4e797a6f4776f6.png)

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

---

<div class="post-metadata">

**Author:** ![nkrkv](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/nkrkv/32/8_2.png) [@nkrkv](https://forum.xod.io/u/nkrkv)\
**Post date:** [May 15, 2019, 4:33pm UTC](https://forum.xod.io/t/disable-pin-port-none-option/2243/4 "2019-05-15T16:33:39Z")

</div>

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++:

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

```

---

<div class="post-metadata">

**Author:** ![cesars](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@cesars](https://forum.xod.io/u/cesars)\
**Post date:** [May 15, 2019, 4:38pm UTC](https://forum.xod.io/t/disable-pin-port-none-option/2243/5 "2019-05-15T16:38:17Z")

</div>

> [@nkrkv](#):
>
> 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.

> **[Adafruit MPRLS Ported Pressure Sensor Breakout - 0 to 25 PSI](https://www.adafruit.com/product/3965)**
>
> We stock a few barometric pressure sensors, great for altitude and weather measurements. This pressure sensor is special because it comes with a metal port! Unlike other pressure sensors, ...

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.

---

<div class="post-metadata">

**Author:** ![nkrkv](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.xod.io/nkrkv/32/8_2.png) [@nkrkv](https://forum.xod.io/u/nkrkv)\
**Post date:** [May 15, 2019, 4:44pm UTC](https://forum.xod.io/t/disable-pin-port-none-option/2243/6 "2019-05-15T16:44:56Z")

</div>

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! ❤

---

<div class="post-metadata">

**Author:** ![cesars](https://avatars.discourse-cdn.com/v4/letter/c/f05b48/32.png) [@cesars](https://forum.xod.io/u/cesars)\
**Post date:** [May 15, 2019, 9:38pm UTC](https://forum.xod.io/t/disable-pin-port-none-option/2243/7 "2019-05-15T21:38:22Z")

</div>

> [@nkrkv](#):
>
> If it will be convenient we can consider adding a similar not-a-pin literal to XOD.

for having a fixed idea or for reading fast I missed this, sorry. 🤦‍♂️

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex027/uploads/xod/original/1X/eb7348baa04192c2ef932d1db54d44f09f8a7888.png) [@system](https://forum.xod.io/u/system)\
**Post date:** [May 17, 2019, 9:38pm UTC](https://forum.xod.io/t/disable-pin-port-none-option/2243/8 "2019-05-17T21:38:25Z")

</div>

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