firstaa

Dependents:   17robo_fuzi 17robo_tokyo_kaede

cylinder.cpp

Committer:
echo_piyo
Date:
2017-09-28
Revision:
1:d4fa6f96bab5
Parent:
0:46dd0245886c

File content as of revision 1:d4fa6f96bab5:

#include "cylinder.h"
#include "mbed.h"

Cylinder::Cylinder(PinName pin_in,PinName pin_out):cylinder_in(pin_in),cylinder_out(pin_out){
    cylinder_in = 1;
    cylinder_out = 0;
}

void Cylinder::cyclic(int state){
    if(state) {
        if(flag == false) {
            cylinder_in = !cylinder_in;
            cylinder_out = !cylinder_out;
        }
        flag = true;
    } else flag = false;
}

void Cylinder::cyclicIn(){
        cylinder_in = 1;
        cylinder_out = 0;
}

void Cylinder::cyclicOut(){
        cylinder_in = 0;
        cylinder_out = 1;
}

int Cylinder::getInState(){
    return (int)cylinder_in;
}

int Cylinder::getOutState(){
    return (int)cylinder_out;
}