Mearm colorsorting with web application

Dependencies:   TCS3200

Servo.cpp

Committer:
pierre11
Date:
2018-01-30
Revision:
7:3b1ce80e424c
Parent:
5:36f1e4e1a427

File content as of revision 7:3b1ce80e424c:

#include "Servo.h"
#include "mbed.h"

    Servo::Servo(PinName Pin) : ServoPin(Pin) {}

    void Servo::SetPosition(int Pos) {
        Position = Pos;
    }

    void Servo::StartPulse() {
        ServoPin = 1;
        PulseStop.attach_us(this, &Servo::EndPulse, Position);
    }

    void Servo::EndPulse() {
        ServoPin = 0;
    }

    void Servo::Enable(int StartPos, int Period) {
        Position = StartPos;
        Pulse.attach_us(this, &Servo::StartPulse, Period);
    }

    void Servo::Disable() {
        Pulse.detach();
    }