Im trying to create a header file to config motors and have them used in all files, im running into errors in the main.h file
main.h
/**
* \file main.h
*
* Contains common definitions and header files used throughout your PROS
* project.
*
* Copyright (c) 2017-2018, Purdue University ACM SIGBots.
* All rights reserved.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef _PROS_MAIN_H_
#define _PROS_MAIN_H_
/**
* If defined, some commonly used enums will have preprocessor macros which give
* a shorter, more convenient naming pattern. If this isn't desired, simply
* comment the following line out.
*
* For instance, E_CONTROLLER_MASTER has a shorter name: CONTROLLER_MASTER.
* E_CONTROLLER_MASTER is pedantically correct within the PROS styleguide, but
* not convienent for most student programmers.
*/
#define PROS_USE_SIMPLE_NAMES
/**
* If defined, C++ literals will be available for use. All literals are in the
* pros::literals namespace.
*
* For instance, you can do `4_mtr = 50` to set motor 4's target velocity to 50
*/
#define PROS_USE_LITERALS
#include "api.h"
#include "config.hpp"
/**
* You should add more #includes here
*/
//#include "okapi/api.hpp"
//#include "pros/api_legacy.h"
/**
* If you find doing pros::Motor() to be tedious and you'd prefer just to do
* Motor, you can use the namespace with the following commented out line.
*
* IMPORTANT: Only the okapi or pros namespace may be used, not both
* concurrently! The okapi namespace will export all symbols inside the pros
* namespace.
*/
// using namespace pros;
// using namespace pros::literals;
// using namespace okapi;
/**
* Prototypes for the competition control tasks are redefined here to ensure
* that they can be called from user code (i.e. calling autonomous from a
* button press in opcontrol() for testing purposes).
*/
#ifdef __cplusplus
extern "C" {
#endif
void autonomous(void);
void initialize(void);
void disabled(void);
void competition_initialize(void);
void opcontrol(void);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
/**
* You can add C++-only headers here
*/
//#include <iostream>
#endif
#endif // _PROS_MAIN_H_
config.hpp
#pragma once
#include "main.h"
extern pros::Motor LeftF;
extern pros::Motor LeftB;
extern pros::Motor RightF;
extern pros::Motor RightB;
extern pros::Motor Intake;
extern pros::Motor Catapult;
extern pros::Motor Strafe;
extern pros::Controller master;
extern pros::ADILineSensor LineLeft;
extern pros::ADILineSensor LineLeft;
extern pros::ADIGyro Gyro1;
extern pros::ADIPotentiometer catapultPT;
void initDriveTrain();
void initStrafe();
void initCatapult();
void initSensors();
config.cpp
#include "main.h"
#include "config.hpp"
void initDriveTrain(){
pros::Motor LeftF(11, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES);
pros::Motor LeftB(15, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES);
pros::Motor RightF(13, pros::E_MOTOR_GEARSET_18, true, pros::E_MOTOR_ENCODER_DEGREES);
pros::Motor RightB(5, pros::E_MOTOR_GEARSET_18, true, pros::E_MOTOR_ENCODER_DEGREES);
}
void initStrafe(){
pros::Motor Strafe(11, pros::E_MOTOR_GEARSET_18, false, pros::E_MOTOR_ENCODER_DEGREES);
}
void initCatapult(){
pros::Motor Catapult(10, pros::E_MOTOR_GEARSET_36, false, pros::E_MOTOR_ENCODER_DEGREES);
pros::Motor Intake(1, pros::E_MOTOR_GEARSET_36, false, pros::E_MOTOR_ENCODER_DEGREES);
}
void initSensors(){
pros::ADILineSensor LineLeft (4);
pros::ADILineSensor LineRight (5);
pros::ADIGyro Gyro1 (3);
pros::ADIPotentiometer catapultPT(1);
}
errors:
Preformatted text