genesys: Simplify API of sanei_genesys_create_slope_table3()

merge-requests/228/merge
Povilas Kanapickas 2019-11-23 12:38:41 +02:00
rodzic ce59a69224
commit c6784d2f1d
3 zmienionych plików z 19 dodań i 31 usunięć

Wyświetl plik

@ -434,14 +434,14 @@ SANE_Int sanei_genesys_generate_slope_table(std::vector<uint16_t>& slope_table,
* @return Time for acceleration
* @note all times in pixel time
*/
SANE_Int sanei_genesys_create_slope_table3(Genesys_Device * dev,
SANE_Int sanei_genesys_create_slope_table3(const Genesys_Motor& motor,
std::vector<uint16_t>& slope_table,
int max_step,
unsigned int use_steps,
int step_type,
int exposure_time,
double yres,
unsigned int *used_steps,
unsigned yres,
unsigned int *used_steps,
unsigned int *final_exposure)
{
unsigned int sum_time = 0;
@ -450,26 +450,18 @@ SANE_Int sanei_genesys_create_slope_table3(Genesys_Device * dev,
unsigned int vstart;
unsigned int vfinal;
DBG(DBG_proc, "%s: step_type = %d, exposure_time = %d, yres = %g\n", __func__,
DBG(DBG_proc, "%s: step_type = %d, exposure_time = %d, yres = %d\n", __func__,
step_type, exposure_time, yres);
/* final speed */
vtarget = static_cast<unsigned>((exposure_time * yres) / dev->motor.base_ydpi);
vtarget = (exposure_time * yres) / motor.base_ydpi;
vstart = dev->motor.slopes[step_type].maximum_start_speed;
vend = dev->motor.slopes[step_type].maximum_speed;
vstart = motor.slopes[step_type].maximum_start_speed;
vend = motor.slopes[step_type].maximum_speed;
vtarget >>= step_type;
if (vtarget > 65535)
vtarget = 65535;
vstart >>= step_type;
if (vstart > 65535)
vstart = 65535;
vend >>= step_type;
if (vend > 65535)
vend = 65535;
vtarget = std::min(vtarget >> step_type, 65535u);
vstart = std::min(vstart >> step_type, 65535u);
vend = std::min(vend >> step_type, 65535u);
sum_time = sanei_genesys_generate_slope_table (slope_table,
max_step,
@ -477,13 +469,13 @@ SANE_Int sanei_genesys_create_slope_table3(Genesys_Device * dev,
vtarget,
vstart,
vend,
dev->motor.slopes[step_type].minimum_steps << step_type,
dev->motor.slopes[step_type].g,
motor.slopes[step_type].minimum_steps << step_type,
motor.slopes[step_type].g,
used_steps,
&vfinal);
if (final_exposure) {
*final_exposure = static_cast<unsigned>((vfinal * dev->motor.base_ydpi) / yres);
*final_exposure = (vfinal * motor.base_ydpi) / yres;
}
DBG(DBG_proc, "%s: returns sum_time=%d, completed\n", __func__, sum_time);

Wyświetl plik

@ -867,8 +867,7 @@ static void gl841_init_motor_regs(Genesys_Device* dev, const Genesys_Sensor& sen
fast_exposure = dev->motor.slopes[0].maximum_start_speed;
}
sanei_genesys_create_slope_table3(
dev,
sanei_genesys_create_slope_table3(dev->motor,
fast_slope_table,
256,
fast_slope_steps,
@ -1031,8 +1030,7 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor
how many steps we need for slow acceleration and how much steps we are
allowed to use.
*/
slow_slope_time = sanei_genesys_create_slope_table3 (
dev,
slow_slope_time = sanei_genesys_create_slope_table3(dev->motor,
slow_slope_table, 256,
256,
scan_step_type,
@ -1041,8 +1039,7 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor
&slow_slope_steps,
nullptr);
sanei_genesys_create_slope_table3 (
dev,
sanei_genesys_create_slope_table3(dev->motor,
back_slope_table, 256,
256,
scan_step_type,
@ -1067,8 +1064,7 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor
DBG(DBG_info, "%s: Maximum allowed slope steps for fast slope: %d\n", __func__,
fast_slope_steps);
fast_slope_time = sanei_genesys_create_slope_table3 (
dev,
fast_slope_time = sanei_genesys_create_slope_table3(dev->motor,
fast_slope_table, 256,
fast_slope_steps,
0,

Wyświetl plik

@ -345,11 +345,11 @@ SANE_Int sanei_genesys_generate_slope_table(std::vector<uint16_t>& slope_table,
unsigned int steps, double g,
unsigned int *used_steps, unsigned int *vfinal);
SANE_Int sanei_genesys_create_slope_table3(Genesys_Device * dev,
SANE_Int sanei_genesys_create_slope_table3(const Genesys_Motor& motor,
std::vector<uint16_t>& slope_table, int max_step,
unsigned int use_steps,
int step_type, int exposure_time,
double yres,
unsigned yres,
unsigned int *used_steps,
unsigned int *final_exposure);