wip 03 bad

This commit is contained in:
Yunhorn 2025-04-01 20:04:35 +08:00
parent 43ce7b01cb
commit f23a02a80c
6 changed files with 17 additions and 17 deletions

View File

@ -352,9 +352,9 @@ void Error_Handler(void);
/*
* STM32WL55, STM32WLE5 Clock=48Mhz 48,000,000/800khz = 60
*/
#define STS_LAMP_BAR_PWM_TIM_PERIOD (240 - 1)
#define STS_LAMP_BAR_PWM_TIM_PERIOD (60 - 1)
#define STS_LAMP_BAR_HTIM htim1
//#define STS_LAMP_BAR_LED_NUM (14) //60 for 46CM length LED strip
#define STS_LAMP_BAR_LED_NUM (18) //60 for 46CM length LED strip
#define WSDATA_PORT_PIN_PA8
//#define WSDATA_PORT_PIN_PA9

View File

@ -30,23 +30,23 @@
#define ONE_PULSE (24) //36
#define ZERO_PULSE (12)
#define STS_LAMP_BAR_LED_NUM (27) //60 for 46CM length LED strip
//#define STS_LAMP_BAR_LED_NUM (27) //60 for 46CM length LED strip
#define LED_DATA_LEN 24
#define WS2812B_DATA_LEN (LED_DATA_LEN * (STS_LAMP_BAR_LED_NUM))
#define RESET_PULSE (16) //(80) TO FIX DARK_COLOR AND SM2
typedef struct ws2812b_e {
//uint16_t head[3];
uint16_t GRB[WS2812B_DATA_LEN+RESET_PULSE];
uint16_t tail[RESET_PULSE];
uint8_t head[3];
uint8_t GRB[WS2812B_DATA_LEN+RESET_PULSE];
uint8_t tail[RESET_PULSE];
} WS2812B_FrameTypeDef;
volatile WS2812B_FrameTypeDef rgb_buf = {
// .head[0] = 10,
// .head[1] = 10,
// .head[2] = 10,
//.tail = 00
.head[0] = 0,
.head[1] = 0,
.head[2] = 0,
.tail = {00}
};
uint8_t color_rgb[8][3] = { //STS_COLOR R G B MAPPING TABLE
@ -101,7 +101,7 @@ void STS_WS2812B_Refresh(void)
{
HAL_TIM_PWM_Start_DMA(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL, (uint32_t *)&rgb_buf, (WS2812B_DATA_LEN+RESET_PULSE));
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)
@ -127,7 +127,7 @@ void STS_Lamp_Bar_Scoller(uint8_t color, uint8_t lum_level)
for(uint8_t i = 0; i<STS_LAMP_BAR_LED_NUM; i++)
{
HAL_Delay(30); //MAKE THIS LESS THAN 10 NOT TO BLOCK JOIN THE LORAWAN
HAL_Delay(10); //MAKE THIS LESS THAN 10 NOT TO BLOCK JOIN THE LORAWAN
STS_WS2812B_Set_RGB(color_rgb[color][0]*lum_level,color_rgb[color][1]*lum_level, color_rgb[color][2]*lum_level, i);
STS_WS2812B_Refresh();
}
@ -162,8 +162,8 @@ void STS_Lamp_Bar_Set_RGB_Color(uint8_t red, uint8_t green, uint8_t blue )
bits++;
}
}
for (i=0; i < RESET_PULSE; i++)
rgb_buf.tail[i] = 0;
//for (i=0; i < RESET_PULSE; i++)
//rgb_buf.tail[i] = 0;
STS_WS2812B_Refresh();
}

View File

@ -131,9 +131,9 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
hdma_tim1_ch1.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_tim1_ch1.Init.MemInc = DMA_MINC_ENABLE;
hdma_tim1_ch1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
hdma_tim1_ch1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; //DMA_MDATAALIGN_BYTE; //DMA_MDATAALIGN_HALFWORD; //DMA_MDATAALIGN_HALFWORD;
hdma_tim1_ch1.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; //DMA_MDATAALIGN_BYTE; //DMA_MDATAALIGN_HALFWORD; //DMA_MDATAALIGN_HALFWORD;
hdma_tim1_ch1.Init.Mode = DMA_CIRCULAR;
hdma_tim1_ch1.Init.Priority = DMA_PRIORITY_LOW; //was HIGH
hdma_tim1_ch1.Init.Priority = DMA_PRIORITY_HIGH; //was HIGH
if (HAL_DMA_Init(&hdma_tim1_ch1) != HAL_OK)
{

View File

@ -503,7 +503,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, LED_PERIOD_TIME, UTIL_TIMER_ONESHOT, OnYunhornSTSLampBarColorTimerEvent, NULL);
UTIL_TIMER_Create(&STSDurationCheckTimer, 5000, UTIL_TIMER_PERIODIC, OnYunhornSTSDurationCheckTimerEvent, NULL);
UTIL_TIMER_Create(&STSDurationCheckTimer, 10000, UTIL_TIMER_PERIODIC, OnYunhornSTSDurationCheckTimerEvent, NULL);
if (FLASH_IF_Init(NULL) != FLASH_IF_OK)
{