---minor improve for stable LED color
This commit is contained in:
parent
a67c466012
commit
89a809911d
|
@ -57,7 +57,7 @@ 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_lamp_bar_flashing_color = STS_RED_DARK; //0x23; RED_BLUE;
|
||||
volatile uint8_t sts_cloud_netcolor = STS_GREEN; //netColor
|
||||
extern volatile uint8_t sts_occupancy_status;
|
||||
|
||||
|
@ -189,7 +189,7 @@ void STS_Lamp_Bar_Refresh(void)
|
|||
void STS_Lamp_Bar_Set_STS_RGB_Color(uint8_t sts_lamp_color, uint8_t lum)
|
||||
{
|
||||
|
||||
switch (sts_lamp_color&0x0f)
|
||||
switch (sts_lamp_color)
|
||||
{
|
||||
case STS_DARK:
|
||||
STS_Lamp_Bar_Set_RGB_Color(0x0, 0x0, 0x0);
|
||||
|
|
|
@ -610,34 +610,25 @@ void STS_Combined_Status_Processing(void)
|
|||
|
||||
if ((last_lamp_bar_color != sts_status_color))
|
||||
{
|
||||
sts_lamp_bar_color = ((sts_service_mask == STS_SERVICE_MASK_L0)? sts_status_color:STS_DARK);
|
||||
sts_lamp_bar_color = sts_status_color;
|
||||
|
||||
STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, luminance_level);
|
||||
|
||||
if ((sts_service_mask == STS_SERVICE_MASK_L0) || (sts_lamp_bar_color == STS_DARK))
|
||||
{
|
||||
// STS_WS2812B_Refresh();
|
||||
}
|
||||
STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, luminance_level);
|
||||
|
||||
last_lamp_bar_color = sts_lamp_bar_color;
|
||||
}
|
||||
}
|
||||
|
||||
//STS_Lamp_Bar_Refresh();
|
||||
#if 1
|
||||
|
||||
if ((sts_rss_result_changed_flag)|| (sts_reed_hall_changed_flag)|| (sts_reed_hall_changed_flag))
|
||||
{
|
||||
|
||||
//sts_rss_result_changed_flag =0;
|
||||
//sts_reed_hall_changed_flag =0;
|
||||
//sts_tof_result_changed_flag =0;
|
||||
#ifdef STS_M1
|
||||
sts_water_leakage_changed_flag=0;
|
||||
#endif
|
||||
sensor_data_ready = 1;
|
||||
//STS_PRESENCE_SENSOR_Prepare_Send_Data();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -684,7 +675,7 @@ void STS_PRESENCE_SENSOR_NVM_CFG_SIMPLE(void)
|
|||
|
||||
void STS_PRESENCE_SENSOR_Init_Send_Data(void)
|
||||
{
|
||||
sts_o7_sensorData.lamp_bar_color = STS_GREEN;
|
||||
//sts_o7_sensorData.lamp_bar_color = STS_GREEN;
|
||||
sts_o7_sensorData.workmode = sts_work_mode; //STS_DUAL_MODE;
|
||||
|
||||
sts_o7_sensorData.state_sensor1_on_off = 0x0;
|
||||
|
@ -767,7 +758,8 @@ void STS_PRESENCE_SENSOR_Prepare_Send_Data(STS_OO_SensorStatusDataTypeDef *senso
|
|||
|
||||
// Fall detection and duration, confirmation duration
|
||||
sensor_data->fall_state = sts_fall_rising_detected_result;
|
||||
if (sts_fall_rising_detected_result == STS_PRESENCE_FALL)
|
||||
if ((sts_fall_rising_detected_result == STS_PRESENCE_FALL)||
|
||||
(sts_fall_rising_detected_result == STS_PRESENCE_LAYDOWN))
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\r\n......FALL RISING DETECTION RESULT: %25s \r\n",
|
||||
(char*)sts_presence_fall_detection_message[sts_fall_rising_detected_result] );
|
||||
|
@ -808,7 +800,7 @@ void STS_PRESENCE_SENSOR_Init(void)
|
|||
APP_LOG(TS_ON, VLEVEL_M, "##### YunHorn SmarToilets(r) Presence Sensor Started\r\n");
|
||||
|
||||
sts_o7_sensorData.workmode = (uint8_t)sts_work_mode; //STS_DUAL_MODE;
|
||||
sts_o7_sensorData.lamp_bar_color = (uint8_t)STS_GREEN;
|
||||
//sts_o7_sensorData.lamp_bar_color = (uint8_t)STS_GREEN;
|
||||
sts_o7_sensorData.battery_Pct = 99;
|
||||
sts_o7_sensorData.dutycycletimelevel = 1;
|
||||
sts_o7_sensorData.event_sensor1_start_time = 0;
|
||||
|
|
|
@ -1124,22 +1124,28 @@ static void OnYunhornSTSLampBarColorTimerEvent(void *context)
|
|||
{
|
||||
if (last_sts_lamp_bar_color != sts_lamp_bar_color)
|
||||
{
|
||||
|
||||
__disable_irq();
|
||||
STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, DEFAULT_LUMINANCE_LEVEL);
|
||||
STS_WS2812B_Refresh();
|
||||
__enable_irq();
|
||||
//STS_WS2812B_Refresh();
|
||||
last_sts_lamp_bar_color = sts_lamp_bar_color;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (r_b)
|
||||
{
|
||||
|
||||
__disable_irq();
|
||||
STS_Lamp_Bar_Set_STS_RGB_Color(high4, DEFAULT_LUMINANCE_LEVEL);
|
||||
STS_WS2812B_Refresh();
|
||||
__enable_irq();
|
||||
last_sts_lamp_bar_color = high4;
|
||||
//STS_WS2812B_Refresh();
|
||||
}
|
||||
else {
|
||||
__disable_irq();
|
||||
STS_Lamp_Bar_Set_STS_RGB_Color(low4, DEFAULT_LUMINANCE_LEVEL);
|
||||
STS_WS2812B_Refresh();
|
||||
__enable_irq();
|
||||
last_sts_lamp_bar_color = low4;
|
||||
//STS_WS2812B_Refresh();
|
||||
}
|
||||
|
||||
r_b = !r_b;
|
||||
|
@ -1257,19 +1263,28 @@ static void OnYunhornSTSDurationCheckTimerEvent(void *context)
|
|||
sts_o7_sensorData.no_movement_duration =0;
|
||||
break;
|
||||
case STS_PRESENCE_FALL:
|
||||
// sts_fall_confirm_threshold_in_10sec
|
||||
sts_o7_sensorData.event_sensor3_fall_duration = current_time.Seconds - sts_o7_sensorData.event_sensor3_fall_start_time;
|
||||
if (sts_o7_sensorData.event_sensor3_fall_duration > 10*sts_cfg_nvm.fall_confirm_threshold_in_10sec)
|
||||
{
|
||||
{
|
||||
//sts_o7_sensorData.occupancy_over_stay_state = 1;
|
||||
sts_o7_sensorData.fall_state = sts_fall_rising_detected_result;
|
||||
sts_o7_sensorData.fall_laydown_duration =sts_o7_sensorData.event_sensor3_fall_duration;
|
||||
over_threshold = TRUE;
|
||||
}
|
||||
} else { // still laydown, but not over fall down confirmation threshold
|
||||
sts_o7_sensorData.fall_state = STS_PRESENCE_LAYDOWN;
|
||||
sts_o7_sensorData.fall_laydown_duration =sts_o7_sensorData.event_sensor3_fall_duration;
|
||||
over_threshold = FALSE;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case STS_PRESENCE_RISING:
|
||||
over_threshold = FALSE;
|
||||
break;
|
||||
|
||||
case STS_PRESENCE_LAYDOWN:
|
||||
|
||||
break;
|
||||
|
||||
case STS_PRESENCE_UNCONSCIOUS:
|
||||
|
@ -1296,8 +1311,14 @@ static void OnYunhornSTSDurationCheckTimerEvent(void *context)
|
|||
|
||||
if (over_threshold == TRUE) {
|
||||
sensor_data_ready = 1;
|
||||
sts_status_color = STS_RED_DARK;
|
||||
sts_lamp_bar_color = STS_RED_DARK; //sts_lamp_bar_flashing_color;
|
||||
if (sts_o7_sensorData.fall_state == STS_PRESENCE_LAYDOWN)
|
||||
{
|
||||
sts_status_color = sts_lamp_bar_flashing_color; //STS_RED_BLUE;
|
||||
sts_lamp_bar_color = sts_lamp_bar_flashing_color; //STS_RED_BLUE;
|
||||
} else {
|
||||
sts_status_color = STS_RED_DARK;
|
||||
sts_lamp_bar_color = STS_RED_DARK; //sts_lamp_bar_flashing_color;
|
||||
}
|
||||
SendTxData();
|
||||
over_threshold = FALSE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue