From 2f37214415cab2e741d5963003c6db1b321165e3 Mon Sep 17 00:00:00 2001 From: zhaohe Date: Thu, 2 Jan 2025 14:18:59 +0800 Subject: [PATCH] V23 --- README.md | 4 +-- .../clst_controler.cpp | 36 +++++++++++++--------- src/version.h | 2 +- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index a56f083..6a5bb8f 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@ V19,20: V22: 基于V17,调整光源亮度计算公式 为duty = 59- 0.58773 * duty; - - +V23: + 修复回读duty值不准确的BUG ``` ``` diff --git a/src/camera_light_src_timing_controller/clst_controler.cpp b/src/camera_light_src_timing_controller/clst_controler.cpp index e0405d1..50a1979 100644 --- a/src/camera_light_src_timing_controller/clst_controler.cpp +++ b/src/camera_light_src_timing_controller/clst_controler.cpp @@ -597,6 +597,10 @@ zaf_error_code_t CLSTControler::LightSrcX_setTriggerModeFirstPluseOffset(int32_t if (index < 1 || index > 4) return kaf_ec_param_error; return reg_write(kreg_light_ctrol_module1_trigger_mode_first_pluse_offset + (index - 1) * 32, offset * 10); // 0.1us } + +#define DUTY_TO_REAL_DUTY(duty) (59 - 0.58773 * duty) +#define REAL_DUTY_TO_DUTY(duty) ((59 - duty) / 0.58773) + zaf_error_code_t CLSTControler::LightSrcX_setLightIntensityDuty(int32_t index, float duty) { // if (index < 1 || index > 4) return kaf_ec_param_error; @@ -606,8 +610,9 @@ zaf_error_code_t CLSTControler::LightSrcX_setLightIntensityDuty(int32_t index, f // duty = duty * 0.4; //旧设备 // duty = (0.767 - duty / 100.0 * 0.25 * 4.13 * 0.74) * 100 / 5 / 0.26; 新设备 ==> duty = 59- 0.58773 * duty - // - duty = 59- 0.58773 * duty; + // + // duty = 59 - 0.58773 * duty; + duty = DUTY_TO_REAL_DUTY(duty); uint32_t freqcnt = 0; DO_CMD(reg_read(kreg_light_ctrol_module1_light_driver_freq_cnt + (index - 1) * 32, freqcnt)); @@ -625,6 +630,21 @@ zaf_error_code_t CLSTControler::LightSrcX_setLightIntensityDuty(int32_t index, f // float bakduty = (cnt * 100.0 / freqcnt); return reg_write(kreg_light_ctrol_module1_light_intensity_cnt + (index - 1) * 32, cnt); } + +zaf_error_code_t CLSTControler::LightSrcX_getLightIntensityDuty(int32_t index, float &duty) { // + if (index < 1 || index > 4) return kaf_ec_param_error; + uint32_t freqcnt = 0; + DO_CMD(reg_read(kreg_light_ctrol_module1_light_driver_freq_cnt + (index - 1) * 32, freqcnt)); + + uint32_t cnt = 0; + DO_CMD(reg_read(kreg_light_ctrol_module1_light_intensity_cnt + (index - 1) * 32, cnt)); + + duty = (cnt * 100.0 / freqcnt); + // duty = duty / 0.4; + duty = REAL_DUTY_TO_DUTY(duty); + return kaf_ec_success; +} + zaf_error_code_t CLSTControler::LightSrcX_setLightDriverFreq(int32_t index, float freq) { // double T = 1.0 / freq; @@ -663,19 +683,7 @@ zaf_error_code_t CLSTControler::LightSrcX_getTriggerModePluseDelay(int32_t index delay = val; return kaf_ec_success; } -zaf_error_code_t CLSTControler::LightSrcX_getLightIntensityDuty(int32_t index, float &duty) { // - if (index < 1 || index > 4) return kaf_ec_param_error; - uint32_t freqcnt = 0; - DO_CMD(reg_read(kreg_light_ctrol_module1_light_driver_freq_cnt + (index - 1) * 32, freqcnt)); - uint32_t cnt = 0; - DO_CMD(reg_read(kreg_light_ctrol_module1_light_intensity_cnt + (index - 1) * 32, cnt)); - - duty = (cnt * 100.0 / freqcnt); - duty = duty / 0.4; - - return kaf_ec_success; -} zaf_error_code_t CLSTControler::LightSrcX_getLightDriverFreq(int32_t index, float &freq) { // return readFreq(kreg_light_ctrol_module1_light_driver_freq_cnt + (index - 1) * 32, freq); } diff --git a/src/version.h b/src/version.h index 28fb6b1..0ed345a 100644 --- a/src/version.h +++ b/src/version.h @@ -1,4 +1,4 @@ #pragma once -#define VERSION 22 +#define VERSION 23 #define MAUFACTURER "iflytop" \ No newline at end of file