View unanswered posts | View active topics It is currently Mon Apr 21, 2014 11:18 am






Reply to topic  [ 7 posts ] 
Problem Moving Values from Pre-Auto into Auto and Tele-Op 
Author Message
Rookie

Joined: Mon Mar 12, 2012 9:03 pm
Posts: 5
Post Problem Moving Values from Pre-Auto into Auto and Tele-Op
I am writing theoretical code for the 2012-2013 season and i decided i was going to use the LCD screen to put a toggle between different autonomouses and ive set this up


Code:
int autoselect;
 
  while(nLCDButtons != 2)
  {
    if(nLCDButtons == 1 && autoselect > 0)
    {
      autoselect ++;
      wait1Msec(100);
    }
   
    else if(nLCDButtons == 4 && autoselect < 8)
    {
      autoselect --;
      wait1Msec(100);
    }
   
    clearLCDLine(0);
    clearLCDLine(1);
   
    displayLCDPos(0,0);
    displayNextLCDString("Autonomous");
    displayNextLCDChar(' ');
    displayNextLCDChar('=');
    displayNextLCDChar(' ');
    displayNextLCDNumber(autoselect);

in theory this will let me toggle between different autonomouses and display in ive put this in the pre-auto section of the vex competion templete, the problem ive run into is in my autonomous section i have a bunch of if and else if statements relating to different values for the auto select variable, one of them looks like this

Code:
if(autoselect == 0)
  {
   
  }


and so my question is do i have to put int autoselect at the beginning of the auto section? and if so will my value carry over? and is the pre-auto the right place to put it? or should i put it in user control so we can change it before the match starts? and if that is the case what will i have to do to make sure that the value transfers to the autonomous section? thanks to anyone that help. :)


Mon Mar 12, 2012 9:13 pm
Profile
Novice
User avatar

Joined: Sat Jul 10, 2010 3:06 pm
Posts: 86
Location: Roanoke, VA
Post Re: Problem Moving Values from Pre-Auto into Auto and Tele-O
Suggestion-- use these tags to make your code more readable... :)
Code:
[code][/code]


Mikeantor11 wrote:
and so my question is do i have to put int autoselect at the beginning of the auto section? and if so will my value carry over? and is the pre-auto the right place to put it? or should i put it in user control so we can change it before the match starts? and if that is the case what will i have to do to make sure that the value transfers to the autonomous section? thanks to anyone that help. :)

I've found that it is best to make your "autoselect" variable a global--put it outside of the autonomous task, outside of the pre_auton() function, etc. If it's inside a function or a task, it will be local to that function/task, and its value cannot be read outside of the function/task.

//Andrew

_________________
Check out my website! www.RoboDesigners.com

VRC Team 2190

Twitter: @RoboDesigners


Tue Mar 13, 2012 2:28 pm
Profile WWW
Rookie

Joined: Mon Mar 12, 2012 9:03 pm
Posts: 5
Post Re: Problem Moving Values from Pre-Auto into Auto and Tele-O
Thank you I havn't tried it yet but that makes perfect sense now, and thank you for telling me how to post code in the forums I knew there was a special way I just didn't know what it was. Thank you :)


Tue Mar 13, 2012 6:04 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3108
Location: Rotterdam, The Netherlands
Post Re: Problem Moving Values from Pre-Auto into Auto and Tele-O
Fixed your post.

- Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Wed Mar 14, 2012 3:22 am
Profile WWW
Rookie

Joined: Mon Mar 12, 2012 9:03 pm
Posts: 5
Post Re: Problem Moving Values from Pre-Auto into Auto and Tele-O
Thank your for fixing the post for me :)


Wed Mar 14, 2012 7:14 pm
Profile
Rookie

Joined: Mon Mar 12, 2012 9:03 pm
Posts: 5
Post Re: Problem Moving Values from Pre-Auto into Auto and Tele-O
Hey guys ive run into another problem basically i dont know where to put my code, to be exact this code here
Code:
 while(nLCDButtons != 2)
  {
    if(nLCDButtons == 1 && autoselect > 0)
    {
      autoselect ++;
      wait1Msec(100);
    }

    else if(nLCDButtons == 4 && autoselect < 8)
    {
      autoselect --;
      wait1Msec(100);
    }

    clearLCDLine(0);
    clearLCDLine(1);

    displayLCDPos(0,0);
    displayNextLCDString("Autonomous");
    displayNextLCDChar(' ');
    displayNextLCDChar('=');
    displayNextLCDChar(' ');
    displayNextLCDNumber(autoselect);
  }


the problem i'm coming into is that it is a while loop that constantly runs well because its a while loop, and i don't know where to put it in the competition template because simply enough if i put in in user control the robot wont move until i hit the middle button, same with autonomous but i want to to able to change the value before a match and then have it run that autonomous and then go into driver control without any problems of waiting for me to press a button, so where should i put the code? thank you


Sat Mar 31, 2012 3:31 pm
Profile
Rookie

Joined: Fri Jan 27, 2012 6:57 pm
Posts: 40
Post Re: Problem Moving Values from Pre-Auto into Auto and Tele-O
You would probably keep it in your void pre_auton() function, and just change your while loop to:
Code:
while (bIfiRobotDisabled)
{
}

That way, your code will run while the robot is disabled (through the Field Controller), but once Autonomous starts, bIfiRobotDisabled will be false, and code execution will instantly exit the while loop and jump to the next part of the code.


Sat Mar 31, 2012 3:42 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.