genesys: Fix step multiplier handling in motor table manipulation utils

merge-requests/463/merge
Povilas Kanapickas 2020-05-18 03:53:14 +03:00
rodzic b8ced2861a
commit 049e69aa79
4 zmienionych plików z 13 dodań i 10 usunięć

Wyświetl plik

@ -649,10 +649,10 @@ void CommandSetGl646::init_regs_for_scan_session(Genesys_Device* dev, const Gene
// 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.table.size() > slope_table2.table.size() + 100) {
slope_table2.expand_table(slope_table1.table.size() - 100);
slope_table2.expand_table(slope_table1.table.size() - 100, 1);
}
if (slope_table2.table.size() > slope_table1.table.size() + 100) {
slope_table1.expand_table(slope_table2.table.size() - 100);
slope_table1.expand_table(slope_table2.table.size() - 100, 1);
}
if (slope_table1.table.size() >= slope_table2.table.size()) {

Wyświetl plik

@ -681,14 +681,14 @@ static void gl841_init_motor_regs_scan(Genesys_Device* dev, const Genesys_Sensor
auto fast_table = create_slope_table_fastest(dev->model->asic_type, step_multiplier,
*fast_profile);
unsigned max_fast_slope_steps_count = 1;
unsigned max_fast_slope_steps_count = step_multiplier;
if (feed_steps > (slow_table.table.size() >> static_cast<unsigned>(motor_profile.step_type)) + 2) {
max_fast_slope_steps_count = (feed_steps -
(slow_table.table.size() >> static_cast<unsigned>(motor_profile.step_type))) / 2;
}
if (fast_table.table.size() > max_fast_slope_steps_count) {
fast_table.slice_steps(max_fast_slope_steps_count);
fast_table.slice_steps(max_fast_slope_steps_count, step_multiplier);
}
/* fast fed special cases handling */

Wyświetl plik

@ -43,6 +43,7 @@
#define DEBUG_DECLARE_ONLY
#include "low.h"
#include "motor.h"
#include "utilities.h"
#include <cmath>
@ -81,20 +82,22 @@ MotorSlope MotorSlope::create_from_steps(unsigned initial_w, unsigned max_w,
return slope;
}
void MotorSlopeTable::slice_steps(unsigned count)
void MotorSlopeTable::slice_steps(unsigned count, unsigned step_multiplier)
{
if (count > table.size()) {
throw SaneException("Excessive steps count");
if (count > table.size() || count < step_multiplier) {
throw SaneException("Invalid steps count");
}
count = align_multiple_floor(count, step_multiplier);
table.resize(count);
generate_pixeltime_sum();
}
void MotorSlopeTable::expand_table(unsigned count)
void MotorSlopeTable::expand_table(unsigned count, unsigned step_multiplier)
{
if (table.empty()) {
throw SaneException("Can't expand empty table");
}
count = align_multiple_ceil(count, step_multiplier);
table.resize(table.size() + count, table.back());
generate_pixeltime_sum();
}

Wyświetl plik

@ -127,10 +127,10 @@ struct MotorSlopeTable
{
std::vector<std::uint16_t> table;
void slice_steps(unsigned count);
void slice_steps(unsigned count, unsigned step_multiplier);
// expands the table by the given number of steps
void expand_table(unsigned count);
void expand_table(unsigned count, unsigned step_multiplier);
std::uint64_t pixeltime_sum() const { return pixeltime_sum_; }