You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.4 KiB
51 lines
1.4 KiB
#include "air_valve.h"
|
|
|
|
// 初始化 GPIO 引脚
|
|
void AirValve::initGPIO() {
|
|
__HAL_RCC_GPIOE_CLK_ENABLE();
|
|
|
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
|
GPIO_InitStruct.Pin = CLEANING_VALVE_PIN | NOZZLE_VALVE_PIN | DEHUMIDIFICATION_VALVE_PIN;
|
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
|
HAL_GPIO_Init(CLEANING_VALVE_PORT, &GPIO_InitStruct);
|
|
|
|
// 初始化时关闭所有阀门
|
|
closeCleaning();
|
|
closeNozzle();
|
|
closeDehumidification();
|
|
}
|
|
|
|
// 构造函数,初始化 GPIO 端口和引脚
|
|
AirValve::AirValve() = default;
|
|
|
|
// 打开清洗阀
|
|
void AirValve::openCleaning() {
|
|
HAL_GPIO_WritePin(CLEANING_VALVE_PORT, CLEANING_VALVE_PIN, GPIO_PIN_RESET);
|
|
}
|
|
|
|
// 关闭清洗阀
|
|
void AirValve::closeCleaning() {
|
|
HAL_GPIO_WritePin(CLEANING_VALVE_PORT, CLEANING_VALVE_PIN, GPIO_PIN_SET);
|
|
}
|
|
|
|
// 打开喷嘴阀
|
|
void AirValve::openNozzle() {
|
|
HAL_GPIO_WritePin(NOZZLE_VALVE_PORT, NOZZLE_VALVE_PIN, GPIO_PIN_RESET);
|
|
}
|
|
|
|
// 关闭喷嘴阀
|
|
void AirValve::closeNozzle() {
|
|
HAL_GPIO_WritePin(NOZZLE_VALVE_PORT, NOZZLE_VALVE_PIN, GPIO_PIN_SET);
|
|
}
|
|
|
|
// 打开除湿阀
|
|
void AirValve::openDehumidification() {
|
|
HAL_GPIO_WritePin(DEHUMIDIFICATION_VALVE_PORT, DEHUMIDIFICATION_VALVE_PIN, GPIO_PIN_RESET);
|
|
}
|
|
|
|
// 关闭除湿阀
|
|
void AirValve::closeDehumidification() {
|
|
HAL_GPIO_WritePin(DEHUMIDIFICATION_VALVE_PORT, DEHUMIDIFICATION_VALVE_PIN, GPIO_PIN_SET);
|
|
}
|