|
|
@ -77,6 +77,20 @@ void OpticalModuleV2::initialize(int32_t moduleid, hardware_config_t* hardwarecf |
|
|
|
ZLOGI(TAG, "t_detector max gain : %f", t_detector_raw_gain_to_gain(255)); |
|
|
|
ZLOGI(TAG, "t_detector min gain : %f", t_detector_raw_gain_to_gain(1)); |
|
|
|
|
|
|
|
// // 选通ADC反馈通道
|
|
|
|
// select_f_channel(0);
|
|
|
|
// _close_t_amp_n5v();
|
|
|
|
// a8000_optical_open_laser(kf_optical);
|
|
|
|
|
|
|
|
// while (true)
|
|
|
|
// {
|
|
|
|
|
|
|
|
// int32_t adcval = 0;
|
|
|
|
// f_read_one_point(0, 0, adcval);
|
|
|
|
// ZLOGI(TAG, "f_read_one_point %d", adcval);
|
|
|
|
// osDelay(100);
|
|
|
|
// }
|
|
|
|
|
|
|
|
m_thread.init("optical_module", 1024); |
|
|
|
} |
|
|
|
|
|
|
@ -292,6 +306,75 @@ int32_t OpticalModuleV2::start_f_optical_scan(int32_t scanDirection, int32_t las |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
int32_t OpticalModuleV2::start_barcode_scan(int32_t lasterGain, int32_t scanGain, int32_t startpos, int32_t intervalstep, int32_t scanNum) { |
|
|
|
if (scanNum >= OPTICAL_MODULE_MAX_SCAN_POINT_NUM) { |
|
|
|
ZLOGE(TAG, "scanNum %d is too big", scanNum); |
|
|
|
return err::kparam_out_of_range; |
|
|
|
} |
|
|
|
|
|
|
|
m_thread.stop(); |
|
|
|
m_thread.start([this, lasterGain, scanGain, startpos, intervalstep, scanNum]() { |
|
|
|
ZLOGI(TAG, "--------------start_barcode_scan-----------"); |
|
|
|
ZLOGI(TAG, "lasterGain : %d", lasterGain); |
|
|
|
ZLOGI(TAG, "scanGain : %d", scanGain); |
|
|
|
ZLOGI(TAG, "startpos : %d", startpos); |
|
|
|
ZLOGI(TAG, "intervalstep : %d", intervalstep); |
|
|
|
ZLOGI(TAG, "scanNum : %d", scanNum); |
|
|
|
|
|
|
|
osDelay(50); |
|
|
|
|
|
|
|
move_to_block(startpos); |
|
|
|
|
|
|
|
// 设置激光亮度增益
|
|
|
|
a8000_optical_set_laster_gain(kf_optical, lasterGain); |
|
|
|
// 设置接收器增益
|
|
|
|
a8000_optical_set_scan_amp_gain(kf_optical, scanGain); |
|
|
|
// 选通ADC反馈通道
|
|
|
|
select_f_channel(3); |
|
|
|
// 打开负5v电源
|
|
|
|
_close_t_amp_n5v(); |
|
|
|
// 打开激光器
|
|
|
|
a8000_optical_open_laser(kf_optical); |
|
|
|
|
|
|
|
osDelay(10); |
|
|
|
|
|
|
|
int step = 0; |
|
|
|
int pointnum = 0; |
|
|
|
int32_t adcval = 0; |
|
|
|
adc_capture_point_num = 0; |
|
|
|
int32_t scanDirection = intervalstep < 0 ? 1 : 0; // 与电机运行相反的方向为正
|
|
|
|
|
|
|
|
motor_prepare(); |
|
|
|
while (true) { |
|
|
|
// 移动到第一个点
|
|
|
|
move_to_block(startpos + step); |
|
|
|
f_read_one_point(lasterGain, scanGain, adcval); |
|
|
|
|
|
|
|
step += intervalstep; |
|
|
|
pointnum++; |
|
|
|
adc_capture_point_num++; |
|
|
|
adc_capture_buf[adc_capture_point_num] = adcval; |
|
|
|
|
|
|
|
if (pointnum >= scanNum) { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
if (m_thread.getExitFlag()) { |
|
|
|
break; |
|
|
|
} |
|
|
|
osDelay(1); |
|
|
|
} |
|
|
|
motor_release(); |
|
|
|
a8000_optical_close_laser(kf_optical); |
|
|
|
if (scanDirection < 0) { |
|
|
|
reverse_capture_data(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// adc_capture_buf[0]
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
int32_t OpticalModuleV2::dumpresult() { |
|
|
|
for (int32_t i = 0; i < adc_capture_point_num; i++) { |
|
|
|
printf("%d,%d", i, adc_capture_buf[i]); |
|
|
@ -528,6 +611,8 @@ int32_t OpticalModuleV2::move_to_block(int32_t pos) { |
|
|
|
int32_t OpticalModuleV2::a8k_opt_v2_t_start_scan(int32_t scanDirection, int32_t lasterGain, int32_t scanGain) { return start_t_optical_scan(scanDirection, lasterGain, scanGain); } |
|
|
|
int32_t OpticalModuleV2::a8k_opt_v2_f_start_scan(int32_t scanDirection, int32_t lasterGain, int32_t scanGain) { return start_f_optical_scan(scanDirection, lasterGain, scanGain); } |
|
|
|
|
|
|
|
int32_t OpticalModuleV2::a8k_opt_v2_barcode_start_scan(int32_t lasterGain, int32_t scanGain, int32_t startpos, int32_t intervalstep, int32_t scanNum) { return start_barcode_scan(lasterGain, scanGain, startpos, intervalstep, scanNum); } |
|
|
|
|
|
|
|
int32_t OpticalModuleV2::a8k_opt_v2_t_open_laster(int32_t lasterGain, int32_t scanGain) { |
|
|
|
a8000_optical_open_laser(kt_optical); |
|
|
|
a8000_optical_set_laster_gain(kt_optical, lasterGain); |
|
|
|