Quasics2017Code/Nike/src/Commands/Lights/AutomaticLighting.cpp
// Called repeatedly when this Command is scheduled to run
Called repeatedly when this Command is scheduled to run
Called repeatedly when this Command is scheduled to run
void AutomaticLighting::Execute() {
	if (DriverStation::GetInstance().GetBatteryVoltage()
			< lowBatteryThreshold) {
		batteryTimer++;
	} else {
		batteryTimer = 0;
	}
	bool isLowBattery = batteryTimer > lowBatteryCounts;
	if (isLowBattery) {
		color = ArduinoController::kYellow;
	} else if (!DriverStation::GetInstance().IsFMSAttached()) {
		color = ArduinoController::kGreen;
	} else if (DriverStation::GetInstance().GetAlliance()
			== DriverStation::kRed) {
		color = ArduinoController::kRed;
	} else if (DriverStation::GetInstance().GetAlliance()
			== DriverStation::kBlue) {
		color = ArduinoController::kBlue;
	} else {
		color = ArduinoController::kRainbow;
	}
	if (isLowBattery) {
		dynamic = ArduinoController::kSnake;
	} else if (DriverStation::GetInstance().IsEnabled()
			&& DriverStation::GetInstance().IsAutonomous()) {
		dynamic = ArduinoController::kBlinking;
	} else if (DriverStation::GetInstance().IsEnabled()
			&& DriverStation::GetInstance().IsOperatorControl()) {
		dynamic = ArduinoController::kDashed;
	} else {
		dynamic = ArduinoController::kOn;
	}
	Robot::arduinoController->SetLightColor(color);
	Robot::arduinoController->SetLightDynamic(dynamic);
}
void AutomaticLighting :: Execute ( ) { if ( DriverStation :: GetInstance ( ) . GetBatteryVoltage ( ) < lowBatteryThreshold ) { batteryTimer ++ ; } else { batteryTimer = 0 ; } bool isLowBattery = batteryTimer > lowBatteryCounts ; if ( isLowBattery ) { color = ArduinoController :: kYellow ; } else if ( ! DriverStation :: GetInstance ( ) . IsFMSAttached ( ) ) { color = ArduinoController :: kGreen ; } else if ( DriverStation :: GetInstance ( ) . GetAlliance ( ) == DriverStation :: kRed ) { color = ArduinoController :: kRed ; } else if ( DriverStation :: GetInstance ( ) . GetAlliance ( ) == DriverStation :: kBlue ) { color = ArduinoController :: kBlue ; } else { color = ArduinoController :: kRainbow ; } if ( isLowBattery ) { dynamic = ArduinoController :: kSnake ; } else if ( DriverStation :: GetInstance ( ) . IsEnabled ( ) && DriverStation :: GetInstance ( ) . IsAutonomous ( ) ) { dynamic = ArduinoController :: kBlinking ; } else if ( DriverStation :: GetInstance ( ) . IsEnabled ( ) && DriverStation :: GetInstance ( ) . IsOperatorControl ( ) ) { dynamic = ArduinoController :: kDashed ; } else { dynamic = ArduinoController :: kOn ; } Robot :: arduinoController -> SetLightColor ( color ) ; Robot :: arduinoController -> SetLightDynamic ( dynamic ) ; }
Called repeatedly when this Command is scheduled to run
Called repeatedly when this Command is scheduled to run
//------------------------------Battery Check------------------------------ //------------------------------------------------------------------------- //-------------------------------Color Tree-------------------------------- //------------------------------------------------------------------------- //---------------------------Dynamic Tree---------------------------------- //-------------------------------------------------------------------------