Example #1
0
        public Servo(int pwmPin, int hertz, int pwmRange, int maximalAusschlagGrad, WirinPiWrapper wiringPiLib, int microSecLeft, int microSecRight)
        {
            WiringPiLib = wiringPiLib;

            PwmRange = (uint)pwmRange;
            //pwmFrequency in Hz = 19.2e6 Hz / pwmClock / pwmRange.
            int PwmClock = 19200000 / pwmRange / hertz;

            WiringPiLib.PinMode(pwmPin, PinType.PWM_OUTPUT);

            WiringPiLib.PwmSetClock(PwmClock);
            WiringPiLib.PwmSetMode(PwmType.PWM_MODE_MS);                //Servos likes mark / Space approach
            WiringPiLib.PwmSetRange(PwmRange);

            PwmPin = pwmPin;

            MaximalAusschlagGrad = maximalAusschlagGrad;

            MicroSecLeft = microSecLeft;

            MicroSecRange = microSecRight - MicroSecLeft;

            PeriodeMicroSecs = 1000000 / hertz;
            Position         = 1;
            SetPosition(0);
        }