WPILibC++ 2025.2.1
Loading...
Searching...
No Matches
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 */
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 */
57
58/**
59 * Sets the raw ADC upper and lower limits of the analog trigger.
60 *
61 * HAL_SetAnalogTriggerLimitsVoltage or HAL_SetAnalogTriggerLimitsDutyCycle
62 * is likely better in most cases.
63 *
64 * @param[in] analogTriggerHandle the trigger handle
65 * @param[in] lower the lower ADC value
66 * @param[in] upper the upper ADC value
67 * @param[out] status Error status variable. 0 on success.
68 */
70 int32_t lower, int32_t upper,
71 int32_t* status);
72
73/**
74 * Sets the upper and lower limits of the analog trigger.
75 *
76 * The limits are given as floating point voltage values.
77 *
78 * @param[in] analogTriggerHandle the trigger handle
79 * @param[in] lower the lower voltage value
80 * @param[in] upper the upper voltage value
81 * @param[out] status Error status variable. 0 on success.
82 */
84 HAL_AnalogTriggerHandle analogTriggerHandle, double lower, double upper,
85 int32_t* status);
86
87/**
88 * Sets the upper and lower limits of the analog trigger.
89 *
90 * The limits are given as floating point duty cycle values.
91 *
92 * @param[in] analogTriggerHandle the trigger handle
93 * @param[in] lower the lower duty cycle value
94 * @param[in] upper the upper duty cycle value
95 * @param[out] status Error status variable. 0 on success.
96 */
98 HAL_AnalogTriggerHandle analogTriggerHandle, double lower, double upper,
99 int32_t* status);
100
101/**
102 * Configures the analog trigger to use the averaged vs. raw values.
103 *
104 * If the value is true, then the averaged value is selected for the analog
105 * trigger, otherwise the immediate value is used.
106 *
107 * This is not allowed to be used if filtered mode is set.
108 * This is not allowed to be used with Duty Cycle based inputs.
109 *
110 * @param[in] analogTriggerHandle the trigger handle
111 * @param[in] useAveragedValue true to use averaged values, false for raw
112 * @param[out] status Error status variable. 0 on success.
113 */
115 HAL_Bool useAveragedValue, int32_t* status);
116
117/**
118 * Configures the analog trigger to use a filtered value.
119 *
120 * The analog trigger will operate with a 3 point average rejection filter. This
121 * is designed to help with 360 degree pot applications for the period where the
122 * pot crosses through zero.
123 *
124 * This is not allowed to be used if averaged mode is set.
125 *
126 * @param[in] analogTriggerHandle the trigger handle
127 * @param[in] useFilteredValue true to use filtered values, false for average
128 * or raw
129 * @param[out] status Error status variable. 0 on success.
130 */
132 HAL_Bool useFilteredValue, int32_t* status);
133
134/**
135 * Returns the InWindow output of the analog trigger.
136 *
137 * True if the analog input is between the upper and lower limits.
138 *
139 * @param[in] analogTriggerHandle the trigger handle
140 * @param[out] status Error status variable. 0 on success.
141 * @return the InWindow output of the analog trigger
142 */
144 HAL_AnalogTriggerHandle analogTriggerHandle, int32_t* status);
145
146/**
147 * Returns the TriggerState output of the analog trigger.
148 *
149 * True if above upper limit.
150 * False if below lower limit.
151 * If in Hysteresis, maintain previous state.
152 *
153 * @param[in] analogTriggerHandle the trigger handle
154 * @param[out] status Error status variable. 0 on success.
155 * @return the TriggerState output of the analog trigger
156 */
158 HAL_AnalogTriggerHandle analogTriggerHandle, int32_t* status);
159
160/**
161 * Gets the state of the analog trigger output.
162 *
163 * @param[in] analogTriggerHandle the trigger handle
164 * @param[in] type the type of trigger to trigger on
165 * @param[out] status Error status variable. 0 on success.
166 * @return the state of the analog trigger output
167 */
170 int32_t* status);
171
172/**
173 * Get the FPGA index for the AnalogTrigger.
174 *
175 * @param[in] analogTriggerHandle the trigger handle
176 * @param[out] status Error status variable. 0 on success.
177 * @return the FPGA index
178 */
180 HAL_AnalogTriggerHandle analogTriggerHandle, int32_t* status);
181#ifdef __cplusplus
182} // extern "C"
183#endif
184/** @} */
void HAL_CleanAnalogTrigger(HAL_AnalogTriggerHandle analogTriggerHandle)
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 AnalogTrigger.
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
#define HAL_ENUM(name)
Definition Types.h:76