HU YANG
/
AnalogOut-HelloWorld
aa
Fork of AnalogOut-HelloWorld by
mdeviceCtrl.cpp
- Committer:
- fewerhy
- Date:
- 2016-10-10
- Revision:
- 5:e6536d2d5aba
File content as of revision 5:e6536d2d5aba:
#include "mdeviceCtrl.h" mdeviceCtrl::mdeviceCtrl() { myDevice= new mdevice(); needleStatus=0; } void mdeviceCtrl::run() { myDevice->updateDeviceStatus(); int tempB=myDevice->getButtonEdge(); int mp0=myDevice->getMotorPos0(); int mp1=myDevice->getMotorPos1(); cout<< mp0 <<" "<< mp1<<endl; if (tempB==1) { myDevice->runMotor0(0.2); myDevice->runMotor1(-0.02); } else if (tempB==-1) { myDevice->runMotor0(0.0); myDevice->runMotor1(0.0); } } bool mdeviceCtrl::inserNeedle( ) { myDevice->runMotor0(1.0); int tempPos=myDevice->getMotorPos0(); if (tempPos>200) { return true; } else { return false; } } bool mdeviceCtrl::retractNeedle( ) { myDevice->runMotor0(-1.0); int tempPos=myDevice->getMotorPos0(); if ( tempPos<10) { return true; } else { return false; } } bool mdeviceCtrl::switchNeedle1() { needleStatus++; if (needleStatus%2==0) { myDevice->runMotor1(-0.2); int tempPos=myDevice->getMotorPos1(); if (tempPos>1) { return true; } else { return false; } } else { myDevice->runMotor1(0.2); int tempPos=myDevice->getMotorPos1(); if (tempPos<0) { return true; } else { return false; } } }