Skip to content

Commit

Permalink
feat(openthread): support configuring indicator color of openthread d…
Browse files Browse the repository at this point in the history
…evice
  • Loading branch information
gytxxsy committed Mar 5, 2024
1 parent efb87ef commit 89962a1
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 5 deletions.
106 changes: 105 additions & 1 deletion examples/openthread/ot_common_components/ot_led/Kconfig.projbuild
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 89962a1

Please sign in to comment.