purduesigbots / pros-atom

Main plugin for supporting PROS development in Atom
http://atom.io/packages/pros
Mozilla Public License 2.0
11 stars 9 forks source link

Error uploading to Cortex #74

Closed ghost closed 5 years ago

ghost commented 5 years ago

I have a very simple drive code for my cortex and whenever I try to build the opcontrol file, it reads "make: nothing to be done for 'quick'". When I try to upload the code, the cortex is unresponsive after connecting to the controller. I think it is a problem with the building process but I have attached the code in case there are issues in it. I am using C by the way.

include "main.h"

 #define LEFTDRIVE_PORT 2&3
 #define RIGHTDRIVE_PORT 4&5

void opcontrol() {

    while (true)    {

        int Joy2 = ((100*(joystickGetAnalog(1, 2)))/127) ; // percent power from joystick
        int Joy3 = ((100*(joystickGetAnalog(1, 3)))/127) ; // percent power from joystick
        int leftdrive = 0 ;
        int rightdrive = 0 ;
        int k = 0 ;
        int rspeed = (((Joy2^3)/1000)/100) ; // takes percent and applies equation
        int lspeed = (((Joy3^3)/1000)/100) ; // takes percent and applies equation

        if (abs(Joy2) < k) {
            rightdrive = 0 ;
        }
        else if (abs(Joy2) > k) {
            rightdrive = 127*rspeed ;
        }
        else {
            rightdrive = 0 ;
        }

        if (abs(Joy3) > k) {
            leftdrive = 0 ;
        }
        else if (abs(Joy3) < k) {
            leftdrive = 127*lspeed ;
        }
        else {
            leftdrive = 0 ;
        }

        motorSet(RIGHTDRIVE_PORT, rightdrive) ;
        motorSet(LEFTDRIVE_PORT, leftdrive) ;

        delay(2);
    }
}
baylessj commented 5 years ago

your macros for the drive motor ports (LEFTDRIVE_PORT) are not going to give you the desired results, motorSet can only take one port value as an integer so your & will prevent any movement. Separate the motorSet calls for each motor port and pass just the integer value for the port and you should see the motors move.