espressif / esp-aliyun

Aliyun Iotkit-embedded, support esp32 & esp8266.
339 stars 151 forks source link

example smartlight cannot modify the RGB light as expect. #184

Open rillhu opened 4 years ago

rillhu commented 4 years ago

1. 开发环境

2.1 复现步骤

flash the bin and elf to flash, and change the color setting using the yunzhineng APP.

2.2 复现问题的代码

linkkit_solo.c Line163

/* Switch Lightbulb Hue / LightSwitch = cJSON_GetObjectItem(root, "RGBColor"); if (LightSwitch) { LightColor = cJSON_GetObjectItem(LightSwitch, "Red"); lightbulb_set_hue(LightColor ? LightColor->valueint : 0); LightColor = cJSON_GetObjectItem(LightSwitch, "Green"); lightbulb_set_hue(LightColor ? LightColor->valueint : 120); LightColor = cJSON_GetObjectItem(LightSwitch, "Blue"); lightbulb_set_hue(LightColor ? LightColor->valueint : 240); }

3. 调试 Logs

4. 其他项

According to current code, the example smartlight uses the hsb2rgb() function, so it looks that the app should use the HSL/HSV color modulation. And the code should be updated accordingly. Below code should be used and APP configuration should be updated.

You could also refer to my repo linkkit_solo.c

/** Switch Lightbulb HSV*/
LightSwitch = cJSON_GetObjectItem(root, "HSLColor");
if (LightSwitch) {
        LightColor = cJSON_GetObjectItem(LightSwitch, "Lightness");
        lightbulb_set_brightness(LightColor ? LightColor->valueint : 0);
        LightColor = cJSON_GetObjectItem(LightSwitch, "Saturation");
        lightbulb_set_saturation(LightColor ? LightColor->valueint : 120);
        LightColor = cJSON_GetObjectItem(LightSwitch, "Hue");
        lightbulb_set_hue(LightColor ? LightColor->valueint : 240);
} 
ljy770 commented 4 years ago

@rillhu 感谢,是有这个问题.