Parking Garage Control System
ESP32 Parking Garage – ESP-IDF/FreeRTOS
Loading...
Searching...
No Matches
EspServoOutput.h
Go to the documentation of this file.
1#pragma once
2
3#include "IGpioOutput.h"
4#include "driver/gpio.h"
5#include "driver/ledc.h"
6
15 public:
22 explicit EspServoOutput(gpio_num_t pin, ledc_channel_t ledcChannel, bool initialLevel = false);
23 ~EspServoOutput() override;
24
25 // Prevent copying
28
29 void setLevel(bool high) override;
30 [[nodiscard]] bool getLevel() const override;
31
32 private:
33 void setAngle(uint32_t angleDegrees);
34
35 gpio_num_t m_pin;
36 ledc_channel_t m_channel;
37 bool m_currentLevel;
38
39 // Servo constants
40 static constexpr uint32_t SERVO_FREQ_HZ = 50; // 50Hz for standard servos
41 static constexpr uint32_t SERVO_PERIOD_US = 20000; // 20ms period
42 static constexpr uint32_t SERVO_MIN_PULSE_US = 1000; // 1ms = 0°
43 static constexpr uint32_t SERVO_MAX_PULSE_US = 2000; // 2ms = 180°
44 static constexpr uint32_t SERVO_ANGLE_CLOSED = 90; // Barrier closed (vertical)
45 static constexpr uint32_t SERVO_ANGLE_OPEN = 0; // Barrier open (horizontal)
46};
ESP32 implementation of servo control via PWM.
Definition EspServoOutput.h:14
~EspServoOutput() override
Definition EspServoOutput.cpp:58
bool getLevel() const override
Get current GPIO output level.
Definition EspServoOutput.cpp:73
EspServoOutput & operator=(const EspServoOutput &)=delete
EspServoOutput(const EspServoOutput &)=delete
void setLevel(bool high) override
Set GPIO output level.
Definition EspServoOutput.cpp:63
Interface for GPIO output abstraction.
Definition IGpioOutput.h:9
Coverage