手机返回APP时,要设置成离开时的值,在心跳包时加入PRINT语句,获取亮度值错误,心跳包里不加,能获取值。
//灯带回调
void rgblight_callback(uint8_t r_value, uint8_t g_value, uint8_t b_value, uint8_t bright_value)
{
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
BLINKER_LOG("r value: ", r_value);
BLINKER_LOG("g value: ", g_value);
BLINKER_LOG("b value: ", b_value);
BLINKER_LOG("brightness value: ", bright_value);
R_value = r_value;
G_value = g_value;
B_value = b_value;
Bright_value = bright_value;
BLINKER_LOG("R value: ", r_value);
BLINKER_LOG("G value: ", g_value);
BLINKER_LOG("B value: ", b_value);
BLINKER_LOG("Brightness value: ", bright_value);
pixels.setBrightness(bright_value);
for (int i = 0; i < NUMPIXELS; i++) {
pixels.setPixelColor(i, r_value, g_value, b_value);
}
pixels.show();
}
//心跳包
void heartbeat()
{
RGBlight.print(R_value, G_value, B_value, Bright_value);//心跳包不加入,没错误。
}
log:
[564278] r value: 29
[564278] g value: 255
[564279] b value: 9
[564279] brightness value: 0
[564279] R value: 29
[564279] G value: 255
[564280] B value: 9
[564281] Brightness value: 0
|