diff --git a/backend/genesys/gl124.cpp b/backend/genesys/gl124.cpp index 78c6a0797..602c96e8d 100644 --- a/backend/genesys/gl124.cpp +++ b/backend/genesys/gl124.cpp @@ -579,10 +579,10 @@ static void gl124_init_motor_regs_scan(Genesys_Device* dev, /* scan and backtracking slope table */ auto scan_table = create_slope_table(dev->model->asic_type, dev->motor, yres, scan_exposure_time, 1, motor_profile); - gl124_send_slope_table(dev, SCAN_TABLE, scan_table.table, scan_table.steps_count); - gl124_send_slope_table(dev, BACKTRACK_TABLE, scan_table.table, scan_table.steps_count); + gl124_send_slope_table(dev, SCAN_TABLE, scan_table.table, scan_table.table.size()); + gl124_send_slope_table(dev, BACKTRACK_TABLE, scan_table.table, scan_table.table.size()); - reg->set16(REG_STEPNO, scan_table.steps_count); + reg->set16(REG_STEPNO, scan_table.table.size()); /* fast table */ fast_dpi=yres; @@ -595,23 +595,23 @@ static void gl124_init_motor_regs_scan(Genesys_Device* dev, */ auto fast_table = create_slope_table(dev->model->asic_type, dev->motor, fast_dpi, scan_exposure_time, 1, motor_profile); - gl124_send_slope_table(dev, STOP_TABLE, fast_table.table, fast_table.steps_count); - gl124_send_slope_table(dev, FAST_TABLE, fast_table.table, fast_table.steps_count); + gl124_send_slope_table(dev, STOP_TABLE, fast_table.table, fast_table.table.size()); + gl124_send_slope_table(dev, FAST_TABLE, fast_table.table, fast_table.table.size()); - reg->set16(REG_FASTNO, fast_table.steps_count); - reg->set16(REG_FSHDEC, fast_table.steps_count); - reg->set16(REG_FMOVNO, fast_table.steps_count); + reg->set16(REG_FASTNO, fast_table.table.size()); + reg->set16(REG_FSHDEC, fast_table.table.size()); + reg->set16(REG_FMOVNO, fast_table.table.size()); /* substract acceleration distance from feedl */ feedl=feed_steps; feedl <<= static_cast(motor_profile.step_type); - dist = scan_table.steps_count; + dist = scan_table.table.size(); if (has_flag(flags, ScanFlag::FEEDING)) { dist *= 2; } if (use_fast_fed) { - dist += fast_table.steps_count * 2; + dist += fast_table.table.size() * 2; } /* get sure we don't use insane value */ @@ -627,9 +627,9 @@ static void gl124_init_motor_regs_scan(Genesys_Device* dev, sanei_genesys_calculate_zmod(use_fast_fed, scan_exposure_time, scan_table.table, - scan_table.steps_count, + scan_table.table.size(), feedl, - scan_table.steps_count, + scan_table.table.size(), &z1, &z2); @@ -641,7 +641,7 @@ static void gl124_init_motor_regs_scan(Genesys_Device* dev, reg->set8(REG_0xA0, (static_cast(motor_profile.step_type) << REG_0xA0S_STEPSEL) | (static_cast(motor_profile.step_type) << REG_0xA0S_FSTPSEL)); - reg->set16(REG_FMOVDEC, fast_table.steps_count); + reg->set16(REG_FMOVDEC, fast_table.table.size()); } /** @brief setup optical related registers diff --git a/backend/genesys/gl646.cpp b/backend/genesys/gl646.cpp index d7ef176b9..384108cb4 100644 --- a/backend/genesys/gl646.cpp +++ b/backend/genesys/gl646.cpp @@ -651,17 +651,17 @@ void CommandSetGl646::init_regs_for_scan_session(Genesys_Device* dev, const Gene // the steps count must be different by at most 128, otherwise it's impossible to construct // a proper backtracking curve. We're using slightly lower limit to allow at least a minimum // distance between accelerations (forward_steps, backward_steps) - if (slope_table1.steps_count > slope_table2.steps_count + 100) { - slope_table2.steps_count += slope_table1.steps_count - 100; + if (slope_table1.table.size() > slope_table2.table.size() + 100) { + slope_table2.expand_table(slope_table1.table.size() - 100); } - if (slope_table2.steps_count > slope_table1.steps_count + 100) { - slope_table1.steps_count += slope_table2.steps_count - 100; + if (slope_table2.table.size() > slope_table1.table.size() + 100) { + slope_table1.expand_table(slope_table2.table.size() - 100); } - if (slope_table1.steps_count >= slope_table2.steps_count) { - backward_steps += (slope_table1.steps_count - slope_table2.steps_count) * 2; + if (slope_table1.table.size() >= slope_table2.table.size()) { + backward_steps += (slope_table1.table.size() - slope_table2.table.size()) * 2; } else { - forward_steps += (slope_table2.steps_count - slope_table1.steps_count) * 2; + forward_steps += (slope_table2.table.size() - slope_table1.table.size()) * 2; } if (forward_steps > 255) { @@ -677,8 +677,8 @@ void CommandSetGl646::init_regs_for_scan_session(Genesys_Device* dev, const Gene forward_steps -= backward_steps - 255; } - regs->find_reg(0x21).value = slope_table1.steps_count; - regs->find_reg(0x24).value = slope_table2.steps_count; + regs->find_reg(0x21).value = slope_table1.table.size(); + regs->find_reg(0x24).value = slope_table2.table.size(); regs->find_reg(0x22).value = forward_steps; regs->find_reg(0x23).value = backward_steps; @@ -801,12 +801,12 @@ void CommandSetGl646::init_regs_for_scan_session(Genesys_Device* dev, const Gene if (motor->fastfed) { - feedl = feedl - 2 * slope_table2.steps_count - - (slope_table1.steps_count >> step_shift); + feedl = feedl - 2 * slope_table2.table.size() - + (slope_table1.table.size() >> step_shift); } else { - feedl = feedl - (slope_table1.steps_count >> step_shift); + feedl = feedl - (slope_table1.table.size() >> step_shift); } break; } @@ -823,7 +823,7 @@ void CommandSetGl646::init_regs_for_scan_session(Genesys_Device* dev, const Gene sanei_genesys_calculate_zmod(regs->find_reg(0x02).value & REG_0x02_FASTFED, sensor.exposure_lperiod, slope_table1.table, - slope_table1.steps_count, + slope_table1.table.size(), move, motor->fwdbwd, &z1, &z2); /* no z1/z2 for sheetfed scanners */ @@ -833,7 +833,7 @@ void CommandSetGl646::init_regs_for_scan_session(Genesys_Device* dev, const Gene } regs->set16(REG_Z1MOD, z1); regs->set16(REG_Z2MOD, z2); - regs->find_reg(0x6b).value = slope_table2.steps_count; + regs->find_reg(0x6b).value = slope_table2.table.size(); regs->find_reg(0x6c).value = (regs->find_reg(0x6c).value & REG_0x6C_TGTIME) | ((z1 >> 13) & 0x38) | ((z2 >> 16) & 0x07); @@ -873,8 +873,8 @@ void CommandSetGl646::init_regs_for_scan_session(Genesys_Device* dev, const Gene } } - gl646_send_slope_table(dev, 0, slope_table1.table, slope_table1.steps_count); - gl646_send_slope_table(dev, 1, slope_table2.table, slope_table2.steps_count); + gl646_send_slope_table(dev, 0, slope_table1.table, slope_table1.table.size()); + gl646_send_slope_table(dev, 1, slope_table2.table, slope_table2.table.size()); } /** @@ -1445,7 +1445,7 @@ void CommandSetGl646::load_document(Genesys_Device* dev) const // send regs // start motor // wait e1 status to become e0 - gl646_send_slope_table(dev, 1, slope_table.table, slope_table.steps_count); + gl646_send_slope_table(dev, 1, slope_table.table, slope_table.table.size()); dev->interface->write_registers(regs); @@ -1601,7 +1601,7 @@ void CommandSetGl646::eject_document(Genesys_Device* dev) const // send regs // start motor // wait c1 status to become c8 : HOMESNR and ~MOTFLAG - gl646_send_slope_table(dev, 1, slope_table.table, slope_table.steps_count); + gl646_send_slope_table(dev, 1, slope_table.table, slope_table.table.size()); dev->interface->write_registers(regs); diff --git a/backend/genesys/gl841.cpp b/backend/genesys/gl841.cpp index 4be16502c..c1484fc3c 100644 --- a/backend/genesys/gl841.cpp +++ b/backend/genesys/gl841.cpp @@ -605,7 +605,7 @@ static void gl841_init_motor_regs_feed(Genesys_Device* dev, const Genesys_Sensor StepType::FULL, fast_exposure, dev->motor.base_ydpi / 4); - feedl = feed_steps - fast_table.steps_count * 2; + feedl = feed_steps - fast_table.table.size() * 2; use_fast_fed = 1; reg->set8(0x3d, (feedl >> 16) & 0xf); @@ -641,15 +641,15 @@ static void gl841_init_motor_regs_feed(Genesys_Device* dev, const Genesys_Sensor reg->find_reg(0x02).value &= ~REG_0x02_MTRREV; } - gl841_send_slope_table(dev, sensor, 3, fast_table.table, fast_table.steps_count); + gl841_send_slope_table(dev, sensor, 3, fast_table.table, fast_table.table.size()); reg->set8(0x67, 0x3f); reg->set8(0x68, 0x3f); reg->set8(REG_STEPNO, 0); reg->set8(REG_FASTNO, 0); reg->set8(0x69, 0); - reg->set8(0x6a, (fast_table.steps_count >> 1) + (fast_table.steps_count & 1)); - reg->set8(0x5f, (fast_table.steps_count >> 1) + (fast_table.steps_count & 1)); + reg->set8(0x6a, (fast_table.table.size() >> 1) + (fast_table.table.size() & 1)); + reg->set8(0x5f, (fast_table.table.size() >> 1) + (fast_table.table.size() & 1)); } static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, @@ -708,9 +708,9 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor auto back_table = sanei_genesys_create_slope_table3(dev->model->asic_type, dev->motor, motor_profile.step_type, 0, scan_yres); - if (feed_steps < (slow_table.steps_count >> static_cast(motor_profile.step_type))) { + if (feed_steps < (slow_table.table.size() >> static_cast(motor_profile.step_type))) { /*TODO: what should we do here?? go back to exposure calculation?*/ - feed_steps = slow_table.steps_count >> static_cast(motor_profile.step_type); + feed_steps = slow_table.table.size() >> static_cast(motor_profile.step_type); } auto fast_table = sanei_genesys_create_slope_table3(dev->model->asic_type, dev->motor, @@ -718,12 +718,12 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor dev->motor.base_ydpi / 4); unsigned max_fast_slope_steps_count = 1; - if (feed_steps > (slow_table.steps_count >> static_cast(motor_profile.step_type)) + 2) { + if (feed_steps > (slow_table.table.size() >> static_cast(motor_profile.step_type)) + 2) { max_fast_slope_steps_count = (feed_steps - - (slow_table.steps_count >> static_cast(motor_profile.step_type))) / 2; + (slow_table.table.size() >> static_cast(motor_profile.step_type))) / 2; } - if (fast_table.steps_count > max_fast_slope_steps_count) { + if (fast_table.table.size() > max_fast_slope_steps_count) { fast_table.slice_steps(max_fast_slope_steps_count); } @@ -735,8 +735,8 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor 2-feed mode */ use_fast_fed = 0; } - else if (feed_steps < fast_table.steps_count * 2 + - (slow_table.steps_count >> static_cast(motor_profile.step_type))) + else if (feed_steps < fast_table.table.size() * 2 + + (slow_table.table.size() >> static_cast(motor_profile.step_type))) { use_fast_fed = 0; DBG(DBG_info, "%s: feed too short, slow move forced.\n", __func__); @@ -751,24 +751,24 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor /*we use full steps as base unit here*/ fast_time = fast_exposure / 4 * - (feed_steps - fast_table.steps_count*2 - - (slow_table.steps_count >> static_cast(motor_profile.step_type))) + (feed_steps - fast_table.table.size()*2 - + (slow_table.table.size() >> static_cast(motor_profile.step_type))) + fast_table.pixeltime_sum*2 + slow_table.pixeltime_sum; slow_time = (scan_exposure_time * scan_yres) / dev->motor.base_ydpi * - (feed_steps - (slow_table.steps_count >> static_cast(motor_profile.step_type))) + (feed_steps - (slow_table.table.size() >> static_cast(motor_profile.step_type))) + slow_table.pixeltime_sum; use_fast_fed = fast_time < slow_time; } if (use_fast_fed) { - feedl = feed_steps - fast_table.steps_count * 2 - - (slow_table.steps_count >> static_cast(motor_profile.step_type)); - } else if ((feed_steps << static_cast(motor_profile.step_type)) < slow_table.steps_count) { + feedl = feed_steps - fast_table.table.size() * 2 - + (slow_table.table.size() >> static_cast(motor_profile.step_type)); + } else if ((feed_steps << static_cast(motor_profile.step_type)) < slow_table.table.size()) { feedl = 0; } else { - feedl = (feed_steps << static_cast(motor_profile.step_type)) - slow_table.steps_count; + feedl = (feed_steps << static_cast(motor_profile.step_type)) - slow_table.table.size(); } DBG(DBG_info, "%s: Decided to use %s mode\n", __func__, use_fast_fed?"fast feed":"slow feed"); @@ -803,16 +803,16 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor reg->find_reg(0x02).value &= ~0x40; } - gl841_send_slope_table(dev, sensor, 0, slow_table.table, slow_table.steps_count); - gl841_send_slope_table(dev, sensor, 1, back_table.table, back_table.steps_count); - gl841_send_slope_table(dev, sensor, 2, slow_table.table, slow_table.steps_count); + gl841_send_slope_table(dev, sensor, 0, slow_table.table, slow_table.table.size()); + gl841_send_slope_table(dev, sensor, 1, back_table.table, back_table.table.size()); + gl841_send_slope_table(dev, sensor, 2, slow_table.table, slow_table.table.size()); if (use_fast_fed) { - gl841_send_slope_table(dev, sensor, 3, fast_table.table, fast_table.steps_count); + gl841_send_slope_table(dev, sensor, 3, fast_table.table, fast_table.table.size()); } if (has_flag(flags, ScanFlag::AUTO_GO_HOME)) { - gl841_send_slope_table(dev, sensor, 4, fast_table.table, fast_table.steps_count); + gl841_send_slope_table(dev, sensor, 4, fast_table.table, fast_table.table.size()); } /* now reg 0x21 and 0x24 are available, we can calculate reg 0x22 and 0x23, @@ -821,18 +821,18 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor 2*STEPNO+FWDSTEP=2*FASTNO+BWDSTEP */ /* steps of table 0*/ - if (min_restep < slow_table.steps_count * 2 + 2) { - min_restep = slow_table.steps_count * 2 + 2; + if (min_restep < slow_table.table.size() * 2 + 2) { + min_restep = slow_table.table.size() * 2 + 2; } /* steps of table 1*/ - if (min_restep < back_table.steps_count * 2 + 2) { - min_restep = back_table.steps_count * 2 + 2; + if (min_restep < back_table.table.size() * 2 + 2) { + min_restep = back_table.table.size() * 2 + 2; } /* steps of table 0*/ - reg->set8(REG_FWDSTEP, min_restep - slow_table.steps_count*2); + reg->set8(REG_FWDSTEP, min_restep - slow_table.table.size()*2); /* steps of table 1*/ - reg->set8(REG_BWDSTEP, min_restep - back_table.steps_count*2); + reg->set8(REG_BWDSTEP, min_restep - back_table.table.size()*2); /* for z1/z2: @@ -855,11 +855,11 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor reg->find_reg(REG_0x1E).value |= scan_dummy; reg->set8(0x67, 0x3f | (static_cast(motor_profile.step_type) << 6)); reg->set8(0x68, 0x3f); - reg->set8(REG_STEPNO, (slow_table.steps_count >> 1) + (slow_table.steps_count & 1)); - reg->set8(REG_FASTNO, (back_table.steps_count >> 1) + (back_table.steps_count & 1)); - reg->set8(0x69, (slow_table.steps_count >> 1) + (slow_table.steps_count & 1)); - reg->set8(0x6a, (fast_table.steps_count >> 1) + (fast_table.steps_count & 1)); - reg->set8(0x5f, (fast_table.steps_count >> 1) + (fast_table.steps_count & 1)); + reg->set8(REG_STEPNO, (slow_table.table.size() >> 1) + (slow_table.table.size() & 1)); + reg->set8(REG_FASTNO, (back_table.table.size() >> 1) + (back_table.table.size() & 1)); + reg->set8(0x69, (slow_table.table.size() >> 1) + (slow_table.table.size() & 1)); + reg->set8(0x6a, (fast_table.table.size() >> 1) + (fast_table.table.size() & 1)); + reg->set8(0x5f, (fast_table.table.size() >> 1) + (fast_table.table.size() & 1)); } static void gl841_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, diff --git a/backend/genesys/gl842.cpp b/backend/genesys/gl842.cpp index 561e50834..153192e6a 100644 --- a/backend/genesys/gl842.cpp +++ b/backend/genesys/gl842.cpp @@ -322,13 +322,13 @@ static void gl842_init_motor_regs_scan(Genesys_Device* dev, auto scan_table = create_slope_table(dev->model->asic_type, dev->motor, scan_yres, exposure, step_multiplier, motor_profile); - gl842_send_slope_table(dev, SCAN_TABLE, scan_table.table, scan_table.steps_count); - gl842_send_slope_table(dev, BACKTRACK_TABLE, scan_table.table, scan_table.steps_count); - gl842_send_slope_table(dev, STOP_TABLE, scan_table.table, scan_table.steps_count); + gl842_send_slope_table(dev, SCAN_TABLE, scan_table.table, scan_table.table.size()); + gl842_send_slope_table(dev, BACKTRACK_TABLE, scan_table.table, scan_table.table.size()); + gl842_send_slope_table(dev, STOP_TABLE, scan_table.table, scan_table.table.size()); - reg->set8(REG_STEPNO, scan_table.steps_count / step_multiplier); - reg->set8(REG_FASTNO, scan_table.steps_count / step_multiplier); - reg->set8(REG_FSHDEC, scan_table.steps_count / step_multiplier); + reg->set8(REG_STEPNO, scan_table.table.size() / step_multiplier); + reg->set8(REG_FASTNO, scan_table.table.size() / step_multiplier); + reg->set8(REG_FSHDEC, scan_table.table.size() / step_multiplier); // fast table const auto* fast_profile = get_motor_profile_ptr(dev->motor.fast_profiles, 0, session); @@ -339,10 +339,10 @@ static void gl842_init_motor_regs_scan(Genesys_Device* dev, auto fast_table = create_slope_table_fastest(dev->model->asic_type, step_multiplier, *fast_profile); - gl842_send_slope_table(dev, FAST_TABLE, fast_table.table, fast_table.steps_count); - gl842_send_slope_table(dev, HOME_TABLE, fast_table.table, fast_table.steps_count); + gl842_send_slope_table(dev, FAST_TABLE, fast_table.table, fast_table.table.size()); + gl842_send_slope_table(dev, HOME_TABLE, fast_table.table, fast_table.table.size()); - reg->set8(REG_FMOVNO, fast_table.steps_count / step_multiplier); + reg->set8(REG_FMOVNO, fast_table.table.size() / step_multiplier); if (motor_profile.motor_vref != -1 && fast_profile->motor_vref != 1) { std::uint8_t vref = 0; @@ -357,10 +357,10 @@ static void gl842_init_motor_regs_scan(Genesys_Device* dev, unsigned feedl = feed_steps; feedl <<= static_cast(motor_profile.step_type); - unsigned dist = scan_table.steps_count / step_multiplier; + unsigned dist = scan_table.table.size() / step_multiplier; if (use_fast_fed) { - dist += (fast_table.steps_count / step_multiplier) * 2; + dist += (fast_table.table.size() / step_multiplier) * 2; } // make sure when don't insane value : XXX STEF XXX in this case we should @@ -378,9 +378,9 @@ static void gl842_init_motor_regs_scan(Genesys_Device* dev, sanei_genesys_calculate_zmod(use_fast_fed, exposure, scan_table.table, - scan_table.steps_count / step_multiplier, + scan_table.table.size() / step_multiplier, feedl, - scan_table.steps_count / step_multiplier, + scan_table.table.size() / step_multiplier, &z1, &z2); if (scan_yres > 600) { @@ -399,7 +399,7 @@ static void gl842_init_motor_regs_scan(Genesys_Device* dev, REG_0x68_FSTPSEL); // steps for STOP table - reg->set8(REG_FMOVDEC, fast_table.steps_count / step_multiplier); + reg->set8(REG_FMOVDEC, fast_table.table.size() / step_multiplier); } static void gl842_init_optical_regs_scan(Genesys_Device* dev, const Genesys_Sensor& sensor, diff --git a/backend/genesys/gl843.cpp b/backend/genesys/gl843.cpp index bd28cea8a..e641e1a0e 100644 --- a/backend/genesys/gl843.cpp +++ b/backend/genesys/gl843.cpp @@ -772,13 +772,13 @@ static void gl843_init_motor_regs_scan(Genesys_Device* dev, auto scan_table = create_slope_table(dev->model->asic_type, dev->motor, scan_yres, exposure, step_multiplier, motor_profile); - gl843_send_slope_table(dev, SCAN_TABLE, scan_table.table, scan_table.steps_count); - gl843_send_slope_table(dev, BACKTRACK_TABLE, scan_table.table, scan_table.steps_count); - gl843_send_slope_table(dev, STOP_TABLE, scan_table.table, scan_table.steps_count); + gl843_send_slope_table(dev, SCAN_TABLE, scan_table.table, scan_table.table.size()); + gl843_send_slope_table(dev, BACKTRACK_TABLE, scan_table.table, scan_table.table.size()); + gl843_send_slope_table(dev, STOP_TABLE, scan_table.table, scan_table.table.size()); - reg->set8(REG_STEPNO, scan_table.steps_count / step_multiplier); - reg->set8(REG_FASTNO, scan_table.steps_count / step_multiplier); - reg->set8(REG_FSHDEC, scan_table.steps_count / step_multiplier); + reg->set8(REG_STEPNO, scan_table.table.size() / step_multiplier); + reg->set8(REG_FASTNO, scan_table.table.size() / step_multiplier); + reg->set8(REG_FSHDEC, scan_table.table.size() / step_multiplier); // fast table const auto* fast_profile = get_motor_profile_ptr(dev->motor.fast_profiles, 0, session); @@ -789,10 +789,10 @@ static void gl843_init_motor_regs_scan(Genesys_Device* dev, auto fast_table = create_slope_table_fastest(dev->model->asic_type, step_multiplier, *fast_profile); - gl843_send_slope_table(dev, FAST_TABLE, fast_table.table, fast_table.steps_count); - gl843_send_slope_table(dev, HOME_TABLE, fast_table.table, fast_table.steps_count); + gl843_send_slope_table(dev, FAST_TABLE, fast_table.table, fast_table.table.size()); + gl843_send_slope_table(dev, HOME_TABLE, fast_table.table, fast_table.table.size()); - reg->set8(REG_FMOVNO, fast_table.steps_count / step_multiplier); + reg->set8(REG_FMOVNO, fast_table.table.size() / step_multiplier); if (motor_profile.motor_vref != -1 && fast_profile->motor_vref != 1) { std::uint8_t vref = 0; @@ -807,10 +807,10 @@ static void gl843_init_motor_regs_scan(Genesys_Device* dev, feedl=feed_steps; feedl <<= static_cast(motor_profile.step_type); - dist = scan_table.steps_count / step_multiplier; + dist = scan_table.table.size() / step_multiplier; if (use_fast_fed) { - dist += (fast_table.steps_count / step_multiplier) * 2; + dist += (fast_table.table.size() / step_multiplier) * 2; } /* get sure when don't insane value : XXX STEF XXX in this case we should @@ -828,9 +828,9 @@ static void gl843_init_motor_regs_scan(Genesys_Device* dev, sanei_genesys_calculate_zmod(use_fast_fed, exposure, scan_table.table, - scan_table.steps_count / step_multiplier, + scan_table.table.size() / step_multiplier, feedl, - scan_table.steps_count / step_multiplier, + scan_table.table.size() / step_multiplier, &z1, &z2); if(scan_yres>600) @@ -848,7 +848,7 @@ static void gl843_init_motor_regs_scan(Genesys_Device* dev, reg->set8_mask(REG_0x68, static_cast(fast_profile->step_type) << REG_0x68S_FSTPSEL, 0xc0); // steps for STOP table - reg->set8(REG_FMOVDEC, fast_table.steps_count / step_multiplier); + reg->set8(REG_FMOVDEC, fast_table.table.size() / step_multiplier); if (dev->model->model_id == ModelId::PANASONIC_KV_SS080 || dev->model->model_id == ModelId::HP_SCANJET_4850C || diff --git a/backend/genesys/gl846.cpp b/backend/genesys/gl846.cpp index 303936158..a6bdd7ffe 100644 --- a/backend/genesys/gl846.cpp +++ b/backend/genesys/gl846.cpp @@ -447,13 +447,13 @@ static void gl846_init_motor_regs_scan(Genesys_Device* dev, auto scan_table = create_slope_table(dev->model->asic_type, dev->motor, scan_yres, scan_exposure_time, step_multiplier, motor_profile); - gl846_send_slope_table(dev, SCAN_TABLE, scan_table.table, scan_table.steps_count); - gl846_send_slope_table(dev, BACKTRACK_TABLE, scan_table.table, scan_table.steps_count); - gl846_send_slope_table(dev, STOP_TABLE, scan_table.table, scan_table.steps_count); + gl846_send_slope_table(dev, SCAN_TABLE, scan_table.table, scan_table.table.size()); + gl846_send_slope_table(dev, BACKTRACK_TABLE, scan_table.table, scan_table.table.size()); + gl846_send_slope_table(dev, STOP_TABLE, scan_table.table, scan_table.table.size()); - reg->set8(REG_STEPNO, scan_table.steps_count / step_multiplier); - reg->set8(REG_FASTNO, scan_table.steps_count / step_multiplier); - reg->set8(REG_FSHDEC, scan_table.steps_count / step_multiplier); + reg->set8(REG_STEPNO, scan_table.table.size() / step_multiplier); + reg->set8(REG_FASTNO, scan_table.table.size() / step_multiplier); + reg->set8(REG_FSHDEC, scan_table.table.size() / step_multiplier); // fast table const auto* fast_profile = get_motor_profile_ptr(dev->motor.fast_profiles, 0, session); @@ -464,11 +464,11 @@ static void gl846_init_motor_regs_scan(Genesys_Device* dev, auto fast_table = create_slope_table_fastest(dev->model->asic_type, step_multiplier, *fast_profile); - gl846_send_slope_table(dev, FAST_TABLE, fast_table.table, fast_table.steps_count); - gl846_send_slope_table(dev, HOME_TABLE, fast_table.table, fast_table.steps_count); + gl846_send_slope_table(dev, FAST_TABLE, fast_table.table, fast_table.table.size()); + gl846_send_slope_table(dev, HOME_TABLE, fast_table.table, fast_table.table.size()); - reg->set8(REG_FMOVNO, fast_table.steps_count / step_multiplier); - reg->set8(REG_FMOVDEC, fast_table.steps_count / step_multiplier); + reg->set8(REG_FMOVNO, fast_table.table.size() / step_multiplier); + reg->set8(REG_FMOVDEC, fast_table.table.size() / step_multiplier); if (motor_profile.motor_vref != -1 && fast_profile->motor_vref != 1) { std::uint8_t vref = 0; @@ -483,13 +483,13 @@ static void gl846_init_motor_regs_scan(Genesys_Device* dev, unsigned dist = 0; if (use_fast_fed) { feedl <<= static_cast(fast_profile->step_type); - dist = (scan_table.steps_count + 2 * fast_table.steps_count); + dist = (scan_table.table.size() + 2 * fast_table.table.size()); // TODO read and decode REG_0xAB dist += (reg->get8(0x5e) & 31); dist += reg->get8(REG_FEDCNT); } else { feedl <<= static_cast(motor_profile.step_type); - dist = scan_table.steps_count; + dist = scan_table.table.size(); if (has_flag(flags, ScanFlag::FEEDING)) { dist *= 2; } @@ -539,7 +539,7 @@ static void gl846_init_motor_regs_scan(Genesys_Device* dev, dev->interface->write_register(REG_0x6C, val); */ - unsigned min_restep = (scan_table.steps_count / step_multiplier) / 2 - 1; + unsigned min_restep = (scan_table.table.size() / step_multiplier) / 2 - 1; if (min_restep < 1) { min_restep = 1; } @@ -551,7 +551,7 @@ static void gl846_init_motor_regs_scan(Genesys_Device* dev, sanei_genesys_calculate_zmod(use_fast_fed, scan_exposure_time * ccdlmt * tgtime, scan_table.table, - scan_table.steps_count, + scan_table.table.size(), feedl, min_restep * step_multiplier, &z1, diff --git a/backend/genesys/gl847.cpp b/backend/genesys/gl847.cpp index bf7e40228..636b71d3c 100644 --- a/backend/genesys/gl847.cpp +++ b/backend/genesys/gl847.cpp @@ -339,8 +339,8 @@ static void gl847_init_motor_regs_scan(Genesys_Device* dev, // scan and backtracking slope table auto scan_table = create_slope_table(dev->model->asic_type, dev->motor, scan_yres, scan_exposure_time, step_multiplier, motor_profile); - gl847_send_slope_table(dev, SCAN_TABLE, scan_table.table, scan_table.steps_count); - gl847_send_slope_table(dev, BACKTRACK_TABLE, scan_table.table, scan_table.steps_count); + gl847_send_slope_table(dev, SCAN_TABLE, scan_table.table, scan_table.table.size()); + gl847_send_slope_table(dev, BACKTRACK_TABLE, scan_table.table, scan_table.table.size()); // fast table unsigned fast_dpi = sanei_genesys_get_lowest_ydpi(dev); @@ -357,9 +357,9 @@ static void gl847_init_motor_regs_scan(Genesys_Device* dev, auto fast_table = create_slope_table(dev->model->asic_type, dev->motor, fast_dpi, scan_exposure_time, step_multiplier, fast_motor_profile); - gl847_send_slope_table(dev, STOP_TABLE, fast_table.table, fast_table.steps_count); - gl847_send_slope_table(dev, FAST_TABLE, fast_table.table, fast_table.steps_count); - gl847_send_slope_table(dev, HOME_TABLE, fast_table.table, fast_table.steps_count); + gl847_send_slope_table(dev, STOP_TABLE, fast_table.table, fast_table.table.size()); + gl847_send_slope_table(dev, FAST_TABLE, fast_table.table, fast_table.table.size()); + gl847_send_slope_table(dev, HOME_TABLE, fast_table.table, fast_table.table.size()); // correct move distance by acceleration and deceleration amounts unsigned feedl = feed_steps; @@ -367,13 +367,13 @@ static void gl847_init_motor_regs_scan(Genesys_Device* dev, if (use_fast_fed) { feedl <<= static_cast(fast_step_type); - dist = (scan_table.steps_count + 2 * fast_table.steps_count); + dist = (scan_table.table.size() + 2 * fast_table.table.size()); // TODO read and decode REG_0xAB dist += (reg->get8(0x5e) & 31); dist += reg->get8(REG_FEDCNT); } else { feedl <<= static_cast(motor_profile.step_type); - dist = scan_table.steps_count; + dist = scan_table.table.size(); if (has_flag(flags, ScanFlag::FEEDING)) { dist *= 2; } @@ -410,7 +410,7 @@ static void gl847_init_motor_regs_scan(Genesys_Device* dev, val = effective | REG_0x6C_GPIO10; dev->interface->write_register(REG_0x6C, val); - unsigned min_restep = scan_table.steps_count / (2 * step_multiplier) - 1; + unsigned min_restep = scan_table.table.size() / (2 * step_multiplier) - 1; if (min_restep < 1) { min_restep = 1; } @@ -422,7 +422,7 @@ static void gl847_init_motor_regs_scan(Genesys_Device* dev, sanei_genesys_calculate_zmod(use_fast_fed, scan_exposure_time * ccdlmt * tgtime, scan_table.table, - scan_table.steps_count, + scan_table.table.size(), feedl, min_restep * step_multiplier, &z1, @@ -436,11 +436,11 @@ static void gl847_init_motor_regs_scan(Genesys_Device* dev, reg->set8(REG_0x67, REG_0x67_MTRPWM); reg->set8(REG_0x68, REG_0x68_FASTPWM); - reg->set8(REG_STEPNO, scan_table.steps_count / step_multiplier); - reg->set8(REG_FASTNO, scan_table.steps_count / step_multiplier); - reg->set8(REG_FSHDEC, scan_table.steps_count / step_multiplier); - reg->set8(REG_FMOVNO, fast_table.steps_count / step_multiplier); - reg->set8(REG_FMOVDEC, fast_table.steps_count / step_multiplier); + reg->set8(REG_STEPNO, scan_table.table.size() / step_multiplier); + reg->set8(REG_FASTNO, scan_table.table.size() / step_multiplier); + reg->set8(REG_FSHDEC, scan_table.table.size() / step_multiplier); + reg->set8(REG_FMOVNO, fast_table.table.size() / step_multiplier); + reg->set8(REG_FMOVDEC, fast_table.table.size() / step_multiplier); } diff --git a/backend/genesys/motor.cpp b/backend/genesys/motor.cpp index 5b4cb98a5..725035299 100644 --- a/backend/genesys/motor.cpp +++ b/backend/genesys/motor.cpp @@ -82,10 +82,18 @@ MotorSlope MotorSlope::create_from_steps(unsigned initial_w, unsigned max_w, void MotorSlopeTable::slice_steps(unsigned count) { - if (count >= table.size() || count > steps_count) { - throw SaneException("Excepssive steps count"); + if (count > table.size()) { + throw SaneException("Excessive steps count"); } - steps_count = count; + table.resize(count); +} + +void MotorSlopeTable::expand_table(unsigned count) +{ + if (table.empty()) { + throw SaneException("Can't expand empty table"); + } + table.resize(table.size() + count, table.back()); } unsigned get_slope_table_max_size(AsicType asic_type) @@ -147,11 +155,6 @@ MotorSlopeTable create_slope_table_for_speed(const MotorSlope& slope, unsigned t table.pixeltime_sum += table.table.back(); } - table.steps_count = table.table.size(); - - // fill the rest of the table with the final speed - table.table.resize(max_size, final_speed); - return table; } diff --git a/backend/genesys/motor.h b/backend/genesys/motor.h index 46ff98d1b..9473a79f0 100644 --- a/backend/genesys/motor.h +++ b/backend/genesys/motor.h @@ -126,10 +126,12 @@ struct MotorSlope struct MotorSlopeTable { std::vector table; - unsigned steps_count = 0; unsigned pixeltime_sum = 0; void slice_steps(unsigned count); + + // expands the table by the given number of steps + void expand_table(unsigned count); }; unsigned get_slope_table_max_size(AsicType asic_type); diff --git a/testsuite/backend/genesys/tests_motor.cpp b/testsuite/backend/genesys/tests_motor.cpp index ce60f8c8c..dbe0ab704 100644 --- a/testsuite/backend/genesys/tests_motor.cpp +++ b/testsuite/backend/genesys/tests_motor.cpp @@ -34,7 +34,6 @@ namespace genesys { void test_create_slope_table3() { auto asic_type = AsicType::GL841; - auto max_table_size = get_slope_table_max_size(asic_type); Genesys_Motor motor; motor.id = MotorId::CANON_LIDE_200; @@ -48,80 +47,66 @@ void test_create_slope_table3() motor.base_ydpi); ASSERT_EQ(table.pixeltime_sum, 10000u); - ASSERT_EQ(table.steps_count, 1u); + ASSERT_EQ(table.table.size(), 1u); std::vector expected_steps = { 10000, }; - expected_steps.resize(max_table_size, 10000); - ASSERT_EQ(table.table, expected_steps); table = sanei_genesys_create_slope_table3(asic_type, motor, StepType::FULL, 2000, motor.base_ydpi); ASSERT_EQ(table.pixeltime_sum, 33830u); - ASSERT_EQ(table.steps_count, 7u); + ASSERT_EQ(table.table.size(), 7u); expected_steps = { 10000, 10000, 4099, 3028, 2511, 2192, 2000 }; - expected_steps.resize(max_table_size, 2000); - ASSERT_EQ(table.table, expected_steps); table = sanei_genesys_create_slope_table3(asic_type, motor, StepType::HALF, 10000, motor.base_ydpi); ASSERT_EQ(table.pixeltime_sum, 5000u); - ASSERT_EQ(table.steps_count, 1u); + ASSERT_EQ(table.table.size(), 1u); expected_steps = { 5000, }; - expected_steps.resize(max_table_size, 5000); - - ASSERT_EQ(table.table, expected_steps); table = sanei_genesys_create_slope_table3(asic_type, motor, StepType::HALF, 2000, motor.base_ydpi); ASSERT_EQ(table.pixeltime_sum, 16914u); - ASSERT_EQ(table.steps_count, 7u); + ASSERT_EQ(table.table.size(), 7u); expected_steps = { 5000, 5000, 2049, 1514, 1255, 1096, 1000 }; - expected_steps.resize(max_table_size, 1000); - ASSERT_EQ(table.table, expected_steps); table = sanei_genesys_create_slope_table3(asic_type, motor, StepType::QUARTER, 10000, motor.base_ydpi); ASSERT_EQ(table.pixeltime_sum, 2500u); - ASSERT_EQ(table.steps_count, 1u); + ASSERT_EQ(table.table.size(), 1u); expected_steps = { 2500, }; - expected_steps.resize(max_table_size, 2500); - - ASSERT_EQ(table.table, expected_steps); table = sanei_genesys_create_slope_table3(asic_type, motor, StepType::QUARTER, 2000, motor.base_ydpi); ASSERT_EQ(table.pixeltime_sum, 7680u); - ASSERT_EQ(table.steps_count, 6u); + ASSERT_EQ(table.table.size(), 6u); expected_steps = { 2500, 2500, 932, 683, 565, 500 }; - expected_steps.resize(max_table_size, 500); - ASSERT_EQ(table.table, expected_steps); } @@ -138,22 +123,20 @@ void test_create_slope_table_small_full_step() auto table = create_slope_table_for_speed(slope, 5000, StepType::FULL, 4, 8, max_table_size); std::vector expected_table = { - 62464, 62464, 6420, 5000 + 62464, 62464, 6420, 5000, 5000, 5000, 5000, 5000 }; - expected_table.resize(max_table_size, 5000); ASSERT_EQ(table.table, expected_table); - ASSERT_EQ(table.steps_count, 8u); + ASSERT_EQ(table.table.size(), 8u); ASSERT_EQ(table.pixeltime_sum, 156348u); table = create_slope_table_for_speed(slope, 3000, StepType::FULL, 4, 8, max_table_size); expected_table = { - 62464, 62464, 6420, 4552, 3720, 3223, 3000 + 62464, 62464, 6420, 4552, 3720, 3223, 3000, 3000 }; - expected_table.resize(max_table_size, 3000); ASSERT_EQ(table.table, expected_table); - ASSERT_EQ(table.steps_count, 8u); + ASSERT_EQ(table.table.size(), 8u); ASSERT_EQ(table.pixeltime_sum, 148843u); } @@ -172,9 +155,8 @@ void test_create_slope_table_small_full_step_target_speed_too_high() std::vector expected_table = { 62464, 62464, 6420, 4552, 3720, 3223, 2883, 2632 }; - expected_table.resize(max_table_size, 2632); ASSERT_EQ(table.table, expected_table); - ASSERT_EQ(table.steps_count, 8u); + ASSERT_EQ(table.table.size(), 8u); ASSERT_EQ(table.pixeltime_sum, 148358u); } @@ -191,22 +173,20 @@ void test_create_slope_table_small_half_step() auto table = create_slope_table_for_speed(slope, 5000, StepType::HALF, 4, 8, max_table_size); std::vector expected_table = { - 31232, 31232, 3210, 2500 + 31232, 31232, 3210, 2500, 2500, 2500, 2500, 2500 }; - expected_table.resize(max_table_size, 2500); ASSERT_EQ(table.table, expected_table); - ASSERT_EQ(table.steps_count, 8u); + ASSERT_EQ(table.table.size(), 8u); ASSERT_EQ(table.pixeltime_sum, 78174u); table = create_slope_table_for_speed(slope, 3000, StepType::HALF, 4, 8, max_table_size); expected_table = { - 31232, 31232, 3210, 2276, 1860, 1611, 1500 + 31232, 31232, 3210, 2276, 1860, 1611, 1500, 1500 }; - expected_table.resize(max_table_size, 1500); ASSERT_EQ(table.table, expected_table); - ASSERT_EQ(table.steps_count, 8u); + ASSERT_EQ(table.table.size(), 8u); ASSERT_EQ(table.pixeltime_sum, 74421u); } @@ -251,11 +231,10 @@ void test_create_slope_table_large_full_step() 5072, 4945, 4826, 4716, 4613, 4517, 4426, 4341, 4260, 4184, 4111, 4043, 3977, 3915, 3855, 3799, 3744, 3692, 3642, 3594, 3548, 3503, 3461, 3419, 3379, 3341, 3304, 3268, 3233, 3199, - 3166, 3135, 3104, 3074, 3045, 3017, 3000, + 3166, 3135, 3104, 3074, 3045, 3017, 3000, 3000, 3000, 3000, }; - expected_table.resize(max_table_size, 3000); ASSERT_EQ(table.table, expected_table); - ASSERT_EQ(table.steps_count, 60u); + ASSERT_EQ(table.table.size(), 60u); ASSERT_EQ(table.pixeltime_sum, 412616u); @@ -284,11 +263,10 @@ void test_create_slope_table_large_full_step() 1614, 1610, 1606, 1601, 1597, 1593, 1589, 1585, 1581, 1577, 1573, 1569, 1565, 1561, 1557, 1554, 1550, 1546, 1542, 1539, 1535, 1531, 1528, 1524, 1520, 1517, 1513, 1510, 1506, 1503, - 1500, + 1500, 1500, 1500, 1500, }; - expected_table.resize(max_table_size, 1500); ASSERT_EQ(table.table, expected_table); - ASSERT_EQ(table.steps_count, 224u); + ASSERT_EQ(table.table.size(), 224u); ASSERT_EQ(table.pixeltime_sum, 734910u); } @@ -311,11 +289,10 @@ void test_create_slope_table_large_half_step() 2536, 2472, 2413, 2358, 2306, 2258, 2213, 2170, 2130, 2092, 2055, 2021, 1988, 1957, 1927, 1899, 1872, 1846, 1821, 1797, 1774, 1751, 1730, 1709, 1689, 1670, 1652, 1634, 1616, 1599, - 1583, 1567, 1552, 1537, 1522, 1508, 1500, + 1583, 1567, 1552, 1537, 1522, 1508, 1500, 1500, 1500, 1500, }; - expected_table.resize(max_table_size, 1500); ASSERT_EQ(table.table, expected_table); - ASSERT_EQ(table.steps_count, 60u); + ASSERT_EQ(table.table.size(), 60u); ASSERT_EQ(table.pixeltime_sum, 206294u); @@ -344,11 +321,10 @@ void test_create_slope_table_large_half_step() 807, 805, 803, 800, 798, 796, 794, 792, 790, 788, 786, 784, 782, 780, 778, 777, 775, 773, 771, 769, 767, 765, 764, 762, 760, 758, 756, 755, 753, 751, - 750, + 750, 750, 750, 750, }; - expected_table.resize(max_table_size, 750); ASSERT_EQ(table.table, expected_table); - ASSERT_EQ(table.steps_count, 224u); + ASSERT_EQ(table.table.size(), 224u); ASSERT_EQ(table.pixeltime_sum, 367399u); }