//Password to module wifi is "password1" /** entry point of the application */ public static void Main() { ds = new CTRE.FRC.DriverStation(wifiport); //Create new Driver station object at port 4 _gamepad = new CTRE.Controller.GameController(ds, 0); //Set controller to look at DS with ID 0 //Create two TalonSrx objects and set their control mode left1 = new CTRE.TalonSrx(1); right1 = new CTRE.TalonSrx(2); left1.SetControlMode(CTRE.TalonSrx.ControlMode.kPercentVbus); right1.SetControlMode(CTRE.TalonSrx.ControlMode.kPercentVbus); //Set IP module looks for and is configured with, Computer must set to Static IP ds.SendIP(new byte[] { 10, 0, 33, 2 }, new byte[] { 10, 0, 33, 5 }); while (true) { //Must be called for DS to function ds.update(); //Send Battery Voltage information to Driver Station ds.SendBattery(left1.GetBusVoltage()); if (ds.IsAuton() && ds.IsEnabled()) { //Auton Code while enabled } else if (ds.IsAuton() && !ds.IsEnabled()) { //Auton Code while disabled } else if (!ds.IsAuton() && ds.IsEnabled()) { //Teleop Code while enabled Drive(); Debug.Print(stringBuilder.ToString()); ds.SendUDP(2550, Encoding.UTF8.GetBytes(stringBuilder.ToString())); stringBuilder.Clear(); } else if (!ds.IsAuton() && !ds.IsEnabled()) { //Teleop Code while disabled } } }
public bool IsLow() { float vbat; vbat = _talon.GetBusVoltage(); if (vbat > 10.50) { _dnCnt = 0; if (_upCnt < 100) { ++_upCnt; } } else if (vbat < 10.00) { _upCnt = 0; if (_dnCnt < 100) { ++_dnCnt; } } if (_dnCnt > 50) { batIsLow = true; } else if (_upCnt > 50) { batIsLow = false; } else { //don't change filter ouput } return(batIsLow); }