refine lamp bar color change. not perfect yet.

This commit is contained in:
Yunhorn 2024-05-31 18:22:38 +08:00
parent 08fa70857e
commit d33f9b7904
5 changed files with 75 additions and 59 deletions

View File

@ -29,7 +29,7 @@ extern "C" {
#define DEFAULT_SATURATION 50 // 0 - 100 SSaturation, 0~100 #define DEFAULT_SATURATION 50 // 0 - 100 SSaturation, 0~100
#define DEFAULT_BRIGHTNESS 50 // 0 - 100 VValue of lightness, 0~100 #define DEFAULT_BRIGHTNESS 50 // 0 - 100 VValue of lightness, 0~100
#define DEFAULT_LUMINANCE_LEVEL (20)
#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
@ -72,7 +72,7 @@ enum sts_oo_work_mode {
//void STS_Lamp_Bar_All(uint8_t lamp_color, uint8_t luminance_level); //void STS_Lamp_Bar_All(uint8_t lamp_color, uint8_t luminance_level);
void STS_Lamp_Bar_Set_Color(uint8_t red, uint8_t green, uint8_t blue ); void STS_Lamp_Bar_Set_Color(uint8_t red, uint8_t green, uint8_t blue );
void STS_Lamp_Bar_Set_RGB(uint8_t red, uint8_t green, uint8_t blue); void STS_Lamp_Bar_Set_RGB(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);
void STS_Lamp_Bar_Init(void); void STS_Lamp_Bar_Init(void);
void STS_Lamp_Bar_Full_Color_Gradient(void); void STS_Lamp_Bar_Full_Color_Gradient(void);
void STS_WS2812B_Refresh(void); void STS_WS2812B_Refresh(void);

View File

@ -97,12 +97,12 @@ int main(void)
MX_TIM1_Init(); MX_TIM1_Init();
MX_SPI1_Init(); MX_SPI1_Init();
/* USER CODE END SysInit */ /* USER CODE END SysInit */
/* Initialize all configured peripherals */ /* Initialize all configured peripherals */
LED1_ON; LED1_ON;
MX_LoRaWAN_Init(); MX_LoRaWAN_Init();
//STS_Lamp_Bar_Self_Test_Simple(); STS_Lamp_Bar_Self_Test();
/* USER CODE BEGIN 2 */ /* USER CODE BEGIN 2 */

View File

@ -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 (20)
#define RESET_PULSE (10) //(80) TO FIX DARK_COLOR AND SM2 #define RESET_PULSE (10) //(80) TO FIX DARK_COLOR AND SM2
@ -95,14 +95,14 @@ void STS_Lamp_Bar_Set_Dark(void)
{ {
STS_WS2812B_Set_RGB(0x00,0x00,0x00,i); STS_WS2812B_Set_RGB(0x00,0x00,0x00,i);
} }
//STS_WS2812B_Refresh(); STS_WS2812B_Refresh();
} }
void STS_WS2812B_Refresh(void) 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)
@ -130,15 +130,16 @@ void STS_Lamp_Bar_Scoller(uint8_t color, uint8_t luminance_level)
{ {
//if (sts_service_mask < STS_SERVICE_MASK_L1) //if (sts_service_mask < STS_SERVICE_MASK_L1)
// STS_WS2812B_Refresh(); // STS_WS2812B_Refresh();
HAL_Delay(60); 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]*luminance_level,color_rgb[color][1]*luminance_level, color_rgb[color][2]*luminance_level, i);
} }
} }
HAL_Delay(10); //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();
//} //}
} }
@ -187,8 +188,8 @@ void STS_Lamp_Bar_Refresh(void)
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 luminance_level)
{ {
uint8_t lum = luminance_level; 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)
{ {
case STS_DARK: case STS_DARK:
@ -216,11 +217,11 @@ void STS_Lamp_Bar_Set_STS_RGB_Color(uint8_t sts_lamp_color, uint8_t luminance_le
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;
} }
} }
@ -408,7 +409,7 @@ void STS_Combined_Status_Processing(void)
} }
} }
STS_Lamp_Bar_Refresh(); //STS_Lamp_Bar_Refresh();
#if 1 #if 1
//if ((sts_rss_result_changed_flag)|| (sts_reed_hall_changed_flag) || (sts_tof_result_changed_flag) || (sts_water_leakage_changed_flag)) //if ((sts_rss_result_changed_flag)|| (sts_reed_hall_changed_flag) || (sts_tof_result_changed_flag) || (sts_water_leakage_changed_flag))
{ {
@ -434,7 +435,7 @@ 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=10; uint8_t color=0, luminance_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++)
{ {
@ -450,14 +451,14 @@ void STS_Lamp_Bar_Self_Test_Simple(void)
} }
void STS_Lamp_Bar_Self_Test(void) void STS_Lamp_Bar_Self_Test(void)
{ {
uint8_t color=0, luminance_level=10; uint8_t color=0, luminance_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");
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");
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, luminance_level);
} }
@ -471,7 +472,7 @@ void STS_Lamp_Bar_Self_Test(void)
{ {
STS_Lamp_Bar_Set_STS_RGB_Color(STS_GREEN, luminance_level); STS_Lamp_Bar_Set_STS_RGB_Color(STS_GREEN, luminance_level);
} }
STS_Lamp_Bar_Set_Dark();
} }
void sts_rgb_unit_test(void) void sts_rgb_unit_test(void)

