Browse Source

Use DPM where possible

Scott Lahteine 8 years ago
parent
commit
9cbedab91b
3 changed files with 15 additions and 18 deletions
  1. 2
    0
      Marlin/fastio.h
  2. 4
    4
      Marlin/temperature.cpp
  3. 9
    14
      Marlin/ultralcd.cpp

+ 2
- 0
Marlin/fastio.h View File

@@ -93,6 +93,8 @@
93 93
 
94 94
 /// set pin as input wrapper
95 95
 #define SET_INPUT(IO)  _SET_INPUT(IO)
96
+/// set pin as input with pullup wrapper
97
+#define SET_INPUT_PULLUP(IO) do{ _SET_INPUT(IO); _WRITE(IO, HIGH); }while(0)
96 98
 /// set pin as output wrapper
97 99
 #define SET_OUTPUT(IO)  _SET_OUTPUT(IO)
98 100
 

+ 4
- 4
Marlin/temperature.cpp View File

@@ -1049,7 +1049,7 @@ void Temperature::init() {
1049 1049
         setPwmFrequency(E0_AUTO_FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
1050 1050
       #endif
1051 1051
     #else
1052
-      pinMode(E0_AUTO_FAN_PIN, OUTPUT);
1052
+      SET_OUTPUT(E0_AUTO_FAN_PIN);
1053 1053
     #endif
1054 1054
   #endif
1055 1055
   #if HAS_AUTO_FAN_1 && !AUTO_1_IS_0
@@ -1059,7 +1059,7 @@ void Temperature::init() {
1059 1059
         setPwmFrequency(E1_AUTO_FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
1060 1060
       #endif
1061 1061
     #else
1062
-      pinMode(E1_AUTO_FAN_PIN, OUTPUT);
1062
+      SET_OUTPUT(E1_AUTO_FAN_PIN);
1063 1063
     #endif
1064 1064
   #endif
1065 1065
   #if HAS_AUTO_FAN_2 && !AUTO_2_IS_0 && !AUTO_2_IS_1
@@ -1069,7 +1069,7 @@ void Temperature::init() {
1069 1069
         setPwmFrequency(E2_AUTO_FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
1070 1070
       #endif
1071 1071
     #else
1072
-      pinMode(E2_AUTO_FAN_PIN, OUTPUT);
1072
+      SET_OUTPUT(E2_AUTO_FAN_PIN);
1073 1073
     #endif
1074 1074
   #endif
1075 1075
   #if HAS_AUTO_FAN_3 && !AUTO_3_IS_0 && !AUTO_3_IS_1 && !AUTO_3_IS_2
@@ -1079,7 +1079,7 @@ void Temperature::init() {
1079 1079
         setPwmFrequency(E3_AUTO_FAN_PIN, 1); // No prescaling. Pwm frequency = F_CPU/256/8
1080 1080
       #endif
1081 1081
     #else
1082
-      pinMode(E3_AUTO_FAN_PIN, OUTPUT);
1082
+      SET_OUTPUT(E3_AUTO_FAN_PIN);
1083 1083
     #endif
1084 1084
   #endif
1085 1085
 

+ 9
- 14
Marlin/ultralcd.cpp View File

@@ -2491,11 +2491,9 @@ void lcd_init() {
2491 2491
     #endif
2492 2492
 
2493 2493
     #if ENABLED(REPRAPWORLD_KEYPAD)
2494
-      pinMode(SHIFT_CLK, OUTPUT);
2495
-      pinMode(SHIFT_LD, OUTPUT);
2496
-      pinMode(SHIFT_OUT, INPUT);
2497
-      WRITE(SHIFT_OUT, HIGH);
2498
-      WRITE(SHIFT_LD, HIGH);
2494
+      SET_OUTPUT(SHIFT_CLK);
2495
+      OUT_WRITE(SHIFT_LD, HIGH);
2496
+      SET_INPUT_PULLUP(SHIFT_OUT);
2499 2497
     #endif
2500 2498
 
2501 2499
     #if BUTTON_EXISTS(UP)
@@ -2514,16 +2512,13 @@ void lcd_init() {
2514 2512
   #else // !NEWPANEL
2515 2513
 
2516 2514
     #if ENABLED(SR_LCD_2W_NL) // Non latching 2 wire shift register
2517
-      pinMode(SR_DATA_PIN, OUTPUT);
2518
-      pinMode(SR_CLK_PIN, OUTPUT);
2515
+      SET_OUTPUT(SR_DATA_PIN);
2516
+      SET_OUTPUT(SR_CLK_PIN);
2519 2517
     #elif defined(SHIFT_CLK)
2520
-      pinMode(SHIFT_CLK, OUTPUT);
2521
-      pinMode(SHIFT_LD, OUTPUT);
2522
-      pinMode(SHIFT_EN, OUTPUT);
2523
-      pinMode(SHIFT_OUT, INPUT);
2524
-      WRITE(SHIFT_OUT, HIGH);
2525
-      WRITE(SHIFT_LD, HIGH);
2526
-      WRITE(SHIFT_EN, LOW);
2518
+      SET_OUTPUT(SHIFT_CLK);
2519
+      OUT_WRITE(SHIFT_LD, HIGH);
2520
+      OUT_WRITE(SHIFT_EN, LOW);
2521
+      SET_INPUT_PULLUP(SHIFT_OUT);
2527 2522
     #endif // SR_LCD_2W_NL
2528 2523
 
2529 2524
   #endif // !NEWPANEL

Loading…
Cancel
Save