minor changes

This commit is contained in:
Yunhorn 2025-07-29 14:02:23 +08:00
parent 36b7e8c00c
commit 088a0a73b9
5 changed files with 30 additions and 10 deletions

View File

@ -144,6 +144,7 @@ void Error_Handler(void);
#define STS_LAMP_BAR_PWM_TIM_PERIOD (240 - 1) #define STS_LAMP_BAR_PWM_TIM_PERIOD (240 - 1)
#define STS_LAMP_BAR_HTIM htim1 #define STS_LAMP_BAR_HTIM htim1
#define STS_LAMP_BAR_LED_NUM (60) //60 for 46CM length LED strip #define STS_LAMP_BAR_LED_NUM (60) //60 for 46CM length LED strip
#define STS_LAMP_BAR_LED_NUM_MAX (60) //60 for 46CM length LED strip
#define LED_COUNT 18 // for 30 cm lamp bar #define LED_COUNT 18 // for 30 cm lamp bar
#define WSDATA_PORT_PIN_PA8 #define WSDATA_PORT_PIN_PA8
//#define WSDATA_PORT_PIN_PA9 //#define WSDATA_PORT_PIN_PA9

View File

@ -50,8 +50,9 @@ volatile WS2812B_FrameTypeDef rgb_buf = {
.tail = 0 .tail = 0
}; };
uint8_t ws2812b_crr_value[LED_COUNT*24+RESET_PULSE]={00}; //uint8_t ws2812b_crr_value[LED_COUNT*24+RESET_PULSE]={00};
uint8_t ws2812b_data[LED_COUNT*3]={0}; uint8_t ws2812b_crr_value[STS_LAMP_BAR_LED_NUM_MAX*24+RESET_PULSE]={00};
uint8_t ws2812b_data[STS_LAMP_BAR_LED_NUM_MAX*3]={0};
uint8_t color_rgb[8][3] = { //STS_COLOR R G B MAPPING TABLE uint8_t color_rgb[8][3] = { //STS_COLOR R G B MAPPING TABLE
{0,0,0},{0,1,0},{1,0,0},{0,0,1},{1,1,0},{1,0,1},{0,1,1},{1,1,1} {0,0,0},{0,1,0},{1,0,0},{0,0,1},{1,1,0},{1,0,1},{0,1,1},{1,1,1}
@ -106,7 +107,7 @@ void ws2812b_data_transfer(uint8_t *src, uint32_t len)
uint8_t i =0; uint8_t i =0;
uint32_t bits = 0; uint32_t bits = 0;
uint32_t bytes = 0; uint32_t bytes = 0;
HAL_TIM_PWM_Stop_DMA(&STS_LAMP_BAR_HTIM, STS_LAMP_BAR_TIM_CHANNEL);
while(len--) while(len--)
{ {
for (i=0; i < 8; i++) for (i=0; i < 8; i++)
@ -350,12 +351,12 @@ static void STS_Lamp_Bar_Set_RGB_Color_FadeOut(uint8_t red, uint8_t green, uint8
} }
ws2812b_data_transfer(ws2812b_data, sizeof(ws2812b_data)); ws2812b_data_transfer(ws2812b_data, sizeof(ws2812b_data));
} }
/*
void STS_Lamp_Bar_Refresh(void) void STS_Lamp_Bar_Refresh(void)
{ {
STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, luminance_level); STS_Lamp_Bar_Set_STS_RGB_Color(sts_lamp_bar_color, luminance_level);
} }
*/
void STS_Lamp_Bar_Set_STS_RGB_Color_FadeIn(uint8_t sts_lamp_color, uint8_t max_lum_level, uint8_t fade_length) void STS_Lamp_Bar_Set_STS_RGB_Color_FadeIn(uint8_t sts_lamp_color, uint8_t max_lum_level, uint8_t fade_length)
{ {
if (sts_lamp_color <=8) if (sts_lamp_color <=8)
@ -428,7 +429,20 @@ void STS_Lamp_Bar_Set_STS_RGB_Color_FadeOut(uint8_t sts_lamp_color, uint8_t max_
} }
void STS_Lamp_Bar_Set_STS_RGB_Color(uint8_t sts_lamp_color, uint8_t lum) void STS_Lamp_Bar_Set_STS_RGB_Color(uint8_t sts_lamp_color, uint8_t lum)
{ {
ws2812b_light_all_with_lum_level(sts_lamp_color, lum); //ws2812b_light_all_with_lum_level(sts_lamp_color, lum);
luminance_level = lum;
//ws2812b_light_all(color);
switch(sts_lamp_color)
{
case STS_DARK : ws2812b_light_custom(0, 0, 0); break;
case STS_GREEN : ws2812b_light_custom(0, luminance_level, 0 ); break;
case STS_RED : ws2812b_light_custom(luminance_level, 0, 0 ); break;
case STS_BLUE : ws2812b_light_custom(0, 0, luminance_level); break;
case STS_YELLOW : ws2812b_light_custom(luminance_level, luminance_level, 0 ); break;
case STS_PINK : ws2812b_light_custom(luminance_level, 0, luminance_level ); break;
case STS_CYAN : ws2812b_light_custom(0, luminance_level, luminance_level ); break;
case STS_WHITE : ws2812b_light_custom(luminance_level, luminance_level, luminance_level ); break;
}
/* /*
if (sts_lamp_color <=8) if (sts_lamp_color <=8)
{ {

View File

@ -59,8 +59,8 @@ volatile uint8_t last_sts_hall1_read=STS_Status_Door_Open, last_sts_hall2_read=S
volatile uint8_t sts_reed_hall_result =0, sts_emergency_button_pushed=0; // inital 0 = close volatile uint8_t sts_reed_hall_result =0, sts_emergency_button_pushed=0; // inital 0 = close
extern volatile uint8_t sts_work_mode, sts_cloud_netcolor, sts_lamp_bar_color, sts_status_color, sts_color_occupy_vacant, sts_color_severity_l2_l3; extern volatile uint8_t sts_work_mode, sts_cloud_netcolor, sts_lamp_bar_color, sts_status_color, sts_color_occupy_vacant, sts_color_severity_l2_l3;
extern volatile uint8_t sts_lamp_bar_flashing_color; extern volatile uint8_t sts_lamp_bar_flashing_color;
volatile uint8_t last_sts_lamp_bar_color=STS_DARK; volatile uint8_t last_sts_lamp_bar_color=STS_WHITE;
extern volatile uint8_t sts_status_color, sts_lamp_bar_color, sts_color_occupy_vacant;//puColor //extern volatile uint8_t sts_status_color, sts_lamp_bar_color, sts_color_occupy_vacant;//puColor
extern volatile uint8_t sts_rss_result; extern volatile uint8_t sts_rss_result;
extern volatile uint8_t sts_rss_result_changed_flag, sts_hall1_changed_flag, sts_hall2_changed_flag, sts_reed_hall_changed_flag; extern volatile uint8_t sts_rss_result_changed_flag, sts_hall1_changed_flag, sts_hall2_changed_flag, sts_reed_hall_changed_flag;
volatile uint8_t sts_fall_detection_acc_threshold = 30, //0.3g volatile uint8_t sts_fall_detection_acc_threshold = 30, //0.3g
@ -1270,7 +1270,11 @@ static void OnYunhornSTSLampBarColorTimerEvent(void *context)
luminance_level %= 60; luminance_level %= 60;
luminance_level = MAX(10,luminance_level); luminance_level = MAX(10,luminance_level);
#endif #endif
if (last_sts_lamp_bar_color != sts_lamp_bar_color)
{
APP_LOG(TS_OFF, VLEVEL_M, "\r\n----Lamp Bar Color changed from %02x to %02x \r\n", last_sts_lamp_bar_color, sts_lamp_bar_color);
last_sts_lamp_bar_color = sts_lamp_bar_color;
}
UTIL_TIMER_Stop(&STSLampBarColorTimer); UTIL_TIMER_Stop(&STSLampBarColorTimer);
if (high4==0) if (high4==0)
@ -1293,6 +1297,8 @@ static void OnYunhornSTSLampBarColorTimerEvent(void *context)
r_b = !r_b; r_b = !r_b;
} }
UTIL_TIMER_Start(&STSLampBarColorTimer); UTIL_TIMER_Start(&STSLampBarColorTimer);
//}
} }
static void OnYunhornSTSDurationCheckTimerEvent(void *context) static void OnYunhornSTSDurationCheckTimerEvent(void *context)

View File

@ -154,7 +154,6 @@
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.1119592399" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.os" valueType="enumerated"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.1119592399" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.optimization.level.value.os" valueType="enumerated"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.2024044405" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols"> <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols.2024044405" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
<listOptionValue builtIn="false" value="CORE_CM4"/> <listOptionValue builtIn="false" value="CORE_CM4"/>
<listOptionValue builtIn="false" value="FADEOUT"/>
<listOptionValue builtIn="false" value="ATAL"/> <listOptionValue builtIn="false" value="ATAL"/>
<listOptionValue builtIn="false" value="CLOCK_SYNC"/> <listOptionValue builtIn="false" value="CLOCK_SYNC"/>
<listOptionValue builtIn="false" value="RM2_1"/> <listOptionValue builtIn="false" value="RM2_1"/>

Binary file not shown.