View File

@ -235,7 +235,7 @@ void STS_YunhornSTSEventP1_Process(void)
void STS_YunhornSTSEventP2_Process(void) void STS_YunhornSTSEventP2_Process(void)
{ {
STS_Lamp_Bar_Refresh(); //TODO XXX eliminate refresh every second.... try //STS_Lamp_Bar_Refresh(); //TODO XXX eliminate refresh every second.... try
if ((sts_work_mode >= STS_RSS_MODE) && (sts_work_mode <= STS_TOF_RSS_MODE)) if ((sts_work_mode >= STS_RSS_MODE) && (sts_work_mode <= STS_TOF_RSS_MODE))
{ {
STS_RSS_Smart_Presence_Detection(); STS_RSS_Smart_Presence_Detection();
@ -294,7 +294,7 @@ void STS_RSS_Smart_Presence_Detection(void)
*/ */
void STS_YunhornSTSEventP3_Process(void) void STS_YunhornSTSEventP3_Process(void)
{ {
#if (defined(YUNHORN_STS_O6_ENABLED) && defined(USE_ACCONEER_A111)) #if (defined(STS_O6) ||defined(STS_O7))
if (STS_Reed_Hall_State == STS_Status_Door_Open) if (STS_Reed_Hall_State == STS_Status_Door_Open)
{ {
sts_lamp_bar_color =STS_GREEN; sts_lamp_bar_color =STS_GREEN;
@ -532,18 +532,15 @@ void STS_PRESENCE_SENSOR_Prepare_Send_Data(STS_OO_SensorStatusDataTypeDef *senso
sensor_data->state_sensor2_on_off = sts_rss_result; sensor_data->state_sensor2_on_off = sts_rss_result;
sensor_data->state_sensor3_on_off = HALL2_STATE;//sts_hall2_read; //sts_emergency_button_pushed; //sts_hall2_read sensor_data->state_sensor3_on_off = HALL2_STATE;//sts_hall2_read; //sts_emergency_button_pushed; //sts_hall2_read
sensor_data->state_sensor4_on_off = sts_rss_2nd_result; sensor_data->state_sensor4_on_off = sts_rss_2nd_result;
APP_LOG(TS_OFF, VLEVEL_M, "\r\nPrepare Upload Message............\r\n");
if (sts_rss_result == STS_RESULT_MOTION) if (sts_rss_result == STS_RESULT_MOTION)
{ {
APP_LOG(TS_OFF, VLEVEL_M, "\r\n......STS_RESULT MOTION............\r\n");
sensor_data->rss_presence_distance = (uint16_t)(sts_presence_rss_distance)&0xFFFF; sensor_data->rss_presence_distance = (uint16_t)(sts_presence_rss_distance)&0xFFFF;
sensor_data->rss_presence_score = (uint16_t)(sts_presence_rss_score)&0xFFFF; sensor_data->rss_presence_score = (uint16_t)(sts_presence_rss_score)&0xFFFF;
// uint8_t sts_unconcious_state; // uint8_t sts_unconcious_state;
// uint16_t sts_unconcious_threshold, sts_unconcious_threshold_duration; // uint16_t sts_unconcious_threshold, sts_unconcious_threshold_duration;
} else { } else {
APP_LOG(TS_OFF, VLEVEL_M, "\r\n......STS_NO MOTION............\r\n");
sensor_data->rss_presence_distance = 0x0; sensor_data->rss_presence_distance = 0x0;
sensor_data->rss_presence_score = 0x0; sensor_data->rss_presence_score = 0x0;
} }
@ -552,7 +549,7 @@ void STS_PRESENCE_SENSOR_Prepare_Send_Data(STS_OO_SensorStatusDataTypeDef *senso
sensor_data->fall_state = sts_fall_rising_detected_result; sensor_data->fall_state = sts_fall_rising_detected_result;
if (sts_fall_rising_detected_result != STS_PRESENCE_NONE) if (sts_fall_rising_detected_result != STS_PRESENCE_NONE)
{ {
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] ); 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] );
sensor_data->fall_speed = (uint8_t)sts_fall_rising_pattern_factor1; sensor_data->fall_speed = (uint8_t)sts_fall_rising_pattern_factor1;
sensor_data->fall_gravity = (uint8_t)sts_roc_acc_standard_variance; sensor_data->fall_gravity = (uint8_t)sts_roc_acc_standard_variance;
} }
@ -575,7 +572,7 @@ void STS_PRESENCE_SENSOR_Prepare_Send_Data(STS_OO_SensorStatusDataTypeDef *senso
sts_status_color = STS_RED_BLUE; sts_status_color = STS_RED_BLUE;
sts_lamp_bar_color = STS_RED_BLUE; sts_lamp_bar_color = STS_RED_BLUE;
STS_Lamp_Bar_Refresh(); //STS_Lamp_Bar_Refresh();
} }
}// else }// else
//{ //{

View File

@ -67,6 +67,7 @@ volatile uint8_t mems_int1_detected = 0;
volatile uint8_t upload_message_timer=0; volatile uint8_t upload_message_timer=0;
volatile uint8_t heart_beat_timer =0; volatile uint8_t heart_beat_timer =0;
uint8_t outbuf[128]={0x0}; uint8_t outbuf[128]={0x0};
volatile static bool r_b=true;
volatile sts_cfg_nvm_t sts_cfg_nvm = { volatile sts_cfg_nvm_t sts_cfg_nvm = {
sts_mtmcode1, sts_mtmcode1,
sts_mtmcode2, sts_mtmcode2,
@ -348,6 +349,12 @@ static void OnRxTimerLedEvent(void *context);
*/ */
static void OnJoinTimerLedEvent(void *context); static void OnJoinTimerLedEvent(void *context);
/**
* @brief STS Lamp Bar timer callback function
* @param context ptr of Lamp Bar LED context
*/
static void OnYunhornSTSLampBarColorTimerEvent(void *context);
/** /**
* @brief Yunhorn STS Occupancy RSS WakeUP timer callback function * @brief Yunhorn STS Occupancy RSS WakeUP timer callback function
* @param context ptr of STS RSS WakeUp context * @param context ptr of STS RSS WakeUp context
@ -479,6 +486,12 @@ static UTIL_TIMER_Object_t RxLedTimer;
*/ */
static UTIL_TIMER_Object_t JoinLedTimer; static UTIL_TIMER_Object_t JoinLedTimer;
/**
* @brief Timer to handle the Yunhorn STS Lamp Bar Color Led to toggle
*/
static UTIL_TIMER_Object_t STSLampBarColorTimer;
/** /**
* @brief Timer to handle the YunHorn STS RSS WakeUP Checking * @brief Timer to handle the YunHorn STS RSS WakeUP Checking
*/ */
@ -546,6 +559,7 @@ void LoRaWAN_Init(void)
UTIL_TIMER_Create(&TxLedTimer, LED_PERIOD_TIME, UTIL_TIMER_ONESHOT, OnTxTimerLedEvent, NULL); UTIL_TIMER_Create(&TxLedTimer, LED_PERIOD_TIME, UTIL_TIMER_ONESHOT, OnTxTimerLedEvent, NULL);
UTIL_TIMER_Create(&RxLedTimer, LED_PERIOD_TIME, UTIL_TIMER_ONESHOT, OnRxTimerLedEvent, NULL); 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(&JoinLedTimer, LED_PERIOD_TIME, UTIL_TIMER_PERIODIC, OnJoinTimerLedEvent, NULL);
UTIL_TIMER_Create(&STSLampBarColorTimer, LED_PERIOD_TIME, UTIL_TIMER_PERIODIC, OnYunhornSTSLampBarColorTimerEvent, NULL);
if (FLASH_IF_Init(NULL) != FLASH_IF_OK) if (FLASH_IF_Init(NULL) != FLASH_IF_OK)
{ {
@ -572,7 +586,7 @@ void LoRaWAN_Init(void)
/* USER CODE BEGIN LoRaWAN_Init_2 */ /* USER CODE BEGIN LoRaWAN_Init_2 */
UTIL_TIMER_Start(&JoinLedTimer); UTIL_TIMER_Start(&JoinLedTimer);
//UTIL_TIMER_Start(&STSLampBarColorTimer);
/* USER CODE END LoRaWAN_Init_2 */ /* USER CODE END LoRaWAN_Init_2 */
LmHandlerJoin(ActivationType, ForceRejoin); LmHandlerJoin(ActivationType, ForceRejoin);
@ -825,14 +839,10 @@ static void SendTxData(void)
AppData.Port = sts_sendhtbtport; //LORAWAN_USER_APP_PORT+1; AppData.Port = sts_sendhtbtport; //LORAWAN_USER_APP_PORT+1;
AppData.Buffer[i++]= AppLedStateOn|0x80; AppData.Buffer[i++]= AppLedStateOn|0x80;
AppData.Buffer[i++] = (uint8_t)(99*batteryLevel/254)&0xff; //#05 AppData.Buffer[i++] = (uint8_t)(99*batteryLevel/254)&0xff; //#05
APP_LOG(TS_OFF, VLEVEL_M, "\r\n\n\n SendTxData Enter Heart-Beat \r\n\n");
} else if ((sensor_data_ready!= 0U)) //sensor_data_ready for manual push button-1 trigger) } else if ((sensor_data_ready!= 0U)) //sensor_data_ready for manual push button-1 trigger)
{ {
APP_LOG(TS_OFF, VLEVEL_M, "\r\n\n\n SendTxData Enter Sensor Data Ready \r\n\n");
sensor_data_ready =0; sensor_data_ready =0;
AppData.Buffer[i++] = AppLedStateOn|0x80; // ************ MUST KEEP IT HERE, NON-ZERO ****** AppData.Buffer[i++] = AppLedStateOn|0x80; // ************ MUST KEEP IT HERE, NON-ZERO ******
AppData.Buffer[i++] = (uint8_t)(sensorData.lamp_bar_color)&0xff; //01 AppData.Buffer[i++] = (uint8_t)(sensorData.lamp_bar_color)&0xff; //01
@ -842,41 +852,30 @@ static void SendTxData(void)
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor2_on_off)&0xff; //04 Sensor head #2 status AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor2_on_off)&0xff; //04 Sensor head #2 status
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor3_on_off)&0xff; //05 Sensor head #3 status AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor3_on_off)&0xff; //05 Sensor head #3 status
AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor4_on_off)&0xff; //06 Sensor head #4 status AppData.Buffer[i++] = (uint8_t)(sensorData.state_sensor4_on_off)&0xff; //06 Sensor head #4 status
#if 1
AppData.Buffer[i++] = (uint8_t)(sensorData.rss_presence_distance>>8)&0xff; //07 MSB distance AppData.Buffer[i++] = (uint8_t)(sensorData.rss_presence_distance>>8)&0xff; //07 MSB distance
AppData.Buffer[i++] = (uint8_t)(sensorData.rss_presence_distance)&0xff; //08 LSB distance AppData.Buffer[i++] = (uint8_t)(sensorData.rss_presence_distance)&0xff; //08 LSB distance
AppData.Buffer[i++] = (uint8_t)(sensorData.rss_presence_score>>8)&0xff; //09 MSB score AppData.Buffer[i++] = (uint8_t)(sensorData.rss_presence_score>>8)&0xff; //09 MSB score
AppData.Buffer[i++] = (uint8_t)(sensorData.rss_presence_score)&0xff; //10 LSB score AppData.Buffer[i++] = (uint8_t)(sensorData.rss_presence_score)&0xff; //10 LSB score
#endif
#if 1
AppData.Buffer[i++] = (uint8_t)(sensorData.unconcious_state)&0xff; //11 unconcious state detected or not AppData.Buffer[i++] = (uint8_t)(sensorData.unconcious_state)&0xff; //11 unconcious state detected or not
AppData.Buffer[i++] = (uint8_t)(sensorData.fall_state)&0xff; //12 fall detected or not AppData.Buffer[i++] = (uint8_t)(sensorData.fall_state)&0xff; //12 fall detected or not
AppData.Buffer[i++] = (uint8_t)(sensorData.over_stay_state)&0xff; //13 occupancy over time or not AppData.Buffer[i++] = (uint8_t)(sensorData.over_stay_state)&0xff; //13 occupancy over time or not
AppData.Buffer[i++] = (uint8_t)(sensorData.over_stay_duration>>8)&0xff; //14 occupancy over time or not AppData.Buffer[i++] = (uint8_t)(sensorData.over_stay_duration>>8)&0xff; //14 occupancy over time or not
AppData.Buffer[i++] = (uint8_t)(sensorData.over_stay_duration)&0xff; //15 occupancy over time or not AppData.Buffer[i++] = (uint8_t)(sensorData.over_stay_duration)&0xff; //15 occupancy over time or not
#endif
#if 1
APP_LOG(TS_OFF, VLEVEL_L, APP_LOG(TS_OFF, VLEVEL_L,
"\r\n######| Color | Mode |\r\n######| %4s | %5s |\r\n",(char *)sts_lamp_color_code[sensorData.lamp_bar_color], (char*)sts_work_mode_code[sensorData.workmode]); "\r\n######| Color =| %4s || Mode =| %5s |\r\n",(char *)sts_lamp_color_code[sensorData.lamp_bar_color], (char*)sts_work_mode_code[sensorData.workmode]);
APP_LOG(TS_OFF, VLEVEL_L, APP_LOG(TS_OFF, VLEVEL_L,
"\r\n######| S1-DoorOpen | S2-Motion | S3-No_Emergency | S4 |Distance(mm) | MotionScore| Unconcious | Over_Stay| Fall Detected|" "\r\n######| S1-DoorOpen | S2-Motion | S3-No_Emergency | S4 |Distance(mm) | MotionScore| Unconcious | Over_Stay | Fall Detected|"
"\r\n######| %1d | %1d | %1d | %1d | %04d | %04d | %1d | %1d | %1d |\r\n", "\r\n######| %1d | %1d | %1d | %1d | %04d | %04d | %1d | %1d | %1d |\r\n",
sensorData.state_sensor1_on_off, sensorData.state_sensor2_on_off,sensorData.state_sensor3_on_off, sensorData.state_sensor4_on_off, sensorData.state_sensor1_on_off, sensorData.state_sensor2_on_off,sensorData.state_sensor3_on_off, sensorData.state_sensor4_on_off,
(uint16_t)sensorData.rss_presence_distance,(uint16_t)sensorData.rss_presence_score, (uint16_t)sensorData.rss_presence_distance,(uint16_t)sensorData.rss_presence_score,
sensorData.unconcious_state, sensorData.unconcious_duration, sensorData.fall_state ); sensorData.unconcious_state, sensorData.unconcious_duration, sensorData.fall_state );
#endif
} }
if ((LmHandlerParams.ActiveRegion == LORAMAC_REGION_US915) || (LmHandlerParams.ActiveRegion == LORAMAC_REGION_AU915)
|| (LmHandlerParams.ActiveRegion == LORAMAC_REGION_AS923))
{
// ORIGIN CODE OF 4 ZERO APPENDED
}
AppData.BufferSize = (sts_service_mask > STS_SERVICE_MASK_L1? 0:i); AppData.BufferSize = (sts_service_mask > STS_SERVICE_MASK_L1? 0:i);
//AppData.BufferSize = (sts_service_mask > STS_SERVICE_MASK_L1? 0:i);
APP_LOG(TS_OFF, VLEVEL_L, "\r\n\n\n**AppData.PORT =%3d **AppData.BufferSize=%3d \r\n**Count Size=%3d\r\n", AppData.Port, AppData.BufferSize, i);
//AppData.BufferSize = (sts_service_mask > STS_SERVICE_MASK_L1? 0:i);
if ((JoinLedTimer.IsRunning) && (LmHandlerJoinStatus() == LORAMAC_HANDLER_SET)) if ((JoinLedTimer.IsRunning) && (LmHandlerJoinStatus() == LORAMAC_HANDLER_SET))
{ {
@ -884,15 +883,12 @@ static void SendTxData(void)
#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
LED1_ON;
} }
status = LmHandlerSend(&AppData, LmHandlerParams.IsTxConfirmed, false); status = LmHandlerSend(&AppData, LmHandlerParams.IsTxConfirmed, false);
if (LORAMAC_HANDLER_SUCCESS == status) if (LORAMAC_HANDLER_SUCCESS == status)
{ {
LED1_ON;
APP_LOG(TS_ON, VLEVEL_L, "SEND REQUEST\r\n"); APP_LOG(TS_ON, VLEVEL_L, "SEND REQUEST\r\n");
LED1_OFF;
} }
else if (LORAMAC_HANDLER_DUTYCYCLE_RESTRICTED == status) else if (LORAMAC_HANDLER_DUTYCYCLE_RESTRICTED == status)
{ {
@ -962,13 +958,34 @@ static void OnJoinTimerLedEvent(void *context)
#ifndef STM32WLE5xx #ifndef STM32WLE5xx
HAL_GPIO_TogglePin(LED3_GPIO_Port, LED3_Pin); /* LED_RED */ HAL_GPIO_TogglePin(LED3_GPIO_Port, LED3_Pin); /* LED_RED */
#endif #endif
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))
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP3), CFG_SEQ_Prio_0); UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP3), CFG_SEQ_Prio_0);
} }
/* USER CODE END PrFD_LedEvents */ /* USER CODE END PrFD_LedEvents */
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))
{
if (sts_lamp_bar_color == STS_RED_BLUE) {
if (r_b)
STS_Lamp_Bar_Set_STS_RGB_Color(STS_RED, lum);
else
STS_Lamp_Bar_Set_STS_RGB_Color(STS_BLUE, lum);
r_b = !r_b;
} else {
STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, lum);
}
STS_Lamp_Bar_Refresh();
}
}
static void OnTxData(LmHandlerTxParams_t *params) static void OnTxData(LmHandlerTxParams_t *params)
@ -985,17 +1002,17 @@ static void OnTxData(LmHandlerTxParams_t *params)
UTIL_TIMER_Start(&TxLedTimer); UTIL_TIMER_Start(&TxLedTimer);
APP_LOG(TS_OFF, VLEVEL_M, "\r\n###### ========== MCPS-Confirm =============\r\n"); APP_LOG(TS_OFF, VLEVEL_M, "\r\n###### ========== MCPS-Confirm =============\r\n");
APP_LOG(TS_OFF, VLEVEL_M, "###### U/L FRAME:%04d | PORT:%d | DR:%d | PWR:%d", params->UplinkCounter, APP_LOG(TS_OFF, VLEVEL_H, "###### U/L FRAME:%04d | PORT:%d | DR:%d | PWR:%d", params->UplinkCounter,
params->AppData.Port, params->Datarate, params->TxPower); params->AppData.Port, params->Datarate, params->TxPower);
APP_LOG(TS_OFF, VLEVEL_M, " | MSG TYPE:"); APP_LOG(TS_OFF, VLEVEL_H, " | MSG TYPE:");
if (params->MsgType == LORAMAC_HANDLER_CONFIRMED_MSG) if (params->MsgType == LORAMAC_HANDLER_CONFIRMED_MSG)
{ {
APP_LOG(TS_OFF, VLEVEL_M, "CONFIRMED [%s]\r\n", (params->AckReceived != 0) ? "ACK" : "NACK"); APP_LOG(TS_OFF, VLEVEL_H, "CONFIRMED [%s]\r\n", (params->AckReceived != 0) ? "ACK" : "NACK");
} }
else else
{ {
APP_LOG(TS_OFF, VLEVEL_M, "UNCONFIRMED\r\n"); APP_LOG(TS_OFF, VLEVEL_H, "UNCONFIRMED\r\n");
} }
} }
} }
@ -1038,6 +1055,7 @@ 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);
UTIL_TIMER_Start(&STSLampBarColorTimer);
/* USER CODE END OnJoinRequest_1 */ /* USER CODE END OnJoinRequest_1 */
} }