Browse Source

Miscellaneous cleanup

Scott Lahteine 6 years ago
parent
commit
4e19c59ab3
4 changed files with 50 additions and 86 deletions
  1. 19
    40
      Marlin/Marlin_main.cpp
  2. 28
    42
      Marlin/Max7219_Debug_LEDs.cpp
  3. 2
    2
      Marlin/configuration_store.cpp
  4. 1
    2
      Marlin/planner.cpp

+ 19
- 40
Marlin/Marlin_main.cpp View File

@@ -8942,8 +8942,8 @@ inline void gcode_M205() {
8942 8942
         set_home_offset((AxisEnum)i, parser.value_linear_units());
8943 8943
 
8944 8944
     #if ENABLED(MORGAN_SCARA)
8945
-      if (parser.seen('T')) set_home_offset(A_AXIS, parser.value_linear_units()); // Theta
8946
-      if (parser.seen('P')) set_home_offset(B_AXIS, parser.value_linear_units()); // Psi
8945
+      if (parser.seen('T')) set_home_offset(A_AXIS, parser.value_float()); // Theta
8946
+      if (parser.seen('P')) set_home_offset(B_AXIS, parser.value_float()); // Psi
8947 8947
     #endif
8948 8948
 
8949 8949
     report_current_position();
@@ -9319,14 +9319,14 @@ inline void gcode_M226() {
9319 9319
     #if ENABLED(BABYSTEP_XY)
9320 9320
       for (uint8_t a = X_AXIS; a <= Z_AXIS; a++)
9321 9321
         if (parser.seenval(axis_codes[a]) || (a == Z_AXIS && parser.seenval('S'))) {
9322
-          const float offs = constrain(parser.value_axis_units(a), -2, 2);
9322
+          const float offs = constrain(parser.value_axis_units((AxisEnum)a), -2, 2);
9323 9323
           #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
9324 9324
             if (a == Z_AXIS) {
9325 9325
               zprobe_zoffset += offs;
9326 9326
               refresh_zprobe_zoffset(true); // 'true' to not babystep
9327 9327
             }
9328 9328
           #endif
9329
-          thermalManager.babystep_axis(a, offs * planner.axis_steps_per_mm[a]);
9329
+          thermalManager.babystep_axis((AxisEnum)a, offs * planner.axis_steps_per_mm[a]);
9330 9330
         }
9331 9331
     #else
9332 9332
       if (parser.seenval('Z') || parser.seenval('S')) {
@@ -13318,48 +13318,27 @@ void prepare_move_to_destination() {
13318 13318
         #if !AVR_AT90USB1286_FAMILY
13319 13319
           case TIMER0A:
13320 13320
         #endif
13321
-        case TIMER0B:
13322
-          //_SET_CS(0, val);
13323
-          break;
13321
+        case TIMER0B:                           //_SET_CS(0, val);
13322
+                                                  break;
13324 13323
       #endif
13325
-      #ifdef TCCR1A
13326
-        case TIMER1A:
13327
-        case TIMER1B:
13328
-          //_SET_CS(1, val);
13329
-          break;
13324
+      #ifdef TCCR1A 
13325
+        case TIMER1A: case TIMER1B:             //_SET_CS(1, val);
13326
+                                                  break;
13330 13327
       #endif
13331
-      #ifdef TCCR2
13332
-        case TIMER2:
13333
-        case TIMER2:
13334
-          _SET_CS(2, val);
13335
-          break;
13328
+      #ifdef TCCR2 
13329
+        case TIMER2: case TIMER2:                 _SET_CS(2, val); break;
13336 13330
       #endif
13337
-      #ifdef TCCR2A
13338
-        case TIMER2A:
13339
-        case TIMER2B:
13340
-          _SET_CS(2, val);
13341
-          break;
13331
+      #ifdef TCCR2A 
13332
+        case TIMER2A: case TIMER2B:               _SET_CS(2, val); break;
13342 13333
       #endif
13343
-      #ifdef TCCR3A
13344
-        case TIMER3A:
13345
-        case TIMER3B:
13346
-        case TIMER3C:
13347
-          _SET_CS(3, val);
13348
-          break;
13334
+      #ifdef TCCR3A 
13335
+        case TIMER3A: case TIMER3B: case TIMER3C: _SET_CS(3, val); break;
13349 13336
       #endif
13350
-      #ifdef TCCR4A
13351
-        case TIMER4A:
13352
-        case TIMER4B:
13353
-        case TIMER4C:
13354
-          _SET_CS(4, val);
13355
-          break;
13337
+      #ifdef TCCR4A 
13338
+        case TIMER4A: case TIMER4B: case TIMER4C: _SET_CS(4, val); break;
13356 13339
       #endif
13357
-      #ifdef TCCR5A
13358
-        case TIMER5A:
13359
-        case TIMER5B:
13360
-        case TIMER5C:
13361
-          _SET_CS(5, val);
13362
-          break;
13340
+      #ifdef TCCR5A 
13341
+        case TIMER5A: case TIMER5B: case TIMER5C: _SET_CS(5, val); break;
13363 13342
       #endif
13364 13343
     }
13365 13344
   }

+ 28
- 42
Marlin/Max7219_Debug_LEDs.cpp View File

@@ -63,54 +63,41 @@
63 63
 
64 64
 static uint8_t LEDs[8] = { 0 };
65 65
 
66
+#ifdef CPU_32_BIT
67
+  #define MS_DELAY() delayMicroseconds(5)  // 32-bit processors need a delay to stabilize the signal
68
+#else
69
+  #define MS_DELAY() NOOP
70
+#endif
71
+
66 72
 void Max7219_PutByte(uint8_t data) {
67 73
   CRITICAL_SECTION_START
68 74
   for (uint8_t i = 8; i--;) {
69
-    #ifdef CPU_32_BIT                    // The 32-bit processors are so fast, a small delay in the code is needed
70
-      delayMicroseconds(5);              // to let the signal wires stabilize.
71
-      WRITE(MAX7219_CLK_PIN, LOW);       // tick
72
-      delayMicroseconds(5);
73
-      WRITE(MAX7219_DIN_PIN, (data & 0x80) ? HIGH : LOW);  // send 1 or 0 based on data bit
74
-      delayMicroseconds(5);
75
-      WRITE(MAX7219_CLK_PIN, HIGH);      // tock
76
-      delayMicroseconds(5);
77
-    #else
78
-      WRITE(MAX7219_CLK_PIN, LOW);       // tick
79
-      WRITE(MAX7219_DIN_PIN, (data & 0x80) ? HIGH : LOW);  // send 1 or 0 based on data bit
80
-      WRITE(MAX7219_CLK_PIN, HIGH);      // tock
81
-    #endif
82
-
75
+    MS_DELAY();
76
+    WRITE(MAX7219_CLK_PIN, LOW);       // tick
77
+    MS_DELAY();
78
+    WRITE(MAX7219_DIN_PIN, (data & 0x80) ? HIGH : LOW);  // send 1 or 0 based on data bit
79
+    MS_DELAY();
80
+    WRITE(MAX7219_CLK_PIN, HIGH);      // tock
81
+    MS_DELAY();
83 82
     data <<= 1;
84 83
   }
85 84
   CRITICAL_SECTION_END
86 85
 }
87 86
 
88 87
 void Max7219(const uint8_t reg, const uint8_t data) {
89
-  #ifdef CPU_32_BIT
90
-    delayMicroseconds(5);
91
-  #endif
88
+  MS_DELAY();
92 89
   CRITICAL_SECTION_START
93 90
   WRITE(MAX7219_LOAD_PIN, LOW);  // begin
94
-  #ifdef CPU_32_BIT              // The 32-bit processors are so fast, a small delay in the code is needed
95
-    delayMicroseconds(5);        // to let the signal wires stabilize.
96
-  #endif
91
+  MS_DELAY();
97 92
   Max7219_PutByte(reg);          // specify register
98
-  #ifdef CPU_32_BIT
99
-    delayMicroseconds(5);
100
-  #endif
93
+  MS_DELAY();
101 94
   Max7219_PutByte(data);         // put data
102
-  #ifdef CPU_32_BIT
103
-    delayMicroseconds(5);
104
-  #endif
95
+  MS_DELAY();
105 96
   WRITE(MAX7219_LOAD_PIN, LOW);  // and tell the chip to load the data
106
-  #ifdef CPU_32_BIT
107
-    delayMicroseconds(5);
108
-  #endif
97
+  MS_DELAY();
109 98
   WRITE(MAX7219_LOAD_PIN, HIGH);
110 99
   CRITICAL_SECTION_END
111
-  #ifdef CPU_32_BIT
112
-    delayMicroseconds(5);
113
-  #endif
100
+  MS_DELAY();
114 101
 }
115 102
 
116 103
 void Max7219_LED_Set(const uint8_t row, const uint8_t col, const bool on) {
@@ -329,23 +316,22 @@ void Max7219_idle_tasks() {
329 316
 
330 317
   #if ENABLED(MAX7219_DEBUG_PRINTER_ALIVE)
331 318
     static millis_t next_blink = 0;
332
-
333 319
     if (ELAPSED(millis(), next_blink)) {
334
-        Max7219_LED_Toggle(7, 7);
335
-        next_blink = millis() + 750;
320
+      Max7219_LED_Toggle(7, 7);
321
+      next_blink = millis() + 750;
336 322
     }
337 323
   #endif
338 324
 
339 325
   #ifdef MAX7219_DEBUG_STEPPER_HEAD
340 326
     static int16_t last_head_cnt=0;
341 327
     if (last_head_cnt != head) {
342
-      if ( last_head_cnt < 8)
328
+      if (last_head_cnt < 8)
343 329
         Max7219_LED_Off( last_head_cnt, MAX7219_DEBUG_STEPPER_HEAD);
344 330
       else
345 331
         Max7219_LED_Off( last_head_cnt-8, MAX7219_DEBUG_STEPPER_HEAD+1);
346 332
 
347 333
       last_head_cnt = head;
348
-      if ( head < 8)
334
+      if (head < 8)
349 335
         Max7219_LED_On(head, MAX7219_DEBUG_STEPPER_HEAD);
350 336
       else
351 337
         Max7219_LED_On(head-8, MAX7219_DEBUG_STEPPER_HEAD+1);
@@ -355,13 +341,13 @@ void Max7219_idle_tasks() {
355 341
   #ifdef MAX7219_DEBUG_STEPPER_TAIL
356 342
     static int16_t last_tail_cnt=0;
357 343
     if (last_tail_cnt != tail) {
358
-      if ( last_tail_cnt < 8)
344
+      if (last_tail_cnt < 8)
359 345
         Max7219_LED_Off( last_tail_cnt, MAX7219_DEBUG_STEPPER_TAIL);
360 346
       else
361 347
         Max7219_LED_Off( last_tail_cnt-8, MAX7219_DEBUG_STEPPER_TAIL+1);
362 348
 
363 349
       last_tail_cnt = tail;
364
-      if ( tail < 8)
350
+      if (tail < 8)
365 351
         Max7219_LED_On(tail, MAX7219_DEBUG_STEPPER_TAIL);
366 352
       else
367 353
         Max7219_LED_On(tail-8, MAX7219_DEBUG_STEPPER_TAIL+1);
@@ -381,10 +367,10 @@ void Max7219_idle_tasks() {
381 367
                     en = max(current_depth, last_depth);
382 368
       if (current_depth < last_depth)
383 369
         for (uint8_t i = st; i <= en; i++)   // clear the highest order LEDs
384
-            Max7219_LED_Off(i/2, MAX7219_DEBUG_STEPPER_QUEUE + (i & 1));
370
+          Max7219_LED_Off(i/2, MAX7219_DEBUG_STEPPER_QUEUE + (i & 1));
385 371
       else
386
-          for (uint8_t i = st; i <= en; i++)   // set the LEDs to current depth
387
-            Max7219_LED_On(i/2, MAX7219_DEBUG_STEPPER_QUEUE + (i & 1));
372
+        for (uint8_t i = st; i <= en; i++)   // set the LEDs to current depth
373
+          Max7219_LED_On(i/2, MAX7219_DEBUG_STEPPER_QUEUE + (i & 1));
388 374
 
389 375
       last_depth = current_depth;
390 376
     }

+ 2
- 2
Marlin/configuration_store.cpp View File

@@ -215,8 +215,8 @@ MarlinSettings settings;
215 215
 #endif
216 216
 
217 217
 /**
218
-* Post-process after Retrieve or Reset
219
-*/
218
+ * Post-process after Retrieve or Reset
219
+ */
220 220
 void MarlinSettings::postprocess() {
221 221
   // steps per s2 needs to be updated to agree with units per s2
222 222
   planner.reset_acceleration_rates();

+ 1
- 2
Marlin/planner.cpp View File

@@ -528,8 +528,7 @@ void Planner::check_axes_activity() {
528 528
 }
529 529
 
530 530
 inline float calculate_volumetric_multiplier(const float &diameter) {
531
-  if (!parser.volumetric_enabled || diameter == 0) return 1.0;
532
-  return 1.0 / CIRCLE_AREA(diameter * 0.5);
531
+  return (parser.volumetric_enabled && diameter) ? 1.0 / CIRCLE_AREA(diameter * 0.5) : 1.0;
533 532
 }
534 533
 
535 534
 void Planner::calculate_volumetric_multipliers() {

Loading…
Cancel
Save