From dc568e9a21eaa102cc4dc0d738b50543d717b801 Mon Sep 17 00:00:00 2001 From: Ivan Li Date: Mon, 21 Nov 2022 19:11:35 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=9B=B4=E6=94=B9=20MQTT=20=E6=8C=87?= =?UTF-8?q?=E7=A4=BA=E7=81=AF=E6=95=88=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/light.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/main/light.c b/main/light.c index f6e5b3b..d5e23eb 100644 --- a/main/light.c +++ b/main/light.c @@ -88,32 +88,38 @@ void led_strip_hsv2rgb(uint32_t h, uint32_t s, uint32_t v, uint32_t *r, void update_desktop_connection_state() { static uint8_t tick = 0; - uint8_t mask = tick / 10 % 2 ? 0xff : 0x00; + bool beat = tick / 10 % 2 ? 1 : 0; switch (light_mode) { case light_mode_desktop_online: - ESP_ERROR_CHECK(light_led_strip->set_pixel(light_led_strip, 0, mask & 150, - mask & 50, mask & 0)); + if (beat) { + ESP_ERROR_CHECK( + light_led_strip->set_pixel(light_led_strip, 0, 77, 77, 77)); + } ESP_ERROR_CHECK( - light_led_strip->set_pixel(light_led_strip, 1, 30, 100, 0)); + light_led_strip->set_pixel(light_led_strip, 1, 77, 77, 77)); ESP_ERROR_CHECK( - light_led_strip->set_pixel(light_led_strip, 2, 30, 100, 0)); + light_led_strip->set_pixel(light_led_strip, 2, 77, 77, 77)); break; case light_mode_mqtt_connected: - ESP_ERROR_CHECK(light_led_strip->set_pixel(light_led_strip, 0, mask & 100, - mask & 30, mask & 0)); - ESP_ERROR_CHECK(light_led_strip->set_pixel(light_led_strip, 1, mask & 100, - mask & 30, mask & 0)); + if (beat) { + ESP_ERROR_CHECK( + light_led_strip->set_pixel(light_led_strip, 0, 77, 77, 77)); + ESP_ERROR_CHECK( + light_led_strip->set_pixel(light_led_strip, 1, 77, 77, 77)); + } ESP_ERROR_CHECK( - light_led_strip->set_pixel(light_led_strip, 2, 50, 150, 0)); + light_led_strip->set_pixel(light_led_strip, 2, 77, 77, 77)); break; case light_mode_idle: - ESP_ERROR_CHECK(light_led_strip->set_pixel(light_led_strip, 0, mask & 100, - mask & 30, mask & 0)); - ESP_ERROR_CHECK(light_led_strip->set_pixel(light_led_strip, 1, mask & 100, - mask & 30, mask & 0)); - ESP_ERROR_CHECK(light_led_strip->set_pixel(light_led_strip, 2, mask & 100, - mask & 30, mask & 0)); + if (beat) { + ESP_ERROR_CHECK( + light_led_strip->set_pixel(light_led_strip, 0, 77, 77, 77)); + ESP_ERROR_CHECK( + light_led_strip->set_pixel(light_led_strip, 1, 77, 77, 77)); + ESP_ERROR_CHECK( + light_led_strip->set_pixel(light_led_strip, 2, 77, 77, 77)); + } break; default: break;