kopia lustrzana https://gitlab.com/sane-project/backends
genesys: Return MotorSlopeTable out of *_create_slope_table3()
rodzic
7c6229f272
commit
8731a6cc5d
|
@ -439,17 +439,15 @@ SANE_Int sanei_genesys_generate_slope_table(std::vector<uint16_t>& slope_table,
|
||||||
* @return Time for acceleration
|
* @return Time for acceleration
|
||||||
* @note all times in pixel time
|
* @note all times in pixel time
|
||||||
*/
|
*/
|
||||||
SANE_Int sanei_genesys_create_slope_table3(const Genesys_Motor& motor,
|
MotorSlopeTable sanei_genesys_create_slope_table3(const Genesys_Motor& motor,
|
||||||
std::vector<uint16_t>& slope_table,
|
unsigned max_steps,
|
||||||
int max_step,
|
unsigned use_steps,
|
||||||
unsigned int use_steps,
|
StepType step_type,
|
||||||
StepType step_type,
|
int exposure_time,
|
||||||
int exposure_time,
|
unsigned yres)
|
||||||
unsigned yres,
|
|
||||||
unsigned int *used_steps,
|
|
||||||
unsigned int *final_exposure)
|
|
||||||
{
|
{
|
||||||
unsigned int sum_time = 0;
|
MotorSlopeTable table;
|
||||||
|
|
||||||
unsigned int vtarget;
|
unsigned int vtarget;
|
||||||
unsigned int vend;
|
unsigned int vend;
|
||||||
unsigned int vstart;
|
unsigned int vstart;
|
||||||
|
@ -471,24 +469,22 @@ SANE_Int sanei_genesys_create_slope_table3(const Genesys_Motor& motor,
|
||||||
vstart = std::min(vstart >> u_step_type, 65535u);
|
vstart = std::min(vstart >> u_step_type, 65535u);
|
||||||
vend = std::min(vend >> u_step_type, 65535u);
|
vend = std::min(vend >> u_step_type, 65535u);
|
||||||
|
|
||||||
sum_time = sanei_genesys_generate_slope_table (slope_table,
|
unsigned used_steps = 0;
|
||||||
max_step,
|
table.pixeltime_sum = sanei_genesys_generate_slope_table(table.table,
|
||||||
use_steps,
|
max_steps,
|
||||||
vtarget,
|
use_steps,
|
||||||
vstart,
|
vtarget,
|
||||||
vend,
|
vstart,
|
||||||
slope.minimum_steps << u_step_type,
|
vend,
|
||||||
slope.g,
|
slope.minimum_steps << u_step_type,
|
||||||
used_steps,
|
slope.g,
|
||||||
&vfinal);
|
&used_steps,
|
||||||
|
&vfinal);
|
||||||
|
|
||||||
if (final_exposure) {
|
table.steps_count = used_steps;
|
||||||
*final_exposure = (vfinal * motor.base_ydpi) / yres;
|
table.final_exposure = (vfinal * motor.base_ydpi) / yres;
|
||||||
}
|
|
||||||
|
|
||||||
DBG(DBG_proc, "%s: returns sum_time=%d, completed\n", __func__, sum_time);
|
return table;
|
||||||
|
|
||||||
return sum_time;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @brief computes gamma table
|
/** @brief computes gamma table
|
||||||
|
|
|
@ -831,23 +831,23 @@ static void gl841_init_motor_regs(Genesys_Device* dev, const Genesys_Sensor& sen
|
||||||
static_cast<unsigned>(flags));
|
static_cast<unsigned>(flags));
|
||||||
unsigned int fast_exposure = 0;
|
unsigned int fast_exposure = 0;
|
||||||
int use_fast_fed = 0;
|
int use_fast_fed = 0;
|
||||||
std::vector<uint16_t> fast_slope_table;
|
|
||||||
unsigned int fast_slope_steps = 0;
|
|
||||||
unsigned int feedl;
|
unsigned int feedl;
|
||||||
GenesysRegister* r;
|
GenesysRegister* r;
|
||||||
/*number of scan lines to add in a scan_lines line*/
|
/*number of scan lines to add in a scan_lines line*/
|
||||||
|
|
||||||
fast_slope_table.resize(256, 0xffff);
|
{
|
||||||
|
std::vector<uint16_t> table;
|
||||||
|
table.resize(256, 0xffff);
|
||||||
|
|
||||||
gl841_send_slope_table(dev, 0, fast_slope_table, 256);
|
gl841_send_slope_table(dev, 0, table, 256);
|
||||||
gl841_send_slope_table(dev, 1, fast_slope_table, 256);
|
gl841_send_slope_table(dev, 1, table, 256);
|
||||||
gl841_send_slope_table(dev, 2, fast_slope_table, 256);
|
gl841_send_slope_table(dev, 2, table, 256);
|
||||||
gl841_send_slope_table(dev, 3, fast_slope_table, 256);
|
gl841_send_slope_table(dev, 3, table, 256);
|
||||||
gl841_send_slope_table(dev, 4, fast_slope_table, 256);
|
gl841_send_slope_table(dev, 4, table, 256);
|
||||||
|
}
|
||||||
|
|
||||||
gl841_write_freq(dev, dev->motor.base_ydpi / 4);
|
gl841_write_freq(dev, dev->motor.base_ydpi / 4);
|
||||||
|
|
||||||
fast_slope_steps = 256;
|
|
||||||
if (action == MOTOR_ACTION_FEED || action == MOTOR_ACTION_GO_HOME) {
|
if (action == MOTOR_ACTION_FEED || action == MOTOR_ACTION_GO_HOME) {
|
||||||
/* FEED and GO_HOME can use fastest slopes available */
|
/* FEED and GO_HOME can use fastest slopes available */
|
||||||
fast_exposure = gl841_exposure_time(dev, sensor,
|
fast_exposure = gl841_exposure_time(dev, sensor,
|
||||||
|
@ -863,17 +863,10 @@ static void gl841_init_motor_regs(Genesys_Device* dev, const Genesys_Sensor& sen
|
||||||
fast_exposure = dev->motor.get_slope(StepType::FULL).legacy().maximum_start_speed;
|
fast_exposure = dev->motor.get_slope(StepType::FULL).legacy().maximum_start_speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
sanei_genesys_create_slope_table3(dev->motor,
|
auto fast_table = sanei_genesys_create_slope_table3(dev->motor, 256, 256, StepType::FULL,
|
||||||
fast_slope_table,
|
fast_exposure, dev->motor.base_ydpi / 4);
|
||||||
256,
|
|
||||||
fast_slope_steps,
|
|
||||||
StepType::FULL,
|
|
||||||
fast_exposure,
|
|
||||||
dev->motor.base_ydpi / 4,
|
|
||||||
&fast_slope_steps,
|
|
||||||
&fast_exposure);
|
|
||||||
|
|
||||||
feedl = feed_steps - fast_slope_steps*2;
|
feedl = feed_steps - fast_table.steps_count * 2;
|
||||||
use_fast_fed = 1;
|
use_fast_fed = 1;
|
||||||
|
|
||||||
/* all needed slopes available. we did even decide which mode to use.
|
/* all needed slopes available. we did even decide which mode to use.
|
||||||
|
@ -950,7 +943,7 @@ HOME_FREE: 3
|
||||||
r->value |= REG_0x02_MTRREV;
|
r->value |= REG_0x02_MTRREV;
|
||||||
}
|
}
|
||||||
|
|
||||||
gl841_send_slope_table(dev, 3, fast_slope_table, 256);
|
gl841_send_slope_table(dev, 3, fast_table.table, 256);
|
||||||
|
|
||||||
r = sanei_genesys_get_address(reg, 0x67);
|
r = sanei_genesys_get_address(reg, 0x67);
|
||||||
r->value = 0x3f;
|
r->value = 0x3f;
|
||||||
|
@ -968,10 +961,10 @@ HOME_FREE: 3
|
||||||
r->value = 0;
|
r->value = 0;
|
||||||
|
|
||||||
r = sanei_genesys_get_address(reg, 0x6a);
|
r = sanei_genesys_get_address(reg, 0x6a);
|
||||||
r->value = (fast_slope_steps >> 1) + (fast_slope_steps & 1);
|
r->value = (fast_table.steps_count >> 1) + (fast_table.steps_count & 1);
|
||||||
|
|
||||||
r = sanei_genesys_get_address(reg, 0x5f);
|
r = sanei_genesys_get_address(reg, 0x5f);
|
||||||
r->value = (fast_slope_steps >> 1) + (fast_slope_steps & 1);
|
r->value = (fast_table.steps_count >> 1) + (fast_table.steps_count & 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
|
static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor,
|
||||||
|
@ -994,14 +987,6 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor
|
||||||
int use_fast_fed = 0;
|
int use_fast_fed = 0;
|
||||||
unsigned int fast_time;
|
unsigned int fast_time;
|
||||||
unsigned int slow_time;
|
unsigned int slow_time;
|
||||||
std::vector<uint16_t> slow_slope_table;
|
|
||||||
std::vector<uint16_t> fast_slope_table;
|
|
||||||
std::vector<uint16_t> back_slope_table;
|
|
||||||
unsigned int slow_slope_time;
|
|
||||||
unsigned int fast_slope_time;
|
|
||||||
unsigned int slow_slope_steps = 0;
|
|
||||||
unsigned int fast_slope_steps = 0;
|
|
||||||
unsigned int back_slope_steps = 0;
|
|
||||||
unsigned int feedl;
|
unsigned int feedl;
|
||||||
GenesysRegister* r;
|
GenesysRegister* r;
|
||||||
unsigned int min_restep = 0x20;
|
unsigned int min_restep = 0x20;
|
||||||
|
@ -1015,13 +1000,17 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor
|
||||||
|
|
||||||
DBG(DBG_info, "%s : fast_exposure=%d pixels\n", __func__, fast_exposure);
|
DBG(DBG_info, "%s : fast_exposure=%d pixels\n", __func__, fast_exposure);
|
||||||
|
|
||||||
slow_slope_table.resize(256, 0xffff);
|
{
|
||||||
|
std::vector<uint16_t> table;
|
||||||
|
table.resize(256, 0xffff);
|
||||||
|
|
||||||
|
gl841_send_slope_table(dev, 0, table, 256);
|
||||||
|
gl841_send_slope_table(dev, 1, table, 256);
|
||||||
|
gl841_send_slope_table(dev, 2, table, 256);
|
||||||
|
gl841_send_slope_table(dev, 3, table, 256);
|
||||||
|
gl841_send_slope_table(dev, 4, table, 256);
|
||||||
|
}
|
||||||
|
|
||||||
gl841_send_slope_table(dev, 0, slow_slope_table, 256);
|
|
||||||
gl841_send_slope_table(dev, 1, slow_slope_table, 256);
|
|
||||||
gl841_send_slope_table(dev, 2, slow_slope_table, 256);
|
|
||||||
gl841_send_slope_table(dev, 3, slow_slope_table, 256);
|
|
||||||
gl841_send_slope_table(dev, 4, slow_slope_table, 256);
|
|
||||||
|
|
||||||
/* motor frequency table */
|
/* motor frequency table */
|
||||||
gl841_write_freq(dev, scan_yres);
|
gl841_write_freq(dev, scan_yres);
|
||||||
|
@ -1031,50 +1020,36 @@ 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
|
how many steps we need for slow acceleration and how much steps we are
|
||||||
allowed to use.
|
allowed to use.
|
||||||
*/
|
*/
|
||||||
slow_slope_time = sanei_genesys_create_slope_table3(dev->motor,
|
|
||||||
slow_slope_table, 256,
|
|
||||||
256,
|
|
||||||
scan_step_type,
|
|
||||||
scan_exposure_time,
|
|
||||||
scan_yres,
|
|
||||||
&slow_slope_steps,
|
|
||||||
nullptr);
|
|
||||||
|
|
||||||
sanei_genesys_create_slope_table3(dev->motor,
|
auto slow_table = sanei_genesys_create_slope_table3(dev->motor, 256, 256, scan_step_type,
|
||||||
back_slope_table, 256,
|
scan_exposure_time, scan_yres);
|
||||||
256,
|
|
||||||
scan_step_type,
|
|
||||||
0,
|
|
||||||
scan_yres,
|
|
||||||
&back_slope_steps,
|
|
||||||
nullptr);
|
|
||||||
|
|
||||||
if (feed_steps < (slow_slope_steps >> static_cast<unsigned>(scan_step_type))) {
|
auto back_table = sanei_genesys_create_slope_table3(dev->motor, 256, 256, scan_step_type,
|
||||||
|
0, scan_yres);
|
||||||
|
|
||||||
|
if (feed_steps < (slow_table.steps_count >> static_cast<unsigned>(scan_step_type))) {
|
||||||
/*TODO: what should we do here?? go back to exposure calculation?*/
|
/*TODO: what should we do here?? go back to exposure calculation?*/
|
||||||
feed_steps = slow_slope_steps >> static_cast<unsigned>(scan_step_type);
|
feed_steps = slow_table.steps_count >> static_cast<unsigned>(scan_step_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (feed_steps > fast_slope_steps*2 -
|
unsigned max_fast_slope_steps = 0; // BUG: this should be 256 for the following conditional
|
||||||
(slow_slope_steps >> static_cast<unsigned>(scan_step_type)))
|
// to make sense
|
||||||
|
if (feed_steps > max_fast_slope_steps * 2 -
|
||||||
|
(slow_table.steps_count >> static_cast<unsigned>(scan_step_type)))
|
||||||
{
|
{
|
||||||
fast_slope_steps = 256;
|
max_fast_slope_steps = 256;
|
||||||
} else {
|
} else {
|
||||||
// we need to shorten fast_slope_steps here.
|
// we need to shorten fast_slope_steps here.
|
||||||
fast_slope_steps = (feed_steps -
|
max_fast_slope_steps = (feed_steps -
|
||||||
(slow_slope_steps >> static_cast<unsigned>(scan_step_type))) / 2;
|
(slow_table.steps_count >> static_cast<unsigned>(scan_step_type))) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
DBG(DBG_info, "%s: Maximum allowed slope steps for fast slope: %d\n", __func__,
|
DBG(DBG_info, "%s: Maximum allowed slope steps for fast slope: %d\n", __func__,
|
||||||
fast_slope_steps);
|
max_fast_slope_steps);
|
||||||
|
|
||||||
fast_slope_time = sanei_genesys_create_slope_table3(dev->motor,
|
auto fast_table = sanei_genesys_create_slope_table3(dev->motor, 256, max_fast_slope_steps,
|
||||||
fast_slope_table, 256,
|
StepType::FULL, fast_exposure,
|
||||||
fast_slope_steps,
|
dev->motor.base_ydpi / 4);
|
||||||
StepType::FULL,
|
|
||||||
fast_exposure,
|
|
||||||
dev->motor.base_ydpi / 4,
|
|
||||||
&fast_slope_steps,
|
|
||||||
&fast_exposure);
|
|
||||||
|
|
||||||
/* fast fed special cases handling */
|
/* fast fed special cases handling */
|
||||||
if (dev->model->gpio_id == GpioId::XP300
|
if (dev->model->gpio_id == GpioId::XP300
|
||||||
|
@ -1084,8 +1059,8 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor
|
||||||
2-feed mode */
|
2-feed mode */
|
||||||
use_fast_fed = 0;
|
use_fast_fed = 0;
|
||||||
}
|
}
|
||||||
else if (feed_steps < fast_slope_steps * 2 +
|
else if (feed_steps < fast_table.steps_count * 2 +
|
||||||
(slow_slope_steps >> static_cast<unsigned>(scan_step_type)))
|
(slow_table.steps_count >> static_cast<unsigned>(scan_step_type)))
|
||||||
{
|
{
|
||||||
use_fast_fed = 0;
|
use_fast_fed = 0;
|
||||||
DBG(DBG_info, "%s: feed too short, slow move forced.\n", __func__);
|
DBG(DBG_info, "%s: feed too short, slow move forced.\n", __func__);
|
||||||
|
@ -1100,13 +1075,13 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor
|
||||||
/*we use full steps as base unit here*/
|
/*we use full steps as base unit here*/
|
||||||
fast_time =
|
fast_time =
|
||||||
fast_exposure / 4 *
|
fast_exposure / 4 *
|
||||||
(feed_steps - fast_slope_steps*2 -
|
(feed_steps - fast_table.steps_count*2 -
|
||||||
(slow_slope_steps >> static_cast<unsigned>(scan_step_type)))
|
(slow_table.steps_count >> static_cast<unsigned>(scan_step_type)))
|
||||||
+ fast_slope_time*2 + slow_slope_time;
|
+ fast_table.pixeltime_sum*2 + slow_table.pixeltime_sum;
|
||||||
slow_time =
|
slow_time =
|
||||||
(scan_exposure_time * scan_yres) / dev->motor.base_ydpi *
|
(scan_exposure_time * scan_yres) / dev->motor.base_ydpi *
|
||||||
(feed_steps - (slow_slope_steps >> static_cast<unsigned>(scan_step_type)))
|
(feed_steps - (slow_table.steps_count >> static_cast<unsigned>(scan_step_type)))
|
||||||
+ slow_slope_time;
|
+ slow_table.pixeltime_sum;
|
||||||
|
|
||||||
DBG(DBG_info, "%s: Time for slow move: %d\n", __func__, slow_time);
|
DBG(DBG_info, "%s: Time for slow move: %d\n", __func__, slow_time);
|
||||||
DBG(DBG_info, "%s: Time for fast move: %d\n", __func__, fast_time);
|
DBG(DBG_info, "%s: Time for fast move: %d\n", __func__, fast_time);
|
||||||
|
@ -1115,12 +1090,12 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_fast_fed) {
|
if (use_fast_fed) {
|
||||||
feedl = feed_steps - fast_slope_steps * 2 -
|
feedl = feed_steps - fast_table.steps_count * 2 -
|
||||||
(slow_slope_steps >> static_cast<unsigned>(scan_step_type));
|
(slow_table.steps_count >> static_cast<unsigned>(scan_step_type));
|
||||||
} else if ((feed_steps << static_cast<unsigned>(scan_step_type)) < slow_slope_steps) {
|
} else if ((feed_steps << static_cast<unsigned>(scan_step_type)) < slow_table.steps_count) {
|
||||||
feedl = 0;
|
feedl = 0;
|
||||||
} else {
|
} else {
|
||||||
feedl = (feed_steps << static_cast<unsigned>(scan_step_type)) - slow_slope_steps;
|
feedl = (feed_steps << static_cast<unsigned>(scan_step_type)) - slow_table.steps_count;
|
||||||
}
|
}
|
||||||
DBG(DBG_info, "%s: Decided to use %s mode\n", __func__, use_fast_fed?"fast feed":"slow feed");
|
DBG(DBG_info, "%s: Decided to use %s mode\n", __func__, use_fast_fed?"fast feed":"slow feed");
|
||||||
|
|
||||||
|
@ -1193,18 +1168,18 @@ HOME_FREE: 3
|
||||||
r->value &= ~0x40;
|
r->value &= ~0x40;
|
||||||
}
|
}
|
||||||
|
|
||||||
gl841_send_slope_table(dev, 0, slow_slope_table, 256);
|
gl841_send_slope_table(dev, 0, slow_table.table, 256);
|
||||||
|
|
||||||
gl841_send_slope_table(dev, 1, back_slope_table, 256);
|
gl841_send_slope_table(dev, 1, back_table.table, 256);
|
||||||
|
|
||||||
gl841_send_slope_table(dev, 2, slow_slope_table, 256);
|
gl841_send_slope_table(dev, 2, slow_table.table, 256);
|
||||||
|
|
||||||
if (use_fast_fed) {
|
if (use_fast_fed) {
|
||||||
gl841_send_slope_table(dev, 3, fast_slope_table, 256);
|
gl841_send_slope_table(dev, 3, fast_table.table, 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_flag(flags, MotorFlag::AUTO_GO_HOME)) {
|
if (has_flag(flags, MotorFlag::AUTO_GO_HOME)) {
|
||||||
gl841_send_slope_table(dev, 4, fast_slope_table, 256);
|
gl841_send_slope_table(dev, 4, fast_table.table, 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* now reg 0x21 and 0x24 are available, we can calculate reg 0x22 and 0x23,
|
/* now reg 0x21 and 0x24 are available, we can calculate reg 0x22 and 0x23,
|
||||||
|
@ -1213,17 +1188,19 @@ HOME_FREE: 3
|
||||||
2*STEPNO+FWDSTEP=2*FASTNO+BWDSTEP
|
2*STEPNO+FWDSTEP=2*FASTNO+BWDSTEP
|
||||||
*/
|
*/
|
||||||
/* steps of table 0*/
|
/* steps of table 0*/
|
||||||
if (min_restep < slow_slope_steps*2+2)
|
if (min_restep < slow_table.steps_count * 2 + 2) {
|
||||||
min_restep = slow_slope_steps*2+2;
|
min_restep = slow_table.steps_count * 2 + 2;
|
||||||
|
}
|
||||||
/* steps of table 1*/
|
/* steps of table 1*/
|
||||||
if (min_restep < back_slope_steps*2+2)
|
if (min_restep < back_table.steps_count * 2 + 2) {
|
||||||
min_restep = back_slope_steps*2+2;
|
min_restep = back_table.steps_count * 2 + 2;
|
||||||
|
}
|
||||||
/* steps of table 0*/
|
/* steps of table 0*/
|
||||||
r = sanei_genesys_get_address(reg, REG_FWDSTEP);
|
r = sanei_genesys_get_address(reg, REG_FWDSTEP);
|
||||||
r->value = min_restep - slow_slope_steps*2;
|
r->value = min_restep - slow_table.steps_count*2;
|
||||||
/* steps of table 1*/
|
/* steps of table 1*/
|
||||||
r = sanei_genesys_get_address(reg, REG_BWDSTEP);
|
r = sanei_genesys_get_address(reg, REG_BWDSTEP);
|
||||||
r->value = min_restep - back_slope_steps*2;
|
r->value = min_restep - back_table.steps_count*2;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
for z1/z2:
|
for z1/z2:
|
||||||
|
@ -1268,19 +1245,19 @@ HOME_FREE: 3
|
||||||
r->value = 0x3f;
|
r->value = 0x3f;
|
||||||
|
|
||||||
r = sanei_genesys_get_address(reg, REG_STEPNO);
|
r = sanei_genesys_get_address(reg, REG_STEPNO);
|
||||||
r->value = (slow_slope_steps >> 1) + (slow_slope_steps & 1);
|
r->value = (slow_table.steps_count >> 1) + (slow_table.steps_count & 1);
|
||||||
|
|
||||||
r = sanei_genesys_get_address(reg, REG_FASTNO);
|
r = sanei_genesys_get_address(reg, REG_FASTNO);
|
||||||
r->value = (back_slope_steps >> 1) + (back_slope_steps & 1);
|
r->value = (back_table.steps_count >> 1) + (back_table.steps_count & 1);
|
||||||
|
|
||||||
r = sanei_genesys_get_address (reg, 0x69);
|
r = sanei_genesys_get_address (reg, 0x69);
|
||||||
r->value = (slow_slope_steps >> 1) + (slow_slope_steps & 1);
|
r->value = (slow_table.steps_count >> 1) + (slow_table.steps_count & 1);
|
||||||
|
|
||||||
r = sanei_genesys_get_address (reg, 0x6a);
|
r = sanei_genesys_get_address (reg, 0x6a);
|
||||||
r->value = (fast_slope_steps >> 1) + (fast_slope_steps & 1);
|
r->value = (fast_table.steps_count >> 1) + (fast_table.steps_count & 1);
|
||||||
|
|
||||||
r = sanei_genesys_get_address (reg, 0x5f);
|
r = sanei_genesys_get_address (reg, 0x5f);
|
||||||
r->value = (fast_slope_steps >> 1) + (fast_slope_steps & 1);
|
r->value = (fast_table.steps_count >> 1) + (fast_table.steps_count & 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
|
@ -1767,6 +1767,7 @@ MotorSlopeTable sanei_genesys_slope_table(int dpi, int exposure, int base_dpi,
|
||||||
auto table = create_slope_table(motor_profile.slope, target_speed_w, motor_profile.step_type,
|
auto table = create_slope_table(motor_profile.slope, target_speed_w, motor_profile.step_type,
|
||||||
factor, 2 * factor);
|
factor, 2 * factor);
|
||||||
table.steps_count /= factor;
|
table.steps_count /= factor;
|
||||||
|
table.final_exposure = (table.final_exposure * base_dpi) / dpi;
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -329,13 +329,12 @@ SANE_Int sanei_genesys_generate_slope_table(std::vector<uint16_t>& slope_table,
|
||||||
unsigned int steps, double g,
|
unsigned int steps, double g,
|
||||||
unsigned int *used_steps, unsigned int *vfinal);
|
unsigned int *used_steps, unsigned int *vfinal);
|
||||||
|
|
||||||
SANE_Int sanei_genesys_create_slope_table3(const Genesys_Motor& motor,
|
MotorSlopeTable sanei_genesys_create_slope_table3(const Genesys_Motor& motor,
|
||||||
std::vector<uint16_t>& slope_table, int max_step,
|
unsigned max_steps,
|
||||||
unsigned int use_steps,
|
unsigned use_steps,
|
||||||
StepType step_type, int exposure_time,
|
StepType step_type,
|
||||||
unsigned yres,
|
int exposure_time,
|
||||||
unsigned int *used_steps,
|
unsigned yres);
|
||||||
unsigned int *final_exposure);
|
|
||||||
|
|
||||||
void sanei_genesys_create_default_gamma_table(Genesys_Device* dev,
|
void sanei_genesys_create_default_gamma_table(Genesys_Device* dev,
|
||||||
std::vector<uint16_t>& gamma_table, float gamma);
|
std::vector<uint16_t>& gamma_table, float gamma);
|
||||||
|
|
|
@ -126,6 +126,8 @@ MotorSlopeTable create_slope_table(const MotorSlope& slope, unsigned target_spee
|
||||||
// fill the rest of the table with the final speed
|
// fill the rest of the table with the final speed
|
||||||
table.table.resize(MotorSlopeTable::SLOPE_TABLE_SIZE, final_speed);
|
table.table.resize(MotorSlopeTable::SLOPE_TABLE_SIZE, final_speed);
|
||||||
|
|
||||||
|
table.final_exposure = final_speed;
|
||||||
|
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,6 +151,9 @@ struct MotorSlopeTable
|
||||||
std::vector<std::uint16_t> table;
|
std::vector<std::uint16_t> table;
|
||||||
unsigned steps_count = 0;
|
unsigned steps_count = 0;
|
||||||
unsigned pixeltime_sum = 0;
|
unsigned pixeltime_sum = 0;
|
||||||
|
|
||||||
|
// table.back() adjusted to the scan dpi
|
||||||
|
unsigned final_exposure = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
MotorSlopeTable create_slope_table(const MotorSlope& slope, unsigned target_speed_w,
|
MotorSlopeTable create_slope_table(const MotorSlope& slope, unsigned target_speed_w,
|
||||||
|
|
|
@ -61,100 +61,88 @@ void test_create_slope_table3()
|
||||||
slope.g = 0.80f;
|
slope.g = 0.80f;
|
||||||
motor.slopes.push_back(slope);
|
motor.slopes.push_back(slope);
|
||||||
|
|
||||||
unsigned used_steps = 0;
|
auto table = sanei_genesys_create_slope_table3(motor, 20, 20, StepType::FULL, 10000,
|
||||||
unsigned final_exposure = 0;
|
motor.base_ydpi);
|
||||||
unsigned sum_time = 0;
|
|
||||||
std::vector<std::uint16_t> slope_table;
|
|
||||||
|
|
||||||
sum_time = sanei_genesys_create_slope_table3(motor, slope_table, 20, 20, StepType::FULL,
|
ASSERT_EQ(table.pixeltime_sum, 10000u);
|
||||||
10000, motor.base_ydpi, &used_steps,
|
ASSERT_EQ(table.steps_count, 1u);
|
||||||
&final_exposure);
|
ASSERT_EQ(table.final_exposure, 10000u);
|
||||||
|
|
||||||
ASSERT_EQ(sum_time, 10000u);
|
|
||||||
ASSERT_EQ(used_steps, 1u);
|
|
||||||
ASSERT_EQ(final_exposure, 10000u);
|
|
||||||
|
|
||||||
std::vector<std::uint16_t> expected_steps = {
|
std::vector<std::uint16_t> expected_steps = {
|
||||||
10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000,
|
10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000,
|
||||||
10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000,
|
10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000,
|
||||||
};
|
};
|
||||||
|
|
||||||
ASSERT_EQ(slope_table, expected_steps);
|
ASSERT_EQ(table.table, expected_steps);
|
||||||
|
|
||||||
sum_time = sanei_genesys_create_slope_table3(motor, slope_table, 20, 20, StepType::FULL,
|
table = sanei_genesys_create_slope_table3(motor, 20, 20, StepType::FULL, 2000, motor.base_ydpi);
|
||||||
2000, motor.base_ydpi, &used_steps,
|
|
||||||
&final_exposure);
|
|
||||||
|
|
||||||
ASSERT_EQ(sum_time, 98183u);
|
ASSERT_EQ(table.pixeltime_sum, 98183u);
|
||||||
ASSERT_EQ(used_steps, 18u);
|
ASSERT_EQ(table.steps_count, 18u);
|
||||||
ASSERT_EQ(final_exposure, 1766u);
|
ASSERT_EQ(table.final_exposure, 1766u);
|
||||||
|
|
||||||
expected_steps = {
|
expected_steps = {
|
||||||
10000, 9146, 8513, 7944, 7412, 6906, 6421, 5951, 5494, 5049,
|
10000, 9146, 8513, 7944, 7412, 6906, 6421, 5951, 5494, 5049,
|
||||||
4614, 4187, 3768, 3356, 2950, 2550, 2156, 1766, 1766, 1766,
|
4614, 4187, 3768, 3356, 2950, 2550, 2156, 1766, 1766, 1766,
|
||||||
};
|
};
|
||||||
|
|
||||||
ASSERT_EQ(slope_table, expected_steps);
|
ASSERT_EQ(table.table, expected_steps);
|
||||||
|
|
||||||
sum_time = sanei_genesys_create_slope_table3(motor, slope_table, 20, 20, StepType::HALF,
|
table = sanei_genesys_create_slope_table3(motor, 20, 20, StepType::HALF, 10000,
|
||||||
10000, motor.base_ydpi, &used_steps,
|
motor.base_ydpi);
|
||||||
&final_exposure);
|
|
||||||
|
|
||||||
ASSERT_EQ(sum_time, 5000u);
|
ASSERT_EQ(table.pixeltime_sum, 5000u);
|
||||||
ASSERT_EQ(used_steps, 1u);
|
ASSERT_EQ(table.steps_count, 1u);
|
||||||
ASSERT_EQ(final_exposure, 5000u);
|
ASSERT_EQ(table.final_exposure, 5000u);
|
||||||
|
|
||||||
expected_steps = {
|
expected_steps = {
|
||||||
5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000,
|
5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000,
|
||||||
5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000,
|
5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000,
|
||||||
};
|
};
|
||||||
|
|
||||||
ASSERT_EQ(slope_table, expected_steps);
|
ASSERT_EQ(table.table, expected_steps);
|
||||||
|
|
||||||
sum_time = sanei_genesys_create_slope_table3(motor, slope_table, 20, 20, StepType::HALF,
|
table = sanei_genesys_create_slope_table3(motor, 20, 20, StepType::HALF, 2000,
|
||||||
2000, motor.base_ydpi, &used_steps,
|
motor.base_ydpi);
|
||||||
&final_exposure);
|
|
||||||
|
|
||||||
ASSERT_EQ(sum_time, 72131u);
|
ASSERT_EQ(table.pixeltime_sum, 72131u);
|
||||||
ASSERT_EQ(used_steps, 20u);
|
ASSERT_EQ(table.steps_count, 20u);
|
||||||
ASSERT_EQ(final_exposure, 2575u);
|
ASSERT_EQ(table.final_exposure, 2575u);
|
||||||
|
|
||||||
expected_steps = {
|
expected_steps = {
|
||||||
5000, 4759, 4581, 4421, 4272, 4129, 3993, 3861, 3732, 3607,
|
5000, 4759, 4581, 4421, 4272, 4129, 3993, 3861, 3732, 3607,
|
||||||
3485, 3365, 3247, 3131, 3017, 2904, 2793, 2684, 2575, 2575,
|
3485, 3365, 3247, 3131, 3017, 2904, 2793, 2684, 2575, 2575,
|
||||||
};
|
};
|
||||||
|
|
||||||
ASSERT_EQ(slope_table, expected_steps);
|
ASSERT_EQ(table.table, expected_steps);
|
||||||
|
|
||||||
sum_time = sanei_genesys_create_slope_table3(motor, slope_table, 20, 20, StepType::QUARTER,
|
table = sanei_genesys_create_slope_table3(motor, 20, 20, StepType::QUARTER, 10000,
|
||||||
10000, motor.base_ydpi, &used_steps,
|
motor.base_ydpi);
|
||||||
&final_exposure);
|
|
||||||
|
|
||||||
ASSERT_EQ(sum_time, 2500u);
|
ASSERT_EQ(table.pixeltime_sum, 2500u);
|
||||||
ASSERT_EQ(used_steps, 1u);
|
ASSERT_EQ(table.steps_count, 1u);
|
||||||
ASSERT_EQ(final_exposure, 2500u);
|
ASSERT_EQ(table.final_exposure, 2500u);
|
||||||
|
|
||||||
expected_steps = {
|
expected_steps = {
|
||||||
2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500,
|
2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500,
|
||||||
2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500,
|
2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500, 2500,
|
||||||
};
|
};
|
||||||
|
|
||||||
ASSERT_EQ(slope_table, expected_steps);
|
ASSERT_EQ(table.table, expected_steps);
|
||||||
|
|
||||||
sum_time = sanei_genesys_create_slope_table3(motor, slope_table, 20, 20, StepType::QUARTER,
|
table = sanei_genesys_create_slope_table3(motor, 20, 20, StepType::QUARTER, 2000,
|
||||||
2000, motor.base_ydpi, &used_steps,
|
motor.base_ydpi);
|
||||||
&final_exposure);
|
|
||||||
|
|
||||||
ASSERT_EQ(sum_time, 40503u);
|
ASSERT_EQ(table.pixeltime_sum, 40503u);
|
||||||
ASSERT_EQ(used_steps, 20u);
|
ASSERT_EQ(table.steps_count, 20u);
|
||||||
ASSERT_EQ(final_exposure, 1674u);
|
ASSERT_EQ(table.final_exposure, 1674u);
|
||||||
|
|
||||||
expected_steps = {
|
expected_steps = {
|
||||||
2500, 2418, 2357, 2303, 2252, 2203, 2157, 2112, 2068, 2025,
|
2500, 2418, 2357, 2303, 2252, 2203, 2157, 2112, 2068, 2025,
|
||||||
1983, 1943, 1902, 1863, 1824, 1786, 1748, 1711, 1674, 1674,
|
1983, 1943, 1902, 1863, 1824, 1786, 1748, 1711, 1674, 1674,
|
||||||
};
|
};
|
||||||
|
|
||||||
ASSERT_EQ(slope_table, expected_steps);
|
ASSERT_EQ(table.table, expected_steps);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_create_slope_table_small_full_step()
|
void test_create_slope_table_small_full_step()
|
||||||
|
|
Ładowanie…
Reference in New Issue