提升亮度调节精度至百分比

This commit is contained in:
2026-07-26 23:20:44 +08:00
parent 9321568920
commit e5e899a8f1
43 changed files with 1914 additions and 1961 deletions
@@ -41,7 +41,7 @@ uint16_t deadTime_W = _deadTime;
uint8_t driveMode=1;
uint8_t PWMMAX=100; //最大占空比
uint8_t Brightness=10;
uint8_t Brightness=BRIGHTNESS_MAX_PERCENT;
// 切换 PWM 输出管脚,蓝牙调用此方法,切换设备输出线序
uint16_t W_PWM_duty;//初始化暖光
@@ -93,8 +93,8 @@ void PWM_SetDuty(uint8_t PWMX ,uint8_t duty) {
static uint16_t scale_display_value(uint16_t value)
{
if(value > 100U) value = 100U;
if(Brightness > 10U) return value;
return (uint16_t)(((uint32_t)value * Brightness + 5U) / 10U);
if(Brightness >= BRIGHTNESS_MAX_PERCENT) return value;
return (uint16_t)(((uint32_t)value * Brightness + 50U) / 100U);
}
void UpdateDisplay(void) // static update with global brightness