WPILibC++ 2024.3.2
AnalogTrigger.h
Go to the documentation of this file.
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.
4
5#pragma once
6
7#include <stdint.h>
8
9#include "hal/Types.h"
10
11/**
12 * @defgroup hal_analogtrigger Analog Trigger Functions
13 * @ingroup hal_capi
14 * @{
15 */
16
17/**
18 * The type of analog trigger to trigger on.
19 */
25};
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31/**
32 * Initializes an analog trigger.
33 *
34 * @param[in] portHandle the analog input to use for triggering
35 * @param[out] status Error status variable. 0 on success.
36 * @return the created analog trigger handle
37 */
39 HAL_AnalogInputHandle portHandle, int32_t* status);
40
41/**
42 * Initializes an analog trigger with a Duty Cycle input
43 *
44 * @param[in] dutyCycleHandle the analog input to use for duty cycle
45 * @param[out] status Error status variable. 0 on success.
46 * @return tbe created analog trigger handle
47 */
49 HAL_DutyCycleHandle dutyCycleHandle, int32_t* status);
50
51/**
52 * Frees an analog trigger.
53 *
54 * @param[in] analogTriggerHandle the trigger handle
55 * @param[out] status Error status variable. 0 on success.
56 */
58 int32_t* status);
59
60/**
61 * Sets the raw ADC upper and lower limits of the analog trigger.
62 *
63 * HAL_SetAnalogTriggerLimitsVoltage or HAL_SetAnalogTriggerLimitsDutyCycle
64 * is likely better in most cases.
65 *
66 * @param[in] analogTriggerHandle the trigger handle
67 * @param[in] lower the lower ADC value
68 * @param[in] upper the upper ADC value
69 * @param[out] status Error status variable. 0 on success.
70 */
72 int32_t lower, int32_t upper,
73 int32_t* status);
74
75/**
76 * Sets the upper and lower limits of the analog trigger.
77 *
78 * The limits are given as floating point voltage values.
79 *
80 * @param[in] analogTriggerHandle the trigger handle
81 * @param[in] lower the lower voltage value
82 * @param[in] upper the upper voltage value
83 * @param[out] status Error status variable. 0 on success.
84 */
86 HAL_AnalogTriggerHandle analogTriggerHandle, double lower, double upper,
87 int32_t* status);
88
89/**
90 * Sets the upper and lower limits of the analog trigger.
91 *
92 * The limits are given as floating point duty cycle values.
93 *
94 * @param[in] analogTriggerHandle the trigger handle
95 * @param[in] lower the lower duty cycle value
96 * @param[in] upper the upper duty cycle value
97 * @param[out] status Error status variable. 0 on success.
98 */
100 HAL_AnalogTriggerHandle analogTriggerHandle, double lower, double upper,
101 int32_t* status);
102
103/**
104 * Configures the analog trigger to use the averaged vs. raw values.
105 *
106 * If the value is true, then the averaged value is selected for the analog
107 * trigger, otherwise the immediate value is used.
108 *
109 * This is not allowed to be used if filtered mode is set.
110 * This is not allowed to be used with Duty Cycle based inputs.
111 *
112 * @param[in] analogTriggerHandle the trigger handle
113 * @param[in] useAveragedValue true to use averaged values, false for raw
114 * @param[out] status Error status variable. 0 on success.
115 */
117 HAL_Bool useAveragedValue, int32_t* status);
118
119/**
120 * Configures the analog trigger to use a filtered value.
121 *
122 * The analog trigger will operate with a 3 point average rejection filter. This
123 * is designed to help with 360 degree pot applications for the period where the
124 * pot crosses through zero.
125 *
126 * This is not allowed to be used if averaged mode is set.
127 *
128 * @param[in] analogTriggerHandle the trigger handle
129 * @param[in] useFilteredValue true to use filtered values, false for average
130 * or raw
131 * @param[out] status Error status variable. 0 on success.
132 */
134 HAL_Bool useFilteredValue, int32_t* status);
135
136/**
137 * Returns the InWindow output of the analog trigger.
138 *
139 * True if the analog input is between the upper and lower limits.
140 *
141 * @param[in] analogTriggerHandle the trigger handle
142 * @param[out] status Error status variable. 0 on success.
143 * @return the InWindow output of the analog trigger
144 */
146 HAL_AnalogTriggerHandle analogTriggerHandle, int32_t* status);
147
148/**
149 * Returns the TriggerState output of the analog trigger.
150 *
151 * True if above upper limit.
152 * False if below lower limit.
153 * If in Hysteresis, maintain previous state.
154 *
155 * @param[in] analogTriggerHandle the trigger handle
156 * @param[out] status Error status variable. 0 on success.
157 * @return the TriggerState output of the analog trigger
158 */
160 HAL_AnalogTriggerHandle analogTriggerHandle, int32_t* status);
161
162/**
163 * Gets the state of the analog trigger output.
164 *
165 * @param[in] analogTriggerHandle the trigger handle
166 * @param[in] type the type of trigger to trigger on
167 * @param[out] status Error status variable. 0 on success.
168 * @return the state of the analog trigger output
169 */
172 int32_t* status);
173
174/**
175 * Get the FPGA index for the AnlogTrigger.
176 *
177 * @param[in] analogTriggerHandle the trigger handle
178 * @param[out] status Error status variable. 0 on success.
179 * @return the FPGA index
180 */
182 HAL_AnalogTriggerHandle analogTriggerHandle, int32_t* status);
183#ifdef __cplusplus
184} // extern "C"
185#endif
186/** @} */
@ HAL_ENUM
Definition: Value.h:14
void HAL_CleanAnalogTrigger(HAL_AnalogTriggerHandle analogTriggerHandle, int32_t *status)
Frees an analog trigger.
HAL_Bool HAL_GetAnalogTriggerInWindow(HAL_AnalogTriggerHandle analogTriggerHandle, int32_t *status)
Returns the InWindow output of the analog trigger.
void HAL_SetAnalogTriggerLimitsDutyCycle(HAL_AnalogTriggerHandle analogTriggerHandle, double lower, double upper, int32_t *status)
Sets the upper and lower limits of the analog trigger.
void HAL_SetAnalogTriggerFiltered(HAL_AnalogTriggerHandle analogTriggerHandle, HAL_Bool useFilteredValue, int32_t *status)
Configures the analog trigger to use a filtered value.
void HAL_SetAnalogTriggerLimitsRaw(HAL_AnalogTriggerHandle analogTriggerHandle, int32_t lower, int32_t upper, int32_t *status)
Sets the raw ADC upper and lower limits of the analog trigger.
HAL_AnalogTriggerHandle HAL_InitializeAnalogTrigger(HAL_AnalogInputHandle portHandle, int32_t *status)
Initializes an analog trigger.
int32_t HAL_GetAnalogTriggerFPGAIndex(HAL_AnalogTriggerHandle analogTriggerHandle, int32_t *status)
Get the FPGA index for the AnlogTrigger.
HAL_AnalogTriggerHandle HAL_InitializeAnalogTriggerDutyCycle(HAL_DutyCycleHandle dutyCycleHandle, int32_t *status)
Initializes an analog trigger with a Duty Cycle input.
void HAL_SetAnalogTriggerLimitsVoltage(HAL_AnalogTriggerHandle analogTriggerHandle, double lower, double upper, int32_t *status)
Sets the upper and lower limits of the analog trigger.
HAL_Bool HAL_GetAnalogTriggerOutput(HAL_AnalogTriggerHandle analogTriggerHandle, HAL_AnalogTriggerType type, int32_t *status)
Gets the state of the analog trigger output.
void HAL_SetAnalogTriggerAveraged(HAL_AnalogTriggerHandle analogTriggerHandle, HAL_Bool useAveragedValue, int32_t *status)
Configures the analog trigger to use the averaged vs.
HAL_Bool HAL_GetAnalogTriggerTriggerState(HAL_AnalogTriggerHandle analogTriggerHandle, int32_t *status)
Returns the TriggerState output of the analog trigger.
HAL_AnalogTriggerType
The type of analog trigger to trigger on.
Definition: AnalogTrigger.h:20
@ HAL_Trigger_kState
Definition: AnalogTrigger.h:22
@ HAL_Trigger_kFallingPulse
Definition: AnalogTrigger.h:24
@ HAL_Trigger_kInWindow
Definition: AnalogTrigger.h:21
@ HAL_Trigger_kRisingPulse
Definition: AnalogTrigger.h:23
int32_t HAL_Bool
Definition: Types.h:73
HAL_Handle HAL_AnalogTriggerHandle
Definition: Types.h:25
HAL_Handle HAL_DutyCycleHandle
Definition: Types.h:59
HAL_Handle HAL_AnalogInputHandle
Definition: Types.h:21
type
Definition: core.h:556