Files
ManGoWalk_STM32/fun/Shake_Motor.c

34 lines
852 B
C

#include "Shake_Motor.h"
void Shake_Motor_Open(void)
{
HAL_GPIO_WritePin(Shake_Motor_GPIO_Port,Shake_Motor_Pin,GPIO_PIN_SET); // 高电平响起
}
void Shake_Motor_Close(void)
{
HAL_GPIO_WritePin(Shake_Motor_GPIO_Port,Shake_Motor_Pin,GPIO_PIN_RESET); // 低电平关闭
}
// 添加方向控制功能
void Shake_Motor_Left(void)
{
// 左振动模式: 短振3次
for(int i=0; i<3; i++)
{
HAL_GPIO_WritePin(Shake_Motor_GPIO_Port, Shake_Motor_Pin, GPIO_PIN_SET);
tx_thread_sleep(50);
HAL_GPIO_WritePin(Shake_Motor_GPIO_Port, Shake_Motor_Pin, GPIO_PIN_RESET);
tx_thread_sleep(100);
}
}
void Shake_Motor_Right(void)
{
// 右振动模式: 长振1次
HAL_GPIO_WritePin(Shake_Motor_GPIO_Port, Shake_Motor_Pin, GPIO_PIN_SET);
tx_thread_sleep(300);
HAL_GPIO_WritePin(Shake_Motor_GPIO_Port, Shake_Motor_Pin, GPIO_PIN_RESET);
}