Skip to content

# File evamServoDriver.h

File List > src > evamServoDriver.h

Go to the documentation of this file

    #pragma once

    #include <Servo.h>
    #include <Arduino.h>

    namespace evam
    {
        template <int kPin>
        class ServoDriver
        {
        private:
            Servo mServo;

        public:
            ServoDriver()
            {
                mServo.attach(kPin);
            }

            int GetPin() const
            {
                return kPin;
            }

        protected:
            void actBipolar(signed short aValue)
            {
                mServo.writeMicroseconds(constrain(aValue / 2 + 1500, 500, 2500));
            }

            void actUnipolar(signed short aValue)
            {
                mServo.writeMicroseconds(constrain(aValue + 1000, 500, 2500));
            }
        };
    }