-->
Page 1 of 1

Minor bug in NodeMCU pin definitions?

PostPosted: Tue Jun 21, 2016 12:21 am
by livetv
Check line 50 of the latest build:

if (Name == F("D8")) PinReturnValue = 13;

I think that should be 15, not 13.

Re: Minor bug in NodeMCU pin definitions?

PostPosted: Tue Jun 21, 2016 9:45 pm
by forlotto
Good catch ....

You are correct it has changed ....

I wonder if this was an intentional change in the map or something else?

Thanks for pointing this out any thing like this is great I think takes some of the load of the devs with error correction. The thing with code if the garbage in is legit but wrong you'll get the wrong garbage out. There is no error checking for this other than human eyes.

Re: Minor bug in NodeMCU pin definitions?

PostPosted: Wed Jun 22, 2016 12:46 pm
by livetv
forlotto wrote:I wonder if this was an intentional change in the map or something else?


I wouldn't know.

I'd suggest this code like this instead of the current LookUpNodeMCUPins function:

Code: Select allbyte LookUpNodeMCUPins(String Name)
{
  byte nodemcuPins[8] = { 16,5,4,0,2,14,12,13,15 };
  if (Name.charAt(0) == F("D"))
  {
    PinReturnValue = nodemcuPins[Name.charAt(1)-48];
  }
  else
  {
    if (Name == F("RX")) PinReturnValue =  3;
    if (Name == F("TX")) PinReturnValue =  1;
  }
  return PinReturnValue;
}


I think this would take less code space and execute faster. Just not sure where nodemcuPins should be declared. Also, I suspect that the code calling this function may already test that first character and it might be faster to fold this function back into the calling routine. I can't tell because I haven't figured out where to find the rest of the code.