Skip to content

Make upload.port.* properties available in compile patterns #2362

@Ebola-Chan-bot

Description

@Ebola-Chan-bot

Describe the request

This issue has already been raised in the forum, but my application scenario is slightly different from his. My computer is connected to multiple boards on different COM ports. They have basically the same model and program to run, but the devices they operate are plugged into different pins.

I would like to have a compile-time macro definition that indicates the COM port currently selected by the IDE. For example, if I had a compile-time attached macro definition "COM", I could code:

#define Pin constexpr uint8_t
#if COM == 3
Pin pBlueLed = 11;
Pin pActiveBuzzer = 52;
#elif COM == 4
Pin pBlueLed = 8;
Pin pActiveBuzzer = 22;
#elif COM == 5
Pin pBlueLed = 11;
Pin pActiveBuzzer = 22;
#endif

This way I don't need to change the pin number every time to upload to a different COM port. I can write the corresponding pin numbers of all COM ports, and then the compiler preprocessing automatically selects the correct pin configuration.

Describe the current behavior

There currently seems to be no way to get COM numbers in the code.

Arduino IDE version

2.2.1

Operating system

Windows

Operating system version

10

Additional context

No response

Issue checklist

  • I searched for previous requests in the issue tracker
  • I verified the feature was still missing when using the latest nightly build
  • My request contains all necessary details

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions