workable L8 with decoder updated and function test report revised

This commit is contained in:
Yunhorn 2024-11-19 21:00:19 +08:00
parent c04476ee08
commit 2199ea2151
5 changed files with 1112 additions and 526 deletions

View File

@ -252,6 +252,12 @@ typedef struct sts_fhmos_sensor_config
} sts_fhmos_sensor_config_t;
typedef struct sts_fhmos_sensor_ambient_height
{
uint32_t h2cm[64]; //height in 2cm scan data, ensure it less than 250*2=500cm, 5meter
} sts_fhmos_sensor_ambient_height_t;
/**
* @brief Store/Write/Flash Configuration in RW RAM
*/
@ -313,6 +319,7 @@ void STS_PRESENCE_SENSOR_Function_Test_Process(uint8_t *self_test_result, uint8_
void STS_PRESENCE_SENSOR_Distance_Measure_Process(void);
void STS_TOF_L8_Process(void);
void STS_LMZ_Ambient_Height_Scan_Process(void);
void STS_FHMOS_sensor_read(sts_fhmos_sensor_data_t *sts_fhmos_data);
void STS_FHMOS_sensor_config_init(void);
void STS_FHMOS_sensor_config_update(void);

View File

@ -640,7 +640,7 @@ void USER_APP_Parse_CMD_P(uint8_t *parse_buffer, uint8_t parse_buffer_size)
{
uint8_t sts_fhmos_cfg_index = (uint8_t)(parse_buffer[CFG_CMD5]-0x30);
uint8_t sts_fhmos_cfg_value = (parse_buffer[CFG_CMD6]-0x30)*100+(parse_buffer[CFG_CMD7]-0x30)*10+(parse_buffer[CFG_CMD8]-0x30);
APP_LOG(TS_OFF, VLEVEL_M, "\r\nCFG_CMD VALUE =0X%02X =%d \r\n", sts_fhmos_cfg_value,sts_fhmos_cfg_value);
//APP_LOG(TS_OFF, VLEVEL_M, "\r\nCFG_CMD VALUE =0X%02X =%d \r\n", sts_fhmos_cfg_value,sts_fhmos_cfg_value);
switch (sts_fhmos_cfg_index) {
case 1: // head level height threshold
sts_fhmos_cfg.sts_head_level_height_threshold_cm = sts_fhmos_cfg_value;
@ -1821,9 +1821,11 @@ void STS_SENSOR_Distance_Test_Process(void)
#if defined(VL53LX)||defined(L8)
//MX_TOF_Init();
//MX_TOF_Process();
MX_TOF_Process();
sts_sensor_install_height = (uint16_t)MX_TOF_Ranging_Process();
APP_LOG(TS_OFF, VLEVEL_M, "\n STS SENSOR INSTALLATION HEIGHT =%d mm\n\r", (uint16_t)sts_sensor_install_height);
STS_LMZ_Ambient_Height_Scan_Process();
#endif
#if defined(VL53L0)
STS_TOF_VL53L0X_Range_Process();
@ -1851,24 +1853,34 @@ void STS_SENSOR_Function_Test_Process(void)
tstbuf[i++] = (uint8_t) sts_hardware_ver;
tstbuf[i++] = (uint8_t) (99*GetBatteryLevel()/254)&0xff;
#if (defined(STS_P2)||defined(STS_T6))
#if (defined(STS_P2)||defined(STS_T6))||defined(L8)
STS_SENSOR_MEMS_Get_ID(&sensor_id);
printf("\r\n Sensor id =%04x \r\n", sensor_id);
#if defined(L8)
if (((sensor_id & 0xff)!= 0x0C) && (((sensor_id >>8) & 0xFF)!=0xF0)) // no VL53L8X found
{
tstbuf[i++] = (uint8_t) 'X'; // Slave MEMS Not Avaliable
}
#else
if (((sensor_id & 0xff)!= 0xCC) && (((sensor_id >>8) & 0xFF)!=0xEA)) // no VL53L1X found
{
tstbuf[i++] = (uint8_t) 'X'; // Slave MEMS Not Avaliable
} else
}
#endif
else
{
STS_SENSOR_Distance_Test_Process();
APP_LOG(TS_OFF, VLEVEL_M, "\nSensor Install Height =%4d mm\n", sts_sensor_install_height);
tstbuf[i++] = (uint8_t) (2)&0xff; //length of following data
tstbuf[i++] = (uint8_t) (4)&0xff; //length of following data
tstbuf[i++] = (uint8_t) (sensor_id >>8)&0xFF;
tstbuf[i++] = (uint8_t) (sensor_id) & 0xFF;
tstbuf[i++] = (uint8_t) (sts_sensor_install_height>>8)&0xff; // MSB of sensor height
tstbuf[i++] = (uint8_t) (sts_sensor_install_height)&0xff; // LSB of sensor height
}
/* */
/* for STS_P2, set ppc_config -> door_jam_profile and distance threshold accordingly */
/* */
#ifdef STS_P2
if ((sts_sensor_install_height >= 1500)&&(sts_sensor_install_height<=4000))
{
sts_door_jam_profile = DOOR_JAM_2000; // DOOR_JAM_2000: assume door_jame less 2000mm
@ -1883,6 +1895,7 @@ void STS_SENSOR_Function_Test_Process(void)
sts_door_jam_profile ++; //DOOR_JAM_4000
}
#endif
#endif
#ifdef YUNHORN_STS_O6_ENABLED
tstbuf[i++] = (uint8_t)20; //length of following data
uint8_t self_test_result[10]={0,0,0,0,0, 0,0,0,0,0};

View File

@ -38,6 +38,8 @@ extern "C" {
volatile uint8_t fhmos_fall=0, fhmos_human_movement=0, fhmos_occupancy=0, fhmos_sos_alarm=0;
volatile uint32_t fhmos_fall_counter=0;
volatile sts_fhmos_sensor_config_t sts_fhmos_cfg;
volatile sts_fhmos_sensor_ambient_height_t sts_fhmos_bg={0x0};
extern volatile uint16_t sts_sensor_install_height; //in mm
#endif
#include "stm32wlxx_nucleo.h"
@ -156,6 +158,53 @@ void MX_TOF_Init(void)
/*
* LM background task
*/
void STS_LMZ_Ambient_Height_Scan_Process(void)
{
uint8_t i=0;
uint32_t range_distance =0;
printf("ambient height init...\r\n");
for (i=0; i<64; i++) sts_fhmos_bg.h2cm[i] = 0;
printf("sts sensor install height = %4d \r\n", (int)sts_sensor_install_height);
for (uint8_t k=0; k<10; k++)
{
int status = VL53L8A1_RANGING_SENSOR_GetDistance(VL53L8A1_DEV_CENTER, &Result);
for (uint8_t i = 0; i < 64; i++)
{
/* Print distance and status */
if (Result.ZoneResult[i].NumberOfTargets > 0)
{
range_distance = (uint32_t)Result.ZoneResult[i].Distance[0];
if (sts_sensor_install_height > range_distance)
sts_fhmos_bg.h2cm[i] = sts_fhmos_bg.h2cm[i] + ((uint32_t)sts_sensor_install_height - range_distance);
printf("|%4d %4d ", range_distance, sts_fhmos_bg.h2cm[i]);
if (i%8==0) printf("\r\n");
//sts_fhmos_bg.h2cm[i] += ((uint32_t)sts_sensor_install_height - range_distance;
//sts_fhmos_bg.h2cm[i] += ((uint32_t)sts_sensor_install_height - (uint32_t)Result.ZoneResult[i].Distance[0]);
}
else {
sts_fhmos_bg.h2cm[i] += 0;
printf(" .%2d. ", i);
}
}
}
for (i=0; i<64; i++)
{
sts_fhmos_bg.h2cm[i] /= 10;
printf("|%4d ", (uint32_t)sts_fhmos_bg.h2cm[i]);
if (i%8==0) printf("\r\n");
}
}
uint16_t MX_TOF_Ranging_Process(void)
{
@ -167,32 +216,38 @@ uint16_t MX_TOF_Ranging_Process(void)
return (uint16_t) range_distance;
#elif defined(L8)
uint16_t range_distance=0;
uint32_t range_distance=0;
uint8_t center_roi[4] = {27,28,35,36};
uint8_t range_mode = 2; //STS_TOF_LONG_RANGE;
int status = VL53L8A1_RANGING_SENSOR_GetDistance(VL53L8A1_DEV_CENTER, &Result);
//int status = VL53L8A1_RANGING_SENSOR_GetDistance(VL53L8A1_DEV_CENTER, &Result);
printf("\r| 27 | 28 | 35 | 36 |\r\n");
for (uint8_t k=0; k<10; k++)
{
int status = VL53L8A1_RANGING_SENSOR_GetDistance(VL53L8A1_DEV_CENTER, &Result);
for (uint8_t zone_nbr = 0; zone_nbr < 4; zone_nbr++)
{
/* Print distance and status */
if (Result.ZoneResult[center_roi[zone_nbr]].NumberOfTargets > 0)
{
printf("| %04ld %2ld",
(long)Result.ZoneResult[center_roi[zone_nbr]].Distance[RANGING_SENSOR_NB_TARGET_PER_ZONE-1],
(long)Result.ZoneResult[center_roi[zone_nbr]].Status[RANGING_SENSOR_NB_TARGET_PER_ZONE-1]);
}
else {
printf("| -- ");
}
for (uint8_t zone_nbr = 0; zone_nbr < 4; zone_nbr++)
{
/* Print distance and status */
if (Result.ZoneResult[center_roi[zone_nbr]].NumberOfTargets > 0)
{
printf("| %04ld %2ld",
(long)Result.ZoneResult[center_roi[zone_nbr]].Distance[RANGING_SENSOR_NB_TARGET_PER_ZONE-1],
(long)Result.ZoneResult[center_roi[zone_nbr]].Status[RANGING_SENSOR_NB_TARGET_PER_ZONE-1]);
}
else {
printf("| -- ");
}
range_distance += Result.ZoneResult[center_roi[zone_nbr]].Distance[RANGING_SENSOR_NB_TARGET_PER_ZONE-1];
range_distance += Result.ZoneResult[center_roi[zone_nbr]].Distance[RANGING_SENSOR_NB_TARGET_PER_ZONE-1];
//printf("| %6d -- ", range_distance);
}
//printf("\n\r");
}
printf("\n\r");
}
printf("\n\r");
range_distance /=4;
range_distance /=40;
printf("| %u mm\r\n", (uint16_t)range_distance);
return (uint16_t) range_distance;
@ -242,7 +297,7 @@ void STS_TOF_L8_Process(void)
if (status == BSP_ERROR_NONE)
{
print_result(&Result);
//print_result(&Result);
}
}
}

File diff suppressed because it is too large Load Diff