diff --git a/chip/zpwm_generator_muti_channel.cpp b/chip/zpwm_generator_muti_channel.cpp index 73eb8f4..9d87534 100644 --- a/chip/zpwm_generator_muti_channel.cpp +++ b/chip/zpwm_generator_muti_channel.cpp @@ -75,7 +75,7 @@ void ZPWMGeneratorMutiChannel::updatePWMState(int32_t channelindex /*1 void ZPWMGeneratorMutiChannel::startPWM(int32_t channelindex /*1,2,3,4*/, float duty) { if (channelindex < 1 || channelindex > 4) return; m_pwmstate[channelindex] = true; - ZEARLY_LOGI(TAG, "[%s] setpwm tim:%s ch:%d duty:%f", m_cfg.name, chip_tim_get_name(m_htim->Instance), channelindex, duty); + if (m_enablelog) ZEARLY_LOGI(TAG, "[%s] setpwm tim:%s ch:%d duty:%f", m_cfg.name, chip_tim_get_name(m_htim->Instance), channelindex, duty); updatePWMState(channelindex, duty); } void ZPWMGeneratorMutiChannel::stopPWM(int32_t channelindex) { diff --git a/chip/zpwm_generator_muti_channel.hpp b/chip/zpwm_generator_muti_channel.hpp index f0dd918..cdf834b 100644 --- a/chip/zpwm_generator_muti_channel.hpp +++ b/chip/zpwm_generator_muti_channel.hpp @@ -41,6 +41,7 @@ class ZPWMGeneratorMutiChannel { * @param Polarity 1:高为有效电平,0:低为有效电平 */ void initialize(hardware_config_t *cfg); + void settrace(bool enable) { m_enablelog = enable; } /******************************************************************************* * PWM_MODE * *******************************************************************************/ diff --git a/components/ti/drv8710.cpp b/components/ti/drv8710.cpp index 8099c24..9668d8b 100644 --- a/components/ti/drv8710.cpp +++ b/components/ti/drv8710.cpp @@ -5,6 +5,7 @@ void DRV8710::initialize(config_t* cfg) { // m_cfg = *cfg; cfg->pwm_cfg.calltrace = cfg->enableTrace; m_pwmCtrl.initialize(&cfg->pwm_cfg); + m_pwmCtrl.settrace(cfg->enableTrace); ZASSERT(cfg->nsleep != PinNull); ZASSERT(cfg->nfault != PinNull); @@ -24,6 +25,8 @@ void DRV8710::moveForward(int32_t duty) { if (duty > 100) duty = 100; if (duty < 0) duty = 0; + if (m_cfg.shaft) duty = 100 - duty; + set_direcetion(true); m_pwmCtrl.startPWM(m_cfg.in1_chnannel_index, duty); } @@ -31,6 +34,8 @@ void DRV8710::moveBackward(int32_t duty) { if (duty > 100) duty = 100; if (duty < 0) duty = 0; + if (!m_cfg.shaft) duty = 100 - duty; + set_direcetion(false); m_pwmCtrl.startPWM(m_cfg.in1_chnannel_index, duty); } @@ -46,9 +51,7 @@ void DRV8710::move(int32_t duty) { } void DRV8710::set_direcetion(bool direcetion) { - if (m_cfg.shaft) { - direcetion = !direcetion; - } + if (m_cfg.shaft) direcetion = !direcetion; m_in2.setState(direcetion); } diff --git a/components/water_cooling_temperature_control_module/pwm_ctrl_module.cpp b/components/water_cooling_temperature_control_module/pwm_ctrl_module.cpp index d80dd52..2083cbc 100644 --- a/components/water_cooling_temperature_control_module/pwm_ctrl_module.cpp +++ b/components/water_cooling_temperature_control_module/pwm_ctrl_module.cpp @@ -37,6 +37,7 @@ void PWMSpeedCtrlModule::initialize(config_t* pcfg) { } cfg.pwm_cfg.calltrace = pcfg->enableTrace; m_fanCtrlPwm.initialize(&cfg.pwm_cfg); + m_fanCtrlPwm.settrace(pcfg->enableTrace); OSDefaultSchduler::getInstance()->regPeriodJob([this](OSDefaultSchduler::Context&) { checkfanState(); }, 1000); } diff --git a/components/water_cooling_temperature_control_module/water_cooling_temperature_control_module.cpp b/components/water_cooling_temperature_control_module/water_cooling_temperature_control_module.cpp index af53439..6a3936c 100644 --- a/components/water_cooling_temperature_control_module/water_cooling_temperature_control_module.cpp +++ b/components/water_cooling_temperature_control_module/water_cooling_temperature_control_module.cpp @@ -11,6 +11,8 @@ using namespace iflytop; #define ACTION_TEST_PUMP_SET_LEVEL 2 #define ACTION_TEST_FAN_SET_LEVEL 3 #define ACTION_TEST_DUMP_DC_MOTOR_STATE 4 +#define ACTION_TEST_ENABLE_LOG 5 +#define ACTION_TEST_DISABLE_LOG 6 void WaterCoolingTemperatureControlModule::initialize(int32_t id, config_t* cfg, hardwared_config_t* hardwaredconfig) { m_id = id; @@ -103,6 +105,12 @@ int32_t WaterCoolingTemperatureControlModule::do_action(int32_t actioncode) { } else if (actioncode == ACTION_TEST_DUMP_DC_MOTOR_STATE) { m_pelter_ctrl->dumpErrorInfo(); return 0; + } else if (actioncode == ACTION_TEST_ENABLE_LOG) { + m_enable_log = 1; + return 0; + } else if (actioncode == ACTION_TEST_DISABLE_LOG) { + m_enable_log = 0; + return 0; } else { @@ -155,7 +163,10 @@ void WaterCoolingTemperatureControlModule::workloop() { float out = 0; m_pidmodule.compute(error, &out); - ZLOGI(TAG, "temperature: %.2f %.2f integral_err:%.2f out:%d", m_target_temperature, val, m_pidmodule.get_integral_err(), (int32_t)out); + if (m_enable_log) { + ZLOGI(TAG, "temperature: %.2f %.2f integral_err:%.2f out:%d", m_target_temperature, val, m_pidmodule.get_integral_err(), (int32_t)out); + } + peltier_set_power_level(out); } diff --git a/components/water_cooling_temperature_control_module/water_cooling_temperature_control_module.hpp b/components/water_cooling_temperature_control_module/water_cooling_temperature_control_module.hpp index 2d67de0..496c72d 100644 --- a/components/water_cooling_temperature_control_module/water_cooling_temperature_control_module.hpp +++ b/components/water_cooling_temperature_control_module/water_cooling_temperature_control_module.hpp @@ -67,7 +67,8 @@ class WaterCoolingTemperatureControlModule : public ZIModule { PidModule m_pidmodule; ZThread m_thread; - float m_target_temperature = 0; + int32_t m_enable_log = 0; + float m_target_temperature = 0; public: WaterCoolingTemperatureControlModule(){};