--- revised for lamp bar...no good so far
This commit is contained in:
parent
83b4a0aeda
commit
aa4214983d
|
@ -52,15 +52,15 @@ void MX_GPIO_Init(void)
|
||||||
/*Configure GPIO pin Output Level */
|
/*Configure GPIO pin Output Level */
|
||||||
//HAL_GPIO_WritePin(GPIOB, LED1_Pin|LED2_Pin|PROB2_Pin|PROB1_Pin|LED3_Pin, GPIO_PIN_RESET);
|
//HAL_GPIO_WritePin(GPIOB, LED1_Pin|LED2_Pin|PROB2_Pin|PROB1_Pin|LED3_Pin, GPIO_PIN_RESET);
|
||||||
|
|
||||||
HAL_GPIO_WritePin(GPIOB, LED1_Pin, GPIO_PIN_RESET);
|
HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_RESET);
|
||||||
HAL_GPIO_WritePin(GPIOA, A111_CS_N_Pin, GPIO_PIN_RESET);
|
HAL_GPIO_WritePin(A111_CS_N_GPIO_Port, A111_CS_N_Pin, GPIO_PIN_RESET);
|
||||||
|
|
||||||
/*Configure GPIO pins : PBPin PBPin PBPin */
|
/*Configure GPIO pins : PBPin PBPin PBPin */
|
||||||
GPIO_InitStruct.Pin = LED1_Pin; //|LED2_Pin|LED3_Pin;
|
GPIO_InitStruct.Pin = LED1_Pin; //|LED2_Pin|LED3_Pin;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||||
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
|
HAL_GPIO_Init(LED1_GPIO_Port, &GPIO_InitStruct);
|
||||||
|
|
||||||
GPIO_InitStruct.Pin = MEMS_POWER_Pin;
|
GPIO_InitStruct.Pin = MEMS_POWER_Pin;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
|
|
|
@ -99,15 +99,12 @@ int main(void)
|
||||||
/* USER CODE END SysInit */
|
/* USER CODE END SysInit */
|
||||||
|
|
||||||
/* Initialize all configured peripherals */
|
/* Initialize all configured peripherals */
|
||||||
LED1_ON;
|
|
||||||
MX_LoRaWAN_Init();
|
MX_LoRaWAN_Init();
|
||||||
|
|
||||||
STS_Lamp_Bar_Self_Test_Simple();
|
|
||||||
|
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* USER CODE END 2 */
|
/* USER CODE END 2 */
|
||||||
|
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
|
|
|
@ -74,7 +74,7 @@ extern volatile uint8_t sts_rss_result;
|
||||||
extern volatile uint8_t sts_rss_2nd_result; //2nd RSS sensor status
|
extern volatile uint8_t sts_rss_2nd_result; //2nd RSS sensor status
|
||||||
extern volatile uint8_t sts_tof_result;
|
extern volatile uint8_t sts_tof_result;
|
||||||
|
|
||||||
//extern volatile uint8_t last_sts_reed_hall_result = 2; //Initial state, not 0, not 1
|
|
||||||
volatile uint8_t last_lamp_bar_color=STS_GREEN;
|
volatile uint8_t last_lamp_bar_color=STS_GREEN;
|
||||||
extern volatile uint8_t sts_presence_fall_detection;
|
extern volatile uint8_t sts_presence_fall_detection;
|
||||||
extern volatile uint8_t sts_fall_rising_detected_result;
|
extern volatile uint8_t sts_fall_rising_detected_result;
|
||||||
|
@ -127,12 +127,11 @@ 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(20); //MAKE THIS LESS THAN 10 NOT TO BLOCK JOIN THE LORAWAN
|
HAL_Delay(20); //MAKE THIS LESS THAN 10 NOT TO BLOCK JOIN THE LORAWAN
|
||||||
|
//UTIL_MEM_set_8((void*)rgb_buf.GRB,ZERO_PULSE,(WS2812B_DATA_LEN+LED_DATA_LEN));
|
||||||
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();
|
||||||
}
|
}
|
||||||
HAL_Delay(10);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,7 +216,7 @@ void STS_Lamp_Bar_Self_Test_Simple(void)
|
||||||
lum_level = 10;
|
lum_level = 10;
|
||||||
do {
|
do {
|
||||||
STS_Lamp_Bar_Set_STS_RGB_Color(color, lum_level);
|
STS_Lamp_Bar_Set_STS_RGB_Color(color, lum_level);
|
||||||
HAL_Delay(50);
|
HAL_Delay(20);
|
||||||
lum_level += 20;
|
lum_level += 20;
|
||||||
} while (lum_level < 99);
|
} while (lum_level < 99);
|
||||||
STS_Lamp_Bar_Set_Dark();
|
STS_Lamp_Bar_Set_Dark();
|
||||||
|
@ -234,11 +233,12 @@ void STS_Lamp_Bar_Self_Test(void)
|
||||||
STS_Lamp_Bar_Self_Test_Simple();
|
STS_Lamp_Bar_Self_Test_Simple();
|
||||||
|
|
||||||
APP_LOG(TS_OFF, VLEVEL_H, "\r\n [#2] Scoller Testing\r\n");
|
APP_LOG(TS_OFF, VLEVEL_H, "\r\n [#2] Scoller Testing\r\n");
|
||||||
|
lum_level=50;
|
||||||
for (color = STS_GREEN; color < STS_COLOR_MAX; color++)
|
for (color = STS_GREEN; color < STS_COLOR_MAX; color++)
|
||||||
{
|
{
|
||||||
STS_Lamp_Bar_Scoller(color, lum_level);
|
STS_Lamp_Bar_Scoller(color, lum_level);
|
||||||
}
|
}
|
||||||
STS_Lamp_Bar_Set_Dark();
|
|
||||||
|
|
||||||
APP_LOG(TS_OFF, VLEVEL_H, "\r\n [##] YunHorn STS Indicative Lamp Self Test Finished\r\n");
|
APP_LOG(TS_OFF, VLEVEL_H, "\r\n [##] YunHorn STS Indicative Lamp Self Test Finished\r\n");
|
||||||
if ((sts_work_mode == STS_WIRED_MODE) )
|
if ((sts_work_mode == STS_WIRED_MODE) )
|
||||||
|
@ -248,7 +248,7 @@ void STS_Lamp_Bar_Self_Test(void)
|
||||||
{
|
{
|
||||||
STS_Lamp_Bar_Set_STS_RGB_Color(STS_GREEN, lum_level);
|
STS_Lamp_Bar_Set_STS_RGB_Color(STS_GREEN, lum_level);
|
||||||
}
|
}
|
||||||
STS_Lamp_Bar_Set_Dark();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,18 @@ void SystemApp_Init(void)
|
||||||
|
|
||||||
/*Initialize the Sensors */
|
/*Initialize the Sensors */
|
||||||
EnvSensors_Init();
|
EnvSensors_Init();
|
||||||
|
// LED1 Flash 3 times for normal power on
|
||||||
|
LED1_TOGGLE;
|
||||||
|
HAL_Delay(500);
|
||||||
|
LED1_TOGGLE;
|
||||||
|
HAL_Delay(500);
|
||||||
|
LED1_TOGGLE;
|
||||||
|
HAL_Delay(500);
|
||||||
|
LED1_TOGGLE;
|
||||||
|
HAL_Delay(500);
|
||||||
|
LED1_TOGGLE;
|
||||||
|
HAL_Delay(500);
|
||||||
|
LED1_TOGGLE;
|
||||||
/*Init low power manager*/
|
/*Init low power manager*/
|
||||||
UTIL_LPM_Init();
|
UTIL_LPM_Init();
|
||||||
/* Disable Stand-by mode */
|
/* Disable Stand-by mode */
|
||||||
|
|
|
@ -69,7 +69,8 @@ void MX_LoRaWAN_Init(void)
|
||||||
/* USER CODE END MX_LoRaWAN_Init_1 */
|
/* USER CODE END MX_LoRaWAN_Init_1 */
|
||||||
SystemApp_Init();
|
SystemApp_Init();
|
||||||
/* USER CODE BEGIN MX_LoRaWAN_Init_2 */
|
/* USER CODE BEGIN MX_LoRaWAN_Init_2 */
|
||||||
|
//STS_Lamp_Bar_Self_Test_Simple();
|
||||||
|
STS_Lamp_Bar_Self_Test();
|
||||||
/* USER CODE END MX_LoRaWAN_Init_2 */
|
/* USER CODE END MX_LoRaWAN_Init_2 */
|
||||||
LoRaWAN_Init();
|
LoRaWAN_Init();
|
||||||
/* USER CODE BEGIN MX_LoRaWAN_Init_3 */
|
/* USER CODE BEGIN MX_LoRaWAN_Init_3 */
|
||||||
|
|
|
@ -686,13 +686,13 @@ void LoRaWAN_Init(void)
|
||||||
#if defined(STS_O7)||defined(STS_O6)
|
#if defined(STS_O7)||defined(STS_O6)
|
||||||
UTIL_TIMER_Create(&YunhornSTSRSSWakeUpTimer,
|
UTIL_TIMER_Create(&YunhornSTSRSSWakeUpTimer,
|
||||||
YUNHORN_STS_RSS_WAKEUP_CHECK_TIME,
|
YUNHORN_STS_RSS_WAKEUP_CHECK_TIME,
|
||||||
UTIL_TIMER_ONESHOT, OnYunhornSTSOORSSWakeUpTimerEvent, NULL);
|
UTIL_TIMER_PERIODIC, OnYunhornSTSOORSSWakeUpTimerEvent, NULL);
|
||||||
UTIL_TIMER_Start(&YunhornSTSRSSWakeUpTimer);
|
//UTIL_TIMER_Start(&YunhornSTSRSSWakeUpTimer);
|
||||||
|
|
||||||
UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer,
|
UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer,
|
||||||
YUNHORN_STS_HEART_BEAT_CHECK_TIME,
|
YUNHORN_STS_HEART_BEAT_CHECK_TIME,
|
||||||
UTIL_TIMER_PERIODIC, OnYunhornSTSHeartBeatTimerEvent, NULL);
|
UTIL_TIMER_PERIODIC, OnYunhornSTSHeartBeatTimerEvent, NULL);
|
||||||
UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
|
//UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
|
||||||
|
|
||||||
UTIL_TIMER_Start(&STSLampBarColorTimer);
|
UTIL_TIMER_Start(&STSLampBarColorTimer);
|
||||||
|
|
||||||
|
@ -1173,7 +1173,7 @@ static void OnYunhornSTSLampBarColorTimerEvent(void *context)
|
||||||
//HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin); /* STS GREEN */
|
//HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin); /* STS GREEN */
|
||||||
//if ((sts_work_mode != STS_WIRED_MODE))
|
//if ((sts_work_mode != STS_WIRED_MODE))
|
||||||
uint8_t high4=(sts_lamp_bar_color>>4)&0x0f, low4=sts_lamp_bar_color&0x0f;
|
uint8_t high4=(sts_lamp_bar_color>>4)&0x0f, low4=sts_lamp_bar_color&0x0f;
|
||||||
HAL_Delay(10);
|
|
||||||
if (high4==0)
|
if (high4==0)
|
||||||
{
|
{
|
||||||
if (last_sts_lamp_bar_color != sts_lamp_bar_color)
|
if (last_sts_lamp_bar_color != sts_lamp_bar_color)
|
||||||
|
@ -1342,8 +1342,9 @@ static void OnYunhornSTSDurationCheckTimerEvent(void *context)
|
||||||
sts_o7_sensorData.event_sensor3_event_duration = sensor_event_time.Seconds - sts_o7_sensorData.event_sensor4_start_time;
|
sts_o7_sensorData.event_sensor3_event_duration = sensor_event_time.Seconds - sts_o7_sensorData.event_sensor4_start_time;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (over_threshold == TRUE) {
|
if (over_threshold == TRUE)
|
||||||
sensor_data_ready = 1;
|
{
|
||||||
|
|
||||||
if (sts_o7_sensorData.fall_state == STS_PRESENCE_LAYDOWN)
|
if (sts_o7_sensorData.fall_state == STS_PRESENCE_LAYDOWN)
|
||||||
{
|
{
|
||||||
sts_status_color = sts_lamp_bar_flashing_color; //STS_RED_BLUE;
|
sts_status_color = sts_lamp_bar_flashing_color; //STS_RED_BLUE;
|
||||||
|
@ -1352,7 +1353,9 @@ static void OnYunhornSTSDurationCheckTimerEvent(void *context)
|
||||||
sts_status_color = STS_RED_DARK;
|
sts_status_color = STS_RED_DARK;
|
||||||
sts_lamp_bar_color = STS_RED_DARK; //sts_lamp_bar_flashing_color;
|
sts_lamp_bar_color = STS_RED_DARK; //sts_lamp_bar_flashing_color;
|
||||||
}
|
}
|
||||||
SendTxData();
|
|
||||||
|
sensor_data_ready = 1;
|
||||||
|
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||||
over_threshold = FALSE;
|
over_threshold = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1427,10 +1430,9 @@ static void OnJoinRequest(LmHandlerJoinParams_t *joinParams)
|
||||||
heart_beat_timer = 1;
|
heart_beat_timer = 1;
|
||||||
SendTxData();
|
SendTxData();
|
||||||
|
|
||||||
OnYunhornSTSHeartBeatPeriodicityChanged(HeartBeatPeriodicity);
|
|
||||||
|
|
||||||
UTIL_TIMER_Start(&YunhornSTSRSSWakeUpTimer);
|
UTIL_TIMER_Start(&YunhornSTSRSSWakeUpTimer);
|
||||||
UTIL_TIMER_Start(&STSDurationCheckTimer);
|
UTIL_TIMER_Start(&STSDurationCheckTimer);
|
||||||
|
OnYunhornSTSHeartBeatPeriodicityChanged(HeartBeatPeriodicity);
|
||||||
|
|
||||||
/* USER CODE END OnJoinRequest_1 */
|
/* USER CODE END OnJoinRequest_1 */
|
||||||
}
|
}
|
||||||
|
@ -1697,7 +1699,7 @@ static void OnYunhornSTSOORSSWakeUpTimerEvent(void *context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UTIL_TIMER_Start(&YunhornSTSRSSWakeUpTimer);
|
//UTIL_TIMER_Start(&YunhornSTSRSSWakeUpTimer);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1718,7 +1720,7 @@ static void OnYunhornSTSHeartBeatTimerEvent(void *context)
|
||||||
}
|
}
|
||||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventRFAC), CFG_SEQ_Prio_0);
|
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventRFAC), CFG_SEQ_Prio_0);
|
||||||
}
|
}
|
||||||
//UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
|
UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue