diff --git a/examples/lighting-app/telink/src/AppTask.cpp b/examples/lighting-app/telink/src/AppTask.cpp index 0ce711f72fdb8a..4b879fbee0ea20 100644 --- a/examples/lighting-app/telink/src/AppTask.cpp +++ b/examples/lighting-app/telink/src/AppTask.cpp @@ -64,7 +64,7 @@ constexpr uint8_t kDefaultMaxLevel = 254; const struct pwm_dt_spec sBluePwmLed = LIGHTING_PWM_SPEC_BLUE; #if USE_RGB_PWM const struct pwm_dt_spec sGreenPwmLed = LIGHTING_PWM_SPEC_GREEN; -const struct pwm_dt_spec sRedPwmLed = LIGHTING_PWM_SPEC_RED; +const struct pwm_dt_spec sRedPwmLed = LIGHTING_PWM_SPEC_RED; #endif #if CONFIG_CHIP_FACTORY_DATA @@ -298,16 +298,18 @@ void AppTask::LightingActionEventHandler(AppEvent * aEvent) { action = PWMDevice::OFF_ACTION; } - else { + else + { action = PWMDevice::ON_ACTION; } #else action = sAppTask.mBluePwmLed.IsTurnedOn() ? PWMDevice::OFF_ACTION : PWMDevice::ON_ACTION; #endif - actor = AppEvent::kEventType_Button; + actor = AppEvent::kEventType_Button; } - if (action != PWMDevice::INVALID_ACTION && ( + if (action != PWMDevice::INVALID_ACTION && + ( #if USE_RGB_PWM !sAppTask.mRedPwmLed.InitiateAction(action, actor, NULL) || !sAppTask.mGreenPwmLed.InitiateAction(action, actor, NULL) || @@ -526,7 +528,7 @@ void AppTask::UpdateClusterState() #if USE_RGB_PWM bool isTurnedOn = sAppTask.mRedPwmLed.IsTurnedOn() || sAppTask.mGreenPwmLed.IsTurnedOn() || sAppTask.mBluePwmLed.IsTurnedOn(); #else - bool isTurnedOn = sAppTask.mBluePwmLed.IsTurnedOn(); + bool isTurnedOn = sAppTask.mBluePwmLed.IsTurnedOn(); #endif // write the new on/off value EmberAfStatus status = Clusters::OnOff::Attributes::OnOff::Set(1, isTurnedOn); @@ -538,9 +540,8 @@ void AppTask::UpdateClusterState() #if USE_RGB_PWM uint8_t setLevel; - if (sColorAction == PWMDevice::COLOR_ACTION_XY - || sColorAction == PWMDevice::COLOR_ACTION_HSV - || sColorAction == PWMDevice::COLOR_ACTION_CT) + if (sColorAction == PWMDevice::COLOR_ACTION_XY || sColorAction == PWMDevice::COLOR_ACTION_HSV || + sColorAction == PWMDevice::COLOR_ACTION_CT) { setLevel = sBrightness; } @@ -622,7 +623,7 @@ void AppTask::InitButtons(void) void AppTask::SetInitiateAction(PWMDevice::Action_t aAction, int32_t aActor, uint8_t * value) { - #if USE_RGB_PWM +#if USE_RGB_PWM bool setRgbAction = false; RgbColor_t rgb; #endif @@ -648,7 +649,7 @@ void AppTask::SetInitiateAction(PWMDevice::Action_t aAction, int32_t aActor, uin else if (sColorAction == PWMDevice::COLOR_ACTION_HSV) { sHSV.v = sBrightness; - rgb = HsvToRgb(sHSV); + rgb = HsvToRgb(sHSV); } else { @@ -669,18 +670,17 @@ void AppTask::SetInitiateAction(PWMDevice::Action_t aAction, int32_t aActor, uin { sXY = *reinterpret_cast(value); rgb = XYToRgb(sBrightness, sXY.x, sXY.y); - ChipLogProgress(Zcl, "XY to RGB: X: %u, Y: %u, Level: %u | R: %u, G: %u, B: %u", - sXY.x, sXY.y, sBrightness, rgb.r, rgb.g, rgb.b); + ChipLogProgress(Zcl, "XY to RGB: X: %u, Y: %u, Level: %u | R: %u, G: %u, B: %u", sXY.x, sXY.y, sBrightness, rgb.r, rgb.g, + rgb.b); setRgbAction = true; sColorAction = PWMDevice::COLOR_ACTION_XY; } else if (aAction == PWMDevice::COLOR_ACTION_HSV) { - sHSV = *reinterpret_cast(value); + sHSV = *reinterpret_cast(value); sHSV.v = sBrightness; - rgb = HsvToRgb(sHSV); - ChipLogProgress(Zcl, "HSV to RGB: H: %u, S: %u, V: %u | R: %u, G: %u, B: %u", - sHSV.h, sHSV.s, sHSV.v, rgb.r, rgb.g, rgb.b); + rgb = HsvToRgb(sHSV); + ChipLogProgress(Zcl, "HSV to RGB: H: %u, S: %u, V: %u | R: %u, G: %u, B: %u", sHSV.h, sHSV.s, sHSV.v, rgb.r, rgb.g, rgb.b); setRgbAction = true; sColorAction = PWMDevice::COLOR_ACTION_HSV; } diff --git a/examples/lighting-app/telink/src/ZclCallbacks.cpp b/examples/lighting-app/telink/src/ZclCallbacks.cpp index d8dd51759f70ae..5a0a6dbec4c07f 100644 --- a/examples/lighting-app/telink/src/ZclCallbacks.cpp +++ b/examples/lighting-app/telink/src/ZclCallbacks.cpp @@ -17,8 +17,8 @@ */ #include "AppTask.h" -#include "PWMDevice.h" #include "ColorFormat.h" +#include "PWMDevice.h" #include #include @@ -42,7 +42,7 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & { ChipLogProgress(Zcl, "Cluster OnOff: attribute OnOff set to %u", *value); GetAppTask().SetInitiateAction(*value ? PWMDevice::ON_ACTION : PWMDevice::OFF_ACTION, - static_cast(AppEvent::kEventType_Lighting), value); + static_cast(AppEvent::kEventType_Lighting), value); } else if (clusterId == LevelControl::Id && attributeId == LevelControl::Attributes::CurrentLevel::Id) { @@ -79,8 +79,8 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & } ChipLogProgress(Zcl, "New XY color: %u|%u", xy.x, xy.y); - GetAppTask().SetInitiateAction(PWMDevice::COLOR_ACTION_XY, - static_cast(AppEvent::kEventType_Lighting), (uint8_t *) &xy); + GetAppTask().SetInitiateAction(PWMDevice::COLOR_ACTION_XY, static_cast(AppEvent::kEventType_Lighting), + (uint8_t *) &xy); } /* HSV color space */ else if (attributeId == ColorControl::Attributes::CurrentHue::Id || @@ -101,13 +101,13 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & hsv.s = *value; } ChipLogProgress(Zcl, "New HSV color: hue = %u| saturation = %u", hsv.h, hsv.s); - GetAppTask().SetInitiateAction(PWMDevice::COLOR_ACTION_HSV, - static_cast(AppEvent::kEventType_Lighting), (uint8_t *) &hsv); + GetAppTask().SetInitiateAction(PWMDevice::COLOR_ACTION_HSV, static_cast(AppEvent::kEventType_Lighting), + (uint8_t *) &hsv); } /* Temperature Mireds color space */ else if (attributeId == ColorControl::Attributes::ColorTemperatureMireds::Id) { - ChipLogProgress(Zcl, "New Temperature Mireds color = %u", *(uint16_t*)value); + ChipLogProgress(Zcl, "New Temperature Mireds color = %u", *(uint16_t *) value); GetAppTask().SetInitiateAction(PWMDevice::COLOR_ACTION_CT, static_cast(AppEvent::kEventType_Lighting), value); } else diff --git a/examples/platform/telink/util/src/PWMDevice.cpp b/examples/platform/telink/util/src/PWMDevice.cpp index a175b45d419eca..6a23b399be7576 100644 --- a/examples/platform/telink/util/src/PWMDevice.cpp +++ b/examples/platform/telink/util/src/PWMDevice.cpp @@ -70,8 +70,8 @@ bool PWMDevice::InitiateAction(Action_t aAction, int32_t aActor, uint8_t * value action_initiated = true; new_state = kState_Off; } - else if ((aAction == LEVEL_ACTION || aAction == COLOR_ACTION_XY - || aAction == COLOR_ACTION_HSV || aAction == COLOR_ACTION_CT) && *value != mLevel) + else if ((aAction == LEVEL_ACTION || aAction == COLOR_ACTION_XY || aAction == COLOR_ACTION_HSV || aAction == COLOR_ACTION_CT) && + *value != mLevel) { action_initiated = true; if (*value == 0) @@ -95,8 +95,7 @@ bool PWMDevice::InitiateAction(Action_t aAction, int32_t aActor, uint8_t * value { Set(new_state == kState_On); } - else if (aAction == LEVEL_ACTION || aAction == COLOR_ACTION_XY - || aAction == COLOR_ACTION_HSV || aAction == COLOR_ACTION_CT) + else if (aAction == LEVEL_ACTION || aAction == COLOR_ACTION_XY || aAction == COLOR_ACTION_HSV || aAction == COLOR_ACTION_CT) { SetLevel(*value); }