diff --git a/CAN.h b/CAN.h new file mode 100644 index 0000000..dc7485e --- /dev/null +++ b/CAN.h @@ -0,0 +1,2 @@ +#pragma once +#include diff --git a/CANAPI.h b/CANAPI.h new file mode 100644 index 0000000..42d080a --- /dev/null +++ b/CANAPI.h @@ -0,0 +1,35 @@ +#pragma once +#include +#include "CANAPITypes.h" +#include "hal/Types.h" + + +HAL_CANHandle HAL_InitializeCAN(HAL_CANManufacturer 1, int32_t 0, HAL_CANDeviceType 1); + +void HAL_CleanCan(Hal_CANHandle TalonSRX); + +void RepeatedRead(){ + +while (HAL_ReadCANPacketTimeout() = error){ + +void HAL_ReadCANPacketNew(HAL_CANHandle HAL_m_Encoder1Handle, int32_t 0, uint8_t* 8, +int32_t* 1, uint64_t* recievedTimestamp, int32_t* status) + +} + +else { + +void HAL_ReadCANPacketTimeout(HAL_CANHandle HAL_m_Encoder1Handle, int32_t 0, +uint8_t* 8, int32_t* 1, uint64_t* recievedTimestamp, int32_t 1000, int32_t* status); + +} + +} + + + + + + + + diff --git a/CANAPITypes.h b/CANAPITypes.h new file mode 100644 index 0000000..e568479 --- /dev/null +++ b/CANAPITypes.h @@ -0,0 +1,20 @@ +#pragma once +#include +#include "hal/Types.h" +#include + +class CAN : public frc::TimedRobot { + +HAL_ENUM(HAL_DeviceType) { +HAL_CAN_Dev_kTalonSRX = 1; +HAL_CAN_Dev_kVictorSPX = 2; +HAL_CAN_Dev_kEncoder1 = 3; +HAL_CAN_Dev_kEncoder2 = 4; +}; + + +HAL_ENUM(HAL_CANMaunfacturer) { +HAL_CAN_Man_kTeamUse = 1; +}; + +} \ No newline at end of file diff --git a/Robot.cpp b/Robot.cpp new file mode 100644 index 0000000..07d843d --- /dev/null +++ b/Robot.cpp @@ -0,0 +1,70 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#include "Robot.h" + +#include + +#include + +void Robot::RobotInit() { + m_chooser.SetDefaultOption(kAutoNameDefault, kAutoNameDefault); + m_chooser.AddOption(kAutoNameCustom, kAutoNameCustom); + frc::SmartDashboard::PutData("Auto Modes", &m_chooser); +} + +/** + * This function is called every robot packet, no matter the mode. Use + * this for items like diagnostics that you want ran during disabled, + * autonomous, teleoperated and test. + * + *

This runs after the mode specific periodic functions, but before + * LiveWindow and SmartDashboard integrated updating. + */ +void Robot::RobotPeriodic() {} + +/** + * This autonomous (along with the chooser code above) shows how to select + * between different autonomous modes using the dashboard. The sendable chooser + * code works with the Java SmartDashboard. If you prefer the LabVIEW Dashboard, + * remove all of the chooser code and uncomment the GetString line to get the + * auto name from the text box below the Gyro. + * + * You can add additional auto modes by adding additional comparisons to the + * if-else structure below with additional strings. If using the SendableChooser + * make sure to add them to the chooser code above as well. + */ +void Robot::AutonomousInit() { + m_autoSelected = m_chooser.GetSelected(); + // m_autoSelected = SmartDashboard::GetString("Auto Selector", + // kAutoNameDefault); + std::cout << "Auto selected: " << m_autoSelected << std::endl; + + if (m_autoSelected == kAutoNameCustom) { + // Custom Auto goes here + } else { + // Default Auto goes here + } +} + +void Robot::AutonomousPeriodic() { + if (m_autoSelected == kAutoNameCustom) { + // Custom Auto goes here + } else { + // Default Auto goes here + } +} + +void Robot::TeleopInit() {} + +void Robot::TeleopPeriodic() {} + +void Robot::TestPeriodic() {} + +#ifndef RUNNING_FRC_TESTS +int main() { return frc::StartRobot(); } +#endif diff --git a/Robot.h b/Robot.h new file mode 100644 index 0000000..09183dc --- /dev/null +++ b/Robot.h @@ -0,0 +1,30 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) 2017-2018 FIRST. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +#pragma once + +#include + +#include +#include + +class Robot : public frc::TimedRobot { + public: + void RobotInit() override; + void RobotPeriodic() override; + void AutonomousInit() override; + void AutonomousPeriodic() override; + void TeleopInit() override; + void TeleopPeriodic() override; + void TestPeriodic() override; + + private: + frc::SendableChooser m_chooser; + const std::string kAutoNameDefault = "Default"; + const std::string kAutoNameCustom = "My Auto"; + std::string m_autoSelected; +}; diff --git a/Types.h b/Types.h new file mode 100644 index 0000000..7c6448b --- /dev/null +++ b/Types.h @@ -0,0 +1,21 @@ +#pragma once +#include +#define HAL_kInvalidHandle 0 + +typedef int32_t HAL_Handle; +typedef HAL_Handle HAL_TalonSRXHandle; +typedef HAL_Handle HAL_VictorSPXHandle; +typedef HAL_Handle HAL_m_Encoder1Handle; +typedef HAL_Handle HAL_m_Encoder2Handle; +typedef HAL_Handle HAL_AnalogInputHandle; +typedef HAL_Handle HAL_CANHandle; +typedef int32_t HAL_Bool; + + +#ifdef __cplusplus +#define HAL_ENUM(name) enum name : int32_t +#else +#define HAL_ENUM(name) + typedef int32_t name; + enum name + #endif \ No newline at end of file