diff --git a/Core/Inc/main.h b/Core/Inc/main.h
index 2e0c2bf..978e2aa 100644
--- a/Core/Inc/main.h
+++ b/Core/Inc/main.h
@@ -292,6 +292,28 @@ void Error_Handler(void);
#endif
+#if defined(O1L)
+/*
+ * STM32WL55, STM32WLE5 Clock=48Mhz 48,000,000/800khz = 60
+ */
+#define STS_LAMP_BAR_PWM_TIM_PERIOD (240 - 1)
+#define STS_LAMP_BAR_HTIM htim1
+#define STS_LAMP_BAR_LED_NUM (60) //60 for 46CM length LED strip
+
+#define WSDATA_PORT_PIN_PA8
+//#define WSDATA_PORT_PIN_PA9
+
+#ifdef WSDATA_PORT_PIN_PA8
+#define STS_LAMP_BAR_TIM_CHANNEL TIM_CHANNEL_1
+#define STS_LAMP_BAR_WSDATA_PIN GPIO_PIN_8
+#define STS_LAMP_BAR_WSDATA_PORT GPIOA
+#elif defined(WSDATA_PORT_PIN_PA9)
+#define STS_LAMP_BAR_TIM_CHANNEL TIM_CHANNEL_2
+#define STS_LAMP_BAR_WSDATA_PIN GPIO_PIN_9
+#define STS_LAMP_BAR_WSDATA_PORT GPIOA
+#endif
+#endif
+
/* USER CODE END Private defines */
#ifdef __cplusplus
diff --git a/Core/Inc/stm32wlxx_hal_conf.h b/Core/Inc/stm32wlxx_hal_conf.h
index bae70e9..660926c 100644
--- a/Core/Inc/stm32wlxx_hal_conf.h
+++ b/Core/Inc/stm32wlxx_hal_conf.h
@@ -54,7 +54,7 @@
/*#define HAL_SMBUS_MODULE_ENABLED */
/*#define HAL_SPI_MODULE_ENABLED */
#define HAL_SUBGHZ_MODULE_ENABLED
-/*#define HAL_TIM_MODULE_ENABLED */
+#define HAL_TIM_MODULE_ENABLED
#define HAL_UART_MODULE_ENABLED
/*#define HAL_USART_MODULE_ENABLED */
/*#define HAL_WWDG_MODULE_ENABLED */
diff --git a/Core/Inc/sts_lamp_bar.h b/Core/Inc/sts_lamp_bar.h
index 1942548..89edc9b 100644
--- a/Core/Inc/sts_lamp_bar.h
+++ b/Core/Inc/sts_lamp_bar.h
@@ -64,7 +64,7 @@ enum sts_lamp_color {
STS_REDGREEN=0x45, // RED/GREEN FLASH 'E'
STS_BLUEGREEN=0x46 // BLUE/GREEN FLASH 'F'
};
-
+/*
enum sts_oo_work_mode {
STS_NETWORK_MODE = 0, // 0 NETWORK MODE
STS_WIRED_MODE, // 1 WIRED MODE === WATER LEAKAGE, SOAP CAPACITY SENSOR MODE
@@ -82,6 +82,7 @@ enum sts_oo_work_mode {
STS_OTHER_MODE // ? OTHER MODE
};
+*/
#if defined(STS_O7)||defined(STS_O6)
#define STS_Reed_Hall_State HALL1_STATE
#define STS_Emergency_Button_State HALL2_STATE
diff --git a/Core/Inc/utilities_def.h b/Core/Inc/utilities_def.h
index 16c631e..68b7566 100644
--- a/Core/Inc/utilities_def.h
+++ b/Core/Inc/utilities_def.h
@@ -85,7 +85,7 @@ typedef enum
#if defined(STS_M1)||defined(STS_O6)
CFG_SEQ_Task_YunhornSTSEventP1, /* REEDSWITCH, IO */
#endif
-#if defined(STS_O6)
+#if defined(STS_O6)||defined(O1L)
CFG_SEQ_Task_YunhornSTSEventP2, /* MOTION */
CFG_SEQ_Task_YunhornSTSEventP3, /* LAMP BAR LED */
#endif
diff --git a/Core/Src/dma.c b/Core/Src/dma.c
index 523a960..64afc88 100644
--- a/Core/Src/dma.c
+++ b/Core/Src/dma.c
@@ -59,10 +59,12 @@ void MX_DMA_Init(void)
#endif
#endif
- /* DMA1_Channel5_IRQn interrupt configuration */
-
- // HAL_NVIC_SetPriority(DMA1_Channel5_IRQn, 2, 0);
- // HAL_NVIC_EnableIRQ(DMA1_Channel5_IRQn);
+#ifdef O1L
+ /* TIM1_CH1 */
+ /* DMA1_Channel1_IRQn interrupt configuration */
+ HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0);
+ HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn);
+#endif
// I2C2
/* DMA1_Channel4_IRQn interrupt configuration */
diff --git a/Core/Src/main.c b/Core/Src/main.c
index 90c0892..ea81c05 100644
--- a/Core/Src/main.c
+++ b/Core/Src/main.c
@@ -27,6 +27,7 @@
#include "dma.h"
#include "usart.h"
#include "sys_app.h"
+#include "tim.h"
#ifdef STS_P2
#include "app_tof.h"
#include "app_tof_peoplecount.h"
@@ -34,6 +35,7 @@
#include "app_tof.h"
#elif defined(L8)
#include "app_tof.h"
+#include "sts_lamp_bar.h"
#endif
/* USER CODE END Includes */
@@ -112,7 +114,10 @@ int main(void)
{
MX_I2C2_Init();
MX_DMA_Init();
+ MX_TIM1_Init();
+
MX_LoRaWAN_Init();
+ //STS_Lamp_Bar_Self_Test();
}
diff --git a/Core/Src/stm32wlxx_it.c b/Core/Src/stm32wlxx_it.c
index 6f36a09..bee7986 100644
--- a/Core/Src/stm32wlxx_it.c
+++ b/Core/Src/stm32wlxx_it.c
@@ -65,7 +65,10 @@ extern DMA_HandleTypeDef hdma_i2c2_rx;
extern DMA_HandleTypeDef hdma_i2c2_tx;
extern DMA_HandleTypeDef hdma_usart2_tx;
extern DMA_HandleTypeDef hdma_usart2_rx;
-
+#ifdef O1L
+//extern DMA_HandleTypeDef hdma_tim1_ch2;
+extern DMA_HandleTypeDef hdma_tim1_ch1;
+#endif
/* USER CODE END EV */
/******************************************************************************/
@@ -275,6 +278,25 @@ void EXTI4_IRQHandler(void)
/* USER CODE END EXTI1_IRQn 1 */
}
+#ifdef O1L
+/**
+ * @brief This function handles DMA1 Channel 1 Interrupt.
+ */
+void DMA1_Channel1_IRQHandler(void)
+{
+ /* USER CODE BEGIN DMA1_Channel1_IRQn 0 */
+
+ /* USER CODE END DMA1_Channel1_IRQn 0 */
+ HAL_DMA_IRQHandler(&hdma_tim1_ch1);
+
+ //HAL_DMA_IRQHandler(&hdma_tim1_ch2);
+
+ /* USER CODE BEGIN DMA1_Channel1_IRQn 1 */
+
+ /* USER CODE END DMA1_Channel1_IRQn 1 */
+}
+#endif
+
/* SPI1 */
/**
* @brief This function handles DMA1 Channel 2 Interrupt.
diff --git a/Core/Src/sys_app.c b/Core/Src/sys_app.c
index cbfffe8..19dbe29 100644
--- a/Core/Src/sys_app.c
+++ b/Core/Src/sys_app.c
@@ -37,6 +37,7 @@
#endif
#ifdef L8
#include "app_tof.h"
+#include "sts_lamp_bar.h"
#endif
/* USER CODE END Includes */
@@ -124,6 +125,7 @@ void SystemApp_Init(void)
EnvSensors_Init();
#if defined(L8)
MX_TOF_Init();
+ //STS_Lamp_Bar_Self_Test();
#endif
#if defined(STS_R1D)
MX_TOF_Init();
@@ -131,7 +133,7 @@ void SystemApp_Init(void)
#if defined(STS_P2)
STS_TOF_VL53LX_PeopleCounting_Process_Init();
#endif
-
+ STS_Lamp_Bar_Self_Test();
/*Init low power manager*/
UTIL_LPM_Init();
/* Disable Stand-by mode */
diff --git a/LoRaWAN/App/lora_app.c b/LoRaWAN/App/lora_app.c
index 6c895de..aa81d01 100644
--- a/LoRaWAN/App/lora_app.c
+++ b/LoRaWAN/App/lora_app.c
@@ -40,6 +40,9 @@
#include "app_tof_peoplecount.h"
#include "yunhorn_sts_prd_conf.h"
#include "yunhorn_sts_sensors.h"
+#if defined(STS_O6)||defined(STS_T6)||defined(O1L)
+#include "sts_lamp_bar.h"
+#endif
/* USER CODE END Includes */
/* External variables ---------------------------------------------------------*/
@@ -47,6 +50,8 @@
uint8_t outbuf[128]={0x0};
extern volatile uint8_t sts_ac_code[20];
extern volatile sts_cfg_nvm_t sts_cfg_nvm;
+extern volatile uint8_t sts_work_mode, sts_cloud_netcolor, sts_lamp_bar_color, sts_status_color, luminance_level;
+volatile static bool r_b=true;
extern volatile uint32_t rfac_timer;
extern volatile uint32_t STS_TOFScanPeriod_msec, STS_TxPeriod_sec, STS_HeartBeatTimerPeriod_sec;
volatile uint8_t sts_data_buf[LORAWAN_APP_DATA_BUFFER_MAX_SIZE]={0x0};
@@ -81,7 +86,7 @@ typedef enum TxEventType_e
/**
* LEDs period value of the timer in ms
*/
-#define LED_PERIOD_TIME 500
+#define LED_PERIOD_TIME 800
/**
* Join switch period value of the timer in ms
@@ -364,6 +369,12 @@ static UTIL_TIMER_Object_t YunhornSTSHeartBeatTimer;
* @brief Timer to handle the application Lamp Bar LED Timer refresh
*/
static UTIL_TIMER_Object_t YunhornSTSLampBarColorTimer;
+static UTIL_TIMER_Object_t STSLampBarColorTimer;
+
+/**
+ * @brief Timer to handle the application Duration check Timer
+ */
+static UTIL_TIMER_Object_t STSDurationCheckTimer;
/**
* @brief Tx Timer period
@@ -460,6 +471,8 @@ void LoRaWAN_Init(void)
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(&JoinLedTimer, LED_PERIOD_TIME, UTIL_TIMER_PERIODIC, OnJoinTimerLedEvent, NULL);
+ UTIL_TIMER_Create(&STSLampBarColorTimer, LED_PERIOD_TIME, UTIL_TIMER_ONESHOT, OnYunhornSTSLampBarColorTimerEvent, NULL);
+ UTIL_TIMER_Create(&STSDurationCheckTimer, 20*LED_PERIOD_TIME, UTIL_TIMER_PERIODIC, OnYunhornSTSDurationCheckTimerEvent, NULL);
if (FLASH_IF_Init(NULL) != FLASH_IF_OK)
{
@@ -535,11 +548,17 @@ void LoRaWAN_Init(void)
UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventP4), UTIL_SEQ_RFU, STS_YunhornSTSEventP4_Process);
#endif
+#if defined(STS_T6)||defined(STS_O6)||defined(O1L)
+ UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_YunhornSTSEventP3), UTIL_SEQ_RFU, STS_YunhornSTSEventP3_Process);
+#endif
+
#if defined(STS_P2)||defined(STS_T6)||defined(L8)
UTIL_TIMER_Create(&YunhornSTSWakeUpScanTimer, STS_TOFScanPeriod_msec, UTIL_TIMER_PERIODIC, STS_YunhornSTSEventP5_Process, NULL);
UTIL_TIMER_Start(&YunhornSTSWakeUpScanTimer);
#endif
+ UTIL_TIMER_Start(&STSLampBarColorTimer);
+
//UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, 1000*STS_HeartBeatTimerPeriod_sec, UTIL_TIMER_PERIODIC, OnYunhornSTSHeartBeatTimerEvent, NULL);
// UTIL_TIMER_Create(&YunhornSTSHeartBeatTimer, 1000*STS_HeartBeatTimerPeriod_sec, UTIL_TIMER_ONESHOT, OnYunhornSTSHeartBeatTimerEvent, NULL);
// UTIL_TIMER_Start(&YunhornSTSHeartBeatTimer);
@@ -1386,11 +1405,27 @@ static void OnRestoreContextRequest(void *nvm, uint32_t nvm_size)
*/
static void OnYunhornSTSLampBarColorTimerEvent(void *context)
{
-#ifdef STS_O6
+ uint8_t high4=(sts_lamp_bar_color>>4)&0x0f, low4=sts_lamp_bar_color&0x0f;
+
+ UTIL_TIMER_Stop(&STSLampBarColorTimer);
+
+ if (high4==0)
+ {
+ STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, luminance_level);
+ } else
+ {
+ STS_Lamp_Bar_Set_STS_RGB_Color(r_b?high4:low4, luminance_level);
+ r_b = !r_b;
+ }
+
+ UTIL_TIMER_Start(&STSLampBarColorTimer);
+#if 0
+#if defined(STS_O6)||defined(O1L)
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_YunhornSTSEventP3), CFG_SEQ_Prio_0);
UTIL_TIMER_Start(&YunhornSTSLampBarColorTimer);
#endif
+#endif
}
/**
diff --git a/STM32CubeIDE/.cproject b/STM32CubeIDE/.cproject
index 63a1da2..c37d0ff 100644
--- a/STM32CubeIDE/.cproject
+++ b/STM32CubeIDE/.cproject
@@ -137,6 +137,7 @@