ソースを参照

Miscellaneous cleanup

Scott Lahteine 6年前
コミット
4e19c59ab3
4個のファイルの変更50行の追加86行の削除
  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 ファイルの表示

8942
         set_home_offset((AxisEnum)i, parser.value_linear_units());
8942
         set_home_offset((AxisEnum)i, parser.value_linear_units());
8943
 
8943
 
8944
     #if ENABLED(MORGAN_SCARA)
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
     #endif
8947
     #endif
8948
 
8948
 
8949
     report_current_position();
8949
     report_current_position();
9319
     #if ENABLED(BABYSTEP_XY)
9319
     #if ENABLED(BABYSTEP_XY)
9320
       for (uint8_t a = X_AXIS; a <= Z_AXIS; a++)
9320
       for (uint8_t a = X_AXIS; a <= Z_AXIS; a++)
9321
         if (parser.seenval(axis_codes[a]) || (a == Z_AXIS && parser.seenval('S'))) {
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
           #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
9323
           #if ENABLED(BABYSTEP_ZPROBE_OFFSET)
9324
             if (a == Z_AXIS) {
9324
             if (a == Z_AXIS) {
9325
               zprobe_zoffset += offs;
9325
               zprobe_zoffset += offs;
9326
               refresh_zprobe_zoffset(true); // 'true' to not babystep
9326
               refresh_zprobe_zoffset(true); // 'true' to not babystep
9327
             }
9327
             }
9328
           #endif
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
     #else
9331
     #else
9332
       if (parser.seenval('Z') || parser.seenval('S')) {
9332
       if (parser.seenval('Z') || parser.seenval('S')) {
13318
         #if !AVR_AT90USB1286_FAMILY
13318
         #if !AVR_AT90USB1286_FAMILY
13319
           case TIMER0A:
13319
           case TIMER0A:
13320
         #endif
13320
         #endif
13321
-        case TIMER0B:
13322
-          //_SET_CS(0, val);
13323
-          break;
13321
+        case TIMER0B:                           //_SET_CS(0, val);
13322
+                                                  break;
13324
       #endif
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
       #endif
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
       #endif
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
       #endif
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
       #endif
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
       #endif
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
       #endif
13342
       #endif
13364
     }
13343
     }
13365
   }
13344
   }

+ 28
- 42
Marlin/Max7219_Debug_LEDs.cpp ファイルの表示

63
 
63
 
64
 static uint8_t LEDs[8] = { 0 };
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
 void Max7219_PutByte(uint8_t data) {
72
 void Max7219_PutByte(uint8_t data) {
67
   CRITICAL_SECTION_START
73
   CRITICAL_SECTION_START
68
   for (uint8_t i = 8; i--;) {
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
     data <<= 1;
82
     data <<= 1;
84
   }
83
   }
85
   CRITICAL_SECTION_END
84
   CRITICAL_SECTION_END
86
 }
85
 }
87
 
86
 
88
 void Max7219(const uint8_t reg, const uint8_t data) {
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
   CRITICAL_SECTION_START
89
   CRITICAL_SECTION_START
93
   WRITE(MAX7219_LOAD_PIN, LOW);  // begin
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
   Max7219_PutByte(reg);          // specify register
92
   Max7219_PutByte(reg);          // specify register
98
-  #ifdef CPU_32_BIT
99
-    delayMicroseconds(5);
100
-  #endif
93
+  MS_DELAY();
101
   Max7219_PutByte(data);         // put data
94
   Max7219_PutByte(data);         // put data
102
-  #ifdef CPU_32_BIT
103
-    delayMicroseconds(5);
104
-  #endif
95
+  MS_DELAY();
105
   WRITE(MAX7219_LOAD_PIN, LOW);  // and tell the chip to load the data
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
   WRITE(MAX7219_LOAD_PIN, HIGH);
98
   WRITE(MAX7219_LOAD_PIN, HIGH);
110
   CRITICAL_SECTION_END
99
   CRITICAL_SECTION_END
111
-  #ifdef CPU_32_BIT
112
-    delayMicroseconds(5);
113
-  #endif
100
+  MS_DELAY();
114
 }
101
 }
115
 
102
 
