Brian Silverman | f7f267a | 2017-02-04 16:16:08 -0800 | [diff] [blame^] | 1 | /*----------------------------------------------------------------------------*/ |
| 2 | /* Copyright (c) FIRST 2008-2017. All Rights Reserved. */ |
| 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */ |
| 4 | /* must be accompanied by the FIRST BSD license file in the root directory of */ |
| 5 | /* the project. */ |
| 6 | /*----------------------------------------------------------------------------*/ |
| 7 | |
| 8 | #include "GyroBase.h" |
| 9 | |
| 10 | #include "LiveWindow/LiveWindow.h" |
| 11 | #include "WPIErrors.h" |
| 12 | |
| 13 | using namespace frc; |
| 14 | |
| 15 | /** |
| 16 | * Get the PIDOutput for the PIDSource base object. Can be set to return |
| 17 | * angle or rate using SetPIDSourceType(). Defaults to angle. |
| 18 | * |
| 19 | * @return The PIDOutput (angle or rate, defaults to angle) |
| 20 | */ |
| 21 | double GyroBase::PIDGet() { |
| 22 | switch (GetPIDSourceType()) { |
| 23 | case PIDSourceType::kRate: |
| 24 | return GetRate(); |
| 25 | case PIDSourceType::kDisplacement: |
| 26 | return GetAngle(); |
| 27 | default: |
| 28 | return 0; |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | void GyroBase::UpdateTable() { |
| 33 | if (m_table != nullptr) { |
| 34 | m_table->PutNumber("Value", GetAngle()); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | void GyroBase::StartLiveWindowMode() {} |
| 39 | |
| 40 | void GyroBase::StopLiveWindowMode() {} |
| 41 | |
| 42 | std::string GyroBase::GetSmartDashboardType() const { return "Gyro"; } |
| 43 | |
| 44 | void GyroBase::InitTable(std::shared_ptr<ITable> subTable) { |
| 45 | m_table = subTable; |
| 46 | UpdateTable(); |
| 47 | } |
| 48 | |
| 49 | std::shared_ptr<ITable> GyroBase::GetTable() const { return m_table; } |