Initial commit: SmartCar Framework v0.1 — 龙芯2K0300智能车开发框架\n\n- HAL: GPIO/PWM/Encoder/Framebuffer 驱动\n- Control: PID/IMU/Motor/Servo 控制\n- Vision: HSV双Otsu→4点标定IPM→洪泛填充→逐行搜线\n- Strategy: 三区前瞻偏差+速度策略\n- Debug: 文件热调参+LCD预览+cv截帧\n- Scheduler: 5ms timerfd+epoll 中央调度器
This commit is contained in:
24
hal/pwm.hpp
Normal file
24
hal/pwm.hpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include "types.hpp"
|
||||
|
||||
class PWM {
|
||||
public:
|
||||
PWM(int chip, int channel, unsigned int period_ns);
|
||||
~PWM();
|
||||
|
||||
void setDutyCycle(unsigned int duty_ns);
|
||||
void setPeriod(unsigned int period_ns);
|
||||
void enable(bool on = true);
|
||||
void setPolarity(const char* pol = "normal");
|
||||
unsigned int readPeriod() const { return _period_ns; }
|
||||
|
||||
private:
|
||||
int _chip;
|
||||
int _channel;
|
||||
unsigned int _period_ns;
|
||||
bool _exported;
|
||||
std::string _basePath() const;
|
||||
void _export();
|
||||
void _unexport();
|
||||
};
|
||||
Reference in New Issue
Block a user