Created
August 9, 2020 05:25
-
-
Save CorniiDog/d210bcde156ff7ab201f0a14e13a0598 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef VEX_H | |
#define VEX_H | |
#include "vex.h" | |
#endif | |
#include "motorObject.h" | |
using namespace vex; | |
using namespace std; | |
//Sets motor (and ratio) | |
cMotor::cMotor(motor& sMotor, int Driver, int Driven) : vMotor(sMotor) { | |
setRatio(Driver, Driven); | |
} | |
//Sets ratio | |
void cMotor::setRatio(int Driver, int Driven){ | |
driver = Driver; | |
driven = Driven; | |
} | |
//Sets position | |
void cMotor::setPos(double degrees){ | |
vMotor.setPosition(degrees * (driven / driver), rotationUnits::deg); | |
} | |
//Gets position | |
double cMotor::getPos(){ | |
return vMotor.position(rotationUnits::deg) / (driven / driver); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//VEX Header Guard | |
#ifndef VEX_H | |
#define VEX_H | |
#include "vex.h" | |
#endif | |
//motorObj Library Header Guard | |
#ifndef motorObj_H | |
#define motorObj_H | |
class cMotor | |
{ | |
private: | |
vex::motor vMotor; | |
double driver; | |
double driven; | |
public: | |
cMotor(motor& sMotor, int Driver, int Driven); | |
void setRatio(int Driver, int Driven); | |
void setPos(double degrees); | |
double getPos(); | |
}; | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "vex.h" | |
#include "motorObject.h" | |
cMotor testMotor(EFL, 3, 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment