blob: 78dd2627d20b4b73ecdcf83a66b60bdcafbd970e [file] [log] [blame]
Nathan Leong217cd762022-10-22 16:07:30 -07001#ifndef FRC971_WPILIB_WPILIB_UTILS_H_
2#define FRC971_WPILIB_WPILIB_UTILS_H_
3
4#include <functional>
5
6#include "frc971/constants.h"
7
8namespace frc971 {
9namespace wpilib {
10
11// Convert min and max angle positions from range to voltage and compare to
12// min and max potentiometer voltage to check if in range.
13
14// subsystem_range is a ::frc971::constants::Range that defines the pot limits
15// potentiometer_offset is a constant that is the initial offset of the pot
16// pot_translate_inverse is a function that translates an angle to voltage
17// reverse is a boolean that sets the pot voltage range as -5 to 0 when true
18// limit_buffer is a constant that is the buffer for the maximum voltage values
19
20bool SafePotVoltageRange(::frc971::constants::Range subsystem_range,
21 double potentiometer_offset,
22 ::std::function<double(double)> pot_translate_inverse,
23 bool reverse, double limit_buffer = 0.05);
24
25} // namespace wpilib
26} // namespace frc971
27
28#endif // FRC971_WPILIB_WPILIB_UTILS_H_