Browse Source

Merge pull request #4893 from thinkyhead/rc_stat_led_check

Define status LED pins without condition
Scott Lahteine 8 years ago
parent
commit
9cebbabd05

+ 4
- 1
Marlin/Conditionals_post.h View File

@@ -462,10 +462,13 @@
462 462
   #define HAS_SOLENOID_1 (PIN_EXISTS(SOL1))
463 463
   #define HAS_SOLENOID_2 (PIN_EXISTS(SOL2))
464 464
   #define HAS_SOLENOID_3 (PIN_EXISTS(SOL3))
465
-  #define HAS_MICROSTEPS (PIN_EXISTS(X_MS1))
465
+  #define HAS_MICROSTEPS_X (PIN_EXISTS(X_MS1))
466
+  #define HAS_MICROSTEPS_Y (PIN_EXISTS(Y_MS1))
467
+  #define HAS_MICROSTEPS_Z (PIN_EXISTS(Z_MS1))
466 468
   #define HAS_MICROSTEPS_E0 (PIN_EXISTS(E0_MS1))
467 469
   #define HAS_MICROSTEPS_E1 (PIN_EXISTS(E1_MS1))
468 470
   #define HAS_MICROSTEPS_E2 (PIN_EXISTS(E2_MS1))
471
+  #define HAS_MICROSTEPS (HAS_MICROSTEPS_X || HAS_MICROSTEPS_Y || HAS_MICROSTEPS_Z || HAS_MICROSTEPS_E0 || HAS_MICROSTEPS_E1 || HAS_MICROSTEPS_E2)
469 472
   #define HAS_STEPPER_RESET (PIN_EXISTS(STEPPER_RESET))
470 473
   #define HAS_X_ENABLE (PIN_EXISTS(X_ENABLE))
471 474
   #define HAS_X2_ENABLE (PIN_EXISTS(X2_ENABLE))

+ 21
- 24
Marlin/Marlin_main.cpp View File

