Skip to content

Commit

Permalink
Cleaned up code formatting and removed useless commented out code.
Browse files Browse the repository at this point in the history
  • Loading branch information
floogulinc committed Jan 24, 2014
1 parent 94e6861 commit 961ed36
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 119 deletions.
126 changes: 63 additions & 63 deletions src/com/frc2879/bender/DSOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package com.frc2879.bender;

import edu.wpi.first.wpilibj.DriverStationLCD;
Expand All @@ -17,72 +16,73 @@
*/
public class DSOutput {

static DriverStationLCD output;
static DriverStationLCD output;

/**
* Make a new DSOutput instance. Not hard.
*/
public DSOutput() {
output = DriverStationLCD.getInstance();
}
/**
* Make a new DSOutput instance. Not hard.
*/
public DSOutput() {
output = DriverStationLCD.getInstance();
}

/**
* Display a line of text without scrolling. Max 21 characters / line.
* <p/>
* @param ln Which line to print in
* @param msg What message to display
*/
public void say(int ln, String msg) {
if(msg == null) {
msg = "null message passed";
}
/**
* Display a line of text without scrolling. Max 21 characters / line.
* <p/>
* @param ln Which line to print in
* @param msg What message to display
*/
public void say(int ln, String msg) {
if (msg == null) {
msg = "null message passed";
}
// DriverStationLCD.kLineLength=21
// Add 21 spaces to clear the rest of the line
msg += " ";
// If the given message is too long, truncate it
if(msg.length() > 21) {
msg = msg.substring(0, 21);
}

switch(ln) {
case (1):
output.println(DriverStationLCD.Line.kMain6, 1, msg);
break;
case (2):
output.println(DriverStationLCD.Line.kUser2, 1, msg);
break;
case (3):
output.println(DriverStationLCD.Line.kUser3, 1, msg);
break;
case (4):
output.println(DriverStationLCD.Line.kUser4, 1, msg);
break;
case (5):
output.println(DriverStationLCD.Line.kUser5, 1, msg);
break;
case (6):
output.println(DriverStationLCD.Line.kUser6, 1, msg);
break;
}
// Show the message
output.updateLCD();
// Add 21 spaces to clear the rest of the line
msg += " ";
// If the given message is too long, truncate it
if (msg.length() > 21) {
msg = msg.substring(0, 21);
}

/**
* Clear the entire output box.
*/
public void clearOutput() {
say(1, " ");
say(2, " ");
say(3, " ");
say(4, " ");
say(5, " ");
say(6, " ");
output.updateLCD();
}
public void clearLine(int line){
say(line, " ");
// Show the message
output.updateLCD();
switch (ln) {
case (1):
output.println(DriverStationLCD.Line.kMain6, 1, msg);
break;
case (2):
output.println(DriverStationLCD.Line.kUser2, 1, msg);
break;
case (3):
output.println(DriverStationLCD.Line.kUser3, 1, msg);
break;
case (4):
output.println(DriverStationLCD.Line.kUser4, 1, msg);
break;
case (5):
output.println(DriverStationLCD.Line.kUser5, 1, msg);
break;
case (6):
output.println(DriverStationLCD.Line.kUser6, 1, msg);
break;
}
// Show the message
output.updateLCD();
}

/**
* Clear the entire output box.
*/
public void clearOutput() {
say(1, " ");
say(2, " ");
say(3, " ");
say(4, " ");
say(5, " ");
say(6, " ");
output.updateLCD();
}

public void clearLine(int line) {
say(line, " ");
// Show the message
output.updateLCD();
}
}
93 changes: 37 additions & 56 deletions src/com/frc2879/bender/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/

package com.frc2879.bender;


import edu.wpi.first.wpilibj.DriverStationLCD;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.SimpleRobot;
Expand All @@ -22,14 +19,14 @@
* directory.
*/
public class Robot extends SimpleRobot {
RobotDrive drivetrain = new RobotDrive(1,2);

RobotDrive drivetrain = new RobotDrive(1, 2);
Joystick joystick = new Joystick(1);

public final String name = "Bender Bot";
public final String version = "v1.03";
public final String fullname = name + " " + version;

// Defining Joystick Mappings:
public final int Button_X = 1;
public final int Button_Y = 4;
Expand All @@ -47,44 +44,35 @@ public class Robot extends SimpleRobot {
public final int Stick_RIGHT_X = 4;
public final int Stick_RIGHT_Y = 5;

// CONFIG VALUES ~~~~~~~~~
// CONFIG VALUES ~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~
int StickSensitivity = 100;
boolean SquaredInputs = true;
// ~~~~~~~~~~~~~~~~~~~~~~~
// CONFIG VALUES ~~~~~~~~~

DSOutput dsout;


DSOutput dsout;

//Called exactly 1 time when the competition starts.
protected void robotInit() {
dsout = new DSOutput();
dsout.say(1, fullname);
saysticksensitivity();
}

boolean pbuttonRB = false;
boolean pbuttonLB = false;




public void saysticksensitivity(){

public void saysticksensitivity() {
dsout.clearLine(2);
dsout.say(2, "Sensitivity: " + Integer.toString(StickSensitivity));
}





/**
* This function is called once each time the robot enters autonomous mode.
*/
public void autonomous() {

}

/**
Expand All @@ -93,45 +81,38 @@ public void autonomous() {
public void operatorControl() {
drivetrain.setSafetyEnabled(true);
while (isOperatorControl() && isEnabled()) {

// Update joystick values:
double moveL = ((joystick.getRawAxis(Stick_LEFT_Y)) * ((double)(StickSensitivity) / 100));
double spinL = ((joystick.getRawAxis(Stick_LEFT_X)) * ((double)(StickSensitivity) / 100));

//if(buttonpress(pbuttonRB, cbuttonRB, joystick.getRawButton(Button_RIGHT_BUMPER))){
// StickSensitivity = (StickSensitivity) + (10);
// saysticksensitivity();
// }

if (joystick.getRawButton(Button_RIGHT_BUMPER)) pbuttonRB = true;
else if(pbuttonRB && !joystick.getRawButton(Button_RIGHT_BUMPER)){
StickSensitivity = (StickSensitivity) + (10);
saysticksensitivity();
pbuttonRB = false;
}


if (joystick.getRawButton(Button_LEFT_BUMPER)) pbuttonLB = true;
else if(pbuttonLB && !joystick.getRawButton(Button_LEFT_BUMPER)){
StickSensitivity = (StickSensitivity) - (10);
saysticksensitivity();
pbuttonLB = false;
}




// Drive da robot:
drivetrain.arcadeDrive(moveL, spinL, SquaredInputs);

Timer.delay(0.01);

// Update joystick values:
double moveL = ((joystick.getRawAxis(Stick_LEFT_Y)) * ((double) (StickSensitivity) / 100));
double spinL = ((joystick.getRawAxis(Stick_LEFT_X)) * ((double) (StickSensitivity) / 100));

if (joystick.getRawButton(Button_RIGHT_BUMPER)) {
pbuttonRB = true;
} else if (pbuttonRB && !joystick.getRawButton(Button_RIGHT_BUMPER)) {
StickSensitivity = (StickSensitivity) + (10);
saysticksensitivity();
pbuttonRB = false;
}

if (joystick.getRawButton(Button_LEFT_BUMPER)) {
pbuttonLB = true;
} else if (pbuttonLB && !joystick.getRawButton(Button_LEFT_BUMPER)) {
StickSensitivity = (StickSensitivity) - (10);
saysticksensitivity();
pbuttonLB = false;
}

// Drive da robot:
drivetrain.arcadeDrive(moveL, spinL, SquaredInputs);

Timer.delay(0.01);
}
}

/**
* This function is called once each time the robot enters test mode.
*/
public void test() {

}
}

0 comments on commit 961ed36

Please sign in to comment.