revised for 3 tof sensors
This commit is contained in:
parent
3863a435a9
commit
635918ca35
|
@ -800,7 +800,8 @@ static void SendTxData(void)
|
||||||
{
|
{
|
||||||
heart_beat_timer = 0;
|
heart_beat_timer = 0;
|
||||||
AppData.Port = LORAWAN_USER_HTBT_PORT; //LORAWAN_USER_APP_PORT+1;
|
AppData.Port = LORAWAN_USER_HTBT_PORT; //LORAWAN_USER_APP_PORT+1;
|
||||||
APP_LOG(TS_ON, VLEVEL_L, "\r\n------------ Heart-Beat ------------- \r\n ------------------Distance = %d mm, VBAT=%d%%\r\n", r0_data.distance_mm, r0_data.battery_Pct);
|
APP_LOG(TS_ON, VLEVEL_L, "\r\n------------ Heart-Beat ------------- \r\n ------------------\r\nDistance0 = %d mm, \r\nDistance1 = %d mm,\r\nDistance2 = %d mm, \r\nVBAT=%d\r\n",
|
||||||
|
r0_data.distance_mm,r0_data.distance1_mm,r0_data.distance2_mm, r0_data.battery_Pct);
|
||||||
|
|
||||||
} else if ((upload_message_timer)||(sensor_data_ready)) //sensor_data_ready for manual push button-1 trigger)
|
} else if ((upload_message_timer)||(sensor_data_ready)) //sensor_data_ready for manual push button-1 trigger)
|
||||||
{
|
{
|
||||||
|
@ -808,15 +809,15 @@ static void SendTxData(void)
|
||||||
sensor_data_ready =0;
|
sensor_data_ready =0;
|
||||||
upload_message_timer =0;
|
upload_message_timer =0;
|
||||||
|
|
||||||
AppData.Buffer[i++] = (uint8_t)(r0_data.distance_mm_h); //#05
|
AppData.Buffer[i++] = (uint8_t)(r0_data.distance_mm >>8)&0xff; //#05
|
||||||
AppData.Buffer[i++] = (uint8_t)(r0_data.distance_mm_l); //#06
|
AppData.Buffer[i++] = (uint8_t)(r0_data.distance_mm)&0xff; //#06
|
||||||
AppData.Buffer[i++] = (uint8_t)(r0_data.distance1_mm >>8)&0xff; //#07
|
AppData.Buffer[i++] = (uint8_t)(r0_data.distance1_mm >>8)&0xff; //#07
|
||||||
AppData.Buffer[i++] = (uint8_t)(r0_data.distance1_mm)&0xff; //#08
|
AppData.Buffer[i++] = (uint8_t)(r0_data.distance1_mm)&0xff; //#08
|
||||||
AppData.Buffer[i++] = (uint8_t)(r0_data.distance2_mm >>8)&0xff; //#09
|
AppData.Buffer[i++] = (uint8_t)(r0_data.distance2_mm >>8)&0xff; //#09
|
||||||
AppData.Buffer[i++] = (uint8_t)(r0_data.distance2_mm)&0xff; //#10
|
AppData.Buffer[i++] = (uint8_t)(r0_data.distance2_mm)&0xff; //#10
|
||||||
|
|
||||||
|
APP_LOG(TS_ON, VLEVEL_L, "\r\n------------ Heart-Beat ------------- \r\n ------------------\r\nDistance0 = %d mm, \r\nDistance1 = %d mm,\r\nDistance2 = %d mm, \r\nVBAT=%d\r\n",
|
||||||
APP_LOG(TS_ON, VLEVEL_L, "\r\n------------ Periodicity Upload Heart-Beat ------------- \r\n ------------------Distance = %d mm, VBAT=%d%%\r\n", r0_data.distance_mm, r0_data.battery_Pct);
|
r0_data.distance_mm,r0_data.distance1_mm,r0_data.distance2_mm, r0_data.battery_Pct);
|
||||||
}
|
}
|
||||||
|
|
||||||
AppData.BufferSize = (sts_service_mask >1?0:i);
|
AppData.BufferSize = (sts_service_mask >1?0:i);
|
||||||
|
|
|
@ -103,9 +103,9 @@ void MX_TOF_Process(void)
|
||||||
|
|
||||||
#ifdef STS_USE_TOF_VL53L0X
|
#ifdef STS_USE_TOF_VL53L0X
|
||||||
STS_SENSOR_Power_ON(1);
|
STS_SENSOR_Power_ON(1);
|
||||||
HAL_Delay(500);
|
HAL_Delay(100);
|
||||||
STS_TOF_VL53L0X_Range_Process();
|
STS_TOF_VL53L0X_Range_Process();
|
||||||
HAL_Delay(500);
|
HAL_Delay(100);
|
||||||
STS_SENSOR_Power_OFF(1);
|
STS_SENSOR_Power_OFF(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -120,13 +120,7 @@ void MX_TOF_Process(void)
|
||||||
}
|
}
|
||||||
void STS_R0_SENSOR_Read(STS_R0_SensorDataTypeDef *r0_data)
|
void STS_R0_SENSOR_Read(STS_R0_SensorDataTypeDef *r0_data)
|
||||||
{
|
{
|
||||||
if (sts_tof_distance_data[0] != 0)
|
r0_data->distance_mm = sts_tof_distance_data[0];
|
||||||
r0_data->distance_mm = sts_tof_distance_data[0];
|
|
||||||
else if (sts_tof_distance_data[1] != 0)
|
|
||||||
r0_data->distance_mm = sts_tof_distance_data[1];
|
|
||||||
else if (sts_tof_distance_data[2] != 0)
|
|
||||||
r0_data->distance_mm = sts_tof_distance_data[2];
|
|
||||||
|
|
||||||
r0_data->distance1_mm = sts_tof_distance_data[1];
|
r0_data->distance1_mm = sts_tof_distance_data[1];
|
||||||
r0_data->distance2_mm = sts_tof_distance_data[2];
|
r0_data->distance2_mm = sts_tof_distance_data[2];
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ int nDevMask=0;
|
||||||
|
|
||||||
int nSensorPresent;
|
int nSensorPresent;
|
||||||
|
|
||||||
volatile int sts_tof_distance_data[MAX_TOF_COUNT];
|
volatile int sts_tof_distance_data[MAX_TOF_COUNT]={0,0,0};
|
||||||
extern volatile uint8_t sensor_data_ready;
|
extern volatile uint8_t sensor_data_ready;
|
||||||
|
|
||||||
VL53L0X_Dev_t VL53L0XDevs[]={
|
VL53L0X_Dev_t VL53L0XDevs[]={
|
||||||
|
@ -109,8 +109,9 @@ void sts_tof_vl53l0x_SetupSingleShot(RangingConfig_e rangingConfig);
|
||||||
* @param err Error case code
|
* @param err Error case code
|
||||||
*/
|
*/
|
||||||
void HandleError(int err){
|
void HandleError(int err){
|
||||||
char msg[16];
|
//char msg[16];
|
||||||
sprintf(msg,"Er%d", err);
|
//sprintf(msg,"Er%d", err);
|
||||||
|
APP_LOG(TS_OFF, VLEVEL_L,"Er%d\r\n",err);
|
||||||
while(1){};
|
while(1){};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,9 +132,9 @@ int sts_tof_vl53l0x_DetectSensors(void)
|
||||||
nDevPresent = 0;
|
nDevPresent = 0;
|
||||||
|
|
||||||
HAL_GPIO_WritePin(TOF_C_XSHUT_GPIO_Port, TOF_C_XSHUT_Pin, GPIO_PIN_RESET);
|
HAL_GPIO_WritePin(TOF_C_XSHUT_GPIO_Port, TOF_C_XSHUT_Pin, GPIO_PIN_RESET);
|
||||||
HAL_Delay(30);
|
HAL_Delay(10);
|
||||||
HAL_GPIO_WritePin(TOF_C_XSHUT_GPIO_Port, TOF_C_XSHUT_Pin, GPIO_PIN_SET);
|
HAL_GPIO_WritePin(TOF_C_XSHUT_GPIO_Port, TOF_C_XSHUT_Pin, GPIO_PIN_SET);
|
||||||
//HAL_Delay(30);
|
HAL_Delay(10);
|
||||||
//HAL_GPIO_WritePin(TOF_C_XSHUT_GPIO_Port, TOF_C_XSHUT_Pin, GPIO_PIN_SET);
|
//HAL_GPIO_WritePin(TOF_C_XSHUT_GPIO_Port, TOF_C_XSHUT_Pin, GPIO_PIN_SET);
|
||||||
//HAL_Delay(100);
|
//HAL_Delay(100);
|
||||||
|
|
||||||
|
@ -351,11 +352,15 @@ void STS_TOF_VL53L0X_Range_Process(void)
|
||||||
if (VL53L0XDevs[i].Present ==1)
|
if (VL53L0XDevs[i].Present ==1)
|
||||||
{
|
{
|
||||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\nStart Ranging #%u sensor, position mask 0x%02x \r\n", i, nDevMask);
|
APP_LOG(TS_OFF, VLEVEL_L, "\r\nStart Ranging #%u sensor, position mask 0x%02x \r\n", i, nDevMask);
|
||||||
|
|
||||||
status = VL53L0X_PerformSingleRangingMeasurement(&VL53L0XDevs[i], &RangingMeasurementData);
|
status = VL53L0X_PerformSingleRangingMeasurement(&VL53L0XDevs[i], &RangingMeasurementData);
|
||||||
|
APP_LOG(TS_OFF, VLEVEL_L, "\r\nRanging status =0x%04x \r\n", status);
|
||||||
|
|
||||||
if( status ==0 )
|
if( status ==0 )
|
||||||
{
|
{
|
||||||
sts_tof_vl53l0x_Sensor_SetNewRange(&VL53L0XDevs[i],&RangingMeasurementData);
|
sts_tof_vl53l0x_Sensor_SetNewRange(&VL53L0XDevs[i],&RangingMeasurementData);
|
||||||
/* Display distance in mm */
|
/* Display distance in mm */
|
||||||
|
APP_LOG(TS_OFF, VLEVEL_L, "\r\nSet New Range status =%u \r\n", RangingMeasurementData.RangeStatus);
|
||||||
if( RangingMeasurementData.RangeStatus == 0 )
|
if( RangingMeasurementData.RangeStatus == 0 )
|
||||||
{
|
{
|
||||||
sts_tof_distance_data[i] = (int)VL53L0XDevs[i].LeakyRange;
|
sts_tof_distance_data[i] = (int)VL53L0XDevs[i].LeakyRange;
|
||||||
|
@ -377,7 +382,7 @@ void STS_TOF_VL53L0X_Range_Process(void)
|
||||||
|
|
||||||
} // for i < MAX_TOF_COUNT
|
} // for i < MAX_TOF_COUNT
|
||||||
|
|
||||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\n## Measured Range: \r\nTOF #0 = %4d mm, \r\nTOF #1 = %4d mm, \r\nTOF #2 = %4d mm\r\n",
|
APP_LOG(TS_OFF, VLEVEL_L, "\r\n## Measured Range: \r\nTOF #0 = %4u mm, \r\nTOF #1 = %4u mm, \r\nTOF #2 = %4u mm\r\n",
|
||||||
(int)sts_tof_distance_data[0],(int)sts_tof_distance_data[1],(int)sts_tof_distance_data[2]);
|
(int)sts_tof_distance_data[0],(int)sts_tof_distance_data[1],(int)sts_tof_distance_data[2]);
|
||||||
} // nSensorPresent >0
|
} // nSensorPresent >0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue