This commit is contained in:
Yunhorn 2025-04-28 15:41:33 +08:00
parent 9fab4c0277
commit b9246801b2
4 changed files with 108 additions and 12 deletions

View File

@ -40,7 +40,7 @@ extern SPI_HandleTypeDef A111_SPI_HANDLE;
* @brief Size of SPI transfer buffer * @brief Size of SPI transfer buffer
*/ */
#ifndef A111_SPI_MAX_TRANSFER_SIZE #ifndef A111_SPI_MAX_TRANSFER_SIZE
#define A111_SPI_MAX_TRANSFER_SIZE 65535 //4096 //65535 #define A111_SPI_MAX_TRANSFER_SIZE 4096 //4096 //65535
#endif #endif
/** /**

View File

@ -410,6 +410,97 @@ static void print_current_configuration(acc_detector_presence_configuration_t pr
(int)(1000*sts_run_f_intra_frame_time_const),(int)(1000*sts_run_f_intra_frame_weight),(int)(1000*sts_run_f_output_time_const)); (int)(1000*sts_run_f_intra_frame_time_const),(int)(1000*sts_run_f_intra_frame_weight),(int)(1000*sts_run_f_output_time_const));
} }
uint8_t yes_count=0;
uint8_t no_count=0;
#define TIME_C 4
static void sts_print_result(acc_detector_presence_result_t result)
{
uint16_t signal=0;
uint16_t dist=0;
uint8_t i=0;
uint16_t threshold = sts_presence_rss_config.default_threshold*1000.0f;
signal=(int)(result.presence_score * 1000.0f);
dist =(int)(result.presence_distance * 1000.0f);
uint8_t flag=0;
if (signal>threshold)
{
if(dist<500)
{
if(signal>(threshold+1000))
{
LED1_ON;
if(yes_count<TIME_C)
{
yes_count++;
}
else
{
no_count=0;
}
}
else
{
LED1_OFF;
if(no_count<TIME_C)
{
no_count++;
}
else
{
yes_count=0;
}
}
}
else
{
LED1_ON;
if(yes_count<TIME_C)
{
yes_count++;
}
else
{
no_count=0;
}
}
}
else
{
LED1_OFF;
if(no_count<TIME_C)
{
no_count++;
}
else
{
yes_count=0;
}
//printf("No motion");
}
// else
// {
// printf("Wait.....");
// }
if(yes_count>(TIME_C-1))
{
//Out1_ON
//Out2_OFF
APP_LOG(TS_OFF, VLEVEL_M,"Motion (%5d), Distance: %4dmm\r\n", signal,dist);
}
else if(no_count>(TIME_C-1))
{
//Out1_OFF
//Out2_ON
APP_LOG(TS_OFF, VLEVEL_M,"NO motion(%5d), Distance: %4dmm\r\n", signal,dist);
}
}
static void print_result(acc_detector_presence_result_t result) static void print_result(acc_detector_presence_result_t result)
{ {
if (result.presence_detected) if (result.presence_detected)
@ -665,6 +756,7 @@ int sts_presence_rss_fall_rise_detection(void)
} }
//print_result(result); //print_result(result);
sts_print_result(result);
if (!result.data_saturated) if (!result.data_saturated)
{ {
//APP_LOG(TS_OFF, VLEVEL_H,"\n%u ", i); //APP_LOG(TS_OFF, VLEVEL_H,"\n%u ", i);
@ -700,7 +792,7 @@ int sts_presence_rss_fall_rise_detection(void)
//acc_integration_sleep_ms(1000 / DEFAULT_UPDATE_RATE_PRESENCE); // 15ms, DEFAULT_UPDATE_RATE); //acc_integration_sleep_ms(1000 / DEFAULT_UPDATE_RATE_PRESENCE); // 15ms, DEFAULT_UPDATE_RATE);
//acc_integration_sleep_ms(10); // --- around 1500 ms in total //acc_integration_sleep_ms(10); // --- around 1500 ms in total
//acc_integration_sleep_ms(2); //--- around 1000ms in total //acc_integration_sleep_ms(2); //--- around 1000ms in total
acc_integration_sleep_ms(1000 / 10); acc_integration_sleep_ms(1000 / 20);
} }
deactivated = acc_detector_presence_deactivate(handle); deactivated = acc_detector_presence_deactivate(handle);

View File

@ -1194,7 +1194,7 @@ static void OnTxTimerEvent(void *context)
{ {
/* USER CODE BEGIN OnTxTimerEvent_1 */ /* USER CODE BEGIN OnTxTimerEvent_1 */
if (sts_warm_up_count < 5) if (sts_warm_up_count <= 5)
{ {
/* USER CODE END OnTxTimerEvent_1 */ /* USER CODE END OnTxTimerEvent_1 */
//if ((sensor_data_ready ==1)) //|| (sts_reed_hall_changed_flag)) //||(sts_rss_result_changed_flag)||(sts_fall_rising_detected_result_changed_flag)) //if ((sensor_data_ready ==1)) //|| (sts_reed_hall_changed_flag)) //||(sts_rss_result_changed_flag)||(sts_fall_rising_detected_result_changed_flag))
@ -1204,8 +1204,10 @@ static void OnTxTimerEvent(void *context)
} }
/*Wait for next tx slot*/ /*Wait for next tx slot*/
sts_warm_up_count++; sts_warm_up_count++;
}
UTIL_TIMER_Start(&TxTimer); UTIL_TIMER_Start(&TxTimer);
}
//} //}
/* USER CODE BEGIN OnTxTimerEvent_2 */ /* USER CODE BEGIN OnTxTimerEvent_2 */
@ -1783,6 +1785,8 @@ static void OnRestoreContextRequest(void *nvm, uint32_t nvm_size)
*/ */
static void OnYunhornSTSOORSSWakeUpTimerEvent(void *context) static void OnYunhornSTSOORSSWakeUpTimerEvent(void *context)
{ {
//UTIL_TIMER_Stop(&YunhornSTSRSSWakeUpTimer);
if ((sts_work_mode == STS_RSS_MODE)||(sts_work_mode == STS_DUAL_MODE)||(sts_work_mode == STS_UNI_MODE)) if ((sts_work_mode == STS_RSS_MODE)||(sts_work_mode == STS_DUAL_MODE)||(sts_work_mode == STS_UNI_MODE))
{ {
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP2), CFG_SEQ_Prio_0); UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP2), CFG_SEQ_Prio_0);

Binary file not shown.