• I see a lot of people on the gitter feed doing things like

    new pin(2)

    to get GPIO pin 2 on ESP8266, instead of using the predefined D2 pin, or just doing digitalWrite(2,1); I had never seen that sort of pattern, and I'm really sort of confused as to why people use it.

    If it's not a recommended method, we should figure out what's causing people to get confused and think they need to do it. It's typically getting asked by people who look like they're totally new to Espruino, too - somehow they're getting the idea they need to instantiate pin instances, which makes Espruino look less user friendly than it is. The pins are already there ready and waiting for you!

  • No, it's not recommended at all. I think initially the developers (aplikatika or Neil) hadn't actually used Espruino much on any other boards first, so they didn't really see how people were using it already.

    Unfortunately that meant that some documentation (which I think is now gone) gave that as an example, and then other places online made tutorials, blog posts and videos about it and people are learning from those.

    There was a conversation on Gitter and someone said they didn't want to use D0/etc because it was confusing when NodeMCU have used D0/etc with completely different numbers... I'm not sure if that's really such a good reason (We could add a NodeMCU.D0/etc like is done for Nucleo.

    So yeah, I'm not really sure how to stop people. I guess if I made some getting started video then people might watch that instead though.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

new Pin() - is it recommended for people to be using this?

Posted by Avatar for DrAzzy @DrAzzy

Actions