/* USER CODE BEGIN Header */ /** ****************************************************************************** * @file yunhorn_sts_lamp_bar.c * * @author Yunhorn (r) Technology Limited Application Team * * @brief Yunhorn (r) SmarToilets (r) Product configuration file. * ****************************************************************************** * @attention * * Copyright (c) 2022 Yunhorn Technology Limited. * Copyright (c) 2022 Shenzhen Yunhorn Technology Co., Ltd. * All rights reserved. * * This software is licensed under terms that can be found in the LICENSE file * in the root directory of this software component. * If no LICENSE file comes with this software, it is provided AS-IS. * ****************************************************************************** */ /* USER CODE END Header */ #include "main.h" #include "dma.h" #include "tim.h" #include "string.h" #include "sys_app.h" #include "stm32_systime.h" #include "sts_lamp_bar.h" #include "yunhorn_sts_sensors.h" #define ONE_PULSE (36) #define ZERO_PULSE (20) #define LED_DATA_LEN 24 #define WS2812B_DATA_LEN (24 * STS_LAMP_BAR_LED_NUM+1) #define RESET_PULSE (24) //(80) TO FIX DARK_COLOR AND SM2 typedef struct ws2812b_e { uint16_t head[3]; uint16_t GRB[WS2812B_DATA_LEN]; uint16_t tail; } WS2812B_FrameTypeDef; volatile WS2812B_FrameTypeDef rgb_buf = { .head[0] = 0, .head[1] = 0, .head[2] = 0, .tail = 0 }; uint8_t color_rgb[8][3] = { //STS_COLOR R G B MAPPING TABLE {0,0,0},{0,1,0},{1,0,0},{0,0,1},{1,1,0},{1,0,1},{0,1,1},{1,1,1} }; extern volatile uint8_t sts_service_mask; extern volatile uint8_t sts_work_mode; volatile uint8_t sts_reed_hall_ext_int = 0; volatile uint8_t sts_status_color = STS_GREEN; volatile uint8_t sts_lamp_bar_color = STS_GREEN; //puColor volatile uint8_t sts_lamp_bar_flashing_color = 0x23; // RED_BLUE; volatile uint8_t sts_cloud_netcolor = STS_GREEN; //netColor extern volatile uint8_t sts_occupancy_status; extern volatile uint8_t sts_reed_hall_result, sts_emergency_button_pushed; // inital 0 = close volatile uint8_t sts_hall1_read=STS_Status_Door_Open,sts_hall2_read=STS_Status_SOS_Release; // Above hall1_read == reed_hall_result, hall2_read == emergency_button extern volatile uint8_t sts_reed_hall_1_result, sts_reed_hall_2_result; extern volatile uint8_t sts_tof_result_changed_flag; 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; extern volatile uint8_t sts_rss_2nd_result; //2nd RSS sensor status 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; extern volatile uint8_t sts_presence_fall_detection; extern volatile uint8_t sts_fall_rising_detected_result; extern volatile float sts_presence_rss_distance; extern volatile uint8_t sensor_data_ready; extern SysTime_t mems_event_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; volatile uint8_t luminance_level = DEFAULT_LUMINANCE_LEVEL; void STS_Lamp_Bar_Set_Dark(void) { for (uint8_t i=0; i< STS_LAMP_BAR_LED_NUM; i++) { STS_WS2812B_Set_RGB(0x00,0x00,0x00,i); } STS_WS2812B_Refresh(); } void STS_WS2812B_Refresh(void) { __disable_irq(); HAL_TIM_PWM_Start_DMA(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL, (uint32_t *)&rgb_buf, (uint16_t)(sizeof(rgb_buf))); __enable_irq(); //HAL_TIM_PWM_Start_IT(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL); } void STS_Lamp_Bar_Init(void) { if (sts_service_mask == STS_SERVICE_MASK_L0) { STS_Lamp_Bar_Set_STS_RGB_Color(STS_GREEN, luminance_level); HAL_Delay(200); STS_Lamp_Bar_Set_STS_RGB_Color(STS_RED, luminance_level); HAL_Delay(200); STS_Lamp_Bar_Set_STS_RGB_Color(STS_BLUE, luminance_level); HAL_Delay(200); } } //marquee scoller void STS_Lamp_Bar_Scoller(uint8_t color, uint8_t lum_level) { STS_Lamp_Bar_Set_Dark(); for(uint8_t i = 0; i