[I want a node] Number-to-port (so we dont have to say D5 when we mean D1)

node-name

number-to-port

Convert a (GPIO) number to a PORT value

Inputs

  • IN (number, default=0) — a number defining a GPIO

Outputs

  • PORT (port) — GPIO that matches the input number
  • ‘ERR’ (pulse) — input value cannot be mapped to a valid PORT

Extra info: different boards have different mappings between GPIO numbers and marked ports such as D0 - Dn.
For example on a NodeMCU board, in order to use pin D1 one has to select D5 in the UI instead of D1

It is therefore easier to use GPIO numbers, and specify we want GPIO 5. This new node would allow us to define 5 in the inspector (or as an output from another node) and have that passed through to a PORT input.

If instead, port numbers could be automatically mapped based on the board in use, then this would remove the need for this node. In other words, if I pick a NodeMCU board and I use D1, then use GPIO value = 5 under the covers.

I have a Wemos Mini, it will also be useful.
You can try it

ps: LED_BUILTIN on with false (Wemos D1 mini)

port-8266.xodball (5.5 KB)

cd050259910368bc7c50ada776a6b9bc58ae8ccd

@daleschultz Hello!

I think this should be better resolved at the engine level. Looks like https://github.com/xodio/xod/issues/1529 should resolve your issue.

but as you state there, this cant be solved there as you don’t know what board is in play.

Unrolling pin D5 to 1 (when defined) or 5 (when it is not defined) does not fix the problems that the user needs 14 on an ESP8266

What is your board, do you have an image?
the definition is the same, only the led changes

user in not see a 14 but D5 on the board, D5 marks and the output to 14

Here there is no 14, if I put 14 it will only confuse.

Same here, D0 … D8 TX RX, A0 works like A0 does not need to change

I mean, if you want to use D4, just put D4, the node will do the rest

The solution of @nkrkv s the indicated but but while you can use this to facilitate a little.

mini

As I said in the justification of the node:

If I pick D4 in the patch - it will activate GPIO 4 which is in fact D2 on NodeMCU.

If you do it with D1 it will be GPIO5, GPIO is something normally abstract

Just use the denomination of Dx and forget about GPIO, you will see that everything works :slightly_smiling_face:

what is that node marked port-8266 that you show? That seems to be mapping D5 to a value of 14.
I cant find that node in my environment. But even if there does exists a remapping node, it means that if one does not use that mapping node, say you put D5 into an inspector, it wont do anything to the pin marked D5 on a NodeMCU it will go to D1

download is’t and try port-8266 or add library cesars/port-8266

here was the xodball file
nodemcu


I thought you downloaded it, I had to put something like download here or download link, sorry

If you do not have to wait, the solution from the developers is the best.
But forget D14 D16, only those marked on board, D0, D1, D2 …

ah yes, I missed the link earlier…
anyway its something to be sorted out instead of a workaround. It is fundamental and the whole scope of XOD is for beginners and can come up in first 10 minutes of use.

ok, I think I’ll eliminate it so I do not confuse it and I’ll leave it for personal use

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