Fix unused vars additional_topics and soft start time
This commit is contained in:
@ -646,9 +646,16 @@ static void motor_soft_start_timer_callback(TimerHandle_t xTimer)
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate increment based on soft start time
|
||||
// We want to go from 0 to target in MOTOR_SOFT_START_TIME_MS
|
||||
// Timer runs every 50ms, so number of steps = MOTOR_SOFT_START_TIME_MS / 50
|
||||
int steps = MOTOR_SOFT_START_TIME_MS / 50;
|
||||
int increment = motor->target_speed / steps;
|
||||
if (increment < 1) increment = 1;
|
||||
|
||||
// Ramp up speed
|
||||
if (motor->speed_percent < motor->target_speed) {
|
||||
motor->speed_percent += 5; // 5% increment
|
||||
motor->speed_percent += increment;
|
||||
if (motor->speed_percent > motor->target_speed) {
|
||||
motor->speed_percent = motor->target_speed;
|
||||
}
|
||||
@ -656,9 +663,13 @@ static void motor_soft_start_timer_callback(TimerHandle_t xTimer)
|
||||
uint8_t duty = (motor->speed_percent * MOTOR_PWM_MAX_DUTY) / 100;
|
||||
motor_update_pwm(id, duty);
|
||||
|
||||
ESP_LOGD(TAG, "Soft start motor %d: %d%% (target: %d%%)",
|
||||
id, motor->speed_percent, motor->target_speed);
|
||||
|
||||
// Stop timer when target reached
|
||||
if (motor->speed_percent >= motor->target_speed) {
|
||||
xTimerStop(xTimer, 0);
|
||||
ESP_LOGD(TAG, "Soft start complete for motor %d", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user