Skip to content

Instantly share code, notes, and snippets.

@CorniiDog
Created August 9, 2020 05:09
Show Gist options
  • Save CorniiDog/bbce85950aef0350c2e265e3dd9252f1 to your computer and use it in GitHub Desktop.
Save CorniiDog/bbce85950aef0350c2e265e3dd9252f1 to your computer and use it in GitHub Desktop.
extern vex::motor testMotor;
#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);
}
//VEX Header Guard
#ifndef VEX_H
#define VEX_H
#include "vex.h"
#endif
#include "motor-config.h"
//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
#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