Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 1 | /*----------------------------------------------------------------------------*/ |
Brian Silverman | 1a67511 | 2016-02-20 20:42:49 -0500 | [diff] [blame^] | 2 | /* Copyright (c) FIRST 2008-2016. All Rights Reserved. */ |
Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 3 | /* Open Source Software - may be modified and shared by FRC teams. The code */ |
Brian Silverman | 1a67511 | 2016-02-20 20:42:49 -0500 | [diff] [blame^] | 4 | /* must be accompanied by the FIRST BSD license file in the root directory of */ |
| 5 | /* the project. */ |
Brian Silverman | 26e4e52 | 2015-12-17 01:56:40 -0500 | [diff] [blame] | 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; } |