Compare commits

..

No commits in common. "b29718418542b6071396cfa66378f601d146ca72" and "4eb4af8eb68102615cf5a4d161745c9441109366" have entirely different histories.

2 changed files with 14 additions and 71 deletions

View File

@ -53,7 +53,7 @@
#endif
#define COLOR_TEMPERATURE_PHYSICAL_MIN 0x009A // 6500K
#define COLOR_TEMPERATURE_PHYSICAL_MAX 0x172 // 2700K, default in z2m for gl-c-008p 2020K aka 0x01ef
#define COLOR_TEMPERATURE_PHYSICAL_MAX 0x01C6 // 2200K
#define COLOR_TEMPERATURE_DEFAULT 0x00FA // 4000K
/**********************************************************************

View File

@ -36,7 +36,7 @@
/**********************************************************************
* LOCAL CONSTANTS
*/
#define ZCL_COLOR_CHANGE_INTERVAL 20 // Step 50 times a second, every 20ms
#define ZCL_COLOR_CHANGE_INTERVAL 100
/**********************************************************************
* TYPEDEFS
@ -57,8 +57,7 @@ typedef struct
u16 colorTempMinMireds;
u16 colorTempMaxMireds;
s32 stepX256;
s32 stepY256;
s32 stepXY;
u32 currentX256;
u32 currentY256;
u16 xyRemainingTime;
@ -82,8 +81,7 @@ static zcl_colorInfo_t colorInfo = {
.colorTempMinMireds = 0,
.colorTempMaxMireds = 0,
.stepX256 = 0,
.stepY256 = 0,
.stepXY = 0,
.currentX256 = 0,
.currentY256 = 0,
.xyRemainingTime = 0,
@ -202,8 +200,8 @@ static s32 sampleLight_colorTimerEvtCb(void *arg)
{
zcl_lightColorCtrlAttr_t *pColor = zcl_colorAttrGet();
if ((pColor->colorMode == ZCL_COLOR_MODE_CURRENT_HUE_SATURATION) ||
(pColor->colorMode == ZCL_ENHANCED_COLOR_MODE_CURRENT_HUE_SATURATION))
if ((pColor->enhancedColorMode == ZCL_COLOR_MODE_CURRENT_HUE_SATURATION) ||
(pColor->enhancedColorMode == ZCL_ENHANCED_COLOR_MODE_CURRENT_HUE_SATURATION))
{
if (colorInfo.saturationRemainingTime)
{
@ -217,7 +215,7 @@ static s32 sampleLight_colorTimerEvtCb(void *arg)
ZCL_COLOR_ATTR_HUE_MIN, ZCL_COLOR_ATTR_HUE_MAX, TRUE);
}
}
else if (pColor->colorMode == ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS)
else if (pColor->enhancedColorMode == ZCL_COLOR_MODE_COLOR_TEMPERATURE_MIREDS)
{
if (colorInfo.colorTempRemainingTime)
{
@ -225,19 +223,8 @@ static s32 sampleLight_colorTimerEvtCb(void *arg)
colorInfo.colorTempMinMireds, colorInfo.colorTempMaxMireds, FALSE);
}
}
else if (pColor->colorMode == ZCL_COLOR_MODE_CURRENT_X_Y)
{
if (colorInfo.xyRemainingTime)
{
light_applyUpdate_16(&pColor->currentX, &colorInfo.currentX256, &colorInfo.stepX256, &colorInfo.xyRemainingTime,
ZCL_COLOR_ATTR_XY_MIN, ZCL_COLOR_ATTR_XY_MAX, FALSE);
light_applyUpdate_16(&pColor->currentY, &colorInfo.currentY256, &colorInfo.stepY256, &colorInfo.xyRemainingTime,
ZCL_COLOR_ATTR_XY_MIN, ZCL_COLOR_ATTR_XY_MAX, FALSE);
}
}
if (colorInfo.saturationRemainingTime || colorInfo.hueRemainingTime || colorInfo.colorTempRemainingTime || colorInfo.xyRemainingTime)
if (colorInfo.saturationRemainingTime || colorInfo.hueRemainingTime || colorInfo.colorTempRemainingTime)
{
return 0;
}
@ -675,55 +662,11 @@ static void sampleLight_moveToColorProcess(zcl_colorCtrlMoveToColorCmd_t *cmd)
pColor->colorMode = ZCL_COLOR_MODE_CURRENT_X_Y;
pColor->enhancedColorMode = ZCL_COLOR_MODE_CURRENT_X_Y;
colorInfo.currentX256 = (u16)(pColor->currentX) << 8;
colorInfo.currentY256 = (u16)(pColor->currentY) << 8;
s16 xDiff = (s16)cmd->colorX - pColor->currentX;
s16 yDiff = (s16)cmd->colorY - pColor->currentY;
// It is recommended to take the shortest path here
if (xDiff > (ZCL_COLOR_ATTR_XY_MAX / 2))
{
xDiff -= (ZCL_COLOR_ATTR_XY_MAX + 1);
}
else if (xDiff < -ZCL_COLOR_ATTR_XY_MAX / 2)
{
xDiff += (ZCL_COLOR_ATTR_XY_MAX + 1);
}
if (yDiff > (ZCL_COLOR_ATTR_XY_MAX / 2))
{
yDiff -= (ZCL_COLOR_ATTR_XY_MAX + 1);
}
else if (yDiff < -ZCL_COLOR_ATTR_XY_MAX / 2)
{
yDiff += (ZCL_COLOR_ATTR_XY_MAX + 1);
}
colorInfo.xyRemainingTime = (cmd->transitionTime == 0) ? 1 : cmd->transitionTime;
colorInfo.stepX256 = ((s32)xDiff) << 8;
colorInfo.stepX256 /= (s32)colorInfo.xyRemainingTime;
colorInfo.stepY256 = ((s32)yDiff) << 8;
colorInfo.stepY256 /= (s32)colorInfo.xyRemainingTime;
light_applyUpdate_16(&pColor->currentX, &colorInfo.currentX256, &colorInfo.stepX256, &colorInfo.xyRemainingTime,
light_applyUpdate_16(&pColor->currentX, &colorInfo.currentX256, &colorInfo.stepXY, &colorInfo.xyRemainingTime,
ZCL_COLOR_ATTR_XY_MIN, ZCL_COLOR_ATTR_XY_MAX, FALSE);
light_applyUpdate_16(&pColor->currentY, &colorInfo.currentY256, &colorInfo.stepY256, &colorInfo.xyRemainingTime,
light_applyUpdate_16(&pColor->currentY, &colorInfo.currentY256, &colorInfo.stepXY, &colorInfo.xyRemainingTime,
ZCL_COLOR_ATTR_XY_MIN, ZCL_COLOR_ATTR_XY_MAX, FALSE);
if (colorInfo.xyRemainingTime)
{
sampleLight_colorTimerStop();
colorTimerEvt = TL_ZB_TIMER_SCHEDULE(sampleLight_colorTimerEvtCb, NULL, ZCL_COLOR_CHANGE_INTERVAL);
}
else
{
sampleLight_colorTimerStop();
}
}
/*********************************************************************
@ -744,10 +687,10 @@ static void sampleLight_moveColorProcess(zcl_colorCtrlMoveColorCmd_t *cmd)
pColor->colorMode = ZCL_COLOR_MODE_CURRENT_X_Y;
pColor->enhancedColorMode = ZCL_COLOR_MODE_CURRENT_X_Y;
light_applyUpdate_16(&pColor->currentX, &colorInfo.currentX256, &colorInfo.stepX256, &colorInfo.xyRemainingTime,
light_applyUpdate_16(&pColor->currentX, &colorInfo.currentX256, &colorInfo.stepXY, &colorInfo.xyRemainingTime,
ZCL_COLOR_ATTR_XY_MIN, ZCL_COLOR_ATTR_XY_MAX, FALSE);
light_applyUpdate_16(&pColor->currentY, &colorInfo.currentY256, &colorInfo.stepY256, &colorInfo.xyRemainingTime,
light_applyUpdate_16(&pColor->currentY, &colorInfo.currentY256, &colorInfo.stepXY, &colorInfo.xyRemainingTime,
ZCL_COLOR_ATTR_XY_MIN, ZCL_COLOR_ATTR_XY_MAX, FALSE);
}
@ -769,10 +712,10 @@ static void sampleLight_stepColorProcess(zcl_colorCtrlStepColorCmd_t *cmd)
pColor->colorMode = ZCL_COLOR_MODE_CURRENT_X_Y;
pColor->enhancedColorMode = ZCL_COLOR_MODE_CURRENT_X_Y;
light_applyUpdate_16(&pColor->currentX, &colorInfo.currentX256, &colorInfo.stepX256, &colorInfo.xyRemainingTime,
light_applyUpdate_16(&pColor->currentX, &colorInfo.currentX256, &colorInfo.stepXY, &colorInfo.xyRemainingTime,
ZCL_COLOR_ATTR_XY_MIN, ZCL_COLOR_ATTR_XY_MAX, FALSE);
light_applyUpdate_16(&pColor->currentY, &colorInfo.currentY256, &colorInfo.stepY256, &colorInfo.xyRemainingTime,
light_applyUpdate_16(&pColor->currentY, &colorInfo.currentY256, &colorInfo.stepXY, &colorInfo.xyRemainingTime,
ZCL_COLOR_ATTR_XY_MIN, ZCL_COLOR_ATTR_XY_MAX, FALSE);
}