wip improved

This commit is contained in:
Yunhorn 2025-07-25 18:56:22 +08:00
parent 0a8435ada1
commit d9659fd92b
4 changed files with 32 additions and 24 deletions

View File

@ -141,7 +141,7 @@ 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 (120 - 1)
#define STS_LAMP_BAR_HTIM htim1
#define STS_LAMP_BAR_LED_NUM (60) //60 for 46CM length LED strip
#define LED_COUNT 18 // for 30 cm lamp bar

View File

@ -33,7 +33,7 @@
#define LED_DATA_LEN 24
#define WS2812B_DATA_LEN (LED_DATA_LEN * (STS_LAMP_BAR_LED_NUM))
#define RESET_PULSE (24) //(80) TO FIX DARK_COLOR AND SM2
#define RESET_PULSE (150) //(80) TO FIX DARK_COLOR AND SM2
typedef struct ws2812b_e {
@ -132,9 +132,10 @@ void STS_Lamp_Bar_Scoller(uint8_t color, uint8_t lum_level)
{
STS_Lamp_Bar_Set_Dark();
for(uint8_t i = 0; i<STS_LAMP_BAR_LED_NUM; i++)
//for(uint8_t i = 0; i<STS_LAMP_BAR_LED_NUM; i++)
for(uint8_t i = 0; i<LED_COUNT; i++)
{
HAL_Delay(20); //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();
}
@ -179,12 +180,11 @@ void STS_Lamp_Bar_Set_RGB_Color_Flow(void)
static void STS_Lamp_Bar_Set_RGB_Color_FadeIn(uint8_t red, uint8_t green, uint8_t blue, uint8_t start_position, uint8_t fade_length)
{
uint8_t fade_len = fade_length;
for (uint8_t idx = 0; idx < LED_COUNT ; idx++)
{
if (idx >= start_position) {
// the most far tail end, the darker, the most head/first, the brighter
uint8_t rev = idx - fade_len ;
uint8_t rev = idx - fade_len+1;
uint8_t lin = (rev * 0xFF / fade_len);
uint8_t bri = (lin * lin) >> 8;
@ -364,24 +364,30 @@ void STS_Lamp_Bar_Self_Test_Fade(void)
for (color=STS_GREEN; color < STS_COLOR_MAX; color++)
{
lum_level = 10;
do {
lum_level = 250;
//do {
APP_LOG(TS_OFF, VLEVEL_M, "\rFade Out %04d\r", lum_level);
STS_Lamp_Bar_Set_STS_RGB_Color_FadeOut(color, lum_level, LED_COUNT/2);
HAL_Delay(100);
lum_level += 10;
} while (lum_level < 99);
STS_Lamp_Bar_Set_Dark();
HAL_Delay(2000);
//lum_level += 5;
//} while (lum_level < 200);
//STS_Lamp_Bar_Set_Dark();
STS_Lamp_Bar_Refresh();
}
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++)
{
lum_level = 10;
do {
lum_level = 250;
// do {
APP_LOG(TS_OFF, VLEVEL_M, "\rFade In %04d\r", lum_level);
STS_Lamp_Bar_Set_STS_RGB_Color_FadeIn(color, lum_level, LED_COUNT/2);
HAL_Delay(100);
lum_level += 10;
} while (lum_level < 99);
STS_Lamp_Bar_Set_Dark();
HAL_Delay(2000);
//lum_level += 5;
//} while (lum_level < 200);
//STS_Lamp_Bar_Set_Dark();
STS_Lamp_Bar_Refresh();
}
APP_LOG(TS_OFF, VLEVEL_M, "\r\n [#1] RGB Space Fade Out Fade In Testing Finished\r\n");
@ -393,16 +399,18 @@ void STS_Lamp_Bar_Self_Test(void)
uint8_t color=0, lum_level=DEFAULT_LUMINANCE_LEVEL;
APP_LOG(TS_OFF, VLEVEL_H, "\r\n YunHorn STS Indicative Lamp Self Test\r\n");
/*
STS_Lamp_Bar_Self_Test_Simple();
APP_LOG(TS_OFF, VLEVEL_H, "\r\n [#2] Scoller Testing\r\n");
lum_level=50;
for (color = STS_GREEN; color < STS_COLOR_MAX; color++)
{
STS_Lamp_Bar_Scoller(color, lum_level);
//for (lum_level=1; lum_level<250; lum_level+=50)
{
STS_Lamp_Bar_Scoller(color, lum_level);
}
}
*/
STS_Lamp_Bar_Self_Test_Fade();
APP_LOG(TS_OFF, VLEVEL_H, "\r\n [##] YunHorn STS Indicative Lamp Self Test Finished\r\n");
@ -424,7 +432,7 @@ void sts_rgb_unit_test(void)
STS_Lamp_Bar_Set_Dark();
STS_Lamp_Bar_Full_Color_Gradient();
//STS_Lamp_Bar_Full_Color_Gradient();
STS_Lamp_Bar_Self_Test();

View File

@ -129,7 +129,7 @@ volatile sts_cfg_nvm_t sts_cfg_nvm = {
0x6E, //P[18] RSS_CFG_BG_MOTION_NOISE 2025-04-14
0x8C, //P[19] RSS SLIDING WINDOW CFG: 0x08 AS threshold, 0x0C as window size
}, // above 20 bytes
#ifdef ATAL
#if defined(ATAL)
0x20, // 0x20 occupy(red:2) | color vacant (dark:0) for ATAL-HK 20241230
#elif defined(FADEOUT)
0x27, // 0x20 occupy(red:2) | color vacant (white:7) for SWIRE INDIGO1 BEIJING

Binary file not shown.