revised fall down lamp bar color to BLUE only, not RED_BLUE flash to

reduce delay.
This commit is contained in:
Yunhorn 2023-05-26 11:59:54 +08:00
parent b2402553d9
commit d621ef1d86
8 changed files with 75 additions and 70 deletions

View File

@ -520,7 +520,7 @@ void STS_Combined_Status_Processing(void)
else
{
if ((last_lamp_bar_color != sts_status_color))
//if ((last_lamp_bar_color != sts_status_color))
{
sts_lamp_bar_color = ((sts_service_mask == STS_SERVICE_MASK_L0)? sts_status_color:STS_DARK);

View File

@ -397,7 +397,7 @@ int sts_presence_rss_fall_rise_detection(void)
}
acc_detector_presence_deactivate(handle);
APP_LOG(TS_OFF, VLEVEL_L,"First Half Presence Detection, Motion Count = %u \r\n", (int)motion_count);
APP_LOG(TS_OFF, VLEVEL_H,"First Half Presence Detection, Motion Count = %u \r\n", (int)motion_count);
// ******** Second Half detection of fall down and rise up
@ -455,7 +455,7 @@ int sts_presence_rss_fall_rise_detection(void)
acc_integration_sleep_ms(1000 / DEFAULT_UPDATE_RATE_PRESENCE); // DEFAULT_UPDATE_RATE);
}
APP_LOG(TS_OFF, VLEVEL_L,"Second Half, Fall Rise Detection, Motion Count = %u \r\n", (int)motion_count);
APP_LOG(TS_OFF, VLEVEL_H,"Second Half, Fall Rise Detection, Motion Count = %u \r\n", (int)motion_count);
sts_rss_result = (average_result > 3)? 1: 0;
average_distance = (1000.0f*average_distance)/average_result; // in meters
@ -572,26 +572,26 @@ void STS_YunhornCheckStandardDeviation(void)
// print result
APP_LOG(TS_OFF, VLEVEL_L, "\r\n-------------Distance Average =%6u; Variance = %6u ; Standard =%6u \r\n",
APP_LOG(TS_OFF, VLEVEL_H, "\r\n-------------Distance Average =%6u; Variance = %6u ; Standard =%6u \r\n",
(int)(average_presence_distance*1000.0f), (int)(variance_presence_distance*1000.0f), (int)(standard_variance_presence_distance*1000.0f));
APP_LOG(TS_OFF, VLEVEL_L, "-------------Motion Average =%6u; Variance = %6u ; Standard =%6u \r\n",
APP_LOG(TS_OFF, VLEVEL_H, "-------------Motion Average =%6u; Variance = %6u ; Standard =%6u \r\n",
(int)(average_presence_score*1000.0f), (int)(variance_presence_score*1000.0f), (int)(standard_variance_presence_score*1000.0f));
APP_LOG(TS_OFF, VLEVEL_L, "-------------ROC Dist Average =%6u; Variance = %6u ; Standard =%6u \r\n",
APP_LOG(TS_OFF, VLEVEL_H, "-------------ROC Dist Average =%6u; Variance = %6u ; Standard =%6u \r\n",
(int)(average_roc_distance), (int)(variance_roc_distance), (int)(standard_variance_roc_distance));
APP_LOG(TS_OFF, VLEVEL_L, "-------------ROC ACC Average =%6u; Variance = %6u ; Standard =%6u \r\n",
APP_LOG(TS_OFF, VLEVEL_H, "-------------ROC ACC Average =%6u; Variance = %6u ; Standard =%6u \r\n",
(int)(average_roc_acc), (int)(variance_roc_acc), (int)(standard_variance_roc_acc));
sts_fall_rising_pattern_factor1 = (int)(standard_variance_roc_distance);
sts_fall_rising_pattern_factor2 = (int)(fabs(average_presence_distance - fmax(0,last_average_presence_distance))*100.0f); // in cm
APP_LOG(TS_OFF, VLEVEL_L,"Avg-Dist =%6u, Last_AVG-Dist =%6u \r\n", (int)(average_presence_distance*1000.0f), (int)(last_average_presence_distance*1000.0f));
APP_LOG(TS_OFF, VLEVEL_H,"Avg-Dist =%6u, Last_AVG-Dist =%6u \r\n", (int)(average_presence_distance*1000.0f), (int)(last_average_presence_distance*1000.0f));
APP_LOG(TS_OFF, VLEVEL_L, "Threshold 1: \r\nAcc = %6u \r\nMeasure 1 = %6u ---- \r\n",
APP_LOG(TS_OFF, VLEVEL_H, "Threshold 1: \r\nAcc = %6u \r\nMeasure 1 = %6u ---- \r\n",
(int)(sts_fall_detection_acc_threshold), (int)(sts_fall_rising_pattern_factor1));
APP_LOG(TS_OFF, VLEVEL_L, "Threshold 2: \r\nDis = %6u cm \r\nMeasure 2 = %6u cm ---- \r\n",
APP_LOG(TS_OFF, VLEVEL_H, "Threshold 2: \r\nDis = %6u cm \r\nMeasure 2 = %6u cm ---- \r\n",
(int)(sts_fall_detection_depth_threshold), (int)(sts_fall_rising_pattern_factor2));
@ -623,7 +623,7 @@ void STS_YunhornCheckStandardDeviation(void)
if ( sts_fall_rising_detected_result == STS_PRESENCE_FALL )
{
APP_LOG(TS_OFF, VLEVEL_L, "\r\n Suspecious Object FALL DOWN detected \r\n");
APP_LOG(TS_OFF, VLEVEL_L, "\r\n\n\n >>>>>>>>>>>>>>>>> Suspecious Object FALL DOWN detected \r\n");
}
//if (average_presence_distance > DEFAULT_START_M)
{
@ -639,7 +639,7 @@ void STS_YunhornCheckStandardDeviation(void)
if ( sts_fall_rising_detected_result == STS_PRESENCE_RISING )
{
APP_LOG(TS_OFF, VLEVEL_L, "\r\n Suspecious Object RISING UP detected \r\n");
APP_LOG(TS_OFF, VLEVEL_L, "\r\n\n\n >>>>>>>>>>>>>>>>> Suspecious Object RISING UP detected \r\n");
}

View File

@ -56,6 +56,7 @@ extern volatile uint16_t sts_fall_rising_pattern_factor1;
extern volatile uint16_t sts_roc_acc_standard_variance;
extern uint8_t luminance_level;
SysTime_t mems_event_time;
#endif
/* USER CODE END Includes */
@ -136,24 +137,27 @@ void STS_YunhornSTSEventRFAC_Process(void)
void STS_FallDetection_LampBarProcess(void)
{
char buf[32]="";
uint8_t i=0;
char outbuf[128]="";
switch (sts_fall_rising_detected_result)
{
case STS_PRESENCE_LAYDOWN:
case STS_PRESENCE_FALL:
sts_lamp_bar_color = STS_RED_BLUE;
//sts_status_color = STS_RED_BLUE;
STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, luminance_level);
outbuf[i++] = (uint8_t)sts_lamp_bar_color;
outbuf[i++] = (uint8_t)sts_work_mode;
outbuf[i++] = (uint8_t)sts_fall_rising_detected_result;
outbuf[i++] = (uint8_t)(sts_fall_rising_pattern_factor1/10 + 0x30)&0xFF;
outbuf[i++] = (uint8_t)(sts_fall_rising_pattern_factor1%10 + 0x30)&0xFF;
outbuf[i++] = (uint8_t)(sts_roc_acc_standard_variance/10 + 0x30)&0xFF;
outbuf[i++] = (uint8_t)(sts_roc_acc_standard_variance%10 + 0x30)&0xFF;
break;
case STS_PRESENCE_FALL:
sts_lamp_bar_color = STS_BLUE; //STS_RED_BLUE;
sts_status_color = STS_BLUE; //STS_RED_BLUE;
sts_rss_result = STS_RESULT_MOTION;
STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, luminance_level);
buf[i++] = (uint8_t)sts_lamp_bar_color;
buf[i++] = (uint8_t)sts_work_mode;
buf[i++] = (uint8_t)sts_fall_rising_detected_result;
buf[i++] = (uint8_t)(sts_fall_rising_pattern_factor1/10 + 0x30)&0xFF;
buf[i++] = (uint8_t)(sts_fall_rising_pattern_factor1%10 + 0x30)&0xFF;
buf[i++] = (uint8_t)(sts_roc_acc_standard_variance/10 + 0x30)&0xFF;
buf[i++] = (uint8_t)(sts_roc_acc_standard_variance%10 + 0x30)&0xFF;
break;
case STS_PRESENCE_RISING:
@ -161,24 +165,22 @@ void STS_FallDetection_LampBarProcess(void)
sts_status_color = STS_RED; // normal occupancy status
sts_rss_result = STS_RESULT_MOTION;
STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, luminance_level);
outbuf[i++] = (uint8_t)sts_lamp_bar_color;
outbuf[i++] = (uint8_t)sts_work_mode;
outbuf[i++] = (uint8_t)sts_fall_rising_detected_result;
buf[i++] = (uint8_t)sts_lamp_bar_color;
buf[i++] = (uint8_t)sts_work_mode;
buf[i++] = (uint8_t)sts_fall_rising_detected_result;
// TESTING ONLY TO BE REMOVED
outbuf[i++] = (uint8_t)(sts_fall_rising_pattern_factor1/10 + 0x30)&0xFF;
outbuf[i++] = (uint8_t)(sts_fall_rising_pattern_factor1%10 + 0x30)&0xFF;
outbuf[i++] = (uint8_t)(sts_roc_acc_standard_variance/10 + 0x30)&0xFF;
outbuf[i++] = (uint8_t)(sts_roc_acc_standard_variance%10 + 0x30)&0xFF;
buf[i++] = (uint8_t)(sts_fall_rising_pattern_factor1/10 + 0x30)&0xFF;
buf[i++] = (uint8_t)(sts_fall_rising_pattern_factor1%10 + 0x30)&0xFF;
buf[i++] = (uint8_t)(sts_roc_acc_standard_variance/10 + 0x30)&0xFF;
buf[i++] = (uint8_t)(sts_roc_acc_standard_variance%10 + 0x30)&0xFF;
break;
default:
break;
}
STS_SENSOR_Upload_Message((LORAWAN_USER_APP_PORT+2), i, outbuf);
STS_SENSOR_Upload_Message((LORAWAN_USER_APP_PORT+2), i, buf);
sts_fall_rising_detected_result = STS_PRESENCE_NONE;

View File

@ -698,7 +698,10 @@ static void OnRxData(LmHandlerAppData_t *appData, LmHandlerRxParams_t *params)
/* USER CODE END OnRxData_1 */
}
static void PrepareSendTxData(void)
{
}
static void SendTxData(void)
{
/* USER CODE BEGIN SendTxData_1 */
@ -2044,7 +2047,7 @@ void STS_SENSOR_Upload_Message(uint8_t appDataPort, uint8_t appBufferSize, char
AppData.Port = appDataPort;
AppData.BufferSize = (sts_service_mask >1 ?0:appBufferSize);
//APP_LOG(TS_OFF, VLEVEL_L, "###########Service Mask = %d Buffer Size =%d \r\n", sts_service_mask, AppData.BufferSize);
APP_LOG(TS_OFF, VLEVEL_L, "###########Service Mask = %d Buffer Size =%d \r\n", sts_service_mask, AppData.BufferSize);
if ((JoinLedTimer.IsRunning) && (LmHandlerJoinStatus() == LORAMAC_HANDLER_SET))
{
@ -2055,14 +2058,14 @@ void STS_SENSOR_Upload_Message(uint8_t appDataPort, uint8_t appBufferSize, char
status = LmHandlerSend(&AppData, LmHandlerParams.IsTxConfirmed, false);
if (LORAMAC_HANDLER_SUCCESS == status)
{
APP_LOG(TS_ON, VLEVEL_L, "SEND REQUEST\r\n");
APP_LOG(TS_ON, VLEVEL_H, "SEND REQUEST\r\n");
}
else if (LORAMAC_HANDLER_DUTYCYCLE_RESTRICTED == status)
{
nextTxIn = LmHandlerGetDutyCycleWaitTime();
if (nextTxIn > 0)
{
APP_LOG(TS_ON, VLEVEL_L, "Next Tx in : ~%d second(s)\r\n", (nextTxIn / 1000));
APP_LOG(TS_ON, VLEVEL_H, "Next Tx in : ~%d second(s)\r\n", (nextTxIn / 1000));
}
}
@ -2354,8 +2357,8 @@ void STS_SENSOR_Function_Test_Process(void)
#endif
}
memset(outbuf,sizeof(outbuf),0x30);
memcpy(outbuf, tstbuf, i);
memset((void*)outbuf,sizeof(outbuf),0x30);
memcpy((void*)outbuf, tstbuf, i);
//STS_SENSOR_Upload_Message(LORAWAN_USER_APP_CTRL_REPLY_PORT, i, outbuf);
}

View File

@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-871373767175061261" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="856846852047785661" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
@ -16,7 +16,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-871373767175061261" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="856846852047785661" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>

View File

@ -15,7 +15,7 @@ sts_lamp_bar.c:342:6:STS_Lamp_Bar_Refresh 1
sts_lamp_bar.c:163:6:STS_RSS_Smart_Presence_Detection 1
sts_lamp_bar.c:180:6:STS_YunhornSTSEventP3_Process 2
sts_lamp_bar.c:386:6:STS_Reed_Hall_Working 1
sts_lamp_bar.c:390:6:STS_Combined_Status_Processing 54
sts_lamp_bar.c:390:6:STS_Combined_Status_Processing 53
sts_lamp_bar.c:84:6:STS_YunhornSTSEventP1_Process 5
sts_lamp_bar.c:103:6:STS_YunhornSTSEventP2_Process 6
sts_lamp_bar.c:549:6:HAL_TIM_PWM_PulseFinishedCallback 1

View File

@ -1,27 +1,27 @@
yunhorn_sts_presence_sensor.c:486:6:STS_SENSOR_Power_ON.part.0 1
yunhorn_sts_presence_sensor.c:100:6:STS_YunhornAuthenticationCode_Process 3
yunhorn_sts_presence_sensor.c:115:6:STS_YunhornSTSEventRFAC_Process 6
yunhorn_sts_presence_sensor.c:137:6:STS_FallDetection_LampBarProcess 3
yunhorn_sts_presence_sensor.c:187:6:STS_YunhornSTSFallDetection 1
yunhorn_sts_presence_sensor.c:195:6:STS_PRESENCE_SENSOR_NVM_CFG 1
yunhorn_sts_presence_sensor.c:225:6:STS_PRESENCE_SENSOR_NVM_CFG_SIMPLE 1
yunhorn_sts_presence_sensor.c:235:6:STS_PRESENCE_SENSOR_Init_Send_Data 1
yunhorn_sts_presence_sensor.c:257:6:STS_PRESENCE_SENSOR_Prepare_Send_Data 3
yunhorn_sts_presence_sensor.c:285:6:STS_PRESENCE_SENSOR_Read 1
yunhorn_sts_presence_sensor.c:305:6:STS_PRESENCE_SENSOR_GetValue 1
yunhorn_sts_presence_sensor.c:310:6:STS_PRESENCE_SENSOR_WakeUp_Process_Sampling 1
yunhorn_sts_presence_sensor.c:317:6:STS_PRESENCE_SENSOR_After_Wake_Up 1
yunhorn_sts_presence_sensor.c:348:6:STS_PRESENCE_SENSOR_TOF_Init 1
yunhorn_sts_presence_sensor.c:353:6:STS_PRESENCE_SENSOR_REEDSWITCH_HALL_Init 1
yunhorn_sts_presence_sensor.c:359:6:STS_PRESENCE_SENSOR_RSS_Init 1
yunhorn_sts_presence_sensor.c:329:6:STS_PRESENCE_SENSOR_Init 1
yunhorn_sts_presence_sensor.c:373:6:STS_MOTION_SENSOR_ACT_INACT_DURATION_Init 1
yunhorn_sts_presence_sensor.c:378:6:STS_PRESENCE_SENSOR_Get_Event_Status 1
yunhorn_sts_presence_sensor.c:407:6:STS_PRESENCE_SENSOR_Distance_Measure_Process 1
yunhorn_sts_presence_sensor.c:423:6:STS_PRESENCE_SENSOR_Function_Test_Process 2
yunhorn_sts_presence_sensor.c:448:6:STS_PRESENCE_SENSOR_Enable_Wake_Up_Detection 1
yunhorn_sts_presence_sensor.c:453:6:STS_PRESENCE_SENSOR_Disable_Wake_Up_Detection 1
yunhorn_sts_presence_sensor.c:458:9:STS_SENSOR_MEMS_Get_ID 2
yunhorn_sts_presence_sensor.c:486:6:STS_SENSOR_Power_ON 2
yunhorn_sts_presence_sensor.c:504:6:STS_SENSOR_Power_OFF 2
yunhorn_sts_presence_sensor.c:522:6:STS_SENSOR_MEMS_Reset 2
yunhorn_sts_presence_sensor.c:488:6:STS_SENSOR_Power_ON.part.0 1
yunhorn_sts_presence_sensor.c:101:6:STS_YunhornAuthenticationCode_Process 3
yunhorn_sts_presence_sensor.c:116:6:STS_YunhornSTSEventRFAC_Process 6
yunhorn_sts_presence_sensor.c:138:6:STS_FallDetection_LampBarProcess 3
yunhorn_sts_presence_sensor.c:189:6:STS_YunhornSTSFallDetection 1
yunhorn_sts_presence_sensor.c:197:6:STS_PRESENCE_SENSOR_NVM_CFG 1
yunhorn_sts_presence_sensor.c:227:6:STS_PRESENCE_SENSOR_NVM_CFG_SIMPLE 1
yunhorn_sts_presence_sensor.c:237:6:STS_PRESENCE_SENSOR_Init_Send_Data 1
yunhorn_sts_presence_sensor.c:259:6:STS_PRESENCE_SENSOR_Prepare_Send_Data 3
yunhorn_sts_presence_sensor.c:287:6:STS_PRESENCE_SENSOR_Read 1
yunhorn_sts_presence_sensor.c:307:6:STS_PRESENCE_SENSOR_GetValue 1
yunhorn_sts_presence_sensor.c:312:6:STS_PRESENCE_SENSOR_WakeUp_Process_Sampling 1
yunhorn_sts_presence_sensor.c:319:6:STS_PRESENCE_SENSOR_After_Wake_Up 1
yunhorn_sts_presence_sensor.c:350:6:STS_PRESENCE_SENSOR_TOF_Init 1
yunhorn_sts_presence_sensor.c:355:6:STS_PRESENCE_SENSOR_REEDSWITCH_HALL_Init 1
yunhorn_sts_presence_sensor.c:361:6:STS_PRESENCE_SENSOR_RSS_Init 1
yunhorn_sts_presence_sensor.c:331:6:STS_PRESENCE_SENSOR_Init 1
yunhorn_sts_presence_sensor.c:375:6:STS_MOTION_SENSOR_ACT_INACT_DURATION_Init 1
yunhorn_sts_presence_sensor.c:380:6:STS_PRESENCE_SENSOR_Get_Event_Status 1
yunhorn_sts_presence_sensor.c:409:6:STS_PRESENCE_SENSOR_Distance_Measure_Process 1
yunhorn_sts_presence_sensor.c:425:6:STS_PRESENCE_SENSOR_Function_Test_Process 2
yunhorn_sts_presence_sensor.c:450:6:STS_PRESENCE_SENSOR_Enable_Wake_Up_Detection 1
yunhorn_sts_presence_sensor.c:455:6:STS_PRESENCE_SENSOR_Disable_Wake_Up_Detection 1
yunhorn_sts_presence_sensor.c:460:9:STS_SENSOR_MEMS_Get_ID 2
yunhorn_sts_presence_sensor.c:488:6:STS_SENSOR_Power_ON 2
yunhorn_sts_presence_sensor.c:506:6:STS_SENSOR_Power_OFF 2
yunhorn_sts_presence_sensor.c:524:6:STS_SENSOR_MEMS_Reset 2