数码之家

 找回密码
 立即注册
搜索
查看: 3133|回复: 3

[Arduino] VSCODE+PLATFORMIO+ARDUINO

[复制链接]
发表于 2020-9-28 05:43:31 | 显示全部楼层 |阅读模式

爱科技、爱创意、爱折腾、爱极致,我们都是技术控

您需要 登录 才可以下载或查看,没有账号?立即注册

x
在此做个记录
折腾了几个黎明时分(白天网络不通)后的结果
1, 安装python最新版+pip (环境变量path需要)
              https://www.python.org/ftp/pytho ... .8.6-webinstall.exe
2,安装vscode
3,vscode里查扩展platformio安装
              在提示正在下载"Use a portable Python 3 Interpreter if available"时关闭vscode
4,在C:\Users\Administrator中删除.platformio目录
5,打开并编辑C:\Users\Administrator\.vscode\extensions\platformio.platformio-ide-2.1.0目录中的package.json文件
6,查找package.json文件中“python”定位
7,把 下面的红字“true”改成绿字“false”并保存
"platformio-ide.useBuiltinPython": {
                                        "type": "boolean",
                                        "default": true,
                                        "description": "Use a portable Python 3 Interpreter if available"
                                 },
"platformio-ide.useBuiltinPython": {
                                        "type": "boolean",
                                        "default": false,
                                        "description": "Use a portable Python 3 Interpreter if available"
                                },

8,重新打开vscode
9,如果platformio扩展未运行就点击platformio图标
10,等待
11,在PIO HOME界面点击“Project Examples”按钮
12,选arduino-blink后点击import按钮
13,等左下角出现房子,打钩,右箭头等符号后点击打钩
14,等待编译成功





发表于 2020-9-28 08:38:54 来自手机浏览器 | 显示全部楼层
你怎么搞这么复杂,我直接装完VSC,再装PIO就可以了,py会自动安装的。
另外请教下arduino里怎么设置stm32的remap功能?我在PIO的配置里加了关闭JTAG的参数,但不生效
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-9-28 17:37:30 | 显示全部楼层
本帖最后由 camell 于 2020-9-28 17:52 编辑

最近PIO刚升级,但内置下载的PY版本还是老的3.77,要升到PY3.8。你的可能是以前装了自动升级的那种
Override package files

PlatformIO Package Manager automatically installs pre-built packages (Frameworks, toolchains, libraries) required by development Development Platforms and build process. Sometimes you need to override original files with own versions: configure custom GPIO, do changes to built-in LD scripts, or some patching to installed library dependency.

The simplest way is using Diff and Patch technique. How does it work?

  • Modify original source files
  • Generate patches
  • Apply patches via PlatformIO extra script before build process.

Example

We need to patch the original standard/pins_arduino.h variant from Arduino framework and add extra macro #define PIN_A8   (99). Let’s duplicate standard/pins_arduino.h and apply changes. Generate a patch file and place it into patches folder located in the root of a project:

diff ~/.platformio/packages/framework-arduinoavr/variants/standard/pins_arduino.h /tmp/pins_arduino_modified.h > /path/to/platformio/project/patches/1-framework-arduinoavr-add-pin-a8.patch

The result of 1-framework-arduinoavr-add-pin-a8.patch:

63a64> #define PIN_A8   (99)112c113< // 14-21 PA0-PA7 works---> // 14-21 PA0-PA7 works

Using extra scripting we can apply patching before a build process. The final result of “platformio.ini” (Project Configuration File) and “PRE” extra script named apply_patches.py:

platformio.ini:

[env:uno]platform = atmelavrboard = unoframework = arduinoextra_scripts = pre:apply_patches.py

apply_patches.py:

from os.path import join, isfileImport("env")FRAMEWORK_DIR = env.PioPlatform().get_package_dir("framework-arduinoavr")patchflag_path = join(FRAMEWORK_DIR, ".patching-done")# patch file only if we didn't do it beforeif not isfile(join(FRAMEWORK_DIR, ".patching-done")):    original_file = join(FRAMEWORK_DIR, "variants", "standard", "pins_arduino.h")    patched_file = join("patches", "1-framework-arduinoavr-add-pin-a8.patch")    assert isfile(original_file) and isfile(patched_file)    env.Execute("patch %s %s" % (original_file, patched_file))    # env.Execute("touch " + patchflag_path)    def _touch(path):        with open(path, "w") as fp:            fp.write("")    env.Execute(lambda *args, **kwargs: _touch(patchflag_path))

Please note that this example will work on a system where a patch tool is available. For Windows OS, you can use patch and diff tools provided by Git client utility (located inside installation directory).

If you need to make it more independent to the operating system, please replace the patch with a multi-platform python-patch script.


回复 支持 0 反对 1

使用道具 举报

发表于 2020-9-29 22:31:26 | 显示全部楼层
安装很简单,先安装vs,再在vs中安装platformIO,安装过程最关键的网络,电信最好、联通差一点,如果是移动宽带基本上是无法安装platformIO。
回复 支持 1 反对 0

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

APP|手机版|小黑屋|关于我们|联系我们|法律条款|技术知识分享平台

闽公网安备35020502000485号

闽ICP备2021002735号-2

GMT+8, 2025-5-9 19:53 , Processed in 0.296401 second(s), 8 queries , Redis On.

Powered by Discuz!

© 2006-2025 MyDigit.Net

快速回复 返回顶部 返回列表