L8 #77
|
@ -352,9 +352,9 @@ void Error_Handler(void);
|
||||||
/*
|
/*
|
||||||
* STM32WL55, STM32WLE5 Clock=48Mhz 48,000,000/800khz = 60
|
* STM32WL55, STM32WLE5 Clock=48Mhz 48,000,000/800khz = 60
|
||||||
*/
|
*/
|
||||||
#define STS_LAMP_BAR_PWM_TIM_PERIOD (240 - 1)
|
#define STS_LAMP_BAR_PWM_TIM_PERIOD (60 - 1)
|
||||||
#define STS_LAMP_BAR_HTIM htim1
|
#define STS_LAMP_BAR_HTIM htim1
|
||||||
//#define STS_LAMP_BAR_LED_NUM (14) //60 for 46CM length LED strip
|
#define STS_LAMP_BAR_LED_NUM (18) //60 for 46CM length LED strip
|
||||||
|
|
||||||
#define WSDATA_PORT_PIN_PA8
|
#define WSDATA_PORT_PIN_PA8
|
||||||
//#define WSDATA_PORT_PIN_PA9
|
//#define WSDATA_PORT_PIN_PA9
|
||||||
|
|
|
@ -30,23 +30,23 @@
|
||||||
|
|
||||||
#define ONE_PULSE (24) //36
|
#define ONE_PULSE (24) //36
|
||||||
#define ZERO_PULSE (12)
|
#define ZERO_PULSE (12)
|
||||||
#define STS_LAMP_BAR_LED_NUM (27) //60 for 46CM length LED strip
|
//#define STS_LAMP_BAR_LED_NUM (27) //60 for 46CM length LED strip
|
||||||
#define LED_DATA_LEN 24
|
#define LED_DATA_LEN 24
|
||||||
#define WS2812B_DATA_LEN (LED_DATA_LEN * (STS_LAMP_BAR_LED_NUM))
|
#define WS2812B_DATA_LEN (LED_DATA_LEN * (STS_LAMP_BAR_LED_NUM))
|
||||||
#define RESET_PULSE (16) //(80) TO FIX DARK_COLOR AND SM2
|
#define RESET_PULSE (16) //(80) TO FIX DARK_COLOR AND SM2
|
||||||
|
|
||||||
|
|
||||||
typedef struct ws2812b_e {
|
typedef struct ws2812b_e {
|
||||||
//uint16_t head[3];
|
uint8_t head[3];
|
||||||
uint16_t GRB[WS2812B_DATA_LEN+RESET_PULSE];
|
uint8_t GRB[WS2812B_DATA_LEN+RESET_PULSE];
|
||||||
uint16_t tail[RESET_PULSE];
|
uint8_t tail[RESET_PULSE];
|
||||||
} WS2812B_FrameTypeDef;
|
} WS2812B_FrameTypeDef;
|
||||||
|
|
||||||
volatile WS2812B_FrameTypeDef rgb_buf = {
|
volatile WS2812B_FrameTypeDef rgb_buf = {
|
||||||
// .head[0] = 10,
|
.head[0] = 0,
|
||||||
// .head[1] = 10,
|
.head[1] = 0,
|
||||||
// .head[2] = 10,
|
.head[2] = 0,
|
||||||
//.tail = 00
|
.tail = {00}
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t color_rgb[8][3] = { //STS_COLOR R G B MAPPING TABLE
|
uint8_t color_rgb[8][3] = { //STS_COLOR R G B MAPPING TABLE
|
||||||
|
@ -101,7 +101,7 @@ void STS_WS2812B_Refresh(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
HAL_TIM_PWM_Start_DMA(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL, (uint32_t *)&rgb_buf, (WS2812B_DATA_LEN+RESET_PULSE));
|
HAL_TIM_PWM_Start_DMA(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL, (uint32_t *)&rgb_buf, (WS2812B_DATA_LEN+RESET_PULSE));
|
||||||
HAL_TIM_PWM_Start_IT(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL);
|
//HAL_TIM_PWM_Start_IT(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void STS_Lamp_Bar_Init(void)
|
void STS_Lamp_Bar_Init(void)
|
||||||
|
@ -127,7 +127,7 @@ void STS_Lamp_Bar_Scoller(uint8_t color, uint8_t lum_level)
|
||||||
|
|
||||||
for(uint8_t i = 0; i<STS_LAMP_BAR_LED_NUM; i++)
|
for(uint8_t i = 0; i<STS_LAMP_BAR_LED_NUM; i++)
|
||||||
{
|
{
|
||||||
HAL_Delay(30); //MAKE THIS LESS THAN 10 NOT TO BLOCK JOIN THE LORAWAN
|
HAL_Delay(10); //MAKE THIS LESS THAN 10 NOT TO BLOCK JOIN THE LORAWAN
|
||||||
STS_WS2812B_Set_RGB(color_rgb[color][0]*lum_level,color_rgb[color][1]*lum_level, color_rgb[color][2]*lum_level, i);
|
STS_WS2812B_Set_RGB(color_rgb[color][0]*lum_level,color_rgb[color][1]*lum_level, color_rgb[color][2]*lum_level, i);
|
||||||
STS_WS2812B_Refresh();
|
STS_WS2812B_Refresh();
|
||||||
}
|
}
|
||||||
|
@ -162,8 +162,8 @@ void STS_Lamp_Bar_Set_RGB_Color(uint8_t red, uint8_t green, uint8_t blue )
|
||||||
bits++;
|
bits++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i=0; i < RESET_PULSE; i++)
|
//for (i=0; i < RESET_PULSE; i++)
|
||||||
rgb_buf.tail[i] = 0;
|
//rgb_buf.tail[i] = 0;
|
||||||
STS_WS2812B_Refresh();
|
STS_WS2812B_Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,9 +131,9 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||||
hdma_tim1_ch1.Init.PeriphInc = DMA_PINC_DISABLE;
|
hdma_tim1_ch1.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||||
hdma_tim1_ch1.Init.MemInc = DMA_MINC_ENABLE;
|
hdma_tim1_ch1.Init.MemInc = DMA_MINC_ENABLE;
|
||||||
hdma_tim1_ch1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
|
hdma_tim1_ch1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
|
||||||
hdma_tim1_ch1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; //DMA_MDATAALIGN_BYTE; //DMA_MDATAALIGN_HALFWORD; //DMA_MDATAALIGN_HALFWORD;
|
hdma_tim1_ch1.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; //DMA_MDATAALIGN_BYTE; //DMA_MDATAALIGN_HALFWORD; //DMA_MDATAALIGN_HALFWORD;
|
||||||
hdma_tim1_ch1.Init.Mode = DMA_CIRCULAR;
|
hdma_tim1_ch1.Init.Mode = DMA_CIRCULAR;
|
||||||
hdma_tim1_ch1.Init.Priority = DMA_PRIORITY_LOW; //was HIGH
|
hdma_tim1_ch1.Init.Priority = DMA_PRIORITY_HIGH; //was HIGH
|
||||||
|
|
||||||
if (HAL_DMA_Init(&hdma_tim1_ch1) != HAL_OK)
|
if (HAL_DMA_Init(&hdma_tim1_ch1) != HAL_OK)
|
||||||
{
|
{
|
||||||
|
|
|
@ -503,7 +503,7 @@ void LoRaWAN_Init(void)
|
||||||
UTIL_TIMER_Create(&RxLedTimer, LED_PERIOD_TIME, UTIL_TIMER_ONESHOT, OnRxTimerLedEvent, NULL);
|
UTIL_TIMER_Create(&RxLedTimer, LED_PERIOD_TIME, UTIL_TIMER_ONESHOT, OnRxTimerLedEvent, NULL);
|
||||||
UTIL_TIMER_Create(&JoinLedTimer, LED_PERIOD_TIME, UTIL_TIMER_PERIODIC, OnJoinTimerLedEvent, NULL);
|
UTIL_TIMER_Create(&JoinLedTimer, LED_PERIOD_TIME, UTIL_TIMER_PERIODIC, OnJoinTimerLedEvent, NULL);
|
||||||
UTIL_TIMER_Create(&STSLampBarColorTimer, LED_PERIOD_TIME, UTIL_TIMER_ONESHOT, OnYunhornSTSLampBarColorTimerEvent, NULL);
|
UTIL_TIMER_Create(&STSLampBarColorTimer, LED_PERIOD_TIME, UTIL_TIMER_ONESHOT, OnYunhornSTSLampBarColorTimerEvent, NULL);
|
||||||
UTIL_TIMER_Create(&STSDurationCheckTimer, 5000, UTIL_TIMER_PERIODIC, OnYunhornSTSDurationCheckTimerEvent, NULL);
|
UTIL_TIMER_Create(&STSDurationCheckTimer, 10000, UTIL_TIMER_PERIODIC, OnYunhornSTSDurationCheckTimerEvent, NULL);
|
||||||
|
|
||||||
if (FLASH_IF_Init(NULL) != FLASH_IF_OK)
|
if (FLASH_IF_Init(NULL) != FLASH_IF_OK)
|
||||||
{
|
{
|
||||||
|
@ -646,9 +646,9 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
||||||
fhmos_occupancy = 1;
|
fhmos_occupancy = 1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
|
||||||
last_sts_hall1_read = sts_hall1_read;
|
last_sts_hall1_read = sts_hall1_read;
|
||||||
|
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||||
|
|
||||||
} //else {
|
} //else {
|
||||||
//APP_LOG(TS_OFF, VLEVEL_M, "\r\n --- ---- ----- -------- hall 1, door close again \r\n");
|
//APP_LOG(TS_OFF, VLEVEL_M, "\r\n --- ---- ----- -------- hall 1, door close again \r\n");
|
||||||
//}
|
//}
|
||||||
|
@ -1405,6 +1405,7 @@ static void OnJoinRequest(LmHandlerJoinParams_t *joinParams)
|
||||||
LmHandlerParams.IsTxConfirmed = true;
|
LmHandlerParams.IsTxConfirmed = true;
|
||||||
LmHandlerErrorStatus_t status = LmHandlerSend(&AppData, LmHandlerParams.IsTxConfirmed, false);
|
LmHandlerErrorStatus_t status = LmHandlerSend(&AppData, LmHandlerParams.IsTxConfirmed, false);
|
||||||
if (status ==LORAMAC_HANDLER_SUCCESS ) LmHandlerParams.IsTxConfirmed = false;
|
if (status ==LORAMAC_HANDLER_SUCCESS ) LmHandlerParams.IsTxConfirmed = false;
|
||||||
|
STS_SENSOR_Distance_Test_Process();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -182,8 +182,9 @@ void STS_LMZ_Ambient_Height_Scan_Process(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
uint8_t i=0;
|
uint8_t i=0, j=0;
|
||||||
uint32_t range_distance =0;
|
uint32_t range_distance =0;
|
||||||
|
uint32_t bg_distance[64]={0x0};
|
||||||
|
|
||||||
for (i=0; i<64; i++)
|
for (i=0; i<64; i++)
|
||||||
{
|
{
|
||||||
|
@ -198,8 +199,11 @@ void STS_LMZ_Ambient_Height_Scan_Process(void)
|
||||||
// printf("sts sensor install height = %4d \r\n", (int)sts_sensor_install_height);
|
// printf("sts sensor install height = %4d \r\n", (int)sts_sensor_install_height);
|
||||||
|
|
||||||
|
|
||||||
sts_high_threshold = sts_sensor_install_height;
|
//sts_high_threshold = sts_sensor_install_height;
|
||||||
sts_low_threshold = sts_sensor_install_height-1400;
|
//sts_low_threshold = sts_sensor_install_height-1400;
|
||||||
|
sts_high_threshold = 5000;
|
||||||
|
sts_low_threshold = 1000;
|
||||||
|
|
||||||
//APP_LOG(TS_OFF, VLEVEL_M, "\r\nReconfig ----> Threshold High=%d mm, Low=%d mm \r\n", sts_high_threshold, sts_low_threshold);
|
//APP_LOG(TS_OFF, VLEVEL_M, "\r\nReconfig ----> Threshold High=%d mm, Low=%d mm \r\n", sts_high_threshold, sts_low_threshold);
|
||||||
|
|
||||||
STS_TOF_L8_Reconfig();
|
STS_TOF_L8_Reconfig();
|
||||||
|
@ -211,7 +215,10 @@ void STS_LMZ_Ambient_Height_Scan_Process(void)
|
||||||
printf("VL53L8A1_RANGING_SENSOR_Start failed\n");
|
printf("VL53L8A1_RANGING_SENSOR_Start failed\n");
|
||||||
while (1);
|
while (1);
|
||||||
}
|
}
|
||||||
|
uint8_t idx[64]={0};
|
||||||
|
|
||||||
|
for (j=0; j<10; j++)
|
||||||
|
{
|
||||||
if (ToF_EventDetected != 0)
|
if (ToF_EventDetected != 0)
|
||||||
{
|
{
|
||||||
ToF_EventDetected = 0;
|
ToF_EventDetected = 0;
|
||||||
|
@ -219,8 +226,28 @@ void STS_LMZ_Ambient_Height_Scan_Process(void)
|
||||||
if (status != BSP_ERROR_NONE)
|
if (status != BSP_ERROR_NONE)
|
||||||
{
|
{
|
||||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n x \r\n");
|
APP_LOG(TS_OFF, VLEVEL_M, "\r\n x \r\n");
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
for (i=0; i<64; i++)
|
||||||
|
{
|
||||||
|
if (i%8==0) APP_LOG(TS_OFF, VLEVEL_L, "\r\n[cm]|");
|
||||||
|
|
||||||
|
if ((Result.ZoneResult[i].NumberOfTargets > 0))
|
||||||
|
{
|
||||||
|
|
||||||
|
bg_distance[i] += (uint32_t)Result.ZoneResult[i].Distance[0];
|
||||||
|
idx[i] ++;
|
||||||
|
APP_LOG(TS_OFF, VLEVEL_L, "|%3d ", Result.ZoneResult[i].Distance[0]/10);
|
||||||
|
} else APP_LOG(TS_OFF, VLEVEL_L, "|%3d ", 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
HAL_Delay(400);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i=0;i<64;i++)
|
||||||
|
bg_distance[i] /= idx[i];
|
||||||
|
|
||||||
//STS_TOF_L8_Process();
|
//STS_TOF_L8_Process();
|
||||||
|
|
||||||
|
|
||||||
|
@ -231,9 +258,10 @@ void STS_LMZ_Ambient_Height_Scan_Process(void)
|
||||||
{
|
{
|
||||||
/* Print distance and status */
|
/* Print distance and status */
|
||||||
if (i%8==0) APP_LOG(TS_OFF, VLEVEL_L, "\r\n[cm]|");
|
if (i%8==0) APP_LOG(TS_OFF, VLEVEL_L, "\r\n[cm]|");
|
||||||
if ((Result.ZoneResult[i].NumberOfTargets > 0))
|
// if ((Result.ZoneResult[i].NumberOfTargets > 0))
|
||||||
{
|
{
|
||||||
range_distance = (uint32_t)Result.ZoneResult[i].Distance[0];
|
// range_distance = (uint32_t)Result.ZoneResult[i].Distance[0];
|
||||||
|
range_distance = (uint32_t)bg_distance[i];
|
||||||
|
|
||||||
fhmos_bg.h2cm[i] = abs(sts_sensor_install_height - range_distance)/20; // in 2 cm
|
fhmos_bg.h2cm[i] = abs(sts_sensor_install_height - range_distance)/20; // in 2 cm
|
||||||
|
|
||||||
|
@ -251,10 +279,11 @@ void STS_LMZ_Ambient_Height_Scan_Process(void)
|
||||||
APP_LOG(TS_OFF, VLEVEL_L, "|%3d ", fhmos_bg.h2cm[i]*2);
|
APP_LOG(TS_OFF, VLEVEL_L, "|%3d ", fhmos_bg.h2cm[i]*2);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
fhmos_bg.h2cm[i] = 0;
|
//else {
|
||||||
APP_LOG(TS_OFF, VLEVEL_L, "|%3d ", fhmos_bg.h2cm[i]);
|
// fhmos_bg.h2cm[i] = 0;
|
||||||
}
|
//APP_LOG(TS_OFF, VLEVEL_L, "|%3d ", fhmos_bg.h2cm[i]);
|
||||||
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
APP_LOG(TS_OFF, VLEVEL_L, "\r\n Thresholds: Headlevel=%4d cm, Gesture Mask off=%d cm, Min body height=%d cm\r\n",
|
APP_LOG(TS_OFF, VLEVEL_L, "\r\n Thresholds: Headlevel=%4d cm, Gesture Mask off=%d cm, Min body height=%d cm\r\n",
|
||||||
|
@ -652,6 +681,7 @@ static void print_result(RANGING_SENSOR_Result_t *Result)
|
||||||
if ((head_distance_from_ceiling <= factor1_floor_level_from_ceiling) && ((head_height_level_from_floor) <= (10*fhmos_cfg.th_head_level_height_cm)) && (head_height_level_from_floor >= (10*fhmos_cfg.th_fall_body_min_height_cm )))
|
if ((head_distance_from_ceiling <= factor1_floor_level_from_ceiling) && ((head_height_level_from_floor) <= (10*fhmos_cfg.th_head_level_height_cm)) && (head_height_level_from_floor >= (10*fhmos_cfg.th_fall_body_min_height_cm )))
|
||||||
{
|
{
|
||||||
to_confirm ++;
|
to_confirm ++;
|
||||||
|
APP_LOG(TS_OFF, VLEVEL_L, "\r\n To_Confirm=%d \r\n", to_confirm);
|
||||||
if (to_confirm >=3 )
|
if (to_confirm >=3 )
|
||||||
{
|
{
|
||||||
sts_head_level_low = 1;
|
sts_head_level_low = 1;
|
||||||
|
|
Loading…
Reference in New Issue