Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Overloaded reverse method to allow for no input (reverse until hit wall), one input (inches), or two inputs (inches and power)
- void Reverse() {
- reset();
- float start = TimeNow();
- left_motor.SetPercent(-1*MOTOR_CORRECTION*DEFAULT_MOTOR_POWER);
- right_motor.SetPercent(-1*DEFAULT_MOTOR_POWER);
- const char* titles[] = { "Left Encoder: ", "Right Encoder: " };
- while(bottom_right_micro.Value() || bottom_left_micro.Value() && TimeNow() - start < 5) {
- LCD.WriteRC(left_encoder.Counts(), 4, 5);
- LCD.WriteRC(right_encoder.Counts(), 5, 5);
- }
- reset();
- }
- void Reverse(int inches) {
- reset();
- float start = TimeNow();
- left_motor.SetPercent(-1 * MOTOR_CORRECTION * DEFAULT_MOTOR_POWER);
- right_motor.SetPercent(-1 * DEFAULT_MOTOR_POWER);
- while ( right_encoder.Counts() <= DRIVE_CORRECTION * COUNTS_PER_INCH * inches && TimeNow() - start < 5) {
- LCD.WriteRC(left_encoder.Counts(), 4, 5);
- LCD.WriteRC(right_encoder.Counts(), 5, 5);
- }
- reset();
- }
- void Reverse(int inches, int motorPower) {
- reset();
- float start = TimeNow();
- left_motor.SetPercent(-1 * motorPower * MOTOR_CORRECTION);
- right_motor.SetPercent(-1 * motorPower);
- while ( right_encoder.Counts() <= DRIVE_CORRECTION * COUNTS_PER_INCH * inches && TimeNow() - start < 5) {
- LCD.WriteRC(left_encoder.Counts(), 4, 5);
- LCD.WriteRC(right_encoder.Counts(), 5, 5);
- }
- reset();
- }
- void ReverseSlant(int inches, int motorPower) {
- reset();
- float start = TimeNow();
- left_motor.SetPercent(-1 * MOTOR_CORRECTION * motorPower * 0.96);
- right_motor.SetPercent(-1 * motorPower);
- while ( right_encoder.Counts() <= DRIVE_CORRECTION * COUNTS_PER_INCH * inches && TimeNow() - start < 10) {
- LCD.WriteRC(left_encoder.Counts(), 4, 5);
- LCD.WriteRC(right_encoder.Counts(), 5, 5);
- }
- reset();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement