Go to Post I do this stuff because...well first inspired me to become me. I now understand who i am better and what i want to do. - Marygrace [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-04-2011, 06:00 PM
Derek012's Avatar
Derek012 Derek012 is offline
I miss my frisbees
FRC #4564 (Orange Chaos)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2009
Location: Maine
Posts: 25
Derek012 is on a distinguished road
Cypress Switch Problem

Hey,
I've got two switches connected up to our team's Cypress board and I wanted one switch if it was false to be able to make the robot drive with joystick, but if it was true I wanted it to photo sense.

Code:
while (isOperatorControl()) {
            gyro.setSensitivity(0.125);
            dsLCD.updateLCD();
            if (GyroAngle >= 360 || GyroAngle <= -360) {
                GyroAngle = GyroAngle % 360;
            }
            updateDashboard();
            PVal = (int) ((petOm.getVoltage()) * 10);
            dsLCD.println(DriverStationLCD.Line.kMain6, 1, "Arm Angle " + PVal);
            dsLCD.println(DriverStationLCD.Line.kUser2, 1, "Light " + light.getAverageValue());
            dsLCD.println(DriverStationLCD.Line.kUser3, 1, "Gyro Angle " + GyroAngle);
            ds = DriverStation.getInstance();
            if (ds.getDigitalIn(1)) {
                photosense(rite, left, middle);
                ds = DriverStation.getInstance();

            }
            else
                {
                if (ds.getDigitalIn(3)) {
                    FullSpeed(r1, r2, l1, l2, rightStick);
                    ds = DriverStation.getInstance();

                }
                if (!ds.getDigitalIn(3)) {
                    HalfSpeed(r1, r2, l1, l2, rightStick);
                    ds = DriverStation.getInstance();
                }
                ds = DriverStation.getInstance();
            }
        }
Reply With Quote
  #2   Spotlight this post!  
Unread 02-04-2011, 06:50 PM
mobilegamer999 mobilegamer999 is offline
Registered User
FRC #3357 (Comets)
Team Role: Programmer
 
Join Date: Feb 2008
Rookie Year: 2008
Location: Michigan
Posts: 124
mobilegamer999 is a jewel in the roughmobilegamer999 is a jewel in the roughmobilegamer999 is a jewel in the rough
Re: Cypress Switch Problem

If youre using the Cypress module, you have to use the EnhancedDigitalIO class (or something close to that) instead.

[EDIT]
Just checked, and its DriverStationEnhancedIO is the class name.
so in initialization you would call (Assumin dio is your DriverStationEnhancedIO variable name)
dio = DriverStation.getInstance().getEnhancedIO();

then you can call getDigital on dio to read in digitalIO's
__________________

Last edited by mobilegamer999 : 02-04-2011 at 07:07 PM.
Reply With Quote
  #3   Spotlight this post!  
Unread 02-05-2011, 11:21 AM
Derek012's Avatar
Derek012 Derek012 is offline
I miss my frisbees
FRC #4564 (Orange Chaos)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2009
Location: Maine
Posts: 25
Derek012 is on a distinguished road
Re: Cypress Switch Problem

I had a problem with the execution of my robot code when I deployed the code and tried to run the robot it wouldn't run the code in operator control

Code:
dio = DriverStation.getInstance().getEnhancedIO();
while (isOperatorControl()) {
            display.updateLCD();
            Camera(cam);
            
            gyro.setSensitivity(0.125);
            if (GyroAngle >= 360 || GyroAngle <= -360) {
                GyroAngle = GyroAngle % 360;
            }
            updateDashboard();
            PVal = (int) ((petOm.getVoltage()) * 10);
            //dsLCD.println(DriverStationLCD.Line.kMain6, 1, "Arm Angle " + PVal);
            //dsLCD.println(DriverStationLCD.Line.kUser2, 1, "Light " + light.getAverageValue());
            //dsLCD.println(DriverStationLCD.Line.kUser3, 1, "Gyro Angle " + GyroAngle);
            dio = DriverStation.getInstance().getEnhancedIO();
            try {
                if (dio.getDigital(1)) {
                    photosense(rite, left, middle);
                    dio = DriverStation.getInstance().getEnhancedIO();
                } if (!dio.getDigital(1)) {
                    if (dio.getDigital(3)) {
                        FullSpeed(r1, r2, l1, l2, rightStick);
                        dio = DriverStation.getInstance().getEnhancedIO();
                    }
                    if (!dio.getDigital(3)) {
                        HalfSpeed(r1, r2, l1, l2, rightStick);
                        dio = DriverStation.getInstance().getEnhancedIO();
                    }
                    dio = DriverStation.getInstance().getEnhancedIO();
                }
            } catch (EnhancedIOException ex) {
                ex.printStackTrace();
            }
            dio = DriverStation.getInstance().getEnhancedIO();
        }
        dio = DriverStation.getInstance().getEnhancedIO();
    }

Last edited by Derek012 : 02-05-2011 at 11:24 AM. Reason: Code Mistake
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 07:37 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi