From 89962a16ab7a7dcdebe0bdd4881671967a352839 Mon Sep 17 00:00:00 2001 From: Xu Si Yu Date: Mon, 4 Mar 2024 19:06:17 +0800 Subject: [PATCH] feat(openthread): support configuring indicator color of openthread device --- .../ot_led/Kconfig.projbuild | 106 +++++++++++++++++- .../ot_led/ot_led_strip.c | 8 +- 2 files changed, 109 insertions(+), 5 deletions(-) diff --git a/examples/openthread/ot_common_components/ot_led/Kconfig.projbuild b/examples/openthread/ot_common_components/ot_led/Kconfig.projbuild index 91299217cc..20bb56cba9 100644 --- a/examples/openthread/ot_common_components/ot_led/Kconfig.projbuild +++ b/examples/openthread/ot_common_components/ot_led/Kconfig.projbuild @@ -1,4 +1,4 @@ -menu "OpenThread Device Role LED" +menu "OpenThread Device Role Indicator" orsource "$IDF_PATH/examples/common_components/env_caps/$IDF_TARGET/Kconfig.env_caps" @@ -21,4 +21,108 @@ menu "OpenThread Device Role LED" GPIO number (IOxx) to blink on and off the LED. Some GPIOs are used for other purposes (flash connections, etc.) and cannot be used to blink. + menu "Indicator of Leader Device" + config LEADER_INDICATOR_RED + depends on OPENTHREAD_STATE_INDICATOR_ENABLE + int "red config" + range 0 255 + default 40 + help + Red config of LED for OpenThread leader device + + config LEADER_INDICATOR_GREEN + depends on OPENTHREAD_STATE_INDICATOR_ENABLE + int "green config" + range 0 255 + default 0 + help + Red config of LED for OpenThread leader device + + config LEADER_INDICATOR_BLUE + depends on OPENTHREAD_STATE_INDICATOR_ENABLE + int "blue config" + range 0 255 + default 0 + help + Blue config of LED for OpenThread leader device + endmenu + + menu "Indicator of Router Device" + config ROUTER_INDICATOR_RED + depends on OPENTHREAD_STATE_INDICATOR_ENABLE + int "red config" + range 0 255 + default 0 + help + Red config of LED for OpenThread router device + + config ROUTER_INDICATOR_GREEN + depends on OPENTHREAD_STATE_INDICATOR_ENABLE + int "green config" + range 0 255 + default 0 + help + Green config of LED for OpenThread router device + + config ROUTER_INDICATOR_BLUE + depends on OPENTHREAD_STATE_INDICATOR_ENABLE + int "blue config" + range 0 255 + default 40 + help + Blue config of LED for OpenThread router device + endmenu + + menu "Indicator of Child Device" + config CHILD_INDICATOR_RED + depends on OPENTHREAD_STATE_INDICATOR_ENABLE + int "red config" + range 0 255 + default 0 + help + Red config of LED for OpenThread child device + + config CHILD_INDICATOR_GREEN + depends on OPENTHREAD_STATE_INDICATOR_ENABLE + int "green config" + range 0 255 + default 40 + help + Green config of LED for OpenThread child device + + config CHILD_INDICATOR_BLUE + depends on OPENTHREAD_STATE_INDICATOR_ENABLE + int "blue config" + range 0 255 + default 0 + help + Blue config of LED for OpenThread child device + endmenu + + menu "Indicator of Detached Device" + config DETACHED_INDICATOR_RED + depends on OPENTHREAD_STATE_INDICATOR_ENABLE + int "red config" + range 0 255 + default 20 + help + Red config of LED for OpenThread detached device + + config DETACHED_INDICATOR_GREEN + depends on OPENTHREAD_STATE_INDICATOR_ENABLE + int "green config" + range 0 255 + default 20 + help + Green config of LED for OpenThread detached device + + config DETACHED_INDICATOR_BLUE + depends on OPENTHREAD_STATE_INDICATOR_ENABLE + int "blue config" + range 0 255 + default 20 + help + Blue config of LED for OpenThread detached device + endmenu + endmenu diff --git a/examples/openthread/ot_common_components/ot_led/ot_led_strip.c b/examples/openthread/ot_common_components/ot_led/ot_led_strip.c index f9e829f12d..cc9de4a188 100644 --- a/examples/openthread/ot_common_components/ot_led/ot_led_strip.c +++ b/examples/openthread/ot_common_components/ot_led/ot_led_strip.c @@ -45,13 +45,13 @@ static void ot_indicator_change_callback(otChangedFlags changed_flags, void* ctx if (role == OT_DEVICE_ROLE_DISABLED) { esp_openthread_state_indicator_clear(); } else if (role == OT_DEVICE_ROLE_DETACHED) { - esp_openthread_state_indicator_set(0, 40, 0, 0); + esp_openthread_state_indicator_set(0, CONFIG_DETACHED_INDICATOR_RED, CONFIG_DETACHED_INDICATOR_GREEN, CONFIG_DETACHED_INDICATOR_BLUE); } else if (role == OT_DEVICE_ROLE_LEADER) { - esp_openthread_state_indicator_set(0, 0, 40, 0); + esp_openthread_state_indicator_set(0, CONFIG_LEADER_INDICATOR_RED, CONFIG_LEADER_INDICATOR_GREEN, CONFIG_LEADER_INDICATOR_BLUE); } else if (role == OT_DEVICE_ROLE_ROUTER) { - esp_openthread_state_indicator_set(0, 0, 0, 40); + esp_openthread_state_indicator_set(0, CONFIG_ROUTER_INDICATOR_RED, CONFIG_ROUTER_INDICATOR_GREEN, CONFIG_ROUTER_INDICATOR_BLUE); } else if (role == OT_DEVICE_ROLE_CHILD) { - esp_openthread_state_indicator_set(0, 40, 8, 60); + esp_openthread_state_indicator_set(0, CONFIG_CHILD_INDICATOR_RED, CONFIG_CHILD_INDICATOR_GREEN, CONFIG_CHILD_INDICATOR_BLUE); } }