From b2c9e673df5e9583bda66c5fd2720b0d6166a892 Mon Sep 17 00:00:00 2001 From: YunHorn Technology Date: Mon, 13 May 2024 21:02:28 +0800 Subject: [PATCH] OPTIMIZED RED BLUE FLASH TIMING less MCU time used --- Core/Src/sts_lamp_bar.c | 7 ++++--- Core/Src/yunhorn_sts_process.c | 8 ++++---- LoRaWAN/App/lora_app.c | 8 ++++++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Core/Src/sts_lamp_bar.c b/Core/Src/sts_lamp_bar.c index 9e2232f..289c521 100644 --- a/Core/Src/sts_lamp_bar.c +++ b/Core/Src/sts_lamp_bar.c @@ -186,7 +186,7 @@ void STS_Lamp_Bar_Refresh(void) void STS_Lamp_Bar_Set_STS_RGB_Color(uint8_t sts_lamp_color, uint8_t luminance_level) { uint8_t lum = luminance_level; - + static bool r_b = false; STS_Lamp_Bar_Set_RGB_Color(0x0, 0x0, 0x0); switch (sts_lamp_color) { @@ -215,10 +215,11 @@ void STS_Lamp_Bar_Set_STS_RGB_Color(uint8_t sts_lamp_color, uint8_t luminance_le STS_Lamp_Bar_Set_RGB_Color(lum, lum, lum); break; case STS_RED_BLUE: + if (r_b) STS_Lamp_Bar_Set_RGB_Color(lum, 0x0, 0x0); - HAL_Delay(300); + else STS_Lamp_Bar_Set_RGB_Color(0x0, 0x0, lum); - HAL_Delay(300); + r_b = !r_b; break; } } diff --git a/Core/Src/yunhorn_sts_process.c b/Core/Src/yunhorn_sts_process.c index e0acf49..7339d02 100644 --- a/Core/Src/yunhorn_sts_process.c +++ b/Core/Src/yunhorn_sts_process.c @@ -214,11 +214,11 @@ void STS_YunhornSTSEventRFAC_Process(void) void STS_YunhornSTSEventP1_Process(void) { - sts_reed_hall_1_result = sts_hall1_read; + sts_reed_hall_1_result = HALL1_STATE; //sts_hall1_read; sts_reed_hall_1_changed =0; last_sts_reed_hall_1_result = sts_reed_hall_1_result; - sts_reed_hall_2_result = sts_hall2_read; + sts_reed_hall_2_result = HALL2_STATE;// sts_hall2_read; sts_reed_hall_2_changed =0; last_sts_reed_hall_2_result = sts_reed_hall_2_result; @@ -692,9 +692,9 @@ void STS_PRESENCE_SENSOR_Prepare_Send_Data(void) { sts_o7_sensorData.lamp_bar_color = sts_lamp_bar_color; sts_o7_sensorData.workmode = sts_work_mode; - sts_o7_sensorData.state_sensor1_on_off = sts_hall1_read; //sts_hsts_reed_hall_result; // sts_hall1_read + sts_o7_sensorData.state_sensor1_on_off = HALL1_STATE;//sts_hall1_read; //sts_hsts_reed_hall_result; // sts_hall1_read sts_o7_sensorData.state_sensor2_on_off = sts_rss_result; - sts_o7_sensorData.state_sensor3_on_off = sts_hall2_read; //sts_emergency_button_pushed; //sts_hall2_read + sts_o7_sensorData.state_sensor3_on_off = HALL2_STATE;//sts_hall2_read; //sts_emergency_button_pushed; //sts_hall2_read sts_o7_sensorData.state_sensor4_on_off = sts_rss_2nd_result; if (sts_rss_result == STS_RESULT_MOTION) { diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c index 2e0a9f6..877b20c 100644 --- a/LoRaWAN/App/lora_app.c +++ b/LoRaWAN/App/lora_app.c @@ -915,11 +915,13 @@ static void SendTxData(void) UTIL_TIMER_Time_t nextTxIn = 0; uint8_t i = 0; - if (LmHandlerIsBusy() == false) + APP_LOG(TS_OFF, VLEVEL_M, "\r\n\n\n SendTxData Enter \r\n\n"); + + //if (LmHandlerIsBusy() == false) { AppData.Port = LORAWAN_USER_APP_PORT; //AppData.Buffer[i++] = AppLedStateOn; //#01 - //STS_PRESENCE_SENSOR_Prepare_Send_Data(); + STS_PRESENCE_SENSOR_Prepare_Send_Data(); if ((heart_beat_timer != 0L)) // sensor data OVERWRITE heart-beat message, 2024-05-12 { @@ -927,10 +929,12 @@ static void SendTxData(void) AppData.Port = sts_sendhtbtport; //LORAWAN_USER_APP_PORT+1; AppData.Buffer[i++]= AppLedStateOn|0x80; AppData.Buffer[i++] = (uint8_t)(99*batteryLevel/254)&0xff; //#05 + APP_LOG(TS_OFF, VLEVEL_M, "\r\n\n\n SendTxData Enter Heart-Beat \r\n\n"); } else if ((upload_message_timer != 0U)||(sensor_data_ready!= 0U)) //sensor_data_ready for manual push button-1 trigger) { + APP_LOG(TS_OFF, VLEVEL_M, "\r\n\n\n SendTxData Enter Sensor Data Ready \r\n\n"); sensor_data_ready =0;