只需一步,快速开始
int colorT; //1000~10000 //色温控制,1000~10000 void setColoTemp(int32_t colorTemp) { //R if (colorTemp <= 6600) { colorR = 255; } else { colorR = 255 - (255 - 205) * (colorTemp - 6600) / (10000 - 6600); } //G if (colorTemp <= 6600) { colorG = 51 + (250 - 51) * (colorTemp - 1000) / (6600 - 1000); } else { colorG = 250 - (250 - 218) * (colorTemp - 6600) / (10000 - 6600); } //B if (colorTemp <= 2000) { colorB = 0; } else if (colorTemp >= 6500) { colorB = 255; } else { colorB = 11 + (255 - 11) * (colorTemp - 2000) / (6500 - 2000); } colorT = colorTemp; BLINKER_LOG("setColoTemp: ", colorT); pixelShow(); } //小爱中直接传值 //色温控制,1000~10000,步长1800 void miotColoTemp(int32_t colorTemp) { BLINKER_LOG("need set colorTemperature: ", colorTemp); setColoTemp(colorTemp); BlinkerMIOT.colorTemp(colorTemp); BlinkerMIOT.print(); } //天猫精灵中转换一下 //色温 void aligenieColoTemp(int32_t colorTemp) { BLINKER_LOG("need set colorTemperature: ", colorTemp); setColoTemp(1000 + 9000 * colorTemp / 100); BlinkerAliGenie.colorTemp(colorTemp); BlinkerAliGenie.print(); } //步长色温 void aligenieRelativeColoTemp(int32_t colorTemp) { BLINKER_LOG("need set relative colorTemperature: ", colorTemp); if (colorTemp == 10) { //冷一点 colorT = (colorT + 1800 > 10000) ? 10000 : (colorT + 1800); } else if (colorTemp == -10) { //暖一点 colorT = (colorT - 1800 < 1000) ? 1000 : (colorT - 1800); } setColoTemp(colorT); BlinkerAliGenie.colorTemp((colorT - 1000) * 100 / 9000); BlinkerAliGenie.print(); }
//色温控制,1000~10000 void setColoTemp(int32_t colorTemp) { //R if (colorTemp <= 6600) { colorR = 255; } else { colorR = 255 - (255 - 205) * (colorTemp - 6600) / (10000 - 6600); } //G if (colorTemp <= 6600) { colorG = 51 + (250 - 51) * (colorTemp - 1000) / (6600 - 1000); } else { colorG = 250 - (250 - 218) * (colorTemp - 6600) / (10000 - 6600); } //B if (colorTemp <= 2000) { colorB = 0; } else if (colorTemp >= 6500) { colorB = 255; } else { colorB = 11 + (255 - 11) * (colorTemp - 2000) / (6500 - 2000); } colorT = colorTemp; BLINKER_LOG("setColoTemp: ", colorT); pixelShow(); }
//小爱中直接传值 //色温控制,1000~10000,步长1800 void miotColoTemp(int32_t colorTemp) { BLINKER_LOG("need set colorTemperature: ", colorTemp); setColoTemp(colorTemp); BlinkerMIOT.colorTemp(colorTemp); BlinkerMIOT.print(); }
举报
本版积分规则 发表回复 回帖后跳转到最后一页
小黑屋|Archiver|手机版|Arduino中文社区
GMT+8, 2024-11-28 12:39 , Processed in 0.312097 second(s), 15 queries .
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.