From 7333afee43e2427c65a68ad2595e94af2181adb8 Mon Sep 17 00:00:00 2001 From: Hussein Elsherbini Date: Mon, 19 Sep 2022 19:30:32 +0000 Subject: [PATCH] Pull request #116: re-enabled Jenkin custom example builds, fixed various issue with RGB example functionality Merge in WMN_TOOLS/matter from custom_examples to silabs Squashed commit of the following: commit a2b4829c9babddf87d6330fe0b5a46cc8b92636d Author: Hussein Elsherbini Date: Mon Sep 19 14:58:14 2022 -0400 added BRD4166A to custom build boards JIRA: MATTER-693 commit 1949cd27b62c1e9b302cff363a90ce49008709ac Author: Hussein Elsherbini Date: Mon Sep 19 14:40:40 2022 -0400 re-enabled Jenkin custom example builds, fixed various issue with RGB example functionality JIRA: MATTER-693 --- Jenkinsfile | 42 ++++++------- .../efr32/light_modules/led_widget_rgb.cpp | 59 ++++++++++++++++--- 2 files changed, 72 insertions(+), 29 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fce378db2d12e3..9ccde6f76482e7 100755 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -839,27 +839,27 @@ def pipeline() } - // TODO re-enable when PR #70 is merged - // stage("Build Custom examples") - // { - // advanceStageMarker() - // // build library dependencies - // def parallelNodes = [:] - // def boardsForCustom = [:] - - // if (env.BRANCH_NAME == "silabs") { - // boardsForCustom = ["BRD4161A", "BRD4186C", "BRD4187C"] - // } else { - // boardsForCustom = ["BRD4161A", "BRD4186C"] - // } - - // boardsForCustom.each { board -> - // parallelNodes[board] = { this.buildSilabsCustomOpenThreadExamples(board) } - // } - - // parallelNodes.failFast = false - // parallel parallelNodes - // } + + stage("Build Custom examples") + { + advanceStageMarker() + + def parallelNodes = [:] + def boardsForCustom = [:] + + if (env.BRANCH_NAME == "silabs") { + boardsForCustom = ["BRD4161A", "BRD4186C", "BRD4187C", "BRD4166A"] + } else { + boardsForCustom = ["BRD4161A", "BRD4186C", "BRD4166A"] + } + + boardsForCustom.each { board -> + parallelNodes[board] = { this.buildSilabsCustomOpenThreadExamples(board) } + } + + parallelNodes.failFast = false + parallel parallelNodes + } stage("Build Tooling") { diff --git a/silabs_examples/sl-newLight/efr32/light_modules/led_widget_rgb.cpp b/silabs_examples/sl-newLight/efr32/light_modules/led_widget_rgb.cpp index 921ad9fe59ba74..30f755ad0ce8c5 100644 --- a/silabs_examples/sl-newLight/efr32/light_modules/led_widget_rgb.cpp +++ b/silabs_examples/sl-newLight/efr32/light_modules/led_widget_rgb.cpp @@ -40,8 +40,11 @@ #include "sl_led.h" #include "sl_pwm_led.h" #include "sl_simple_rgb_pwm_led.h" +#include "AppTask.h" + +using namespace chip; +using namespace ::chip::DeviceLayer; -using namespace chip::app::Clusters::OnOff; /** * @brief Red led instance. */ @@ -168,7 +171,6 @@ void LEDWidgetRGB::Init(const sl_led_rgb_pwm_t* led) void LEDWidgetRGB::SetLevel(uint8_t level) { bool currentValue; - EmberAfStatus status; /* 1. Check if the input value is correct. */ if (level > ATTRIBUTE_LEVEL_MAX) { @@ -184,7 +186,15 @@ void LEDWidgetRGB::SetLevel(uint8_t level) } /* 2. Update the color. */ - this->SetColor(this->current_hue_, this->current_saturation_, this->current_level_); + chip::DeviceLayer::PlatformMgr().LockChipStack(); + OnOffServer::Instance().getOnOffValue(1, ¤tValue); + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); + + if(currentValue){ + + this->SetColor(this->current_hue_, this->current_saturation_, this->current_level_); + } + } @@ -229,25 +239,44 @@ void LEDWidgetRGB::GetLevel(ColorElements* rgb) void LEDWidgetRGB::SetHue(uint8_t hue) { + bool currentValue; // Hue takes a value [0, 360] and is expressed in degrees. // See appclusters, section 3.2.7.1. + chip::DeviceLayer::PlatformMgr().LockChipStack(); + OnOffServer::Instance().getOnOffValue(1, ¤tValue); + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); + this->current_hue_ = static_cast((hue * 360) / ATTRIBUTE_LEVEL_MAX); - this->SetColor(this->current_hue_, this->current_saturation_, this->current_level_); + if(currentValue){ + + this->SetColor(this->current_hue_, this->current_saturation_, this->current_level_); + } + + } void LEDWidgetRGB::SetSaturation(uint8_t sat) { + bool currentValue; // Saturation takes a value [0, 1] representing a percentage. // The Color Control cluster accepts saturation values 0 to 254. // See appclusters, section 3.2.7.2. - this->current_saturation_ = sat/254.0; - this->SetColor(this->current_hue_, this->current_saturation_, this->current_level_); + chip::DeviceLayer::PlatformMgr().LockChipStack(); + OnOffServer::Instance().getOnOffValue(1, ¤tValue); + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); + + this->current_saturation_ = static_cast((sat * 360) / ATTRIBUTE_LEVEL_MAX); + if(currentValue){ + + this->SetColor(this->current_hue_, this->current_saturation_, this->current_level_); + } } void LEDWidgetRGB::SetColor(uint8_t hue, float saturation, uint8_t level) { + bool currentValue; /* 1. Convert the hue and saturation input to RGB values. (HSV to RGB conversion) */ ColorElements rgb = { @@ -257,14 +286,20 @@ void LEDWidgetRGB::SetColor(uint8_t hue, float saturation, uint8_t level) }; HueToRGB(hue, saturation, level, &rgb, PWM_MAX_VALUE); + chip::DeviceLayer::PlatformMgr().LockChipStack(); + OnOffServer::Instance().getOnOffValue(1, ¤tValue); + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); /* 2. Set the color values. */ - this->SetColorRGB(&rgb); + if(currentValue){ + this->SetColorRGB(&rgb); + } } void LEDWidgetRGB::SetColorRGB(ColorElements* rgb) { + bool currentValue; /* 1. Verify that the struct argument is not null. */ if (rgb == nullptr) { @@ -273,7 +308,15 @@ void LEDWidgetRGB::SetColorRGB(ColorElements* rgb) } /* 2. Call the PWM driver to set the new values. */ - this->led_rgb_->set_rgb_color(this->led_rgb_->led_common.context, rgb->red_value, rgb->green_value, rgb->blue_value); + + chip::DeviceLayer::PlatformMgr().LockChipStack(); + OnOffServer::Instance().getOnOffValue(1, ¤tValue); + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); + + /* 2. Set the color values. */ + if(currentValue){ + this->led_rgb_->set_rgb_color(this->led_rgb_->led_common.context, rgb->red_value, rgb->green_value, rgb->blue_value); + } }