修复亮度不能到最大的问题,解决app删除不能配网的问题

This commit is contained in:
2025-08-11 13:14:37 +08:00
parent 3165aafe83
commit b6567e34a9
7 changed files with 10 additions and 9 deletions

View File

@@ -66,7 +66,7 @@ typedef struct __attribute__((packed, aligned(1))) {
// 物模型同步需要 持久化维持
uint8_t on; // 开关状态
lightMode_e elightMode;
uint16_t brightness_local; // 当前亮度 (0-1000)
uint16_t brightness_local; // 当前亮度 (0-10000)
uint16_t fade_time; // 渐变时长(s)
uint16_t cct_local; // 当前色温 (2700-6500)
uint8_t colourMode; // 色温模式 (0:单色温, 1:双色温)
@@ -131,7 +131,8 @@ typedef struct __attribute__((packed, aligned(1))) {
#define FADE_INTERVAL_MIN (10*1000) //us
#define NORMAL_FADE_TIME 3 //s
#define PWM_DUTY_RATIO_MAX 20000
#define PWM_DUTY_RATIO_MAX 10000
#define BRINGHTNING2PWMDUTY(x) ((x) * 1)
//呼吸灯定义
#define BREARTH_PERIOD (3*1000*1000) //呼吸灯周期(Us)

View File

@@ -478,13 +478,13 @@ static void stop_breath_timer(void)
// 计算PWM占空比
void calculate_pwm_duty(device_control_t* pdevice_control)
{ // 如果开关关闭则占空比为0
uint32_t total_brightness_pwm = pdevice_control->brightness_local;
uint32_t total_brightness_pwm = BRINGHTNING2PWMDUTY(pdevice_control->brightness_local);
// 计算色温比例 (0-10000)
float cct_ratio = ((pdevice_control->cct_local - CCT_LOCAL_MIN) * 1.0) / CCT_RANGE;
// 根据色温比例计算CW和WW的占空比
// 总亮度保持不变只调整CW和WW的比例
pdevice_control->duty_cw = (total_brightness_pwm * cct_ratio);
pdevice_control->duty_cw = total_brightness_pwm * cct_ratio + 0.5;
pdevice_control->duty_ww = total_brightness_pwm - pdevice_control->duty_cw;
}
@@ -1278,11 +1278,11 @@ void handle_device_unbind(void)
if (g_device_control.is_bound) {
g_device_control.is_bound = false;
g_device_control.power_on_cnt = 0; // 重置上电计数
stop_spotlight_main_task();
// stop_spotlight_main_task();
device_control_t tmp = DEFAULT_DEVICE_DATA;//恢复默认
if (!g_reset_factory_flag) {
tmp.is_net_configured = g_device_control.is_net_configured;
}
// if (!g_reset_factory_flag) {
// tmp.is_net_configured = g_device_control.is_net_configured;
// }
g_device_control = tmp;
save_device_data();
}