Soooo Im not sure why but my code won’t start the mini autonomous that I made im not sure if I phrased it right or if their is an internal error but im really hopping someone can guide me on autonomous.
here's the code.
#include "main.h"
#define R 20
#define L 11
#define R2 19
#define L2 12
pros::Controller controller1(pros::E_CONTROLLER_MASTER);
pros:: Motor frontRight(20);
pros:: Motor frontLeft(11);
pros:: Motor backRight(19);
pros:: Motor backLeft(12);
int JoystickAxis1(){
int toReturn = controller1.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_X);
return toReturn;
}
int JoystickAxis2(){
int toReturn = controller1.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_Y);
return toReturn;
}
int JoystickAxis3(){
int toReturn = controller1.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y);
return toReturn;
}
int JoystickAxis4(){
int toReturn = controller1.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_X);
return toReturn;
}
void drive_straight(int straight_ticks, int speed) {
frontLeft.move_relative(straight_ticks, speed);
backLeft.move_relative(straight_ticks, speed);
frontRight.move_relative(straight_ticks, speed);
backRight.move_relative(straight_ticks, speed);
}
void on_center_button() {
static bool pressed = false;
pressed = !pressed;
if (pressed) {
pros::lcd::set_text(2, "I was pressed!");
} else {
pros::lcd::clear_line(2);
}
}
void auton() {
if(controller1.get_digital(DIGITAL_A)){
autonomous();
}
}
void initialize() {
pros::lcd::initialize();
pros::lcd::set_text(1, "Scar Is here!!!!");
pros::lcd::register_btn1_cb(on_center_button);
}
void disabled() {}
void competition_initialize() {}
void autonomous() {
drive_straight(1000,100);
}
void opcontrol() {
/**
Arm Example! :)
ControllerButton btnUp(E_CONTROLLER_DIGITAL_R1);
ControllerButton btnDown(E_CONTROLLER_DIGITAL_R2);
Motor lift(LIFT_MOTOR);
void opcontrol() {
while (true) {
if (btnUp.isPressed()) {
lift.moveVoltage(12000);
} else if (btnDown.isPressed()) {
lift.moveVoltage(-12000);
} else {
lift.moveVoltage(0);
}
*/
while (true) {
//int left = controller1.get_analog(ANALOG_LEFT_Y);
// int right = controller1.get_analog(ANALOG_RIGHT_Y);
frontLeft.move_velocity(JoystickAxis3() + JoystickAxis1() + JoystickAxis4()*2);
frontRight.move_velocity(JoystickAxis3() - JoystickAxis1() - JoystickAxis4()*2);
backLeft.move_velocity(JoystickAxis3() + JoystickAxis1() - JoystickAxis4()*2);
backRight.move_velocity(JoystickAxis3() - JoystickAxis1() + JoystickAxis4()*2);
if(controller1.get_digital(pros::E_CONTROLLER_DIGITAL_X)){
autonomous();
}
pros::delay(20);
}
}