gpt4 book ai didi

arduino - arduino 中的多个选项卡/文件?

转载 作者:行者123 更新时间:2023-12-02 16:51:51 35 4
gpt4 key购买 nike

我已经看了很多,但还没有找到涵盖所有这些的好教程。因此,我需要将项目分成多个选项卡/ino 文件,只是为了使其更清晰。

所以当你打开一个新标签后,我想问几个问题:

  1. 如果主项目文件(例如 main)还有另外 2 个选项卡(例如 AB),因此,每个B 中的函数对 mainA 可见?

  2. 中断会发生什么?如果我在A文件中定义了一些中断,它可以调用main文件中的中断函数吗?

  3. 定义会发生什么?和包括?如果文件 A 包含一些库,比如 Wire,那么 main 文件是否也能看到它,反之亦然?

处理文件的策略是什么?您是否将所有库添加到主文件中,或者还应该将它们添加到其他文件中? (例如处理陀螺仪的文件并且必须包含一些库)

最佳答案

您可能已经注意到,每个 .ino 文件必须包含在同名的文件夹中。然后,该文件夹中包含的所有其他 .ino 文件都被视为“额外选项卡”。

据我所知,编译时,.ino 文件会被合并为一个文件。例如,这是由于在不同的 . ino 文件位于同一文件夹中。

来自“the docs”:

Multi-file sketches

A sketch can contain multiple files (tabs). To manage them, click on the right-facing arrow just above the scroll bar near the top of the environment. Tabs have one of four extensions: no extension, .c, .cpp, or .h (if you provide any other extension, the period will be converted to an underscore).

When your sketch is compiled, all tabs with no extension are concatenated together to form the "main sketch file". Tabs with .c or .cpp extensions are compiled separately. To use tabs with a .h extension, you need to #include it (using "double quotes" not ).

虽然它提到“没有扩展名的文件”,但我相信它也适用于具有 .ino 扩展名的文件。

关于arduino - arduino 中的多个选项卡/文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31011117/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com