For servos and motor controllers that use servo signals (ESCs)
More...
#include <JMotorDriverEsp32Servo.h>
|
| JMotorDriverEsp32Servo (byte _pwmChannel, byte _servoPin, int _freq=50, int _resBits=14, int _minServoValue=544, int _maxServoValue=2400, bool _constrainRange=true) |
| constructor, sets pins, custom frequency and resolution optional
|
|
void | adjustFrequency (float freq=1.0) |
| helper function for adjusting the frequency that the servo signal pulse is repeated at For some servos this can be used to adjust the strength of the servo ( <1.0 makes it weaker)
|
|
float | setFrequencyAndResolution (int freq=50, int resBits=14) |
| set frequency that servo signal pulse is repeated at and how many bits are used internally for resolution
|
|
bool | set (float _val) |
| set motor power
|
|
bool | setEnable (bool _enable) |
| use to enable or disable a motor, and sets up pin states
|
|
bool | getEnable () |
| get the enable state of the driver
|
|
float | getMaxRange () |
| high end of the range
|
|
float | getMinRange () |
| low end of the range
|
|
void | setMinServoValue (int value) |
| microseconds for shortest servo pulse
|
|
void | setMaxServoValue (int value) |
| microseconds for longest servo pulse
|
|
int | getMinServoValue () |
| returns setting for microseconds for shortest servo pulse
|
|
int | getMaxServoValue () |
| returns setting for microseconds for longest servo pulse
|
|
int | getServoValueRange () |
| returns difference (in microseconds) between longest and shortest servo pulse settings
|
|
void | setServoValues (int min, int max) |
| set the settings for short and long servo pulses at the same time
|
|
int | getSetMicroseconds () |
| returns how many microseconds the servo signal pulse was most recently set to
|
|
bool | getConstrainRange () |
| returns whether the range of set() will be constrained to within -1 and 1
|
|
void | setConstrainRange (bool _constrainRange) |
| set whether the range of set() will be constrained to within -1 and 1
|
|
bool | enable () |
| enable motor
|
|
bool | disable () |
| disable motor
|
|
For servos and motor controllers that use servo signals (ESCs)
- Note
- platform: ESP32
◆ JMotorDriverEsp32Servo()
JMotorDriverEsp32Servo::JMotorDriverEsp32Servo |
( |
byte |
_pwmChannel, |
|
|
byte |
_servoPin, |
|
|
int |
_freq = 50 , |
|
|
int |
_resBits = 14 , |
|
|
int |
_minServoValue = 544 , |
|
|
int |
_maxServoValue = 2400 , |
|
|
bool |
_constrainRange = true |
|
) |
| |
|
inline |
constructor, sets pins, custom frequency and resolution optional
- Parameters
-
_pwmChannel | ledc channel (must be unique for each driver) |
_servoPin | pin to output signal on |
_freq | = 50: Hz (default 50) must be <= int(80E6 / 2^resBits) |
_resBits | = 14: (default 14) tradeoff with max available frequency |
_minServoValue | (int) minimum servo pulse, default: 544 microseconds |
_maxServoValue | (int) maximum servo pulse, default: 2400 microseconds |
_constrainRange | (bool) constrain range of set() to within -1 and 1, default: true |
◆ adjustFrequency()
void JMotorDriverEsp32Servo::adjustFrequency |
( |
float |
freq = 1.0 | ) |
|
|
inlinevirtual |
helper function for adjusting the frequency that the servo signal pulse is repeated at For some servos this can be used to adjust the strength of the servo ( <1.0 makes it weaker)
- Parameters
-
freq | default 1.0, freq*50 is sent to setFrequencyAndResolution |
Implements JMotorDriverServoAdvanced.
◆ getEnable()
bool JMotorDriverEsp32Servo::getEnable |
( |
| ) |
|
|
inlinevirtual |
get the enable state of the driver
- Return values
-
(bool) | true if enabled, false if disabled |
Reimplemented from JMotorDriver.
◆ getMaxRange()
float JMotorDriverEsp32Servo::getMaxRange |
( |
| ) |
|
|
inlinevirtual |
high end of the range
- Note
- usually 1.0
- Return values
-
Reimplemented from JMotorDriver.
◆ getMinRange()
float JMotorDriverEsp32Servo::getMinRange |
( |
| ) |
|
|
inlinevirtual |
low end of the range
- Note
- usually -1.0, if 0, that indicates a motor controller with no reverse function
- Return values
-
Reimplemented from JMotorDriver.
◆ set()
bool JMotorDriverEsp32Servo::set |
( |
float |
val | ) |
|
|
inlinevirtual |
set motor power
- Note
- val should be between getMinRange and getMaxRange, but constrained internally
- Parameters
-
- Return values
-
(bool) | false if at end of power range, true otherwise |
Reimplemented from JMotorDriver.
◆ setEnable()
bool JMotorDriverEsp32Servo::setEnable |
( |
bool |
_enable | ) |
|
|
inlinevirtual |
use to enable or disable a motor, and sets up pin states
- Note
- setEnable(true) must be called before a motor driver will activate
- Parameters
-
_enable | (bool) true=enable, false=disable |
- Return values
-
(bool) | true if state changed, false if state already set |
Reimplemented from JMotorDriver.
◆ setFrequencyAndResolution()
float JMotorDriverEsp32Servo::setFrequencyAndResolution |
( |
int |
freq = 50 , |
|
|
int |
resBits = 14 |
|
) |
| |
|
inline |
set frequency that servo signal pulse is repeated at and how many bits are used internally for resolution
- Parameters
-
freq | Hz (default 50) |
resBits | (default 14) tradeoff with max available frequency |
- Return values
-
(float) | returns PWM cycles per microsecond-used in ledcWrite call, returned for debugging purposes |
The documentation for this class was generated from the following file: