From 0f5e2a966465bf57756935abf7753360f053ad3c Mon Sep 17 00:00:00 2001 From: Ivan Li Date: Sun, 30 Apr 2023 23:23:25 +0800 Subject: [PATCH] feat: ping pong. --- main/light.c | 2 ++ main/main.c | 18 +++++++++--------- main/udp_server.c | 5 +++++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/main/light.c b/main/light.c index f521461..06e2726 100644 --- a/main/light.c +++ b/main/light.c @@ -85,6 +85,8 @@ void led_strip_set_color_calibration(float red, float green, float blue) { led_strip_green_calibration = green; led_strip_blue_calibration = blue; + ESP_LOGI(LIGHT_TAG, "Calibration: %f %f %f", red, green, blue); + nvs_handle_t local_nvs_handle; esp_err_t err = nvs_open("storage", NVS_READWRITE, &local_nvs_handle); diff --git a/main/main.c b/main/main.c index 261e221..b8f81d9 100644 --- a/main/main.c +++ b/main/main.c @@ -29,15 +29,15 @@ void app_main(void) { init_display(); display_print8_str(0, 0, "Ambient Light"); - // ci_03t_init(); - // apds_9960_init(); - // apds_9960_auto_fetch(); - // auto_fetch_temperature(); - // pca9555_init(); - // ui_input_init(); - // xTaskCreate(mqtt_publish_ui_input, "mqtt_publish_ui_input", 2048, NULL, 10, - // NULL); - // vTaskDelay(pdMS_TO_TICKS(10)); + ci_03t_init(); + apds_9960_init(); + apds_9960_auto_fetch(); + auto_fetch_temperature(); + pca9555_init(); + ui_input_init(); + xTaskCreate(mqtt_publish_ui_input, "mqtt_publish_ui_input", 2048, NULL, 10, + NULL); + vTaskDelay(pdMS_TO_TICKS(10)); light_play(light_mode_connection_wifi); if (connect_wifi()) { light_play(light_mode_idle); diff --git a/main/udp_server.c b/main/udp_server.c index c411679..485acbb 100644 --- a/main/udp_server.c +++ b/main/udp_server.c @@ -83,6 +83,11 @@ static void udp_server_task(void *pvParameters) { // like a string... switch (rx_buffer[0]) { + case 1: + sendto(sock, rx_buffer, 1, 0, (struct sockaddr *)&source_addr, + sizeof(source_addr)); + break; + case 2: set_display_ambient_light_colors( ((uint16_t)rx_buffer[1] << 8 | (uint16_t)rx_buffer[2]),