sf
Diff: motor.cpp
- Revision:
- 0:597047b3b728
diff -r 000000000000 -r 597047b3b728 motor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/motor.cpp Tue Sep 27 09:41:43 2016 +0000 @@ -0,0 +1,57 @@ + +#include "motor.h" + + DigitalIn motorguan(PB_12); + DigitalIn motorkai(PB_13); + DigitalOut motorzheng(PB_14); + DigitalOut motorfan(PB_15); + +MotorCtl::MotorCtl() +{ + //motorguan.DigitalIn(PB_12); + motorfan=0; + motorzheng=0; +} + +unsigned short MotorCtl::open(void) +{ + unsigned short MotorTimeout=10; + + motorzheng=1; //start open + + while(MotorTimeout&&motorkai) + { + wait(1); + MotorTimeout--; + } + if(motorkai==0) + + motorzheng=0; + + if(MotorTimeout!=0) + MotorTimeout=1; + + return MotorTimeout; //Err +} + + +unsigned short MotorCtl::close() +{ + unsigned short MotorTimeout=10; + + motorfan=1; + + while(MotorTimeout&&motorguan) + { + wait(1); + MotorTimeout--; + } + + motorfan=0; + if(motorguan==0) + + if(MotorTimeout!=0) //close done Err? + MotorTimeout=1; + + return MotorTimeout; //Err +}