116
 void Max7219_LED_Set(const uint8_t row, const uint8_t col, const bool on) {
103
 void Max7219_LED_Set(const uint8_t row, const uint8_t col, const bool on) {
329
 
316
 
330
   #if ENABLED(MAX7219_DEBUG_PRINTER_ALIVE)
317
   #if ENABLED(MAX7219_DEBUG_PRINTER_ALIVE)
331
     static millis_t next_blink = 0;
318
     static millis_t next_blink = 0;
332
-
333
     if (ELAPSED(millis(), next_blink)) {
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
   #endif
323
   #endif
338
 
324
 
339
   #ifdef MAX7219_DEBUG_STEPPER_HEAD
325
   #ifdef MAX7219_DEBUG_STEPPER_HEAD
340
     static int16_t last_head_cnt=0;
326
     static int16_t last_head_cnt=0;
341
     if (last_head_cnt != head) {
327
     if (last_head_cnt != head) {
342
-      if ( last_head_cnt < 8)
328
+      if (last_head_cnt < 8)
343
         Max7219_LED_Off( last_head_cnt, MAX7219_DEBUG_STEPPER_HEAD);
329
         Max7219_LED_Off( last_head_cnt, MAX7219_DEBUG_STEPPER_HEAD);
344
       else
330
       else
345
         Max7219_LED_Off( last_head_cnt-8, MAX7219_DEBUG_STEPPER_HEAD+1);
331
         Max7219_LED_Off( last_head_cnt-8, MAX7219_DEBUG_STEPPER_HEAD+1);
346
 
332
 
347
       last_head_cnt = head;
333
       last_head_cnt = head;
348
-      if ( head < 8)
334
+      if (head < 8)
349
         Max7219_LED_On(head, MAX7219_DEBUG_STEPPER_HEAD);
335
         Max7219_LED_On(head, MAX7219_DEBUG_STEPPER_HEAD);
350
       else
336
       else
351
         Max7219_LED_On(head-8, MAX7219_DEBUG_STEPPER_HEAD+1);
337
         Max7219_LED_On(head-8, MAX7219_DEBUG_STEPPER_HEAD+1);
355
   #ifdef MAX7219_DEBUG_STEPPER_TAIL
341
   #ifdef MAX7219_DEBUG_STEPPER_TAIL
356
     static int16_t last_tail_cnt=0;
342
     static int16_t last_tail_cnt=0;
357
     if (last_tail_cnt != tail) {
343
     if (last_tail_cnt != tail) {
358
-      if ( last_tail_cnt < 8)
344
+      if (last_tail_cnt < 8)
359
         Max7219_LED_Off( last_tail_cnt, MAX7219_DEBUG_STEPPER_TAIL);
345
         Max7219_LED_Off( last_tail_cnt, MAX7219_DEBUG_STEPPER_TAIL);
360
       else
346
       else
361
         Max7219_LED_Off( last_tail_cnt-8, MAX7219_DEBUG_STEPPER_TAIL+1);
347
         Max7219_LED_Off( last_tail_cnt-8, MAX7219_DEBUG_STEPPER_TAIL+1);
362
 
348
 
363
       last_tail_cnt = tail;
349
       last_tail_cnt = tail;
364
-      if ( tail < 8)
350
+      if (tail < 8)
365
         Max7219_LED_On(tail, MAX7219_DEBUG_STEPPER_TAIL);
351
         Max7219_LED_On(tail, MAX7219_DEBUG_STEPPER_TAIL);
366
       else
352
       else
367
         Max7219_LED_On(tail-8, MAX7219_DEBUG_STEPPER_TAIL+1);
353
         Max7219_LED_On(tail-8, MAX7219_DEBUG_STEPPER_TAIL+1);
381
                     en = max(current_depth, last_depth);
367
                     en = max(current_depth, last_depth);
382
       if (current_depth < last_depth)
368
       if (current_depth < last_depth)
383
         for (uint8_t i = st; i <= en; i++)   // clear the highest order LEDs
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
       else
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
       last_depth = current_depth;
375
       last_depth = current_depth;
390
     }
376
     }

+ 2
- 2
Marlin/configuration_store.cpp ファイルの表示

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

+ 1
- 2
Marlin/planner.cpp ファイルの表示

528
 }
528
 }
529
 
529
 
530
 inline float calculate_volumetric_multiplier(const float &diameter) {
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
 void Planner::calculate_volumetric_multipliers() {
534
 void Planner::calculate_volumetric_multipliers() {

読み込み中…
キャンセル
保存