3131*/
3232
3333namespace SimRacing {
34+ /* *
35+ * Type alias for pin numbers, using Arduino numbering
36+ */
37+ using PinNum = uint8_t ;
38+
39+
3440 /* *
3541 * Enumeration for analog axis names, mapped to integers
3642 */
@@ -68,7 +74,7 @@ namespace SimRacing {
6874 * @param detectTime the amount of time, in ms, the input must be stable for
6975 * before it's interpreted as 'detected'
7076 */
71- DeviceConnection (uint8_t pin, bool invert = false , unsigned long detectTime = 250 );
77+ DeviceConnection (PinNum pin, bool invert = false , unsigned long detectTime = 250 );
7278
7379 /* *
7480 * Checks if the pin detects a connection. This polls the input and checks
@@ -108,7 +114,7 @@ namespace SimRacing {
108114 */
109115 bool readPin () const ;
110116
111- const uint8_t Pin; // /< The pin number being read from. Can be 'NOT_A_PIN' to disable
117+ const PinNum Pin; // /< The pin number being read from. Can be 'NOT_A_PIN' to disable
112118 const bool Inverted; // /< Whether the input is inverted, so 'LOW' is detected instead of 'HIGH'
113119 unsigned long stablePeriod; // /< The amount of time the input must be stable for (ms)
114120
@@ -131,7 +137,7 @@ namespace SimRacing {
131137 *
132138 * @param p the I/O pin for this input (Arduino numbering)
133139 */
134- AnalogInput (uint8_t p);
140+ AnalogInput (PinNum p);
135141
136142 /* *
137143 * Updates the current value of the axis by polling the ADC
@@ -225,7 +231,7 @@ namespace SimRacing {
225231 void setCalibration (Calibration newCal);
226232
227233 private:
228- const uint8_t Pin = NOT_A_PIN; // /< the digital pin number for this input
234+ const PinNum Pin = NOT_A_PIN; // /< the digital pin number for this input
229235 int position; // /< the axis' position in its range, buffered
230236 Calibration cal; // /< the calibration values for the axis
231237 };
@@ -285,7 +291,7 @@ namespace SimRacing {
285291 * @param nPedals the number of pedals stored in said data pointer
286292 * @param detectPin the digital pin for device detection (high is detected)
287293 */
288- Pedals (AnalogInput* dataPtr, uint8_t nPedals, uint8_t detectPin);
294+ Pedals (AnalogInput* dataPtr, uint8_t nPedals, PinNum detectPin);
289295
290296 /* * @copydoc Peripheral::begin() */
291297 virtual void begin ();
@@ -385,7 +391,7 @@ namespace SimRacing {
385391 * @param brakePin the analog pin for the brake pedal potentiometer
386392 * @param detectPin the digital pin for device detection (high is detected)
387393 */
388- TwoPedals (uint8_t gasPin, uint8_t brakePin, uint8_t detectPin = NOT_A_PIN);
394+ TwoPedals (PinNum gasPin, PinNum brakePin, PinNum detectPin = NOT_A_PIN);
389395
390396 /* *
391397 * Sets the calibration data (min/max) for the pedals
@@ -414,7 +420,7 @@ namespace SimRacing {
414420 * @param clutchPin the analog pin for the clutch pedal potentiometer
415421 * @param detectPin the digital pin for device detection (high is detected)
416422 */
417- ThreePedals (uint8_t gasPin, uint8_t brakePin, uint8_t clutchPin, uint8_t detectPin = NOT_A_PIN);
423+ ThreePedals (PinNum gasPin, PinNum brakePin, PinNum clutchPin, PinNum detectPin = NOT_A_PIN);
418424
419425 /* *
420426 * Sets the calibration data (min/max) for the pedals
@@ -542,7 +548,7 @@ namespace SimRacing {
542548 * @param pinRev the digital input pin for the 'reverse' button
543549 * @param detectPin the digital pin for device detection (high is detected)
544550 */
545- AnalogShifter (uint8_t pinX, uint8_t pinY, uint8_t pinRev = NOT_A_PIN, uint8_t detectPin = NOT_A_PIN);
551+ AnalogShifter (PinNum pinX, PinNum pinY, PinNum pinRev = NOT_A_PIN, PinNum detectPin = NOT_A_PIN);
546552
547553 /* *
548554 * Initializes the hardware pins for reading the gear states.
@@ -663,7 +669,7 @@ namespace SimRacing {
663669 } calibration;
664670
665671 AnalogInput analogAxis[2 ]; // /< Axis data for X and Y
666- const uint8_t PinReverse; // /< The pin for the reverse gear button
672+ const PinNum PinReverse; // /< The pin for the reverse gear button
667673 DeviceConnection detector; // /< detector instance for checking if the shifter is connected
668674 };
669675
@@ -681,7 +687,7 @@ namespace SimRacing {
681687 * @param pinAx analog pin number for the handbrake axis
682688 * @param detectPin the digital pin for device detection (high is detected)
683689 */
684- Handbrake (uint8_t pinAx, uint8_t detectPin = NOT_A_PIN);
690+ Handbrake (PinNum pinAx, PinNum detectPin = NOT_A_PIN);
685691
686692 /* *
687693 * Initializes the pin for reading from the handbrake.
@@ -748,7 +754,7 @@ namespace SimRacing {
748754 class LogitechPedals : public ThreePedals {
749755 public:
750756 /* * @copydoc ThreePedals::ThreePedals */
751- LogitechPedals (uint8_t gasPin, uint8_t brakePin, uint8_t clutchPin, uint8_t detectPin = NOT_A_PIN);
757+ LogitechPedals (PinNum gasPin, PinNum brakePin, PinNum clutchPin, PinNum detectPin = NOT_A_PIN);
752758 };
753759
754760 /* *
@@ -763,7 +769,7 @@ namespace SimRacing {
763769 class LogitechDrivingForceGT_Pedals : public TwoPedals {
764770 public:
765771 /* * @copydoc TwoPedals::TwoPedals */
766- LogitechDrivingForceGT_Pedals (uint8_t gasPin, uint8_t brakePin, uint8_t detectPin = NOT_A_PIN);
772+ LogitechDrivingForceGT_Pedals (PinNum gasPin, PinNum brakePin, PinNum detectPin = NOT_A_PIN);
767773 };
768774
769775 /* *
@@ -775,7 +781,7 @@ namespace SimRacing {
775781 class LogitechShifter : public AnalogShifter {
776782 public:
777783 /* * @copydoc AnalogShifter::AnalogShifter */
778- LogitechShifter (uint8_t pinX, uint8_t pinY, uint8_t pinRev = NOT_A_PIN, uint8_t detectPin = NOT_A_PIN);
784+ LogitechShifter (PinNum pinX, PinNum pinY, PinNum pinRev = NOT_A_PIN, PinNum detectPin = NOT_A_PIN);
779785 };
780786
781787
0 commit comments