@@ -781,7 +781,7 @@ void setup_killpin() {
781 781
 #if ENABLED(FILAMENT_RUNOUT_SENSOR)
782 782
 
783 783
   void setup_filrunoutpin() {
784
-    pinMode(FIL_RUNOUT_PIN, INPUT);
784
+    SET_INPUT(FIL_RUNOUT_PIN);
785 785
     #if ENABLED(ENDSTOPPULLUP_FIL_RUNOUT)
786 786
       WRITE(FIL_RUNOUT_PIN, HIGH);
787 787
     #endif
@@ -859,10 +859,9 @@ void servo_init() {
859 859
  */
860 860
 #if HAS_STEPPER_RESET
861 861
   void disableStepperDrivers() {
862
-    pinMode(STEPPER_RESET_PIN, OUTPUT);
863
-    digitalWrite(STEPPER_RESET_PIN, LOW);  // drive it down to hold in reset motor driver chips
862
+    OUT_WRITE(STEPPER_RESET_PIN, LOW);  // drive it down to hold in reset motor driver chips
864 863
   }
865
-  void enableStepperDrivers() { pinMode(STEPPER_RESET_PIN, INPUT); }  // set to input, which allows it to be pulled high by pullups
864
+  void enableStepperDrivers() { SET_INPUT(STEPPER_RESET_PIN); }  // set to input, which allows it to be pulled high by pullups
866 865
 #endif
867 866
 
868 867
 #if ENABLED(EXPERIMENTAL_I2CBUS) && I2C_SLAVE_ADDRESS > 0
@@ -6514,18 +6513,19 @@ inline void gcode_M503() {
6514 6513
 inline void gcode_M907() {
6515 6514
   #if HAS_DIGIPOTSS
6516 6515
     LOOP_XYZE(i)
6517
-      if (code_seen(axis_codes[i])) stepper.digipot_current(i, code_value_int());
6516
+    if (code_seen(axis_codes[i])) stepper.digipot_current(i, code_value_int());
6518 6517
     if (code_seen('B')) stepper.digipot_current(4, code_value_int());
6519 6518
     if (code_seen('S')) for (int i = 0; i <= 4; i++) stepper.digipot_current(i, code_value_int());
6520
-  #endif
6521
-  #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
6522
-    if (code_seen('X')) stepper.digipot_current(0, code_value_int());
6523
-  #endif
6524
-  #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
6525
-    if (code_seen('Z')) stepper.digipot_current(1, code_value_int());
6526
-  #endif
6527
-  #if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
6528
-    if (code_seen('E')) stepper.digipot_current(2, code_value_int());
6519
+  #elif HAS_MOTOR_CURRENT_PWM
6520
+    #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
6521
+      if (code_seen('X')) stepper.digipot_current(0, code_value_int());
6522
+    #endif
6523
+    #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
6524
+      if (code_seen('Z')) stepper.digipot_current(1, code_value_int());
6525
+    #endif
6526
+    #if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
6527
+      if (code_seen('E')) stepper.digipot_current(2, code_value_int());
6528
+    #endif
6529 6529
   #endif
6530 6530
   #if ENABLED(DIGIPOT_I2C)
6531 6531
     // this one uses actual amps in floating point
@@ -8718,8 +8718,8 @@ void prepare_move_to_destination() {
8718 8718
       bool new_led = (max_temp > 55.0) ? true : (max_temp < 54.0) ? false : red_led;
8719 8719
       if (new_led != red_led) {
8720 8720
         red_led = new_led;
8721
-        digitalWrite(STAT_LED_RED, new_led ? HIGH : LOW);
8722
-        digitalWrite(STAT_LED_BLUE, new_led ? LOW : HIGH);
8721
+        WRITE(STAT_LED_RED_PIN, new_led ? HIGH : LOW);
8722
+        WRITE(STAT_LED_BLUE_PIN, new_led ? LOW : HIGH);
8723 8723
       }
8724 8724
     }
8725 8725
   }
@@ -9193,20 +9193,17 @@ void setup() {
9193 9193
   #endif
9194 9194
 
9195 9195
   #if ENABLED(Z_PROBE_SLED) && PIN_EXISTS(SLED)
9196
-    pinMode(SLED_PIN, OUTPUT);
9197
-    digitalWrite(SLED_PIN, LOW); // turn it off
9196
+    OUT_WRITE(SLED_PIN, LOW); // turn it off
9198 9197
   #endif // Z_PROBE_SLED
9199 9198
 
9200 9199
   setup_homepin();
9201 9200
 
9202
-  #ifdef STAT_LED_RED
9203
-    pinMode(STAT_LED_RED, OUTPUT);
9204
-    digitalWrite(STAT_LED_RED, LOW); // turn it off
9201
+  #if PIN_EXISTS(STAT_LED_RED)
9202
+    OUT_WRITE(STAT_LED_RED_PIN, LOW); // turn it off
9205 9203
   #endif
9206 9204
 
9207
-  #ifdef STAT_LED_BLUE
9208
-    pinMode(STAT_LED_BLUE, OUTPUT);
9209
-    digitalWrite(STAT_LED_BLUE, LOW); // turn it off
9205
+  #if PIN_EXISTS(STAT_LED_BLUE)
9206
+    OUT_WRITE(STAT_LED_BLUE_PIN, LOW); // turn it off
9210 9207
   #endif
9211 9208
 
9212 9209
   lcd_init();

+ 17
- 4
Marlin/SanityCheck.h View File

@@ -61,10 +61,6 @@
61 61
   #error "Z_LATE_ENABLE can't be used with COREXZ."
62 62
 #elif defined(X_HOME_RETRACT_MM)
63 63
   #error "[XYZ]_HOME_RETRACT_MM settings have been renamed [XYZ]_HOME_BUMP_MM."
64
-#elif defined(BEEPER)
65
-  #error "BEEPER is now BEEPER_PIN. Please update your pins definitions."
66
-#elif defined(SDCARDDETECT)
67
-  #error "SDCARDDETECT is now SD_DETECT_PIN. Please update your pins definitions."
68 64
 #elif defined(SDCARDDETECTINVERTED)
69 65
   #error "SDCARDDETECTINVERTED is now SD_DETECT_INVERTED. Please update your configuration."
70 66
 #elif defined(BTENABLED)
@@ -143,6 +139,16 @@
143 139
   #error "SCARA is now MORGAN_SCARA. Please update your configuration."
144 140
 #elif defined(AUTO_BED_LEVELING_GRID_POINTS)
145 141
   #error "AUTO_BED_LEVELING_GRID_POINTS is now ABL_GRID_POINTS_X and ABL_GRID_POINTS_Y. Please update your configuration."
142
+#elif defined(BEEPER)
143
+  #error "BEEPER is now BEEPER_PIN. Please update your pins definitions."
144
+#elif defined(SDCARDDETECT)
145
+  #error "SDCARDDETECT is now SD_DETECT_PIN. Please update your pins definitions."
146
+#elif defined(STAT_LED_RED) || defined(STAT_LED_BLUE)
147
+  #error "STAT_LED_RED/STAT_LED_BLUE are now STAT_LED_RED_PIN/STAT_LED_BLUE_PIN. Please update your pins definitions."
148
+#elif defined(LCD_PIN_BL)
149
+  #error "LCD_PIN_BL is now LCD_BACKLIGHT_PIN. Please update your pins definitions."
150
+#elif defined(LCD_PIN_RESET)
151
+  #error "LCD_PIN_RESET is now LCD_RESET_PIN. Please update your pins definitions."
146 152
 #endif
147 153
 
148 154
 /**
@@ -723,6 +729,13 @@
723 729
 #endif
724 730
 
725 731
 /**
732
+ * Temperature status LEDs
733
+ */
734
+#if ENABLED(TEMP_STAT_LEDS) && !(PIN_EXISTS(STAT_LED_RED) && PIN_EXISTS(STAT_LED_BLUE))
735
+  #error "TEMP_STAT_LEDS requires STAT_LED_RED_PIN and STAT_LED_BLUE_PIN."
736
+#endif
737
+
738
+/**
726 739
  * Basic 2-nozzle duplication mode
727 740
  */
728 741
 #if ENABLED(DUAL_NOZZLE_DUPLICATION_MODE)

+ 5
- 5
Marlin/Sd2Card.cpp View File

@@ -302,16 +302,16 @@ bool Sd2Card::init(uint8_t sckRateID, uint8_t chipSelectPin) {
302 302
   // set pin modes
303 303
   pinMode(chipSelectPin_, OUTPUT);
304 304
   chipSelectHigh();
305
-  pinMode(SPI_MISO_PIN, INPUT);
306
-  pinMode(SPI_MOSI_PIN, OUTPUT);
307
-  pinMode(SPI_SCK_PIN, OUTPUT);
305
+  SET_INPUT(SPI_MISO_PIN);
306
+  SET_OUTPUT(SPI_MOSI_PIN);
307
+  SET_OUTPUT(SPI_SCK_PIN);
308 308
 
309 309
   #if DISABLED(SOFTWARE_SPI)
310 310
     // SS must be in output mode even it is not chip select
311
-    pinMode(SS_PIN, OUTPUT);
311
+    SET_OUTPUT(SS_PIN);
312 312
     // set SS high - may be chip select for another SPI device
313 313
     #if SET_SPI_SS_HIGH
314
-      digitalWrite(SS_PIN, HIGH);
314
+      WRITE(SS_PIN, HIGH);
315 315
     #endif  // SET_SPI_SS_HIGH
316 316
     // set SCK rate for initialization commands
317 317
     spiRate_ = SPI_SD_INIT_RATE;

+ 802
- 803
Marlin/fastio.h
File diff suppressed because it is too large
View File


+ 34
- 36
Marlin/pins_A4JP.h View File

@@ -104,53 +104,51 @@
104 104
 //
105 105
 // Heaters / Fans
106 106
 //
107
-#define HEATER_0_PIN   9
108
-#define HEATER_1_PIN   7
109
-#define HEATER_BED_PIN 3
107
+#define HEATER_0_PIN         9
108
+#define HEATER_1_PIN         7
109
+#define HEATER_BED_PIN       3
110 110
 
111
-#define FAN_PIN        8
112
-#define FAN0_PIN       6
113
-#define FAN1_PIN       2
111
+#define FAN_PIN              8
112
+#define FAN0_PIN             6
113
+#define FAN1_PIN             2
114 114
 
115
-#define TEMP_0_PIN     0
116
-#define TEMP_BED_PIN   7
115
+#define TEMP_0_PIN           0
116
+#define TEMP_BED_PIN         7
117 117
 
118
-#define SDSS          53
119
-#define LED_PIN       13
120
-#define PS_ON_PIN      4
118
+#define SDSS                53
119
+#define LED_PIN             13
120
+#define PS_ON_PIN            4
121 121
 
122 122
 //
123 123
 // LCD / Controller
124 124
 //
125
-#define LCD_PINS_RS     70 //ext2_5
126
-#define LCD_PINS_ENABLE 71 //ext2_7
127
-#define LCD_PINS_D4     72 ///////Ext2 9 ?
128
-#define LCD_PINS_D5     73 ///////Ext2 11 ?
129
-#define LCD_PINS_D6     74 //ext2_13
130
-#define LCD_PINS_D7     75 ///////Ext2 15 ?
131
-#define BEEPER_PIN      -1
132
-
133
-#define BTN_HOME        80 //ext_16
134
-#define BTN_CENTER      81 //ext_14
135
-#define BTN_ENC         BTN_CENTER
136
-#define BTN_RIGHT       82 //ext_12
137
-#define BTN_LEFT        83 //ext_10
138
-#define BTN_UP          84 //ext2_8
139
-#define BTN_DOWN        85 //ext2_6
140
-
141
-#define HOME_PIN        BTN_HOME
125
+#define LCD_PINS_RS         70 //ext2_5
126
+#define LCD_PINS_ENABLE     71 //ext2_7
127
+#define LCD_PINS_D4         72 ///////Ext2 9 ?
128
+#define LCD_PINS_D5         73 ///////Ext2 11 ?
129
+#define LCD_PINS_D6         74 //ext2_13
130
+#define LCD_PINS_D7         75 ///////Ext2 15 ?
131
+#define BEEPER_PIN          -1
132
+
133
+#define BTN_HOME            80 //ext_16
134
+#define BTN_CENTER          81 //ext_14
135
+#define BTN_ENC             BTN_CENTER
136
+#define BTN_RIGHT           82 //ext_12
137
+#define BTN_LEFT            83 //ext_10
138
+#define BTN_UP              84 //ext2_8
139
+#define BTN_DOWN            85 //ext2_6
140
+
141
+#define HOME_PIN            BTN_HOME
142 142
 
143 143
 #if ENABLED(VIKI2) || ENABLED(miniVIKI)
144
-  #define BEEPER_PIN 44
144
+  #define BEEPER_PIN        44
145 145
   // Pins for DOGM SPI LCD Support
146
-  #define DOGLCD_A0  70
147
-  #define DOGLCD_CS  71
146
+  #define DOGLCD_A0         70
147
+  #define DOGLCD_CS         71
148 148
   #define LCD_SCREEN_ROT_180
149 149
 
150
-  #define SD_DETECT_PIN -1 // Pin 72 if using easy adapter board
150
+  #define SD_DETECT_PIN     -1 // Pin 72 if using easy adapter board
151 151
 
152
-  #if ENABLED(TEMP_STAT_LEDS)
153
-    #define STAT_LED_RED      22
154
-    #define STAT_LED_BLUE     32
155
-  #endif
152
+  #define STAT_LED_RED_PIN  22
153
+  #define STAT_LED_BLUE_PIN 32
156 154
 #endif // VIKI2/miniVIKI

+ 7
- 9
Marlin/pins_AZTEEG_X3.h View File

@@ -41,16 +41,14 @@
41 41
   #define DOGLCD_CS         32
42 42
   #define BTN_ENC           12
43 43
 
44
-  #if ENABLED(TEMP_STAT_LEDS)
45
-    #undef STAT_LED_RED
46
-    #undef STAT_LED_BLUE
47
-    #define STAT_LED_RED    64
48
-    #define STAT_LED_BLUE   63
49
-  #endif
44
+  #undef STAT_LED_RED_PIN
45
+  #undef STAT_LED_BLUE_PIN
46
+  #define STAT_LED_RED_PIN  64
47
+  #define STAT_LED_BLUE_PIN 63
50 48
 
51
-#elif ENABLED(TEMP_STAT_LEDS)
49
+#else
52 50
 
53
-  #define STAT_LED_RED       6
54
-  #define STAT_LED_BLUE     11
51
+  #define STAT_LED_RED_PIN   6
52
+  #define STAT_LED_BLUE_PIN 11
55 53
 
56 54
 #endif

+ 2
- 2
Marlin/pins_AZTEEG_X3_PRO.h View File

@@ -117,6 +117,6 @@
117 117
   #undef SD_DETECT_PIN
118 118
   #define SD_DETECT_PIN    49 // For easy adapter board
119 119
 #else
120
-  #define STAT_LED_RED     32
121
-  #define STAT_LED_BLUE    35
120
+  #define STAT_LED_RED_PIN 32
121
+  #define STAT_LED_BLUE_PIN 35
122 122
 #endif

+ 2
- 2
Marlin/pins_CNCONTROLS_11.h View File

@@ -115,5 +115,5 @@
115 115
 //
116 116
 // Misc. Functions
117 117
 //
118
-#define STAT_LED_BLUE      -1
119
-#define STAT_LED_RED       31
118
+#define STAT_LED_BLUE_PIN  -1
119
+#define STAT_LED_RED_PIN   31

+ 2
- 2
Marlin/pins_CNCONTROLS_12.h View File

@@ -111,8 +111,8 @@
111 111
 //#define UI1              43
112 112
 //#define UI2              37
113 113
 
114
-#define STAT_LED_BLUE      -1
115
-#define STAT_LED_RED       10 // TOOL_0_PWM_PIN
114
+#define STAT_LED_BLUE_PIN  -1
115
+#define STAT_LED_RED_PIN   10 // TOOL_0_PWM_PIN
116 116
 
117 117
 //
118 118
 // SD Card

+ 1
- 1
Marlin/pins_MEGACONTROLLER.h View File

@@ -134,7 +134,7 @@
134 134
   // Pins for DOGM SPI LCD Support
135 135
   #define DOGLCD_A0        47
136 136
   #define DOGLCD_CS        45
137
-  #define LCD_PIN_BL       44  // backlight LED on PA3
137
+  #define LCD_BACKLIGHT_PIN 44  // backlight LED on PA3
138 138
 
139 139
   #define KILL_PIN         12
140 140
   // GLCD features

+ 2
- 2
Marlin/pins_MKS_13.h View File

@@ -120,9 +120,9 @@
120 120
   #define BEEPER_PIN      25
121 121
 
122 122
   // yellow               RED-LED
123
-  #define STAT_LED_RED    16
123
+  #define STAT_LED_RED_PIN 16
124 124
 
125 125
   // white                BLUE-LED
126
-  #define STAT_LED_BLUE   17
126
+  #define STAT_LED_BLUE_PIN 17
127 127
 
128 128
 #endif

+ 4
- 4
Marlin/pins_PRINTRBOARD.h View File

@@ -131,8 +131,8 @@
131 131
 
132 132
   #define SDSS 45
133 133
   #define SD_DETECT_PIN -1 // FastIO (Manual says 72 I'm not certain cause I can't test)
134
-  #if ENABLED(TEMP_STAT_LEDS)
135
-    #define STAT_LED_RED      12 //Non-FastIO
136
-    #define STAT_LED_BLUE     10 //Non-FastIO
137
-  #endif
134
+
135
+  #define STAT_LED_RED_PIN  12 //Non-FastIO
136
+  #define STAT_LED_BLUE_PIN 10 //Non-FastIO
137
+
138 138
 #endif

+ 4
- 7
Marlin/pins_PRINTRBOARD_REVF.h View File

@@ -117,21 +117,18 @@
117 117
 
118 118
 #if ENABLED(VIKI2) || ENABLED(miniVIKI)
119 119
   #define BEEPER_PIN 32 //FastIO
120
-  // Pins for DOGM SPI LCD Support
121 120
   #define DOGLCD_A0  42 //Non-FastIO
122 121
   #define DOGLCD_CS  43 //Non-FastIO
123 122
   #define LCD_SCREEN_ROT_180
124 123
 
125
-  //The encoder and click button (FastIO Pins)
124
+  // (FastIO Pins)
126 125
   #define BTN_EN1 26
127 126
   #define BTN_EN2 27
128 127
   #define BTN_ENC 47
129 128
 
130 129
   #define SDSS 45
131
-  #define SD_DETECT_PIN -1 // FastIO (Manual says 72 I'm not certain cause I can't test)
130
+  #define SD_DETECT_PIN -1 // FastIO (Manual says 72)
132 131
 
133
-  #if ENABLED(TEMP_STAT_LEDS)
134
-    #define STAT_LED_RED      12 //Non-FastIO
135
-    #define STAT_LED_BLUE     10 //Non-FastIO
136
-  #endif
132
+  #define STAT_LED_RED_PIN 12 //Non-FastIO
133
+  #define STAT_LED_BLUE_PIN 10 //Non-FastIO
137 134
 #endif

+ 2
- 4
Marlin/pins_RAMBO.h View File

@@ -169,10 +169,8 @@
169 169
 
170 170
       #define SD_DETECT_PIN -1 // Pin 72 if using easy adapter board
171 171
 
172
-      #if ENABLED(TEMP_STAT_LEDS)
173
-        #define STAT_LED_RED      22
174
-        #define STAT_LED_BLUE     32
175
-      #endif
172
+      #define STAT_LED_RED_PIN 22
173
+      #define STAT_LED_BLUE_PIN 32
176 174
 
177 175
     #else
178 176
 

+ 6
- 7
Marlin/pins_RAMPS.h View File

@@ -240,7 +240,7 @@
240 240
       #define KILL_PIN 41
241 241
 
242 242
       #if ENABLED(BQ_LCD_SMART_CONTROLLER)
243
-        #define LCD_PIN_BL 39
243
+        #define LCD_BACKLIGHT_PIN 39
244 244
       #endif
245 245
 
246 246
     #elif ENABLED(REPRAPWORLD_GRAPHICAL_LCD)
@@ -280,10 +280,9 @@
280 280
 
281 281
       #define KILL_PIN         31
282 282
 
283
-      #if ENABLED(TEMP_STAT_LEDS)
284
-        #define STAT_LED_RED   32
285
-        #define STAT_LED_BLUE  35
286
-      #endif
283
+      #define STAT_LED_RED_PIN 32
284
+      #define STAT_LED_BLUE_PIN 35
285
+
287 286
     #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
288 287
       #define BTN_EN1 35  // reverse if the encoder turns the wrong way.
289 288
       #define BTN_EN2 37
@@ -294,13 +293,13 @@
294 293
       #define BEEPER_PIN 23
295 294
       #define DOGLCD_CS 29
296 295
       #define DOGLCD_A0 27
297
-      #define LCD_PIN_BL 33
296
+      #define LCD_BACKLIGHT_PIN 33
298 297
     #elif ENABLED(MINIPANEL)
299 298
       #define BEEPER_PIN 42
300 299
       // Pins for DOGM SPI LCD Support
301 300
       #define DOGLCD_A0  44
302 301
       #define DOGLCD_CS  66
303
-      #define LCD_PIN_BL 65 // backlight LED on A11/D65
302
+      #define LCD_BACKLIGHT_PIN 65 // backlight LED on A11/D65
304 303
       #define SDSS   53
305 304
 
306 305
       #define KILL_PIN 64

+ 2
- 2
Marlin/pins_SANGUINOLOLU_11.h View File

@@ -56,7 +56,7 @@
56 56
 #if IS_MELZI
57 57
   #define LED_PIN          27 // On some broken versions of the Sanguino libraries the pin definitions are wrong, so LED_PIN needs to be 28. But you should upgrade your Sanguino libraries! See #368.
58 58
 #elif MB(STB_11)
59
-  #define LCD_PIN_BL       17 // LCD backlight LED
59
+  #define LCD_BACKLIGHT_PIN 17 // LCD backlight LED
60 60
 #endif
61 61
 
62 62
 #if ENABLED(Z_PROBE_SLED)
@@ -173,7 +173,7 @@
173 173
   // Pins for DOGM SPI LCD Support
174 174
   #define DOGLCD_A0             30
175 175
   #define DOGLCD_CS             17
176
-  #define LCD_PIN_BL            28 // backlight LED on PA3
176
+  #define LCD_BACKLIGHT_PIN     28 // backlight LED on PA3
177 177
   // GLCD features
178 178
   #define LCD_CONTRAST           1
179 179
   // Uncomment screen orientation

+ 152
- 126
Marlin/stepper.cpp View File

@@ -733,19 +733,27 @@ void Stepper::isr() {
733 733
 
734 734
 void Stepper::init() {
735 735
 
736
-  digipot_init(); //Initialize Digipot Motor Current
737
-  microstep_init(); //Initialize Microstepping Pins
736
+  // Init Digipot Motor Current
737
+  #if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM
738
+    digipot_init();
739
+  #endif
738 740
 
739
-  // initialise TMC Steppers
741
+  // Init Microstepping Pins
742
+  #if HAS_MICROSTEPS
743
+    microstep_init();
744
+  #endif
745
+
746
+  // Init TMC Steppers
740 747
   #if ENABLED(HAVE_TMCDRIVER)
741 748
     tmc_init();
742 749
   #endif
743
-    // initialise L6470 Steppers
750
+
751
+  // Init L6470 Steppers
744 752
   #if ENABLED(HAVE_L6470DRIVER)
745 753
     L6470_init();
746 754
   #endif
747 755
 
748
-  // Initialize Dir Pins
756
+  // Init Dir Pins
749 757
   #if HAS_X_DIR
750 758
     X_DIR_INIT;
751 759
   #endif
@@ -777,8 +785,7 @@ void Stepper::init() {
777 785
     E3_DIR_INIT;
778 786
   #endif
779 787
 
780
-  //Initialize Enable Pins - steppers default to disabled.
781
-
788
+  // Init Enable Pins - steppers default to disabled.
782 789
   #if HAS_X_ENABLE
783 790
     X_ENABLE_INIT;
784 791
     if (!X_ENABLE_ON) X_ENABLE_WRITE(HIGH);
@@ -787,7 +794,6 @@ void Stepper::init() {
787 794
       if (!X_ENABLE_ON) X2_ENABLE_WRITE(HIGH);
788 795
     #endif
789 796
   #endif
790
-
791 797
   #if HAS_Y_ENABLE
792 798
     Y_ENABLE_INIT;
793 799
     if (!Y_ENABLE_ON) Y_ENABLE_WRITE(HIGH);
@@ -796,7 +802,6 @@ void Stepper::init() {
796 802
       if (!Y_ENABLE_ON) Y2_ENABLE_WRITE(HIGH);
797 803
     #endif
798 804
   #endif
799
-
800 805
   #if HAS_Z_ENABLE
801 806
     Z_ENABLE_INIT;
802 807
     if (!Z_ENABLE_ON) Z_ENABLE_WRITE(HIGH);
@@ -805,7 +810,6 @@ void Stepper::init() {
805 810
       if (!Z_ENABLE_ON) Z2_ENABLE_WRITE(HIGH);
806 811
     #endif
807 812
   #endif
808
-
809 813
   #if HAS_E0_ENABLE
810 814
     E0_ENABLE_INIT;
811 815
     if (!E_ENABLE_ON) E0_ENABLE_WRITE(HIGH);
@@ -823,9 +827,7 @@ void Stepper::init() {
823 827
     if (!E_ENABLE_ON) E3_ENABLE_WRITE(HIGH);
824 828
   #endif
825 829
 
826
-  //
827
-  // Init endstops and pullups here
828
-  //
830
+  // Init endstops and pullups
829 831
   endstops.init();
830 832
 
831 833
   #define _STEP_INIT(AXIS) AXIS ##_STEP_INIT
@@ -839,7 +841,7 @@ void Stepper::init() {
839 841
 
840 842
   #define E_AXIS_INIT(NUM) AXIS_INIT(e## NUM, E## NUM, E)
841 843
 
842
-  // Initialize Step Pins
844
+  // Init Step Pins
843 845
   #if HAS_X_STEP
844 846
     #if ENABLED(X_DUAL_STEPPER_DRIVERS) || ENABLED(DUAL_X_CARRIAGE)
845 847
       X2_STEP_INIT;
@@ -1155,143 +1157,167 @@ void Stepper::report_positions() {
1155 1157
 
1156 1158
   // From Arduino DigitalPotControl example
1157 1159
   void Stepper::digitalPotWrite(int address, int value) {
1158
-    digitalWrite(DIGIPOTSS_PIN, LOW); // take the SS pin low to select the chip
1160
+    WRITE(DIGIPOTSS_PIN, LOW); // take the SS pin low to select the chip
1159 1161
     SPI.transfer(address); //  send in the address and value via SPI:
1160 1162
     SPI.transfer(value);
1161
-    digitalWrite(DIGIPOTSS_PIN, HIGH); // take the SS pin high to de-select the chip:
1163
+    WRITE(DIGIPOTSS_PIN, HIGH); // take the SS pin high to de-select the chip:
1162 1164
     //delay(10);
1163 1165
   }
1164 1166
 
1165 1167
 #endif //HAS_DIGIPOTSS
1166 1168
 
1167
-void Stepper::digipot_init() {
1168
-  #if HAS_DIGIPOTSS
1169
-    const uint8_t digipot_motor_current[] = DIGIPOT_MOTOR_CURRENT;
1169
+#if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM
1170 1170
 
1171
-    SPI.begin();
1172
-    pinMode(DIGIPOTSS_PIN, OUTPUT);
1173
-    for (uint8_t i = 0; i < COUNT(digipot_motor_current); i++) {
1174
-      //digitalPotWrite(digipot_ch[i], digipot_motor_current[i]);
1175
-      digipot_current(i, digipot_motor_current[i]);
1176
-    }
1177
-  #endif
1178
-  #if HAS_MOTOR_CURRENT_PWM
1179
-    #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
1180
-      pinMode(MOTOR_CURRENT_PWM_XY_PIN, OUTPUT);
1181
-      digipot_current(0, motor_current_setting[0]);
1182
-    #endif
1183
-    #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
1184
-      pinMode(MOTOR_CURRENT_PWM_Z_PIN, OUTPUT);
1185
-      digipot_current(1, motor_current_setting[1]);
1186
-    #endif
1187
-    #if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
1188
-      pinMode(MOTOR_CURRENT_PWM_E_PIN, OUTPUT);
1189
-      digipot_current(2, motor_current_setting[2]);
1190
-    #endif
1191
-    //Set timer5 to 31khz so the PWM of the motor power is as constant as possible. (removes a buzzing noise)
1192
-    TCCR5B = (TCCR5B & ~(_BV(CS50) | _BV(CS51) | _BV(CS52))) | _BV(CS50);
1193
-  #endif
1194
-}
1195
-
1196
-void Stepper::digipot_current(uint8_t driver, int current) {
1197
-  #if HAS_DIGIPOTSS
1198
-    const uint8_t digipot_ch[] = DIGIPOT_CHANNELS;
1199
-    digitalPotWrite(digipot_ch[driver], current);
1200
-  #elif HAS_MOTOR_CURRENT_PWM
1201
-    #define _WRITE_CURRENT_PWM(P) analogWrite(P, 255L * current / (MOTOR_CURRENT_PWM_RANGE))
1202
-    switch (driver) {
1171
+  void Stepper::digipot_init() {
1172
+    #if HAS_DIGIPOTSS
1173
+      static const uint8_t digipot_motor_current[] = DIGIPOT_MOTOR_CURRENT;
1174
+      SPI.begin();
1175
+      SET_OUTPUT(DIGIPOTSS_PIN);
1176
+      for (uint8_t i = 0; i < COUNT(digipot_motor_current); i++) {
1177
+        //digitalPotWrite(digipot_ch[i], digipot_motor_current[i]);
1178
+        digipot_current(i, digipot_motor_current[i]);
1179
+      }
1180
+    #elif HAS_MOTOR_CURRENT_PWM
1203 1181
       #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
1204
-        case 0: _WRITE_CURRENT_PWM(MOTOR_CURRENT_PWM_XY_PIN); break;
1182
+        SET_OUTPUT(MOTOR_CURRENT_PWM_XY_PIN);
1183
+        digipot_current(0, motor_current_setting[0]);
1205 1184
       #endif
1206 1185
       #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
1207
-        case 1: _WRITE_CURRENT_PWM(MOTOR_CURRENT_PWM_Z_PIN); break;
1186
+        SET_OUTPUT(MOTOR_CURRENT_PWM_Z_PIN);
1187
+        digipot_current(1, motor_current_setting[1]);
1208 1188
       #endif
1209 1189
       #if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
1210
-        case 2: _WRITE_CURRENT_PWM(MOTOR_CURRENT_PWM_E_PIN); break;
1190
+        SET_OUTPUT(MOTOR_CURRENT_PWM_E_PIN);
1191
+        digipot_current(2, motor_current_setting[2]);
1211 1192
       #endif
1212
-    }
1213
-  #else
1214
-    UNUSED(driver);
1215
-    UNUSED(current);
1216
-  #endif
1217
-}
1193
+      //Set timer5 to 31khz so the PWM of the motor power is as constant as possible. (removes a buzzing noise)
1194
+      TCCR5B = (TCCR5B & ~(_BV(CS50) | _BV(CS51) | _BV(CS52))) | _BV(CS50);
1195
+    #endif
1196
+  }
1218 1197
 
1219
-void Stepper::microstep_init() {
1220
-  #if HAS_MICROSTEPS_E1
1221
-    pinMode(E1_MS1_PIN, OUTPUT);
1222
-    pinMode(E1_MS2_PIN, OUTPUT);
1223
-  #endif
1198
+  void Stepper::digipot_current(uint8_t driver, int current) {
1199
+    #if HAS_DIGIPOTSS
1200
+      const uint8_t digipot_ch[] = DIGIPOT_CHANNELS;
1201
+      digitalPotWrite(digipot_ch[driver], current);
1202
+    #elif HAS_MOTOR_CURRENT_PWM
1203
+      #define _WRITE_CURRENT_PWM(P) analogWrite(P, 255L * current / (MOTOR_CURRENT_PWM_RANGE))
1204
+      switch (driver) {
1205
+        #if PIN_EXISTS(MOTOR_CURRENT_PWM_XY)
1206
+          case 0: _WRITE_CURRENT_PWM(MOTOR_CURRENT_PWM_XY_PIN); break;
1207
+        #endif
1208
+        #if PIN_EXISTS(MOTOR_CURRENT_PWM_Z)
1209
+          case 1: _WRITE_CURRENT_PWM(MOTOR_CURRENT_PWM_Z_PIN); break;
1210
+        #endif
1211
+        #if PIN_EXISTS(MOTOR_CURRENT_PWM_E)
1212
+          case 2: _WRITE_CURRENT_PWM(MOTOR_CURRENT_PWM_E_PIN); break;
1213
+        #endif
1214
+      }
1215
+    #endif
1216
+  }
1224 1217
 
1225
-  #if HAS_MICROSTEPS
1226
-    pinMode(X_MS1_PIN, OUTPUT);
1227
-    pinMode(X_MS2_PIN, OUTPUT);
1228
-    pinMode(Y_MS1_PIN, OUTPUT);
1229
-    pinMode(Y_MS2_PIN, OUTPUT);
1230
-    pinMode(Z_MS1_PIN, OUTPUT);
1231
-    pinMode(Z_MS2_PIN, OUTPUT);
1232
-    pinMode(E0_MS1_PIN, OUTPUT);
1233
-    pinMode(E0_MS2_PIN, OUTPUT);
1234
-    const uint8_t microstep_modes[] = MICROSTEP_MODES;
1235
-    for (uint16_t i = 0; i < COUNT(microstep_modes); i++)
1236
-      microstep_mode(i, microstep_modes[i]);
1237
-  #endif
1238
-}
1218
+#endif
1239 1219
 
1240
-/**
1241
- * Software-controlled Microstepping
1242
- */
1220
+#if HAS_MICROSTEPS
1221
+
1222
+  /**
1223
+   * Software-controlled Microstepping
1224
+   */
1243 1225
 
1244
-void Stepper::microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2) {
1245
-  if (ms1 >= 0) switch (driver) {
1246
-    case 0: digitalWrite(X_MS1_PIN, ms1); break;
1247
-    case 1: digitalWrite(Y_MS1_PIN, ms1); break;
1248
-    case 2: digitalWrite(Z_MS1_PIN, ms1); break;
1249
-    case 3: digitalWrite(E0_MS1_PIN, ms1); break;
1226
+  void Stepper::microstep_init() {
1227
+    SET_OUTPUT(X_MS1_PIN);
1228
+    SET_OUTPUT(X_MS2_PIN);
1229
+    #if HAS_MICROSTEPS_Y
1230
+      SET_OUTPUT(Y_MS1_PIN);
1231
+      SET_OUTPUT(Y_MS2_PIN);
1232
+    #endif
1233
+    #if HAS_MICROSTEPS_Z
1234
+      SET_OUTPUT(Z_MS1_PIN);
1235
+      SET_OUTPUT(Z_MS2_PIN);
1236
+    #endif
1237
+    #if HAS_MICROSTEPS_E0
1238
+      SET_OUTPUT(E0_MS1_PIN);
1239
+      SET_OUTPUT(E0_MS2_PIN);
1240
+    #endif
1250 1241
     #if HAS_MICROSTEPS_E1
1251
-      case 4: digitalWrite(E1_MS1_PIN, ms1); break;
1242
+      SET_OUTPUT(E1_MS1_PIN);
1243
+      SET_OUTPUT(E1_MS2_PIN);
1252 1244
     #endif
1245
+    static const uint8_t microstep_modes[] = MICROSTEP_MODES;
1246
+    for (uint16_t i = 0; i < COUNT(microstep_modes); i++)
1247
+      microstep_mode(i, microstep_modes[i]);
1253 1248
   }
1254
-  if (ms2 >= 0) switch (driver) {
1255
-    case 0: digitalWrite(X_MS2_PIN, ms2); break;
1256
-    case 1: digitalWrite(Y_MS2_PIN, ms2); break;
1257
-    case 2: digitalWrite(Z_MS2_PIN, ms2); break;
1258
-    case 3: digitalWrite(E0_MS2_PIN, ms2); break;
1259
-    #if PIN_EXISTS(E1_MS2)
1260
-      case 4: digitalWrite(E1_MS2_PIN, ms2); break;
1261
-    #endif
1249
+
1250
+  void Stepper::microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2) {
1251
+    if (ms1 >= 0) switch (driver) {
1252
+      case 0: digitalWrite(X_MS1_PIN, ms1); break;
1253
+      #if HAS_MICROSTEPS_Y
1254
+        case 1: digitalWrite(Y_MS1_PIN, ms1); break;
1255
+      #endif
1256
+      #if HAS_MICROSTEPS_Z
1257
+        case 2: digitalWrite(Z_MS1_PIN, ms1); break;
1258
+      #endif
1259
+      #if HAS_MICROSTEPS_E0
1260
+        case 3: digitalWrite(E0_MS1_PIN, ms1); break;
1261
+      #endif
1262
+      #if HAS_MICROSTEPS_E1
1263
+        case 4: digitalWrite(E1_MS1_PIN, ms1); break;
1264
+      #endif
1265
+    }
1266
+    if (ms2 >= 0) switch (driver) {
1267
+      case 0: digitalWrite(X_MS2_PIN, ms2); break;
1268
+      #if HAS_MICROSTEPS_Y
1269
+        case 1: digitalWrite(Y_MS2_PIN, ms2); break;
1270
+      #endif
1271
+      #if HAS_MICROSTEPS_Z
1272
+        case 2: digitalWrite(Z_MS2_PIN, ms2); break;
1273
+      #endif
1274
+      #if HAS_MICROSTEPS_E0
1275
+        case 3: digitalWrite(E0_MS2_PIN, ms2); break;
1276
+      #endif
1277
+      #if HAS_MICROSTEPS_E1
1278
+        case 4: digitalWrite(E1_MS2_PIN, ms2); break;
1279
+      #endif
1280
+    }
1262 1281
   }
1263
-}
1264 1282
 
1265
-void Stepper::microstep_mode(uint8_t driver, uint8_t stepping_mode) {
1266
-  switch (stepping_mode) {
1267
-    case 1: microstep_ms(driver, MICROSTEP1); break;
1268
-    case 2: microstep_ms(driver, MICROSTEP2); break;
1269
-    case 4: microstep_ms(driver, MICROSTEP4); break;
1270
-    case 8: microstep_ms(driver, MICROSTEP8); break;
1271
-    case 16: microstep_ms(driver, MICROSTEP16); break;
1283
+  void Stepper::microstep_mode(uint8_t driver, uint8_t stepping_mode) {
1284
+    switch (stepping_mode) {
1285
+      case 1: microstep_ms(driver, MICROSTEP1); break;
1286
+      case 2: microstep_ms(driver, MICROSTEP2); break;
1287
+      case 4: microstep_ms(driver, MICROSTEP4); break;
1288
+      case 8: microstep_ms(driver, MICROSTEP8); break;
1289
+      case 16: microstep_ms(driver, MICROSTEP16); break;
1290
+    }
1272 1291
   }
1273
-}
1274 1292
 
1275
-void Stepper::microstep_readings() {
1276
-  SERIAL_PROTOCOLLNPGM("MS1,MS2 Pins");
1277
-  SERIAL_PROTOCOLPGM("X: ");
1278
-  SERIAL_PROTOCOL(digitalRead(X_MS1_PIN));
1279
-  SERIAL_PROTOCOLLN(digitalRead(X_MS2_PIN));
1280
-  SERIAL_PROTOCOLPGM("Y: ");
1281
-  SERIAL_PROTOCOL(digitalRead(Y_MS1_PIN));
1282
-  SERIAL_PROTOCOLLN(digitalRead(Y_MS2_PIN));
1283
-  SERIAL_PROTOCOLPGM("Z: ");
1284
-  SERIAL_PROTOCOL(digitalRead(Z_MS1_PIN));
1285
-  SERIAL_PROTOCOLLN(digitalRead(Z_MS2_PIN));
1286
-  SERIAL_PROTOCOLPGM("E0: ");
1287
-  SERIAL_PROTOCOL(digitalRead(E0_MS1_PIN));
1288
-  SERIAL_PROTOCOLLN(digitalRead(E0_MS2_PIN));
1289
-  #if HAS_MICROSTEPS_E1
1290
-    SERIAL_PROTOCOLPGM("E1: ");
1291
-    SERIAL_PROTOCOL(digitalRead(E1_MS1_PIN));
1292
-    SERIAL_PROTOCOLLN(digitalRead(E1_MS2_PIN));
1293
-  #endif
1294
-}
1293
+  void Stepper::microstep_readings() {
1294
+    SERIAL_PROTOCOLLNPGM("MS1,MS2 Pins");
1295
+    SERIAL_PROTOCOLPGM("X: ");
1296
+    SERIAL_PROTOCOL(READ(X_MS1_PIN));
1297
+    SERIAL_PROTOCOLLN(READ(X_MS2_PIN));
1298
+    #if HAS_MICROSTEPS_Y
1299
+      SERIAL_PROTOCOLPGM("Y: ");
1300
+      SERIAL_PROTOCOL(READ(Y_MS1_PIN));
1301
+      SERIAL_PROTOCOLLN(READ(Y_MS2_PIN));
1302
+    #endif
1303
+    #if HAS_MICROSTEPS_Z
1304
+      SERIAL_PROTOCOLPGM("Z: ");
1305
+      SERIAL_PROTOCOL(READ(Z_MS1_PIN));
1306
+      SERIAL_PROTOCOLLN(READ(Z_MS2_PIN));
1307
+    #endif
1308
+    #if HAS_MICROSTEPS_E0
1309
+      SERIAL_PROTOCOLPGM("E0: ");
1310
+      SERIAL_PROTOCOL(READ(E0_MS1_PIN));
1311
+      SERIAL_PROTOCOLLN(READ(E0_MS2_PIN));
1312
+    #endif
1313
+    #if HAS_MICROSTEPS_E1
1314
+      SERIAL_PROTOCOLPGM("E1: ");
1315
+      SERIAL_PROTOCOL(READ(E1_MS1_PIN));
1316
+      SERIAL_PROTOCOLLN(READ(E1_MS2_PIN));
1317
+    #endif
1318
+  }
1319
+
1320
+#endif // HAS_MICROSTEPS
1295 1321
 
1296 1322
 #if ENABLED(LIN_ADVANCE)
1297 1323
 

+ 12
- 6
Marlin/stepper.h View File

@@ -239,13 +239,16 @@ class Stepper {
239 239
     //
240 240
     static FORCE_INLINE bool motor_direction(AxisEnum axis) { return TEST(last_direction_bits, axis); }
241 241
 
242
-    #if HAS_DIGIPOTSS
242
+    #if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM
243 243
       static void digitalPotWrite(int address, int value);
244
+      static void digipot_current(uint8_t driver, int current);
245
+    #endif
246
+
247
+    #if HAS_MICROSTEPS
248
+      static void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2);
249
+      static void microstep_mode(uint8_t driver, uint8_t stepping);
250
+      static void microstep_readings();
244 251
     #endif
245
-    static void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2);
246
-    static void digipot_current(uint8_t driver, int current);
247
-    static void microstep_mode(uint8_t driver, uint8_t stepping);
248
-    static void microstep_readings();
249 252
 
250 253
     #if ENABLED(Z_DUAL_ENDSTOPS)
251 254
       static FORCE_INLINE void set_homing_flag(bool state) { performing_homing = state; }
@@ -380,7 +383,10 @@ class Stepper {
380 383
     }
381 384
 
382 385
     static void digipot_init();
383
-    static void microstep_init();
386
+
387
+    #if HAS_MICROSTEPS
388
+      static void microstep_init();
389
+    #endif
384 390
 
385 391
 };
386 392
 

+ 1
- 2
Marlin/stepper_dac.cpp View File

@@ -52,8 +52,7 @@
52 52
 
53 53
   int dac_init() {
54 54
     #if PIN_EXISTS(DAC_DISABLE)
55
-      pinMode(DAC_DISABLE_PIN, OUTPUT);
56
-      digitalWrite(DAC_DISABLE_PIN, LOW);  // set pin low to enable DAC
55
+      OUT_WRITE(DAC_DISABLE_PIN, LOW);  // set pin low to enable DAC
57 56
     #endif
58 57
 
59 58
     mcp4728_init();

+ 4
- 6
Marlin/ultralcd_impl_DOGM.h View File

@@ -220,14 +220,12 @@ void lcd_printPGM(const char* str) {
220 220
 // Initialize or re-initializw the LCD
221 221
 static void lcd_implementation_init() {
222 222
 
223
-  #if defined(LCD_PIN_BL) && LCD_PIN_BL > -1 // Enable LCD backlight
224
-    pinMode(LCD_PIN_BL, OUTPUT);
225
-    digitalWrite(LCD_PIN_BL, HIGH);
223
+  #if PIN_EXISTS(LCD_BACKLIGHT) // Enable LCD backlight
224
+    OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH);
226 225
   #endif
227 226
 
228
-  #if defined(LCD_PIN_RESET) && LCD_PIN_RESET > -1
229
-    pinMode(LCD_PIN_RESET, OUTPUT);
230
-    digitalWrite(LCD_PIN_RESET, HIGH);
227
+  #if PIN_EXISTS(LCD_RESET)
228
+    OUT_WRITE(LCD_RESET_PIN, HIGH);
231 229
   #endif
232 230
 
233 231
   #if DISABLED(MINIPANEL) // setContrast not working for Mini Panel

Loading…
Cancel
Save