View Single Post
  #2   Spotlight this post!  
Unread 11-02-2009, 20:39
Sentient's Avatar
Sentient Sentient is offline
Registered User
FRC #0639 (Code Red)
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Ithaca
Posts: 21
Sentient is on a distinguished road
Re: chaging values on an axis/toogle switch

You can clamp the joystick values from the joystick pretty easily.

float inputZ = stick->GetZ();
if(inputZ < 0.0)
inputZ = 0.0;

motor->Set(inputZ);

As for the toggle switch, what exactly are you using it for? If you are wanting to use a toggle switch that you on the driver station digital IO, you can just check the driver station inputs with driverStation->GetDigitalInput(channel);

EDIT: The above method for clamping would disregard anything below 0. If you want -1 to equal 0, 0.0 to equal 0.5, and 1.0 to equal 1.0, you can do this (although it would be very unintuitive for the driver):

motor->Set((stick->GetZ()+1.0)/2);

Last edited by Sentient : 11-02-2009 at 20:42.
Reply With Quote