good at SOS flash red/blue, good at green/red occupy/vacant
This commit is contained in:
parent
d33f9b7904
commit
e2dd2a8005
|
@ -129,7 +129,7 @@ void Error_Handler(void);
|
||||||
*/
|
*/
|
||||||
#define STS_LAMP_BAR_PWM_TIM_PERIOD (60 - 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 (20)
|
#define STS_LAMP_BAR_LED_NUM (50)
|
||||||
|
|
||||||
#define WSDATA_PORT_PIN_PA8
|
#define WSDATA_PORT_PIN_PA8
|
||||||
//#define WSDATA_PORT_PIN_PA9
|
//#define WSDATA_PORT_PIN_PA9
|
||||||
|
|
|
@ -29,7 +29,7 @@ extern "C" {
|
||||||
|
|
||||||
#define DEFAULT_SATURATION 50 // 0 - 100 S:Saturation, 0~100
|
#define DEFAULT_SATURATION 50 // 0 - 100 S:Saturation, 0~100
|
||||||
#define DEFAULT_BRIGHTNESS 50 // 0 - 100 V:Value of lightness, 0~100
|
#define DEFAULT_BRIGHTNESS 50 // 0 - 100 V:Value of lightness, 0~100
|
||||||
#define DEFAULT_LUMINANCE_LEVEL (20)
|
#define DEFAULT_LUMINANCE_LEVEL (30)
|
||||||
#define STS_Status_Door_Close (0) //Normal Close NC:Open
|
#define STS_Status_Door_Close (0) //Normal Close NC:Open
|
||||||
#define STS_Status_Door_Open (1) //Normal Close NC:Close
|
#define STS_Status_Door_Open (1) //Normal Close NC:Close
|
||||||
#define STS_Status_SOS_Pushdown (0) //Normal Open NO:Open
|
#define STS_Status_SOS_Pushdown (0) //Normal Open NO:Open
|
||||||
|
|
|
@ -102,7 +102,7 @@ int main(void)
|
||||||
LED1_ON;
|
LED1_ON;
|
||||||
MX_LoRaWAN_Init();
|
MX_LoRaWAN_Init();
|
||||||
|
|
||||||
STS_Lamp_Bar_Self_Test();
|
STS_Lamp_Bar_Self_Test_Simple();
|
||||||
|
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
#define LED_DATA_LEN (24)
|
#define LED_DATA_LEN (24)
|
||||||
#define WS2812B_DATA_LEN (LED_DATA_LEN * (STS_LAMP_BAR_LED_NUM+4))
|
#define WS2812B_DATA_LEN (LED_DATA_LEN * (STS_LAMP_BAR_LED_NUM+4))
|
||||||
//#define DEFAULT_LUMINANCE_LEVEL (20)
|
//#define DEFAULT_LUMINANCE_LEVEL (30)
|
||||||
#define RESET_PULSE (10) //(80) TO FIX DARK_COLOR AND SM2
|
#define RESET_PULSE (10) //(80) TO FIX DARK_COLOR AND SM2
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ extern volatile uint8_t sensor_data_ready;
|
||||||
extern SysTime_t mems_event_time;
|
extern SysTime_t mems_event_time;
|
||||||
extern volatile uint32_t event_start_time, event_stop_time;
|
extern volatile uint32_t event_start_time, event_stop_time;
|
||||||
extern volatile uint32_t event_door_lock_start_time, event_door_lock_stop_time;
|
extern volatile uint32_t event_door_lock_start_time, event_door_lock_stop_time;
|
||||||
uint8_t luminance_level = DEFAULT_LUMINANCE_LEVEL;
|
volatile uint8_t luminance_level = DEFAULT_LUMINANCE_LEVEL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ void STS_WS2812B_Refresh(void)
|
||||||
{
|
{
|
||||||
HAL_TIM_PWM_Start_DMA(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL, (uint32_t *)&rgb_buf, (RESET_PULSE+WS2812B_DATA_LEN+1));
|
HAL_TIM_PWM_Start_DMA(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL, (uint32_t *)&rgb_buf, (RESET_PULSE+WS2812B_DATA_LEN+1));
|
||||||
|
|
||||||
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)
|
||||||
|
@ -122,24 +122,23 @@ void STS_Lamp_Bar_Init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
//marquee scoller
|
//marquee scoller
|
||||||
void STS_Lamp_Bar_Scoller(uint8_t color, uint8_t luminance_level)
|
void STS_Lamp_Bar_Scoller(uint8_t color, uint8_t lum_level)
|
||||||
{
|
{
|
||||||
STS_Lamp_Bar_Set_Dark();
|
STS_Lamp_Bar_Set_Dark();
|
||||||
|
|
||||||
for(uint8_t i = 0; i<(STS_LAMP_BAR_LED_NUM+1); i++)
|
for(uint8_t i = 0; i<STS_LAMP_BAR_LED_NUM; i++)
|
||||||
{
|
{
|
||||||
//if (sts_service_mask < STS_SERVICE_MASK_L1)
|
//if (sts_service_mask < STS_SERVICE_MASK_L1)
|
||||||
// STS_WS2812B_Refresh();
|
// STS_WS2812B_Refresh();
|
||||||
HAL_Delay(10); //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
|
||||||
if (i < STS_LAMP_BAR_LED_NUM) {
|
//if (i < STS_LAMP_BAR_LED_NUM) {
|
||||||
STS_WS2812B_Set_RGB(color_rgb[color][0]*luminance_level,color_rgb[color][1]*luminance_level, color_rgb[color][2]*luminance_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);
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
HAL_Delay(10);
|
||||||
}
|
//STS_Lamp_Bar_Init();
|
||||||
//HAL_Delay(10);
|
|
||||||
|
|
||||||
//if (sts_service_mask == STS_SERVICE_MASK_L0) {
|
//if (sts_service_mask == STS_SERVICE_MASK_L0) {
|
||||||
STS_WS2812B_Refresh();
|
//STS_WS2812B_Refresh();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -164,7 +163,9 @@ void STS_WS2812B_Set_RGB(uint8_t R, uint8_t G, uint8_t B, uint8_t idx)
|
||||||
|
|
||||||
void STS_Lamp_Bar_Set_RGB_Color(uint8_t red, uint8_t green, uint8_t blue )
|
void STS_Lamp_Bar_Set_RGB_Color(uint8_t red, uint8_t green, uint8_t blue )
|
||||||
{
|
{
|
||||||
HAL_Delay(1);
|
//HAL_Delay(1);
|
||||||
|
memset((void*)rgb_buf.GRB,0x0,(2*24*STS_LAMP_BAR_LED_NUM));
|
||||||
|
|
||||||
for(uint8_t i = 0; i < STS_LAMP_BAR_LED_NUM; i++)
|
for(uint8_t i = 0; i < STS_LAMP_BAR_LED_NUM; i++)
|
||||||
{
|
{
|
||||||
for (uint8_t j = 0; j < 8; j ++)
|
for (uint8_t j = 0; j < 8; j ++)
|
||||||
|
@ -185,9 +186,8 @@ void STS_Lamp_Bar_Refresh(void)
|
||||||
{
|
{
|
||||||
STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, luminance_level);
|
STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, luminance_level);
|
||||||
}
|
}
|
||||||
void STS_Lamp_Bar_Set_STS_RGB_Color(uint8_t sts_lamp_color, uint8_t luminance_level)
|
void STS_Lamp_Bar_Set_STS_RGB_Color(uint8_t sts_lamp_color, uint8_t lum)
|
||||||
{
|
{
|
||||||
uint8_t lum = luminance_level;
|
|
||||||
//static bool r_b = false;
|
//static bool r_b = false;
|
||||||
//STS_Lamp_Bar_Set_RGB_Color(0x0, 0x0, 0x0);
|
//STS_Lamp_Bar_Set_RGB_Color(0x0, 0x0, 0x0);
|
||||||
switch (sts_lamp_color)
|
switch (sts_lamp_color)
|
||||||
|
@ -216,13 +216,13 @@ void STS_Lamp_Bar_Set_STS_RGB_Color(uint8_t sts_lamp_color, uint8_t luminance_le
|
||||||
case STS_WHITE:
|
case STS_WHITE:
|
||||||
STS_Lamp_Bar_Set_RGB_Color(lum, lum, lum);
|
STS_Lamp_Bar_Set_RGB_Color(lum, lum, lum);
|
||||||
break;
|
break;
|
||||||
case STS_RED_BLUE:
|
//case STS_RED_BLUE:
|
||||||
// if (r_b)
|
// if (r_b)
|
||||||
// STS_Lamp_Bar_Set_RGB_Color(lum, 0x0, 0x0);
|
// STS_Lamp_Bar_Set_RGB_Color(lum, 0x0, 0x0);
|
||||||
// else
|
// else
|
||||||
// STS_Lamp_Bar_Set_RGB_Color(0x0, 0x0, lum);
|
// STS_Lamp_Bar_Set_RGB_Color(0x0, 0x0, lum);
|
||||||
// r_b = !r_b;
|
// r_b = !r_b;
|
||||||
break;
|
//break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,23 +435,23 @@ void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim)
|
||||||
|
|
||||||
void STS_Lamp_Bar_Self_Test_Simple(void)
|
void STS_Lamp_Bar_Self_Test_Simple(void)
|
||||||
{
|
{
|
||||||
uint8_t color=0, luminance_level=DEFAULT_LUMINANCE_LEVEL;
|
uint8_t color=0, lum_level=DEFAULT_LUMINANCE_LEVEL;
|
||||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n [#1] RGB Space Lumianance Level Testing Start\r\n");
|
APP_LOG(TS_OFF, VLEVEL_M, "\r\n [#1] RGB Space Lumianance Level Testing Start\r\n");
|
||||||
for (color=STS_GREEN; color <= STS_RED_BLUE; color++)
|
for (color=STS_GREEN; color <= STS_RED_BLUE; color++)
|
||||||
{
|
{
|
||||||
luminance_level = 10;
|
lum_level = 10;
|
||||||
do {
|
do {
|
||||||
STS_Lamp_Bar_Set_STS_RGB_Color(color, luminance_level);
|
STS_Lamp_Bar_Set_STS_RGB_Color(color, lum_level);
|
||||||
HAL_Delay(50);
|
HAL_Delay(50);
|
||||||
luminance_level += 20;
|
lum_level += 20;
|
||||||
} while (luminance_level < 99);
|
} while (lum_level < 99);
|
||||||
//STS_Lamp_Bar_Set_Dark();
|
STS_Lamp_Bar_Set_Dark();
|
||||||
}
|
}
|
||||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n [#1] RGB Space Lumianance Level Testing Finished\r\n");
|
APP_LOG(TS_OFF, VLEVEL_M, "\r\n [#1] RGB Space Lumianance Level Testing Finished\r\n");
|
||||||
}
|
}
|
||||||
void STS_Lamp_Bar_Self_Test(void)
|
void STS_Lamp_Bar_Self_Test(void)
|
||||||
{
|
{
|
||||||
uint8_t color=0, luminance_level=DEFAULT_LUMINANCE_LEVEL;
|
uint8_t color=0, lum_level=DEFAULT_LUMINANCE_LEVEL;
|
||||||
|
|
||||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n YunHorn STS Indicative Lamp Self Test\r\n");
|
APP_LOG(TS_OFF, VLEVEL_M, "\r\n YunHorn STS Indicative Lamp Self Test\r\n");
|
||||||
|
|
||||||
|
@ -460,7 +460,7 @@ void STS_Lamp_Bar_Self_Test(void)
|
||||||
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");
|
||||||
for (color = STS_GREEN; color < STS_RED_BLUE; color++)
|
for (color = STS_GREEN; color < STS_RED_BLUE; color++)
|
||||||
{
|
{
|
||||||
STS_Lamp_Bar_Scoller(color, luminance_level);
|
STS_Lamp_Bar_Scoller(color, lum_level);
|
||||||
}
|
}
|
||||||
STS_Lamp_Bar_Set_Dark();
|
STS_Lamp_Bar_Set_Dark();
|
||||||
|
|
||||||
|
@ -470,7 +470,7 @@ void STS_Lamp_Bar_Self_Test(void)
|
||||||
STS_Lamp_Bar_Set_Dark();
|
STS_Lamp_Bar_Set_Dark();
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
STS_Lamp_Bar_Set_STS_RGB_Color(STS_GREEN, luminance_level);
|
STS_Lamp_Bar_Set_STS_RGB_Color(STS_GREEN, lum_level);
|
||||||
}
|
}
|
||||||
STS_Lamp_Bar_Set_Dark();
|
STS_Lamp_Bar_Set_Dark();
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ extern volatile uint8_t sts_hall1_read, sts_hall2_read;
|
||||||
extern volatile uint8_t sts_reed_hall_1_changed, sts_reed_hall_2_changed;
|
extern volatile uint8_t sts_reed_hall_1_changed, sts_reed_hall_2_changed;
|
||||||
volatile uint8_t sts_reed_hall_result =0, sts_emergency_button_pushed=0; // inital 0 = close
|
volatile uint8_t sts_reed_hall_result =0, sts_emergency_button_pushed=0; // inital 0 = close
|
||||||
extern volatile uint8_t sts_work_mode, sts_cloud_netcolor, sts_lamp_bar_color, sts_status_color;
|
extern volatile uint8_t sts_work_mode, sts_cloud_netcolor, sts_lamp_bar_color, sts_status_color;
|
||||||
|
volatile uint8_t last_sts_lamp_bar_color=STS_DARK;
|
||||||
extern volatile uint8_t sts_rss_result_changed_flag, sts_hall1_changed_flag, sts_hall2_changed_flag, sts_reed_hall_changed_flag;
|
extern volatile uint8_t sts_rss_result_changed_flag, sts_hall1_changed_flag, sts_hall2_changed_flag, sts_reed_hall_changed_flag;
|
||||||
volatile uint8_t sts_fall_detection_acc_threshold = 10, sts_fall_detection_depth_threshold=20, sts_occupancy_overtime_threshold=20;
|
volatile uint8_t sts_fall_detection_acc_threshold = 10, sts_fall_detection_depth_threshold=20, sts_occupancy_overtime_threshold=20;
|
||||||
extern volatile uint32_t event_start_time, event_stop_time;
|
extern volatile uint32_t event_start_time, event_stop_time;
|
||||||
|
@ -969,8 +970,8 @@ static void OnYunhornSTSLampBarColorTimerEvent(void *context)
|
||||||
{
|
{
|
||||||
|
|
||||||
uint8_t lum=DEFAULT_LUMINANCE_LEVEL;
|
uint8_t lum=DEFAULT_LUMINANCE_LEVEL;
|
||||||
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))
|
||||||
{
|
{
|
||||||
if (sts_lamp_bar_color == STS_RED_BLUE) {
|
if (sts_lamp_bar_color == STS_RED_BLUE) {
|
||||||
if (r_b)
|
if (r_b)
|
||||||
|
@ -980,9 +981,13 @@ static void OnYunhornSTSLampBarColorTimerEvent(void *context)
|
||||||
|
|
||||||
r_b = !r_b;
|
r_b = !r_b;
|
||||||
} else {
|
} else {
|
||||||
|
if (last_sts_lamp_bar_color != sts_lamp_bar_color)
|
||||||
|
{
|
||||||
STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, lum);
|
STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, lum);
|
||||||
|
last_sts_lamp_bar_color = sts_lamp_bar_color;
|
||||||
}
|
}
|
||||||
STS_Lamp_Bar_Refresh();
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1027,6 +1032,9 @@ static void OnJoinRequest(LmHandlerJoinParams_t *joinParams)
|
||||||
if (joinParams->Status == LORAMAC_HANDLER_SUCCESS)
|
if (joinParams->Status == LORAMAC_HANDLER_SUCCESS)
|
||||||
{
|
{
|
||||||
UTIL_TIMER_Stop(&JoinLedTimer);
|
UTIL_TIMER_Stop(&JoinLedTimer);
|
||||||
|
STS_Lamp_Bar_Set_Dark();
|
||||||
|
sts_lamp_bar_color = STS_GREEN;
|
||||||
|
STS_WS2812B_Refresh();
|
||||||
#ifndef STM32WLE5xx
|
#ifndef STM32WLE5xx
|
||||||
HAL_GPIO_WritePin(LED3_GPIO_Port, LED3_Pin, GPIO_PIN_RESET); /* LED_RED */
|
HAL_GPIO_WritePin(LED3_GPIO_Port, LED3_Pin, GPIO_PIN_RESET); /* LED_RED */
|
||||||
#endif
|
#endif
|
||||||
|
@ -1055,6 +1063,8 @@ static void OnJoinRequest(LmHandlerJoinParams_t *joinParams)
|
||||||
}
|
}
|
||||||
heart_beat_timer = 1;
|
heart_beat_timer = 1;
|
||||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
|
||||||
|
|
||||||
|
//STS_Lamp_Bar_Set_Dark();
|
||||||
UTIL_TIMER_Start(&STSLampBarColorTimer);
|
UTIL_TIMER_Start(&STSLampBarColorTimer);
|
||||||
/* USER CODE END OnJoinRequest_1 */
|
/* USER CODE END OnJoinRequest_1 */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue