fix: 数据传输卡顿。

This commit is contained in:
Ivan Li 2022-11-23 21:42:09 +08:00
parent cd16a29389
commit 259b29f4b3
2 changed files with 1 additions and 13 deletions

View File

@ -244,23 +244,11 @@ void light_play_colors(uint16_t len, uint8_t *buffer) {
light_mode = light_mode_desktop_sending_colors; light_mode = light_mode_desktop_sending_colors;
printf("COLORS=%.*s\r\n", len, buffer); printf("COLORS=%.*s\r\n", len, buffer);
ESP_ERROR_CHECK(light_led_strip->clear(light_led_strip, 100));
for (uint16_t led_index = 0, buffer_cursor = 0; for (uint16_t led_index = 0, buffer_cursor = 0;
led_index < STRIP_LED_NUMBER && buffer_cursor < len; led_index < STRIP_LED_NUMBER && buffer_cursor < len;
led_index++, buffer_cursor += 3) { led_index++, buffer_cursor += 3) {
uint8_t r = buffer[buffer_cursor], g = buffer[buffer_cursor + 1], uint8_t r = buffer[buffer_cursor], g = buffer[buffer_cursor + 1],
b = buffer[buffer_cursor + 2]; b = buffer[buffer_cursor + 2];
ESP_LOGI(LIGHT_TAG, "RGB: %d %d %d", r, g, b);
ESP_ERROR_CHECK(
light_led_strip->set_pixel(light_led_strip, led_index, r, g, b));
}
ESP_ERROR_CHECK(light_led_strip->refresh(light_led_strip, 100));
vTaskDelay(pdMS_TO_TICKS(10));
for (uint16_t led_index = 0, buffer_cursor = 0;
led_index < STRIP_LED_NUMBER && buffer_cursor < len;
led_index++, buffer_cursor += 3) {
uint8_t r = buffer[buffer_cursor], g = buffer[buffer_cursor + 1], b = 0;
ESP_LOGI(LIGHT_TAG, "RGB: %d %d %d", r, g, b);
ESP_ERROR_CHECK( ESP_ERROR_CHECK(
light_led_strip->set_pixel(light_led_strip, led_index, r, g, b)); light_led_strip->set_pixel(light_led_strip, led_index, r, g, b));
} }

View File

@ -66,7 +66,7 @@ static void mqtt_event_handler(void *handler_args, esp_event_base_t base,
msg_id = esp_mqtt_client_publish(client, MQTT_KEY_BOARD_ONLINE, "ONLINE", msg_id = esp_mqtt_client_publish(client, MQTT_KEY_BOARD_ONLINE, "ONLINE",
0, 1, 0); 0, 1, 0);
ESP_LOGI(MQTT_TAG, "sent publish successful, msg_id=%d", msg_id); ESP_LOGI(MQTT_TAG, "sent publish successful, msg_id=%d", msg_id);
esp_mqtt_client_subscribe(client, MQTT_KEY_DESKTOP_ALL, 0); esp_mqtt_client_subscribe(client, MQTT_KEY_DESKTOP_ALL, 1);
break; break;
case MQTT_EVENT_DISCONNECTED: case MQTT_EVENT_DISCONNECTED:
ESP_LOGI(MQTT_TAG, "MQTT_EVENT_DISCONNECTED"); ESP_LOGI(MQTT_TAG, "MQTT_EVENT_DISCONNECTED");