|
|
@ -69,7 +69,18 @@ void OpticalModuleV2::initialize(int32_t moduleid, hardware_config_t* hardwarecf |
|
|
|
|
|
|
|
m_reg.scan_step_interval = 1; |
|
|
|
m_reg.scan_pointnum = 1200; |
|
|
|
m_default_reg = m_reg; |
|
|
|
|
|
|
|
m_reg.scan_vstart = 400; |
|
|
|
m_reg.scan_vstop = 400; |
|
|
|
m_reg.scan_v1 = 550; |
|
|
|
m_reg.scan_a1 = 300; |
|
|
|
m_reg.scan_d1 = 300; |
|
|
|
m_reg.scan_amax = 1000; |
|
|
|
m_reg.scan_dmax = 1000; |
|
|
|
m_reg.scan_vdefault = 1200; |
|
|
|
m_reg.scan_tzerowait = 0; |
|
|
|
|
|
|
|
m_default_reg = m_reg; |
|
|
|
|
|
|
|
ZLOGI(TAG, "-----------------module info--------------"); |
|
|
|
ZLOGI(TAG, "f_detector max gain : %f", f_detector_raw_gain_to_gain(255)); |
|
|
@ -145,6 +156,16 @@ int32_t OpticalModuleV2::module_xxx_reg(int32_t param_id, bool read, int32_t& va |
|
|
|
PROCESS_REG(kreg_a8k_opt_t_reverse_scan_pos_offset, REG_GET(m_reg.t_reverse_scan_pos_offset), REG_SET(m_reg.t_reverse_scan_pos_offset)); |
|
|
|
PROCESS_REG(kreg_a8k_opt_f_reverse_scan_pos_offset, REG_GET(m_reg.f_reverse_scan_pos_offset), REG_SET(m_reg.f_reverse_scan_pos_offset)); |
|
|
|
|
|
|
|
PROCESS_REG(kreg_a8k_opt_scan_vdefault, REG_GET(m_reg.scan_vdefault), REG_SET(m_reg.scan_vdefault)); |
|
|
|
PROCESS_REG(kreg_a8k_opt_scan_vstart, REG_GET(m_reg.scan_vstart), REG_SET(m_reg.scan_vstart)); |
|
|
|
PROCESS_REG(kreg_a8k_opt_scan_a1, REG_GET(m_reg.scan_a1), REG_SET(m_reg.scan_a1)); |
|
|
|
PROCESS_REG(kreg_a8k_opt_scan_amax, REG_GET(m_reg.scan_amax), REG_SET(m_reg.scan_amax)); |
|
|
|
PROCESS_REG(kreg_a8k_opt_scan_v1, REG_GET(m_reg.scan_v1), REG_SET(m_reg.scan_v1)); |
|
|
|
PROCESS_REG(kreg_a8k_opt_scan_dmax, REG_GET(m_reg.scan_dmax), REG_SET(m_reg.scan_dmax)); |
|
|
|
PROCESS_REG(kreg_a8k_opt_scan_d1, REG_GET(m_reg.scan_d1), REG_SET(m_reg.scan_d1)); |
|
|
|
PROCESS_REG(kreg_a8k_opt_scan_vstop, REG_GET(m_reg.scan_vstop), REG_SET(m_reg.scan_vstop)); |
|
|
|
PROCESS_REG(kreg_a8k_opt_scan_tzerowait, REG_GET(m_reg.scan_tzerowait), REG_SET(m_reg.scan_tzerowait)); |
|
|
|
|
|
|
|
PROCESS_REG(kreg_a8k_opt_scan_step_interval, REG_GET(m_reg.scan_step_interval), REG_SET(m_reg.scan_step_interval)); |
|
|
|
PROCESS_REG(kreg_a8k_opt_scan_pointnum, REG_GET(m_reg.scan_pointnum), REG_SET(m_reg.scan_pointnum)); |
|
|
|
default: |
|
|
@ -159,28 +180,16 @@ int32_t OpticalModuleV2::module_stop() { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
// virtual int32_t a8000_optical_start_capture();
|
|
|
|
// virtual int32_t a8000_optical_read_raw(int32_t index, uint8_t* data, int32_t* len);
|
|
|
|
|
|
|
|
#define MAX_SCAN_POINT_NUM 1200
|
|
|
|
|
|
|
|
// bittly.variableSet("scan_start_pos","2860"); //F
|
|
|
|
// bittly.variableSet("scan_step_interval","1");
|
|
|
|
// bittly.variableSet("scan_pointnum","1200");
|
|
|
|
// bittly.variableSet("scan_direction","-1");
|
|
|
|
|
|
|
|
// bittly.variableSet("scan_start_pos","4005"); //T
|
|
|
|
// bittly.variableSet("scan_step_interval","1");
|
|
|
|
// bittly.variableSet("scan_pointnum","1200");
|
|
|
|
// bittly.variableSet("scan_direction","-1");
|
|
|
|
|
|
|
|
int32_t OpticalModuleV2::start_t_optical_scan(int32_t scanDirection, int32_t lasterGain, int32_t scanGain) { |
|
|
|
m_thread.stop(); |
|
|
|
m_thread.start([this, scanDirection, lasterGain, scanGain]() { |
|
|
|
ZLOGI(TAG, "--------------start_t_optical_scan-----------"); |
|
|
|
int32_t intervalStep = 0; |
|
|
|
int32_t scanStartPos = 0; |
|
|
|
osDelay(50); |
|
|
|
osDelay(10); |
|
|
|
|
|
|
|
if (scanDirection >= 0) { |
|
|
|
intervalStep = -m_reg.scan_step_interval; |
|
|
@ -189,7 +198,7 @@ int32_t OpticalModuleV2::start_t_optical_scan(int32_t scanDirection, int32_t las |
|
|
|
intervalStep = m_reg.scan_step_interval; |
|
|
|
scanStartPos = m_reg.t_reverse_scan_pos_offset; |
|
|
|
} |
|
|
|
|
|
|
|
active_motor_default_cfg(); |
|
|
|
move_to_block(scanStartPos); |
|
|
|
|
|
|
|
// 设置激光亮度增益
|
|
|
@ -206,7 +215,8 @@ int32_t OpticalModuleV2::start_t_optical_scan(int32_t scanDirection, int32_t las |
|
|
|
int32_t adcval = 0; |
|
|
|
adc_capture_point_num = 0; |
|
|
|
|
|
|
|
motor_prepare(); |
|
|
|
int32_t startTicket = HAL_GetTick(); |
|
|
|
active_motor_opt_cfg(); |
|
|
|
while (true) { |
|
|
|
// 移动到第一个点
|
|
|
|
move_to_block(scanStartPos + step); |
|
|
@ -226,13 +236,18 @@ int32_t OpticalModuleV2::start_t_optical_scan(int32_t scanDirection, int32_t las |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// end of scan
|
|
|
|
m_t_laster_enable_io.setState(false); |
|
|
|
motor_release(); |
|
|
|
_close_t_amp_n5v(); |
|
|
|
recover_motor_default_cfg(); |
|
|
|
|
|
|
|
if (scanDirection < 0) { |
|
|
|
reverse_capture_data(); |
|
|
|
} |
|
|
|
ZLOGI(TAG, "use time: %f s", (HAL_GetTick() - startTicket) / 1000.0); |
|
|
|
|
|
|
|
ZLOGI(TAG, "--------------end_t_optical_scan-----------"); |
|
|
|
}); |
|
|
|
return 0; |
|
|
|
|
|
|
@ -242,7 +257,7 @@ int32_t OpticalModuleV2::start_f_optical_scan(int32_t scanDirection, int32_t las |
|
|
|
m_thread.stop(); |
|
|
|
m_thread.start([this, scanDirection, lasterGain, scanGain]() { |
|
|
|
ZLOGI(TAG, "--------------start_f_optical_scan-----------"); |
|
|
|
osDelay(50); |
|
|
|
osDelay(10); |
|
|
|
|
|
|
|
int32_t intervalStep = 0; |
|
|
|
int32_t scanStartPos = 0; |
|
|
@ -254,7 +269,7 @@ int32_t OpticalModuleV2::start_f_optical_scan(int32_t scanDirection, int32_t las |
|
|
|
intervalStep = m_reg.scan_step_interval; |
|
|
|
scanStartPos = m_reg.f_reverse_scan_pos_offset; |
|
|
|
} |
|
|
|
|
|
|
|
active_motor_default_cfg(); |
|
|
|
move_to_block(scanStartPos); |
|
|
|
|
|
|
|
// 设置激光亮度增益
|
|
|
@ -274,8 +289,8 @@ int32_t OpticalModuleV2::start_f_optical_scan(int32_t scanDirection, int32_t las |
|
|
|
int pointnum = 0; |
|
|
|
int32_t adcval = 0; |
|
|
|
adc_capture_point_num = 0; |
|
|
|
|
|
|
|
motor_prepare(); |
|
|
|
active_motor_opt_cfg(); |
|
|
|
int32_t startTicket = HAL_GetTick(); |
|
|
|
while (true) { |
|
|
|
// 移动到第一个点
|
|
|
|
move_to_block(scanStartPos + step); |
|
|
@ -293,13 +308,19 @@ int32_t OpticalModuleV2::start_f_optical_scan(int32_t scanDirection, int32_t las |
|
|
|
if (m_thread.getExitFlag()) { |
|
|
|
break; |
|
|
|
} |
|
|
|
osDelay(1); |
|
|
|
// osDelay(1);
|
|
|
|
} |
|
|
|
motor_release(); |
|
|
|
|
|
|
|
// end of scan
|
|
|
|
select_f_channel(0); |
|
|
|
a8000_optical_close_laser(kf_optical); |
|
|
|
recover_motor_default_cfg(); |
|
|
|
|
|
|
|
if (scanDirection < 0) { |
|
|
|
reverse_capture_data(); |
|
|
|
} |
|
|
|
ZLOGI(TAG, "use time: %f s", (HAL_GetTick() - startTicket) / 1000.0); |
|
|
|
ZLOGI(TAG, "--------------end_f_optical_scan-----------"); |
|
|
|
}); |
|
|
|
|
|
|
|
// adc_capture_buf[0]
|
|
|
@ -321,8 +342,8 @@ int32_t OpticalModuleV2::start_barcode_scan(int32_t lasterGain, int32_t scanGain |
|
|
|
ZLOGI(TAG, "intervalstep : %d", intervalstep); |
|
|
|
ZLOGI(TAG, "scanNum : %d", scanNum); |
|
|
|
|
|
|
|
osDelay(50); |
|
|
|
|
|
|
|
osDelay(10); |
|
|
|
active_motor_default_cfg(); |
|
|
|
move_to_block(startpos); |
|
|
|
|
|
|
|
// 设置激光亮度增益
|
|
|
@ -344,7 +365,8 @@ int32_t OpticalModuleV2::start_barcode_scan(int32_t lasterGain, int32_t scanGain |
|
|
|
adc_capture_point_num = 0; |
|
|
|
int32_t scanDirection = intervalstep < 0 ? 1 : 0; // 与电机运行相反的方向为正
|
|
|
|
|
|
|
|
motor_prepare(); |
|
|
|
active_motor_opt_cfg(); |
|
|
|
int32_t startTicket = HAL_GetTick(); |
|
|
|
while (true) { |
|
|
|
// 移动到第一个点
|
|
|
|
move_to_block(startpos + step); |
|
|
@ -362,13 +384,19 @@ int32_t OpticalModuleV2::start_barcode_scan(int32_t lasterGain, int32_t scanGain |
|
|
|
if (m_thread.getExitFlag()) { |
|
|
|
break; |
|
|
|
} |
|
|
|
osDelay(1); |
|
|
|
// osDelay(1);
|
|
|
|
} |
|
|
|
motor_release(); |
|
|
|
|
|
|
|
// end of scan
|
|
|
|
select_f_channel(0); |
|
|
|
a8000_optical_close_laser(kf_optical); |
|
|
|
recover_motor_default_cfg(); |
|
|
|
|
|
|
|
if (scanDirection < 0) { |
|
|
|
reverse_capture_data(); |
|
|
|
} |
|
|
|
ZLOGI(TAG, "use time: %f s", (HAL_GetTick() - startTicket) / 1000.0); |
|
|
|
ZLOGI(TAG, "--------------end_barcode_scan-----------"); |
|
|
|
}); |
|
|
|
|
|
|
|
// adc_capture_buf[0]
|
|
|
@ -579,27 +607,26 @@ int32_t OpticalModuleV2::_close_t_amp_n5v() { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
int32_t OpticalModuleV2::motor_prepare() { |
|
|
|
auto _motor = motor->getMotor(); |
|
|
|
// _motor->setNoAccLimit(true);
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t OpticalModuleV2::motor_release() { |
|
|
|
void OpticalModuleV2::active_motor_default_cfg() { motor->step_motor_active_cfg(); } |
|
|
|
void OpticalModuleV2::recover_motor_default_cfg() { active_motor_default_cfg(); } |
|
|
|
|
|
|
|
void OpticalModuleV2::active_motor_opt_cfg() { |
|
|
|
auto _motor = motor->getMotor(); |
|
|
|
// _motor->setNoAccLimit(false);
|
|
|
|
return 0; |
|
|
|
_motor->set_vstart(m_reg.scan_vstart); |
|
|
|
_motor->set_vstop(m_reg.scan_vstop); |
|
|
|
_motor->set_a1(m_reg.scan_a1); |
|
|
|
_motor->set_d1(m_reg.scan_d1); |
|
|
|
_motor->set_v1(m_reg.scan_v1); |
|
|
|
_motor->set_amax(m_reg.scan_amax); |
|
|
|
_motor->set_dmax(m_reg.scan_dmax); |
|
|
|
_motor->set_tzerowait(m_reg.scan_tzerowait); |
|
|
|
} |
|
|
|
|
|
|
|
int32_t OpticalModuleV2::move_to_block(int32_t pos) { |
|
|
|
auto _motor = motor->getMotor(); |
|
|
|
_motor->setAcceleration(3600); |
|
|
|
_motor->setDeceleration(3600); |
|
|
|
_motor->moveTo(pos, motor->getCfg()->motor_default_velocity); |
|
|
|
while (!_motor->isReachTarget() && !m_thread.getExitFlag()) { |
|
|
|
// zos_early_delayus(100);
|
|
|
|
// osDelay(1);
|
|
|
|
_motor->moveTo(pos, m_reg.scan_vdefault); |
|
|
|
while (!_motor->isReachTarget()) { |
|
|
|
} |
|
|
|
_motor->stop(); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|