Skip to content

Commit

Permalink
Restyled by clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits authored and s07641069 committed Jan 19, 2023
1 parent acca2e0 commit 4a68ee1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 27 deletions.
32 changes: 16 additions & 16 deletions examples/lighting-app/telink/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) ||
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down Expand Up @@ -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
Expand All @@ -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
{
Expand All @@ -669,18 +670,17 @@ void AppTask::SetInitiateAction(PWMDevice::Action_t aAction, int32_t aActor, uin
{
sXY = *reinterpret_cast<XyColor_t *>(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<HsvColor_t *>(value);
sHSV = *reinterpret_cast<HsvColor_t *>(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;
}
Expand Down
14 changes: 7 additions & 7 deletions examples/lighting-app/telink/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*/

#include "AppTask.h"
#include "PWMDevice.h"
#include "ColorFormat.h"
#include "PWMDevice.h"

#include <app-common/zap-generated/attributes/Accessors.h>
#include <app-common/zap-generated/ids/Attributes.h>
Expand All @@ -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<int32_t>(AppEvent::kEventType_Lighting), value);
static_cast<int32_t>(AppEvent::kEventType_Lighting), value);
}
else if (clusterId == LevelControl::Id && attributeId == LevelControl::Attributes::CurrentLevel::Id)
{
Expand Down Expand Up @@ -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<int32_t>(AppEvent::kEventType_Lighting), (uint8_t *) &xy);
GetAppTask().SetInitiateAction(PWMDevice::COLOR_ACTION_XY, static_cast<int32_t>(AppEvent::kEventType_Lighting),
(uint8_t *) &xy);
}
/* HSV color space */
else if (attributeId == ColorControl::Attributes::CurrentHue::Id ||
Expand All @@ -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<int32_t>(AppEvent::kEventType_Lighting), (uint8_t *) &hsv);
GetAppTask().SetInitiateAction(PWMDevice::COLOR_ACTION_HSV, static_cast<int32_t>(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<int32_t>(AppEvent::kEventType_Lighting), value);
}
else
Expand Down
7 changes: 3 additions & 4 deletions examples/platform/telink/util/src/PWMDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
}
Expand Down

0 comments on commit 4a68ee1

Please sign in to comment.