overall good red/white changes
This commit is contained in:
parent
0099747508
commit
33eeecfcdf
|
@ -82,18 +82,19 @@ 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 ws2812b_data_transfer(uint8_t *src, uint32_t len);
|
||||
void ws2812b_light_custom(uint8_t red, uint8_t green, uint8_t blue);
|
||||
void ws2812b_light_all_with_lum_level(uint8_t color, uint8_t lum_level);
|
||||
void ws2812b_light_all(uint8_t color);
|
||||
static void ws2812b_data_transfer(uint8_t *src, uint32_t len);
|
||||
static void ws2812b_light_custom(uint8_t red, uint8_t green, uint8_t blue);
|
||||
static void sts_test_color_with_lum_level(void);
|
||||
static void ws2812b_light_all_with_lum_level(uint8_t color, uint8_t lum_level);
|
||||
static void ws2812b_light_all(uint8_t color);
|
||||
|
||||
void ws2812b_data_transfer(uint8_t *src, uint32_t len)
|
||||
static void ws2812b_data_transfer(uint8_t *src, uint32_t len)
|
||||
{
|
||||
uint8_t i =0;
|
||||
uint32_t bits = 0;
|
||||
uint32_t bytes = 0;
|
||||
//HAL_TIM_PWM_Stop_DMA(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL);
|
||||
memset(ws2812b_crr_value,0,sizeof(ws2812b_crr_value));
|
||||
HAL_TIM_PWM_Stop_DMA(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL);
|
||||
UTIL_MEM_set_8(ws2812b_crr_value,0,sizeof(ws2812b_crr_value));
|
||||
while(len--)
|
||||
{
|
||||
for (i=0; i < 8; i++)
|
||||
|
@ -113,10 +114,10 @@ void ws2812b_data_transfer(uint8_t *src, uint32_t len)
|
|||
|
||||
}
|
||||
|
||||
void ws2812b_light_custom(uint8_t red, uint8_t green, uint8_t blue)
|
||||
static void ws2812b_light_custom(uint8_t red, uint8_t green, uint8_t blue)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
memset(ws2812b_data, 0, sizeof(ws2812b_data));
|
||||
UTIL_MEM_set_8(ws2812b_data, 0, sizeof(ws2812b_data));
|
||||
for (i=0; i<(LED_COUNT); i++)
|
||||
{
|
||||
ws2812b_data[3*i] = green;
|
||||
|
@ -127,23 +128,23 @@ void ws2812b_light_custom(uint8_t red, uint8_t green, uint8_t blue)
|
|||
}
|
||||
void ws2812b_light_one_rgb(uint8_t red, uint8_t green, uint8_t blue, uint8_t idx)
|
||||
{
|
||||
uint8_t i = 0;
|
||||
memset(ws2812b_data, 0, sizeof(ws2812b_data));
|
||||
for (i=0; i<(LED_COUNT); i++)
|
||||
//uint8_t i = 0;
|
||||
UTIL_MEM_set_8(ws2812b_data, 0, sizeof(ws2812b_data));
|
||||
//for (i=0; i<(LED_COUNT); i++)
|
||||
{
|
||||
ws2812b_data[3*i] = green;
|
||||
ws2812b_data[3*i+1] = red;
|
||||
ws2812b_data[3*i+2] = blue;
|
||||
ws2812b_data[3*idx] = green;
|
||||
ws2812b_data[3*idx+1] = red;
|
||||
ws2812b_data[3*idx+2] = blue;
|
||||
}
|
||||
ws2812b_data_transfer(ws2812b_data, sizeof(ws2812b_data));
|
||||
}
|
||||
void ws2812b_light_all_with_lum_level(uint8_t color, uint8_t lum_level)
|
||||
static void ws2812b_light_all_with_lum_level(uint8_t color, uint8_t lum_level)
|
||||
{
|
||||
luminance_level = lum_level;
|
||||
ws2812b_light_all(color);
|
||||
}
|
||||
|
||||
void ws2812b_light_all(uint8_t color)
|
||||
static void ws2812b_light_all(uint8_t color)
|
||||
{
|
||||
switch(color)
|
||||
{
|
||||
|
@ -182,17 +183,16 @@ void STS_Lamp_Bar_Init(void)
|
|||
void STS_Lamp_Bar_Scoller(uint8_t color, uint8_t lum_level)
|
||||
{
|
||||
uint8_t i =0;
|
||||
memset(ws2812b_data, 0, sizeof(ws2812b_data));
|
||||
for(i=0; i < (LED_COUNT+1); i++)
|
||||
UTIL_MEM_set_8(ws2812b_data, 0, sizeof(ws2812b_data));
|
||||
for(i=0; i < (LED_COUNT); i++)
|
||||
{
|
||||
ws2812b_data[3*i] = color_rgb[color][1]*lum_level;
|
||||
ws2812b_data[3*i+1] = color_rgb[color][0]*lum_level;
|
||||
ws2812b_data[3*i+2] = color_rgb[color][2]*lum_level;
|
||||
|
||||
ws2812b_data_transfer(ws2812b_data, sizeof(ws2812b_data));
|
||||
HAL_Delay(20);
|
||||
|
||||
if (i<LED_COUNT){
|
||||
ws2812b_data[i*3 + color] = lum_level;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -220,6 +220,7 @@ static void STS_Lamp_Bar_Set_RGB_Color_FadeIn(uint8_t red, uint8_t green, uint8_
|
|||
}
|
||||
}
|
||||
ws2812b_data_transfer(ws2812b_data, sizeof(ws2812b_data));
|
||||
HAL_Delay(1);
|
||||
}
|
||||
|
||||
static void STS_Lamp_Bar_Set_RGB_Color_FadeOut(uint8_t red, uint8_t green, uint8_t blue, uint8_t start_position, uint8_t fade_length)
|
||||
|
@ -247,6 +248,7 @@ static void STS_Lamp_Bar_Set_RGB_Color_FadeOut(uint8_t red, uint8_t green, uint8
|
|||
}
|
||||
}
|
||||
ws2812b_data_transfer(ws2812b_data, sizeof(ws2812b_data));
|
||||
HAL_Delay(1);
|
||||
}
|
||||
|
||||
void STS_Lamp_Bar_Set_STS_RGB_Color_FadeIn(uint8_t sts_lamp_color, uint8_t max_lum_level, uint8_t fade_length)
|
||||
|
@ -333,29 +335,21 @@ void STS_Lamp_Bar_Set_STS_RGB_Color(uint8_t sts_lamp_color, uint8_t lum)
|
|||
case STS_CYAN : ws2812b_light_custom(0, luminance_level, luminance_level ); break;
|
||||
case STS_WHITE : ws2812b_light_custom(luminance_level, luminance_level, luminance_level ); break;
|
||||
}
|
||||
HAL_Delay(1);
|
||||
}
|
||||
|
||||
void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim)
|
||||
{
|
||||
__HAL_TIM_SetCompare(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL,0);
|
||||
//__HAL_TIM_SetCompare(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL,0);
|
||||
HAL_TIM_PWM_Stop_DMA(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL);
|
||||
|
||||
}
|
||||
|
||||
void STS_Lamp_Bar_Self_Test_Simple(void)
|
||||
{
|
||||
uint16_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");
|
||||
for (color=STS_GREEN; color < STS_COLOR_MAX; color++)
|
||||
{
|
||||
lum_level = 0;
|
||||
do {
|
||||
STS_Lamp_Bar_Set_STS_RGB_Color(color, lum_level);
|
||||
HAL_Delay(20);
|
||||
lum_level += 5;
|
||||
} while (lum_level < 250);
|
||||
STS_Lamp_Bar_Set_Dark();
|
||||
}
|
||||
sts_test_color_with_lum_level();
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n [#1] RGB Space Lumianance Level Testing Finished\r\n");
|
||||
}
|
||||
|
||||
|
@ -367,37 +361,39 @@ void STS_Lamp_Bar_Self_Test_Fade(void)
|
|||
for (color=STS_GREEN; color < STS_COLOR_MAX; color++)
|
||||
{
|
||||
STS_Lamp_Bar_Set_STS_RGB_Color_FadeOut(color&0xff, lum_level&0xff, LED_COUNT/2);
|
||||
HAL_Delay(2000);
|
||||
HAL_Delay(500);
|
||||
}
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n [#1] RGB Space Fade In Testing Start\r\n");
|
||||
for (color=STS_GREEN; color < STS_COLOR_MAX; color++)
|
||||
{
|
||||
STS_Lamp_Bar_Set_STS_RGB_Color_FadeIn(color&0xff, lum_level&0xff, LED_COUNT/2);
|
||||
HAL_Delay(2000);
|
||||
HAL_Delay(500);
|
||||
}
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n [#1] RGB Space Fade Out / Fade In Testing Finished\r\n");
|
||||
}
|
||||
|
||||
void sts_test_scoller_bar(void)
|
||||
static void sts_test_scoller_bar(void)
|
||||
{
|
||||
for (uint8_t color = STS_GREEN; color < STS_COLOR_MAX; color++)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n [#1] Scoller Testing Color #%02x \r\n", color);
|
||||
{
|
||||
STS_Lamp_Bar_Scoller(color, DEFAULT_LUMINANCE_LEVEL);
|
||||
}
|
||||
HAL_Delay(500);
|
||||
}
|
||||
}
|
||||
|
||||
void sts_test_color_with_lum_level(void)
|
||||
static void sts_test_color_with_lum_level(void)
|
||||
{
|
||||
|
||||
for (uint8_t color = STS_GREEN; color < STS_COLOR_MAX; color++)
|
||||
{
|
||||
for (uint16_t lum_level=1; lum_level<250; lum_level+=5)
|
||||
for (uint16_t lum_level=1; lum_level<250; lum_level+=10)
|
||||
{
|
||||
ws2812b_light_all_with_lum_level(color, lum_level&0xff);
|
||||
HAL_Delay(50);
|
||||
HAL_Delay(30);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -406,29 +402,26 @@ void STS_Lamp_Bar_Self_Test(void)
|
|||
{
|
||||
uint16_t 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 [#1] YunHorn STS Indicative Lamp Self Test\r\n");
|
||||
|
||||
STS_Lamp_Bar_Self_Test_Simple();HAL_Delay(500);
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n [#2] Scoller Testing\r\n");
|
||||
sts_test_scoller_bar();HAL_Delay(500);
|
||||
|
||||
STS_Lamp_Bar_Self_Test_Simple();
|
||||
HAL_Delay(1000);
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n [#1] Scoller Testing\r\n");
|
||||
sts_test_scoller_bar();
|
||||
HAL_Delay(1000);
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n [#2] Color with Lum Level \r\n");
|
||||
sts_test_color_with_lum_level();
|
||||
HAL_Delay(1000);
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n [#3] Color Set Dark \r\n");
|
||||
STS_Lamp_Bar_Set_Dark();
|
||||
HAL_Delay(1000);
|
||||
HAL_Delay(500);
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n [#4] RGB Space Fade Out Testing Start\r\n");
|
||||
STS_Lamp_Bar_Self_Test_Fade();
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n [##] YunHorn STS Indicative Lamp Self Test Finished\r\n");
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n [#5] YunHorn STS Indicative Lamp Self Test Finished\r\n");
|
||||
if ((sts_work_mode == STS_WIRED_MODE) )
|
||||
{
|
||||
STS_Lamp_Bar_Set_Dark();
|
||||
} else
|
||||
{
|
||||
STS_Lamp_Bar_Set_STS_RGB_Color(STS_GREEN, lum_level);
|
||||
STS_Lamp_Bar_Set_STS_RGB_Color(STS_COLOR_DEFAULT_VACANT, lum_level);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ volatile uint8_t last_sts_hall1_read=STS_Status_Door_Open, last_sts_hall2_read=S
|
|||
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, sts_color_occupy_vacant, sts_color_severity_l2_l3;
|
||||
extern volatile uint8_t sts_lamp_bar_flashing_color;
|
||||
volatile uint8_t last_sts_lamp_bar_color=STS_WHITE;
|
||||
volatile uint8_t last_sts_lamp_bar_color=STS_DARK;
|
||||
//extern volatile uint8_t sts_status_color, sts_lamp_bar_color, sts_color_occupy_vacant;//puColor
|
||||
extern volatile uint8_t sts_rss_result;
|
||||
extern volatile uint8_t sts_rss_result_changed_flag, sts_hall1_changed_flag, sts_hall2_changed_flag, sts_reed_hall_changed_flag;
|
||||
|
@ -629,7 +629,7 @@ void LoRaWAN_Init(void)
|
|||
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(&STSLampBarColorTimer, 2*LED_PERIOD_TIME, UTIL_TIMER_ONESHOT, OnYunhornSTSLampBarColorTimerEvent, NULL);
|
||||
UTIL_TIMER_Create(&STSLampBarColorTimer, LED_PERIOD_TIME, UTIL_TIMER_ONESHOT, OnYunhornSTSLampBarColorTimerEvent, NULL);
|
||||
// UTIL_TIMER_Create(&STSDurationCheckTimer, 30*LED_PERIOD_TIME, UTIL_TIMER_PERIODIC, OnYunhornSTSDurationCheckTimerEvent, NULL);
|
||||
|
||||
if (FLASH_IF_Init(NULL) != FLASH_IF_OK)
|
||||
|
@ -1261,20 +1261,16 @@ static void OnJoinTimerLedEvent(void *context)
|
|||
static void OnYunhornSTSLampBarColorTimerEvent(void *context)
|
||||
{
|
||||
|
||||
//uint8_t lum=DEFAULT_LUMINANCE_LEVEL;
|
||||
//HAL_GPIO_TogglePin(LED1_GPIO_Port, LED1_Pin); /* STS GREEN */
|
||||
//if ((sts_work_mode != STS_WIRED_MODE))
|
||||
uint8_t high4=(sts_lamp_bar_color>>4)&0x0f, low4=sts_lamp_bar_color&0x0f;
|
||||
#if 0
|
||||
luminance_level += 10;
|
||||
luminance_level %= 60;
|
||||
luminance_level = MAX(10,luminance_level);
|
||||
#endif
|
||||
if (last_sts_lamp_bar_color != sts_lamp_bar_color)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n----Lamp Bar Color changed from %02x to %02x \r\n", last_sts_lamp_bar_color, sts_lamp_bar_color);
|
||||
last_sts_lamp_bar_color = sts_lamp_bar_color;
|
||||
}
|
||||
|
||||
//if (last_sts_lamp_bar_color != sts_lamp_bar_color)
|
||||
{
|
||||
if (last_sts_lamp_bar_color != sts_lamp_bar_color)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n----Lamp Bar Color changed from %02x to %02x \r\n", last_sts_lamp_bar_color, sts_lamp_bar_color);
|
||||
last_sts_lamp_bar_color = sts_lamp_bar_color;
|
||||
}
|
||||
|
||||
UTIL_TIMER_Stop(&STSLampBarColorTimer);
|
||||
|
||||
if (high4==0)
|
||||
|
@ -1283,11 +1279,12 @@ if (last_sts_lamp_bar_color != sts_lamp_bar_color)
|
|||
#if defined(FADEOUT)
|
||||
if ((sts_rss_result == STS_RESULT_MOTION)) //||(sts_reed_hall_result == STS_Status_Door_Close ))
|
||||
{
|
||||
|
||||
//STS_Lamp_Bar_Set_STS_RGB_Color_FadeOut(STS_COLOR_DEFAULT_OCCUPY, luminance_level, LED_COUNT/2);
|
||||
STS_Lamp_Bar_Set_STS_RGB_Color_FadeOut(sts_lamp_bar_color, luminance_level, LED_COUNT/2);
|
||||
} else //if ((sts_rss_result == STS_RESULT_NO_MOTION)||(sts_reed_hall_result == STS_Status_Door_Open )){
|
||||
{
|
||||
STS_Lamp_Bar_Set_STS_RGB_Color_FadeIn(sts_lamp_bar_color, luminance_level, LED_COUNT/2);
|
||||
//STS_Lamp_Bar_Set_STS_RGB_Color_FadeIn(STS_COLOR_DEFAULT_VACANT, luminance_level, LED_COUNT/2);
|
||||
}
|
||||
#else
|
||||
STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, luminance_level);
|
||||
|
@ -1299,7 +1296,7 @@ if (last_sts_lamp_bar_color != sts_lamp_bar_color)
|
|||
r_b = !r_b;
|
||||
}
|
||||
UTIL_TIMER_Start(&STSLampBarColorTimer);
|
||||
//}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -3206,11 +3203,11 @@ void OnRestoreSTSCFGContextProcess(void)
|
|||
}
|
||||
|
||||
sts_work_mode = sts_cfg_nvm.work_mode;
|
||||
sts_lamp_bar_color = STS_GREEN;
|
||||
sts_service_mask = sts_cfg_nvm.sts_service_mask;
|
||||
sts_lamp_bar_flashing_color = sts_cfg_nvm.alarm_lamp_bar_flashing_color;
|
||||
sts_color_occupy_vacant = sts_cfg_nvm.color_occupy_vacant;
|
||||
sts_color_severity_l2_l3 = sts_cfg_nvm.color_severity_l2_l3;
|
||||
sts_lamp_bar_color = STS_COLOR_DEFAULT_VACANT;
|
||||
if (sts_work_mode == STS_UNI_MODE){
|
||||
sts_presence_fall_detection =TRUE;
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue