Skip to content

Add files via upload #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CAN.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#pragma once
#include <stdint.h>
35 changes: 35 additions & 0 deletions CANAPI.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma once
#include <stdint.h>
#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);

}

}








20 changes: 20 additions & 0 deletions CANAPITypes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once
#include <stdint.h>
#include "hal/Types.h"
#include <frc/TimedRobot.h>

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;
};

}
70 changes: 70 additions & 0 deletions Robot.cpp
Original file line number Diff line number Diff line change
@@ -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 <iostream>

#include <frc/smartdashboard/SmartDashboard.h>

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.
*
* <p> 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<Robot>(); }
#endif
30 changes: 30 additions & 0 deletions Robot.h
Original file line number Diff line number Diff line change
@@ -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 <string>

#include <frc/TimedRobot.h>
#include <frc/smartdashboard/SendableChooser.h>

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<std::string> m_chooser;
const std::string kAutoNameDefault = "Default";
const std::string kAutoNameCustom = "My Auto";
std::string m_autoSelected;
};
21 changes: 21 additions & 0 deletions Types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once
#include <stdint.h>
#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