-
Notifications
You must be signed in to change notification settings - Fork 875
feat(led_indicator): Refactor the components into the Factory Pattern #532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
👋 Hello zhongchaoesp, we appreciate your contribution to this project! Click to see more instructions ...
Review and merge process you can expect ...
|
b4f8bc5
to
a1760b8
Compare
…s, add esp_types.h
components/led/led_indicator/test_apps/main/test_led_indicator.c
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the led_indicator
component into a Factory Pattern, introducing per-device creation APIs and removing the legacy mode-based led_indicator_create
function.
- Added new factory functions (
led_indicator_new_*_device
) for GPIO, LEDC, RGB, and Strips. - Updated all examples, tests, and documentation to use the new APIs and include per-device headers.
- Cleaned up source and header layout, removed legacy files, and conditioned blink defaults on
CONFIG_USE_MI_BLINK_DEFAULT
.
Reviewed Changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
examples/usb/host/usb_cdc_4g_module/main/app_main.c | Switched to led_indicator_new_gpio_device and include gpio header |
examples/indicator/ws2812_strips/main/main.c | Switched to led_indicator_new_strips_device and include strips header |
examples/indicator/rgb/main/main.c | Switched to led_indicator_new_rgb_device and include rgb header |
examples/indicator/ledc/main/main.c | Switched to led_indicator_new_ledc_device and include ledc header |
examples/indicator/gpio/main/main.c | Switched to led_indicator_new_gpio_device and include gpio header |
docs/zh_CN/display/led_indicator.rst | Updated Chinese docs for factory API; fixed syntax typos |
docs/en/display/led_indicator.rst | Updated English docs for factory API; fixed syntax typos |
components/led/led_indicator/test_apps/main/test_led_indicator.c | Updated tests to use factory APIs and added deinit guard |
components/led/led_indicator/src/mi_led_indicator_blink_default.c | Added MI-specific default blink lists under CONFIG_USE_MI_BLINK_DEFAULT |
components/led/led_indicator/src/led_indicator_strips.c | Refactored strips driver; added led_indicator_new_strips_device |
components/led/led_indicator/src/led_indicator_rgb.c | Refactored RGB driver; added led_indicator_new_rgb_device |
components/led/led_indicator/src/led_indicator_ledc.c | Refactored LEDC driver; added led_indicator_new_ledc_device |
components/led/led_indicator/src/led_indicator_gpio.c | Added GPIO driver; added led_indicator_new_gpio_device |
components/led/led_indicator/src/led_indicator.c | Removed legacy led_indicator_create , updated internal API calls |
components/led/led_indicator/src/led_gpio.c | Removed legacy GPIO implementation |
components/led/led_indicator/include/led_types.h | Introduced shared types and moved enums/structs |
components/led/led_indicator/include/led_indicator_strips.h | Added factory API header for strips |
components/led/led_indicator/include/led_indicator_rgb.h | Added factory API header for RGB |
components/led/led_indicator/include/led_indicator_ledc.h | Added factory API header for LEDC |
components/led/led_indicator/include/led_indicator_gpio.h | Added factory API header for GPIO |
components/led/led_indicator/include/led_indicator_blink_default.h | Split blink-default enum under CONFIG_USE_MI_BLINK_DEFAULT |
components/led/led_indicator/include/led_indicator.h | Updated core header; removed mode-based create |
components/led/led_indicator/include/led_gpio.h | Removed legacy header |
components/led/led_indicator/include/led_rgb.h | Removed legacy header |
components/led/led_indicator/include/led_ledc.h | Removed legacy header |
components/led/led_indicator/include/led_strips.h | Removed legacy header |
components/led/led_indicator/include/led_custom.h | Removed legacy header |
components/led/led_indicator/include/led_convert.h | Updated copyright year |
components/led/led_indicator/Kconfig | Added CONFIG_USE_MI_BLINK_DEFAULT option |
components/led/led_indicator/CMakeLists.txt | Updated source list for new implementations and conditional blink default |
Comments suppressed due to low confidence (4)
docs/zh_CN/display/led_indicator.rst:293
- Remove the extra comma to fix the syntax:
.blink_lists = led_blink_lst,
.
.blink_lists = led_blink_lst,,
docs/zh_CN/display/led_indicator.rst:294
- Remove the extra comma to fix the syntax:
.blink_list_num = BLINK_MAX,
.
.blink_list_num = BLINK_MAX,,
docs/en/display/led_indicator.rst:296
- Remove the extra comma to fix the syntax:
.blink_lists = led_blink_lst,
.
.blink_lists = led_blink_lst,,
docs/en/display/led_indicator.rst:297
- Remove the extra comma to fix the syntax:
.blink_list_num = BLINK_MAX,
.
.blink_list_num = BLINK_MAX,,
Description
This PR refactors the
led_indicator
component into a factory pattern, reducing the coupling of API functions.Original Implementation (Before Refactoring)
Original Configuration Structure:
Original Creation API:
Major Changes (After Refactoring)
Testing
Before:
After:
Checklist