Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 1 | // Copyright (c) FIRST and other WPILib contributors. |
| 2 | // Open Source Software; you can modify and/or share it under the terms of |
| 3 | // the WPILib BSD license file in the root directory of this project. |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 4 | |
| 5 | #include "frc/AnalogTriggerOutput.h" |
| 6 | |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 7 | #include <hal/AnalogTrigger.h> |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 8 | #include <hal/FRCUsageReporting.h> |
| 9 | |
| 10 | #include "frc/AnalogTrigger.h" |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 11 | #include "frc/AnalogTriggerType.h" |
| 12 | #include "frc/Errors.h" |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 13 | |
| 14 | using namespace frc; |
| 15 | |
| 16 | bool AnalogTriggerOutput::Get() const { |
| 17 | int32_t status = 0; |
| 18 | bool result = HAL_GetAnalogTriggerOutput( |
| 19 | m_trigger->m_trigger, static_cast<HAL_AnalogTriggerType>(m_outputType), |
| 20 | &status); |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 21 | FRC_CheckErrorStatus(status, "{}", "Get"); |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 22 | return result; |
| 23 | } |
| 24 | |
| 25 | HAL_Handle AnalogTriggerOutput::GetPortHandleForRouting() const { |
| 26 | return m_trigger->m_trigger; |
| 27 | } |
| 28 | |
| 29 | AnalogTriggerType AnalogTriggerOutput::GetAnalogTriggerTypeForRouting() const { |
| 30 | return m_outputType; |
| 31 | } |
| 32 | |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 33 | bool AnalogTriggerOutput::IsAnalogTrigger() const { |
| 34 | return true; |
| 35 | } |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 36 | |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 37 | int AnalogTriggerOutput::GetChannel() const { |
| 38 | return m_trigger->GetIndex(); |
| 39 | } |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 40 | |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 41 | void AnalogTriggerOutput::InitSendable(wpi::SendableBuilder&) {} |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 42 | |
| 43 | AnalogTriggerOutput::AnalogTriggerOutput(const AnalogTrigger& trigger, |
| 44 | AnalogTriggerType outputType) |
| 45 | : m_trigger(&trigger), m_outputType(outputType) { |
| 46 | HAL_Report(HALUsageReporting::kResourceType_AnalogTriggerOutput, |
| 47 | trigger.GetIndex() + 1, static_cast<uint8_t>(outputType) + 1); |
| 48 | } |