Skip to content

Commit

Permalink
Pull request project-chip#116: re-enabled Jenkin custom example build…
Browse files Browse the repository at this point in the history
…s, 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 <huelsher@silabs.com>
Date:   Mon Sep 19 14:58:14 2022 -0400

    added BRD4166A to custom build boards
    JIRA: MATTER-693

commit 1949cd27b62c1e9b302cff363a90ce49008709ac
Author: Hussein Elsherbini <huelsher@silabs.com>
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
  • Loading branch information
HusseinElsherbini authored and jmartinez-silabs committed Jan 9, 2024
1 parent 0e4a104 commit 34fc8a6
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 29 deletions.
42 changes: 21 additions & 21 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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")
{
Expand Down
59 changes: 51 additions & 8 deletions silabs_examples/sl-newLight/efr32/light_modules/led_widget_rgb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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)
{
Expand All @@ -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, &currentValue);
chip::DeviceLayer::PlatformMgr().UnlockChipStack();

if(currentValue){

this->SetColor(this->current_hue_, this->current_saturation_, this->current_level_);
}

}


Expand Down Expand Up @@ -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, &currentValue);
chip::DeviceLayer::PlatformMgr().UnlockChipStack();

this->current_hue_ = static_cast<uint16_t>((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, &currentValue);
chip::DeviceLayer::PlatformMgr().UnlockChipStack();

this->current_saturation_ = static_cast<uint16_t>((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 =
{
Expand All @@ -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, &currentValue);
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)
{
Expand All @@ -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, &currentValue);
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);
}
}


Expand Down

0 comments on commit 34fc8a6

Please sign in to comment.