Daniel Petti | aece37f | 2014-10-25 17:13:44 -0700 | [diff] [blame] | 1 | #ifndef FRC971_SHIFTER_HALL_EFFECT_H_ |
| 2 | #define FRC971_SHIFTER_HALL_EFFECT_H_ |
| 3 | |
Stephan Pleines | f63bde8 | 2024-01-13 15:59:33 -0800 | [diff] [blame] | 4 | namespace frc971::constants { |
Daniel Petti | aece37f | 2014-10-25 17:13:44 -0700 | [diff] [blame] | 5 | |
Sabina Davis | 415bb6c | 2017-10-16 23:30:52 -0700 | [diff] [blame] | 6 | // Contains the constants for mapping the analog voltages that the shifter |
| 7 | // sensors return to the shifter position. The code which uses this is trying |
| 8 | // to sort out if we are in low gear, high gear, or neutral. |
Daniel Petti | aece37f | 2014-10-25 17:13:44 -0700 | [diff] [blame] | 9 | struct ShifterHallEffect { |
Sabina Davis | 415bb6c | 2017-10-16 23:30:52 -0700 | [diff] [blame] | 10 | // low_gear_low is the voltage that the shifter position sensor reads when it |
| 11 | // is all the way in low gear. high_gear_high is the voltage that the shifter |
| 12 | // position sensor reads when it is all the way in high gear. These two |
| 13 | // values are used to calculate a position from 0 to 1, where we get 0 when |
| 14 | // the shifter is in low gear, and 1 when it is high gear. |
| 15 | double low_gear_low; |
| 16 | double high_gear_high; |
Daniel Petti | aece37f | 2014-10-25 17:13:44 -0700 | [diff] [blame] | 17 | |
| 18 | // The numbers for when the dog is clear of each gear. |
Sabina Davis | 415bb6c | 2017-10-16 23:30:52 -0700 | [diff] [blame] | 19 | // We are in low gear when the position is less than clear_low, and in high |
| 20 | // gear when the shifter position is greater than clear_high. |
Daniel Petti | aece37f | 2014-10-25 17:13:44 -0700 | [diff] [blame] | 21 | double clear_low, clear_high; |
| 22 | }; |
| 23 | |
Sabina Davis | 415bb6c | 2017-10-16 23:30:52 -0700 | [diff] [blame] | 24 | struct DualHallShifterHallEffect { |
| 25 | ShifterHallEffect shifter_hall_effect; |
| 26 | double low_gear_middle; |
| 27 | double high_gear_middle; |
| 28 | }; |
| 29 | |
Stephan Pleines | f63bde8 | 2024-01-13 15:59:33 -0800 | [diff] [blame] | 30 | } // namespace frc971::constants |
Daniel Petti | aece37f | 2014-10-25 17:13:44 -0700 | [diff] [blame] | 31 | |
| 32 | #endif |