ESP32Servo
Public Member Functions | Private Member Functions | Private Attributes
Servo Class Reference

#include <ESP32Servo.h>

Collaboration diagram for Servo:
Collaboration graph
[legend]

Public Member Functions

 Servo ()
 
int attach (int pin)
 
int attach (int pin, int min, int max)
 
void detach ()
 
void write (int value)
 
void writeMicroseconds (int value)
 
int read ()
 
int readMicroseconds ()
 
bool attached ()
 
void setTimerWidth (int value)
 
int readTimerWidth ()
 
void setPeriodHertz (int hertz)
 

Private Member Functions

int usToTicks (int usec)
 
int ticksToUs (int ticks)
 
ESP32PWMgetPwm ()
 

Private Attributes

int min = DEFAULT_uS_LOW
 
int max = DEFAULT_uS_HIGH
 
int pinNumber = 0
 
int timer_width = DEFAULT_TIMER_WIDTH
 
int ticks = DEFAULT_PULSE_WIDTH_TICKS
 
int timer_width_ticks = DEFAULT_TIMER_WIDTH_TICKS
 
ESP32PWM pwm
 
int REFRESH_CPS = 50
 

Detailed Description

Definition at line 121 of file ESP32Servo.h.

Constructor & Destructor Documentation

◆ Servo()

Servo::Servo ( )

Member Function Documentation

◆ attach() [1/2]

int Servo::attach ( int  pin)

Definition at line 73 of file ESP32Servo.cpp.

References DEFAULT_uS_HIGH, and DEFAULT_uS_LOW.

Referenced by loop(), and setup().

◆ attach() [2/2]

int Servo::attach ( int  pin,
int  min,
int  max 
)

◆ attached()

bool Servo::attached ( )

Definition at line 183 of file ESP32Servo.cpp.

References ESP32PWM::attached(), and pwm.

Referenced by detach(), loop(), readMicroseconds(), setTimerWidth(), and writeMicroseconds().

Here is the call graph for this function:

◆ detach()

void Servo::detach ( )

Definition at line 120 of file ESP32Servo.cpp.

References attached(), ESP32PWM::detachPin(), pinNumber, and pwm.

Referenced by loop().

Here is the call graph for this function:

◆ getPwm()

ESP32PWM * Servo::getPwm ( )
private

Definition at line 68 of file ESP32Servo.cpp.

References pwm.

◆ read()

int Servo::read ( )

Definition at line 163 of file ESP32Servo.cpp.

References max, min, and readMicroseconds().

Here is the call graph for this function:

◆ readMicroseconds()

int Servo::readMicroseconds ( )

Definition at line 168 of file ESP32Servo.cpp.

References attached(), ticks, and ticksToUs().

Referenced by read().

Here is the call graph for this function:

◆ readTimerWidth()

int Servo::readTimerWidth ( )

Definition at line 221 of file ESP32Servo.cpp.

References timer_width.

◆ setPeriodHertz()

void Servo::setPeriodHertz ( int  hertz)
inline

Definition at line 138 of file ESP32Servo.h.

References REFRESH_CPS, setTimerWidth(), ticks, ticksToUs(), timer_width, and usToTicks().

Referenced by loop(), and setup().

Here is the call graph for this function:

◆ setTimerWidth()

void Servo::setTimerWidth ( int  value)

Definition at line 188 of file ESP32Servo.cpp.

References attached(), ESP32PWM::attachPin(), ESP32PWM::detachPin(), pinNumber, pwm, REFRESH_CPS, ticks, timer_width, and timer_width_ticks.

Referenced by setPeriodHertz().

Here is the call graph for this function:

◆ ticksToUs()

int Servo::ticksToUs ( int  ticks)
private

Definition at line 231 of file ESP32Servo.cpp.

References REFRESH_CPS, REFRESH_USEC, and timer_width_ticks.

Referenced by readMicroseconds(), and setPeriodHertz().

◆ usToTicks()

int Servo::usToTicks ( int  usec)
private

Definition at line 226 of file ESP32Servo.cpp.

References REFRESH_CPS, REFRESH_USEC, and timer_width_ticks.

Referenced by setPeriodHertz(), and writeMicroseconds().

◆ write()

void Servo::write ( int  value)

Definition at line 131 of file ESP32Servo.cpp.

References max, min, MIN_PULSE_WIDTH, and writeMicroseconds().

Referenced by loop().

Here is the call graph for this function:

◆ writeMicroseconds()

void Servo::writeMicroseconds ( int  value)

Definition at line 146 of file ESP32Servo.cpp.

References attached(), max, min, pwm, ticks, usToTicks(), and ESP32PWM::write().

Referenced by write().

Here is the call graph for this function:

Field Documentation

◆ max

int Servo::max = DEFAULT_uS_HIGH
private

Definition at line 150 of file ESP32Servo.h.

Referenced by attach(), read(), Servo(), write(), and writeMicroseconds().

◆ min

int Servo::min = DEFAULT_uS_LOW
private

Definition at line 149 of file ESP32Servo.h.

Referenced by attach(), read(), Servo(), write(), and writeMicroseconds().

◆ pinNumber

int Servo::pinNumber = 0
private

Definition at line 151 of file ESP32Servo.h.

Referenced by attach(), detach(), Servo(), and setTimerWidth().

◆ pwm

ESP32PWM Servo::pwm
private

Definition at line 156 of file ESP32Servo.h.

Referenced by attach(), attached(), detach(), getPwm(), setTimerWidth(), and writeMicroseconds().

◆ REFRESH_CPS

int Servo::REFRESH_CPS = 50
private

Definition at line 157 of file ESP32Servo.h.

Referenced by attach(), Servo(), setPeriodHertz(), setTimerWidth(), ticksToUs(), and usToTicks().

◆ ticks

int Servo::ticks = DEFAULT_PULSE_WIDTH_TICKS
private

◆ timer_width

int Servo::timer_width = DEFAULT_TIMER_WIDTH
private

Definition at line 152 of file ESP32Servo.h.

Referenced by attach(), readTimerWidth(), Servo(), setPeriodHertz(), and setTimerWidth().

◆ timer_width_ticks

int Servo::timer_width_ticks = DEFAULT_TIMER_WIDTH_TICKS
private

Definition at line 154 of file ESP32Servo.h.

Referenced by attach(), Servo(), setTimerWidth(), ticksToUs(), and usToTicks().


The documentation for this class was generated from the following files: