Skip to content

Fix build.board variables for NodeMCU and others #1878

Closed
@focalintent

Description

@focalintent

I'm maintaining a library that does, among other things, direct pin accesses for higher performance. As part of this, I do my own mapping of pins on the board to the underlying hardware. The adafruit Huzzah boards label each pin on the board with the actual gpis pin, while many nodemcu based boards instead label their GPIO pins D0 - D10 (which then map, under the hood, to the actual set of gpio pins).

Because there is no way, as far as I can tell, at compile time to differentiate when someone has selected the Huzzah variant from, say, the NodeMCU variant - I can't provide the correct mapping for one platform or the other, in part this is because, in your boards.txt, you identify all these boards (adafruit huzzah, nodemcu, d1_mini) as being build.board=ESP8266_ESP12. There's no differentiation between the boards.

Meanwhile, if you look at the selection of attiny8 boards that adafruit has, their build.board values are set to AVR_GEMMA, or AVR_TRINKET3, or AVR_TRINKET5, etc... which allows me to differentiate between their different attiny8 boards and the pin to gpio mappings.

Right now, I get to either tell users of the adafruit huzzah esp boards to add a special define to their sketches to get the "right" mappings, or switch things around and tell users of the nodemcu/weemos/etc... boards to add a special define to their sketches to get the right mappings, etc...

(Also, you haven't defined the Dx mappings for the adafruit board, so someone who has pinMode(D3, OUTPUT); will fail to compile on the adafruit boards. Of course, if they change their code to pinMode(3, OUTPUT); to get it to compile, then go back to the NodeMCU board, pin D9 is what will get set to output (since that's the pin that maps to GPIO 3))

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions