refactor the use of g_APinDescription ?
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 30/100
- Issue 类型
- 重构
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- cpp
- 领域
- embedded-iot
调研方向
首先比较 variant.h 和 Arduino.h 中的访问宏与 cores/arduino/Tone.cpp 中的数组直接使用情况,包括 g_APinDescription 和 digital_pin_to_xxx。梳理当前直接访问的引脚相关数据,然后定义可重写正式 API 的范围;当 core 和库代码使用这些定义而不假定特定实现时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
It bothers me, in a sort of "Code Purity" sense, that so many core and library functions access
the g_APinDescription[] (for sam/samd) or digital_pin_to_xxx[] (for avr) arrays directly.
There are some macros in variant.h or Arduino.h (digitalPinToBitMask and similar), but they are not consistently used, not all functions have macros, and sometimes they aren't well-placed WRT redefining them for new board types.
Example:
variants/mkr1000/variant.h:47: #define digitalPinToBitMask(P) (1 << g_APinDescription[P].ulPin)
cores/arduino/Tone.cpp:133: portBitMask = (1ul << g_APinDescription[outputPin].ulPin);
The definition of a more formal API presents the opportunity to offer more formal rules:
-
macros or inline functions to access all pin-related data should be defined in the variant-specific files, or perhaps WVariant.h for core-wide data.
-
if such definitions are defined in core-wide functions, it should be possible to override them in variant-specific files.
-
All other code should use these definitions, instead of assuming a particular implementation. (the tone.cpp example above should not exist, even now.)
The immediate practical benefit would be the possibility of more compact implementations for the "tiny" chips (avr tiny, SAMD11, etc), and greater portability of the functions in the "upper level" areas of code.
- 主要语言
- C++
- 星标
- 307
- 派生
- 152
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
arduino/ArduinoCore-API 的其他 Issue
-
Bit manipulation not working with 64 bit values可能已有人在做 @asumo-1xts 于 42 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 25/100
arduino/ArduinoCore-API#261 ·
-
Missing virtual destructor for `Print` class可能已有人在做 @andreagilardoni 于 1110 天前认领。 未关闭bug
难度 1/5 1 小时以内 新手友好度 30/100
arduino/ArduinoCore-API#256 ·
-
enhancement
难度 3/5 1-2 天 新手友好度 48/100
arduino/ArduinoCore-API#251 · 1 条评论 ·
-
Use modern C++ casts instead of current C-style casting approaches可能已有人在做 @anotherSimpleCoder 于 312 天前认领。 未关闭enhancement
难度 4/5 3-5 天 新手友好度 35/100
arduino/ArduinoCore-API#250 ·
-
Always true condition in IPAddress string-to-ipv6 conversion可能已有人在做 @pruthvi828 于 19 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 45/100
arduino/ArduinoCore-API#249 ·
查看 arduino/ArduinoCore-API 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 64/100
utopia-rise/godot-jvm#1004 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 3 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
new contributor
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
Component: R
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复