50 lines
818 B
C
50 lines
818 B
C
/**
|
|
* @file servo.h
|
|
* @brief 180° PWM 舵机控制 (LEDC)
|
|
*/
|
|
|
|
#ifndef SERVO_H
|
|
#define SERVO_H
|
|
|
|
#include <stdbool.h>
|
|
#include "driver/gpio.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/**
|
|
* @brief 初始化舵机 (50Hz PWM)
|
|
* @param gpio PWM 输出引脚
|
|
*/
|
|
void servo_init(int gpio);
|
|
|
|
/**
|
|
* @brief 设置舵机角度
|
|
* @param angle 角度 0.0 ~ 180.0
|
|
*/
|
|
void servo_set_angle(float angle);
|
|
|
|
/**
|
|
* @brief 设置舵机到上限位 (默认 180°)
|
|
*/
|
|
void servo_set_up(void);
|
|
|
|
/**
|
|
* @brief 设置舵机到下限位 (默认 0°)
|
|
*/
|
|
void servo_set_down(void);
|
|
|
|
/**
|
|
* @brief 自定义上下限位角度
|
|
* @param up 上限位角度 (默认 180°)
|
|
* @param down 下限位角度 (默认 0°)
|
|
*/
|
|
void servo_set_limits(float up, float down);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* SERVO_H */
|