help with code

Can someone tell me what might be wrong with this code.
/** @file init.c

  • @brief File for initialization code
  • This file should contain the user initialize() function and any functions related to it.
  • Copyright (c) 2011-2013, Purdue University ACM SIG BOTS.
  • All rights reserved.
  • Redistribution and use in source and binary forms, with or without
  • modification, are permitted provided that the following conditions are met:
  • * Redistributions of source code must retain the above copyright
    
  •   notice, this list of conditions and the following disclaimer.
    
  • * Redistributions in binary form must reproduce the above copyright
    
  •   notice, this list of conditions and the following disclaimer in the
    
  •   documentation and/or other materials provided with the distribution.
    
  • * Neither the name of Purdue University ACM SIG BOTS nor the
    
  •   names of its contributors may be used to endorse or promote products
    
  •   derived from this software without specific prior written permission.
    
  • THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND
  • ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  • WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  • DISCLAIMED. IN NO EVENT SHALL PURDUE UNIVERSITY ACM SIG BOTS BE LIABLE FOR ANY
  • DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  • (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  • LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  • ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  • (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  • SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  • Purdue Robotics OS contains FreeRTOS (http://www.freertos.org) whose source code may be
  • obtained from FreeRTOS Real Time Kernel (RTOS) - Browse Files at SourceForge.net or on request.
    */

#include “main.h”

/*

  • Runs pre-initialization code. This function will be started in kernel mode one time while the
  • VEX Cortex is starting up. As the scheduler is still paused, most API functions will fail.
  • The purpose of this function is solely to set the default pin modes (pinMode()) and port
  • states (digitalWrite()) of limit switches, push buttons, and solenoids. It can also safely
  • configure a UART port (usartOpen()) but cannot set up an LCD (lcdInit()).
    */
    void initializeIO() {
    }

/*

  • Runs user initialization code. This function will be started in its own task with the default

  • priority and stack size once when the robot is starting up. It is possible that the VEXnet

  • communication link may not be fully established at this time, so reading from the VEX

  • Joystick may fail.

  • This function should initialize most sensors (gyro, encoders, ultrasonics), LCDs, global

  • variables, and IMEs.

  • This function must exit relatively promptly, or the operatorControl() and autonomous() tasks

  • will not start. An autonomous mode selection menu like the pre_auton() in other environments

  • can be implemented in this task if desired.
    */
    void initialize() {
    //Leave this value alone
    int lcdScreenMin = 1;
    //This keeps track of which program you want to run
    int lcdScreen = 1;
    //Change this value to be the maximum number of programs you want on the robot
    int lcdScreenMax = 4;
    lcdInit(uart1);
    lcdSetBacklight(uart1, 1);

    while (isEnabled(0)) { //Ensures this code will run ONLY when the robot is disabled
    if (lcdReadButtons(uart1 ) == 1) { //Scrolls to the left
    if (lcdScreenMin == lcdScreen) {
    lcdScreen = lcdScreenMax;
    delay(250);
    } else {
    lcdScreen --;
    delay(250);
    }
    }
    if (lcdReadButtons(uart1 ) == 4) { //Scrolls to the right
    if (lcdScreenMax == lcdScreen) {
    lcdScreen = lcdScreenMin;
    delay(250);
    } else {
    lcdScreen++;
    delay(250);
    }
    }
    if (lcdScreen == 1 && Program != 1) {
    lcdPrint(uart1, 1, “1”); //Name the first program here
    lcdPrint(uart1, 2, “1”); //Name the first program here
    if (lcdReadButtons(uart1 ) == 2) {
    Program = lcdScreen; //Sets the Program to the one on-screen
    lcdPrint(uart1, 1, “Autonomous Has”);
    lcdPrint(uart1, 2, “Been Selected!”);
    delay(1500);
    }
    } else if (lcdScreen == 1 && Program == 1) {
    lcdPrint(uart1, 1, “[1]”); //We use brackets to mark which program we have chosen
    lcdPrint(uart1, 2, “[1]”); //So that while we’re scrolling, we can have one marked
    } else if (lcdScreen == 2 && Program != 2) {
    lcdPrint(uart1, 1, “2”); //Name the second program here
    lcdPrint(uart1, 2, “2”); //Name the second program here
    if (lcdReadButtons(uart1 ) == 2) {
    Program = lcdScreen; //Sets the Program to the one on-screen
    lcdPrint(uart1, 1, “Autonomous Has”);
    lcdPrint(uart1, 2, “Been Selected!”);
    delay(1500);
    }
    } else if (lcdScreen == 2 && Program == 2) {
    lcdPrint(uart1, 1, “[2]”); //We use brackets to mark which program we have chosen
    lcdPrint(uart1, 2, “[2]”); //So that while we’re scrolling, we can have one marked
    } else if (lcdScreen == 3 && Program != 3) {
    lcdPrint(uart1, 1, “3”); //Name the third program here
    lcdPrint(uart1, 2, “3”); //Name the third program here
    if (lcdReadButtons(uart1 ) == 2) {
    Program = lcdScreen; //Sets the Program to the one on-screen
    lcdPrint(uart1, 1, “Autonomous Has”);
    lcdPrint(uart1, 2, “Been Selected!”);
    delay(1500);
    }
    } else if (lcdScreen == 3 && Program == 3) {
    lcdPrint(uart1, 1, “[3]”); //We use brackets to mark which program we have chosen
    lcdPrint(uart1, 2, “[3]”); //So that while we’re scrolling, we can have one marked
    } else if (lcdScreen == 4 && Program != 4) {
    lcdPrint(uart1, 1, “4”); //Name the fourth program here
    lcdPrint(uart1, 2, “4”); //Name the fourth program here
    if (lcdReadButtons(uart1 ) == 2) {
    Program = lcdScreen; //Sets the Program to the one on-screen
    lcdPrint(uart1, 1, “Autonomous Has”);
    lcdPrint(uart1, 2, “Been Selected!”);
    delay(1500);
    }
    } else if (lcdScreen == 4 && Program == 4) {
    lcdPrint(uart1, 1, “[4]”); //We use brackets to mark which program we have chosen
    lcdPrint(uart1, 2, “[4]”); //So that while we’re scrolling, we can have one marked
    }
    }

}

I’m getting errors on the while loop and if (lcdScreen == 1 && Program != 1) {

What exactly does it say in the error message for each?

Have you initialized Program variable before the while loop ?
if it is not init errors, can you post the compilation error ?

First error says to many arguments to function bool is enabled () and the second error says program was not declared in this scope.

Program variable is not anywhere declared before the while loop, that should fix the second error.

hover over isEnabled, does it give you the function signature, then change the code accordingly , check if it isEnabled() and not isEnabled(0)

@2501B RoboJackets the function


isEnabled()

does not have any parameters which is why at compilation time you are getting the first error. See our documentation here on the function isEnabled. When reviewing this we see that


isEnabled()

returns true if the robot is enabled or false otherwise. With that your code fixed would look like:


while (!isEnabled()){
      // rest of your loop code here
}

Also, a protip in the future when posting code be sure to use the


code

tags for easier readability on the forums.