在带有 PlatformIO 的 Visual Studio Code 上,当我单击[v]按钮 ( PlatformIO:Build ) 时,IDE 运行以下任务:
> Executing task: C:\Users\Mary\.platformio\penv\Scripts\platformio.exe run <
Processing d1_mini (platform: espressif8266; board: d1_mini; framework: arduino)
...
...
当我单击[=>]按钮(PlatformIO:Upload)时,IDE 运行以下任务:
> Executing task: ~\.platformio\penv\Scripts\platformio.exe run --target upload <
Processing d1_mini (platform: espressif8266; board: d1_mini; framework: arduino)
...
...
解释:
https://docs.platformio.org/en/latest/userguide/cmd_run.html
我需要区分何时运行目标(编译)或目标上传(--target 上传)以设置不同的环境变量。就像是
[env:specific_defines]
build_flags =
-D MY_VAR=true
因为当我编译项目时,我不想要调试信息(例如 Serial.println()),当我通过 USB 上传程序并附有板时我想要这些信息。
提前致谢。