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