Browse Source

Cleanup narrowing warning in pin_is_protected

Thomas Moore 7 years ago
parent
commit
5f9592a523

+ 2
- 2
Marlin/src/HAL/HAL_LPC1768/pinmapping.cpp View File

27
 #include "../../gcode/parser.h"
27
 #include "../../gcode/parser.h"
28
 
28
 
29
 // Get the digital pin for an analog index
29
 // Get the digital pin for an analog index
30
-pin_t analogInputToDigitalPin(const uint8_t p) {
31
-  return (p < COUNT(adc_pin_table) ? adc_pin_table[p] : P_NC);
30
+pin_t analogInputToDigitalPin(const int8_t p) {
31
+  return (WITHIN(p, 0, NUM_ANALOG_INPUTS) ? adc_pin_table[p] : P_NC);
32
 }
32
 }
33
 
33
 
34
 // Return the index of a pin number
34
 // Return the index of a pin number

+ 2
- 2
Marlin/src/HAL/HAL_LPC1768/pinmapping.h View File

239
   P_NC,  P_NC,  P_NC,  P_NC,  P4_28, P4_29, P_NC,  P_NC
239
   P_NC,  P_NC,  P_NC,  P_NC,  P4_28, P4_29, P_NC,  P_NC
240
 };
240
 };
241
 
241
 
242
-constexpr int16_t NUM_DIGITAL_PINS = COUNT(pin_map);
242
+constexpr int8_t NUM_DIGITAL_PINS = COUNT(pin_map);
243
 
243
 
244
 constexpr pin_t adc_pin_table[] = {
244
 constexpr pin_t adc_pin_table[] = {
245
   P0_23, P0_24, P0_25, P0_26, P1_30, P1_31,
245
   P0_23, P0_24, P0_25, P0_26, P1_30, P1_31,
255
 #define HAL_SENSITIVE_PINS P0_06, P0_07, P0_08, P0_09, P0_29, P0_30
255
 #define HAL_SENSITIVE_PINS P0_06, P0_07, P0_08, P0_09, P0_29, P0_30
256
 
256
 
257
 // Get the digital pin for an analog index
257
 // Get the digital pin for an analog index
258
-pin_t analogInputToDigitalPin(const uint8_t p);
258
+pin_t analogInputToDigitalPin(const int8_t p);
259
 
259
 
260
 // Return the index of a pin number
260
 // Return the index of a pin number
261
 // The pin number given here is in the form ppp:nnnnn
261
 // The pin number given here is in the form ppp:nnnnn

+ 6
- 9
Marlin/src/pins/pins.h View File

485
   #define MAX_EXTRUDERS 5
485
   #define MAX_EXTRUDERS 5
486
 #endif
486
 #endif
487
 
487
 
488
-// Marlin needs to account for pins that equal -1
489
-#define marlinAnalogInputToDigitalPin(p) ((p) == -1 ? -1 : analogInputToDigitalPin(p))
490
-
491
 //
488
 //
492
 // Assign auto fan pins if needed
489
 // Assign auto fan pins if needed
493
 //
490
 //
541
   #endif // EXTRUDERS > 2
538
   #endif // EXTRUDERS > 2
542
 #endif // EXTRUDERS > 1
539
 #endif // EXTRUDERS > 1
543
 
540
 
544
-#define _H0_PINS HEATER_0_PIN, E0_AUTO_FAN_PIN, marlinAnalogInputToDigitalPin(TEMP_0_PIN),
541
+#define _H0_PINS HEATER_0_PIN, E0_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_0_PIN),
545
 #define _H1_PINS
542
 #define _H1_PINS
546
 #define _H2_PINS
543
 #define _H2_PINS
547
 #define _H3_PINS
544
 #define _H3_PINS
549
 
546
 
550
 #if HOTENDS > 1
547
 #if HOTENDS > 1
551
   #undef _H1_PINS
548
   #undef _H1_PINS
552
-  #define _H1_PINS HEATER_1_PIN, E1_AUTO_FAN_PIN, marlinAnalogInputToDigitalPin(TEMP_1_PIN),
549
+  #define _H1_PINS HEATER_1_PIN, E1_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_1_PIN),
553
   #if HOTENDS > 2
550
   #if HOTENDS > 2
554
     #undef _H2_PINS
551
     #undef _H2_PINS
555
-    #define _H2_PINS HEATER_2_PIN, E2_AUTO_FAN_PIN, marlinAnalogInputToDigitalPin(TEMP_2_PIN),
552
+    #define _H2_PINS HEATER_2_PIN, E2_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_2_PIN),
556
     #if HOTENDS > 3
553
     #if HOTENDS > 3
557
       #undef _H3_PINS
554
       #undef _H3_PINS
558
-      #define _H3_PINS HEATER_3_PIN, E3_AUTO_FAN_PIN, marlinAnalogInputToDigitalPin(TEMP_3_PIN),
555
+      #define _H3_PINS HEATER_3_PIN, E3_AUTO_FAN_PIN, analogInputToDigitalPin(TEMP_3_PIN),
559
       #if HOTENDS > 4
556
       #if HOTENDS > 4
560
         #undef _H4_PINS
557
         #undef _H4_PINS
561
-        #define _H4_PINS HEATER_4_PIN, marlinAnalogInputToDigitalPin(TEMP_4_PIN),
558
+        #define _H4_PINS HEATER_4_PIN, analogInputToDigitalPin(TEMP_4_PIN),
562
       #endif // HOTENDS > 4
559
       #endif // HOTENDS > 4
563
     #endif // HOTENDS > 3
560
     #endif // HOTENDS > 3
564
   #endif // HOTENDS > 2
561
   #endif // HOTENDS > 2
579
   #endif // MIXING_STEPPERS > 2
576
   #endif // MIXING_STEPPERS > 2
580
 #endif // MIXING_STEPPERS > 1
577
 #endif // MIXING_STEPPERS > 1
581
 
578
 
582
-#define BED_PINS HEATER_BED_PIN, marlinAnalogInputToDigitalPin(TEMP_BED_PIN),
579
+#define BED_PINS HEATER_BED_PIN, analogInputToDigitalPin(TEMP_BED_PIN),
583
 
580
 
584
 //
581
 //
585
 // Assign endstop pins for boards with only 3 connectors
582
 // Assign endstop pins for boards with only 3 connectors

Loading…
Cancel
Save