refactor the use of g_APinDescription ?
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 30/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- cpp
- Lĩnh vực
- embedded-iot
Hướng nghiên cứu
Bắt đầu bằng cách so sánh các macro truy cập trong variant.h và Arduino.h với việc sử dụng mảng trực tiếp trong cores/arduino/Tone.cpp, bao gồm g_APinDescription và digital_pin_to_xxx. Liệt kê dữ liệu liên quan đến pin hiện đang được truy cập trực tiếp, sau đó xác định phạm vi của một API chính thức có thể override; được xem là hoàn tất khi mã core và mã thư viện sử dụng các định nghĩa đó mà không giả định một triển khai cụ thể.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- C++
- Star
- 306
- Fork
- 150
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của arduino/ArduinoCore-API
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
arduino/ArduinoCore-API#261 ·
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 30/100
arduino/ArduinoCore-API#256 ·
-
enhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
arduino/ArduinoCore-API#251 · 1 bình luận ·
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
arduino/ArduinoCore-API#250 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 45/100
arduino/ArduinoCore-API#249 ·
Tất cả issue của arduino/ArduinoCore-API
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
google/libultrahdr#485 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
godotengine/godot#123776 ·
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 60/100
-
good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
ros2/common_interfaces#344 ·