blob: 0600f662fcb45ad74299b31781862cadd027a003 [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
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -08008namespace frc971::wpilib {
Nathan Leong217cd762022-10-22 16:07:30 -07009
10// Convert min and max angle positions from range to voltage and compare to
11// min and max potentiometer voltage to check if in range.
12
13// subsystem_range is a ::frc971::constants::Range that defines the pot limits
14// potentiometer_offset is a constant that is the initial offset of the pot
15// pot_translate_inverse is a function that translates an angle to voltage
16// reverse is a boolean that sets the pot voltage range as -5 to 0 when true
17// limit_buffer is a constant that is the buffer for the maximum voltage values
18
19bool SafePotVoltageRange(::frc971::constants::Range subsystem_range,
20 double potentiometer_offset,
21 ::std::function<double(double)> pot_translate_inverse,
22 bool reverse, double limit_buffer = 0.05);
23
Stephan Pleinesd99b1ee2024-02-02 20:56:44 -080024} // namespace frc971::wpilib
Nathan Leong217cd762022-10-22 16:07:30 -070025
26#endif // FRC971_WPILIB_WPILIB_UTILS_H_