Sfoglia il codice sorgente

Cleanup narrowing warning in pin_is_protected

Thomas Moore 7 anni fa
parent
commit
5f9592a523

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

@@ -27,8 +27,8 @@
27 27
 #include "../../gcode/parser.h"
28 28
 
29 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 34
 // Return the index of a pin number

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

@@ -239,7 +239,7 @@ constexpr pin_t pin_map[] = {
239 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 244
 constexpr pin_t adc_pin_table[] = {
245 245
   P0_23, P0_24, P0_25, P0_26, P1_30, P1_31,
@@ -255,7 +255,7 @@ constexpr int16_t NUM_ANALOG_INPUTS = COUNT(adc_pin_table);
255 255
 #define HAL_SENSITIVE_PINS P0_06, P0_07, P0_08, P0_09, P0_29, P0_30
256 256
 
257 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 260
 // Return the index of a pin number
261 261
 // The pin number given here is in the form ppp:nnnnn

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

@@ -485,9 +485,6 @@
485 485
   #define MAX_EXTRUDERS 5
486 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 489
 // Assign auto fan pins if needed
493 490
 //
@@ -541,7 +538,7 @@
541 538
   #endif // EXTRUDERS > 2
542 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 542
 #define _H1_PINS
546 543
 #define _H2_PINS
547 544
 #define _H3_PINS
@@ -549,16 +546,16 @@
549 546
 
550 547
 #if HOTENDS > 1
551 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 550
   #if HOTENDS > 2
554 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 553
     #if HOTENDS > 3
557 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 556
       #if HOTENDS > 4
560 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 559
       #endif // HOTENDS > 4
563 560
     #endif // HOTENDS > 3
564 561
   #endif // HOTENDS > 2
@@ -579,7 +576,7 @@
579 576
   #endif // MIXING_STEPPERS > 2
580 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 582
 // Assign endstop pins for boards with only 3 connectors

Loading…
Annulla
Salva