Brushed motors drivers were implemented
This commit is contained in:
@@ -1,40 +1,41 @@
|
||||
// This is a personal academic project. Dear PVS-Studio, please check it.
|
||||
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: https://pvs-studio.com
|
||||
|
||||
#include <stdint.h>
|
||||
#include <cstdint>
|
||||
#include "Arduino.h"
|
||||
#include "string.h"
|
||||
#include "driver/ledc.h"
|
||||
|
||||
// TODO: implement class
|
||||
|
||||
class BrushedMotor {
|
||||
/* Driver for native MCPWM controller. */
|
||||
// TODO: define default values
|
||||
// TODO: rewrite with MCPWM
|
||||
public:
|
||||
BrushedMotor(uint32_t PwmAGpioNum, uint32_t PwmBGpioNum, uint32_t PwmFreqHz,
|
||||
uint32_t McpwmResolutionHz, int McpwmGroupId = 0);
|
||||
BrushedMotor(uint32_t pwmAGpioNum, uint32_t pwmBGpioNum, uint32_t frequency,
|
||||
uint8_t channel, uint8_t resolution, const char *name = "Rotor1", bool forward_directional = true);
|
||||
|
||||
void setDuty(uint16_t duty);
|
||||
void setDuty(uint32_t duty) const;
|
||||
|
||||
uint16_t maxDuty();
|
||||
void setExtendedDuty(int32_t duty);
|
||||
|
||||
void enable();
|
||||
|
||||
void disable();
|
||||
[[nodiscard]] uint32_t maxDuty() const;
|
||||
|
||||
void forward();
|
||||
|
||||
void backward();
|
||||
|
||||
void reverse();
|
||||
|
||||
void coast();
|
||||
|
||||
void brake();
|
||||
private:
|
||||
uint8_t _channel;
|
||||
uint32_t _frequency;
|
||||
uint32_t _resolution;
|
||||
|
||||
protected:
|
||||
/* MCPWM group */
|
||||
int _mcpwmGroupId = 0;
|
||||
uint32_t _mcpwmResolutionHz;
|
||||
|
||||
/* Brushed motor properties */
|
||||
uint32_t _pwmAGpioNum;
|
||||
uint32_t _pwmBGpioNum;
|
||||
uint32_t _pwmFreqHz;
|
||||
bool _forward_directional;
|
||||
String _tag_name = "BrushedMotor";
|
||||
|
||||
void _apply_directional() const;
|
||||
};
|
||||
Reference in New Issue
Block a user