Last active
August 29, 2015 14:15
-
-
Save jimmyli97/8788e1b2063a37cc72a2 to your computer and use it in GitHub Desktop.
LiftPreset2-18
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
#define LIFT_UP_POW -100 | |
#define ENC_SIGN sgn(LIFT_UP_POW) | |
#define LIFT_MAX ENC_SIGN * 9800 //high goal | |
#define NINETY_GOAL ENC_SIGN * 7400 | |
#define SIXTY_GOAL ENC_SIGN * 4600 | |
#define THIRTY_GOAL ENC_SIGN * 2000 | |
#define LIFT_MIN 0 | |
void joyLift(DesiredMotorVals *desiredMotorVals, DesiredEncVals *desiredEncVals, TJoystick *joyState){ | |
long encTarget = ENC_OFF; //turn off targeting by default | |
if (joyButtonPressed(joyState, JOY2, BUTTON_RB)) { //raise | |
desiredMotorVals->power[Lift] = LIFT_UP_POW; | |
encTarget = LIFT_MAX; | |
} else if (joyButtonPressed(joyState, JOY2, BUTTON_LB)) { //lower | |
desiredMotorVals->power[Lift] = -1 * LIFT_UP_POW; | |
encTarget = LIFT_MIN; | |
} else { | |
if (joyGetTophat(joyState, JOY2) == TOPHAT_N) { //high goal | |
if (abs(motorGetEncoder(Lift)) > abs(NINETY_GOAL)) { | |
desiredMotorVals->power[Lift] = -1 * LIFT_UP_POW; | |
} else { | |
desiredMotorVals->power[Lift] = LIFT_UP_POW; | |
} | |
encTarget = NINETY_GOAL; | |
} else if (joyGetTophat(joyState, JOY2) == TOPHAT_E) { //med goal | |
... // handle rest of the preset cases | |
} | |
} | |
motorSetEncoder(desiredEncVals, Lift, encTarget); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment